diff --git a/integrationTests/relayers/slowTests/ethToMultiversXWithChainSimulator_test.go b/integrationTests/relayers/slowTests/ethToMultiversXWithChainSimulator_test.go index 0e59329b..83883a65 100644 --- a/integrationTests/relayers/slowTests/ethToMultiversXWithChainSimulator_test.go +++ b/integrationTests/relayers/slowTests/ethToMultiversXWithChainSimulator_test.go @@ -26,7 +26,8 @@ import ( ) const ( - timeout = time.Minute * 15 + timeout = time.Minute * 15 + projectedShardForTestKeys = byte(2) ) func TestRelayersShouldExecuteTransfers(t *testing.T) { @@ -369,7 +370,7 @@ func testEthContractsShouldError(tb testing.TB, testToken framework.TestTokenPar valueToMintOnEth, ok := big.NewInt(0).SetString(testToken.ValueToMintOnEth, 10) require.True(tb, ok) - receiverKeys := framework.GenerateMvxPrivatePublicKey(tb) + receiverKeys := framework.GenerateMvxPrivatePublicKey(tb, projectedShardForTestKeys) auth, _ := bind.NewKeyedTransactorWithChainID(setup.DepositorKeys.EthSK, setup.EthereumHandler.ChainID) _, err := setup.EthereumHandler.SafeContract.Deposit(auth, token.EthErc20Address, valueToMintOnEth, receiverKeys.MvxAddress.AddressSlice()) require.Error(tb, err) diff --git a/integrationTests/relayers/slowTests/framework/keys.go b/integrationTests/relayers/slowTests/framework/keys.go index f90a9dd2..e05b1474 100644 --- a/integrationTests/relayers/slowTests/framework/keys.go +++ b/integrationTests/relayers/slowTests/framework/keys.go @@ -13,13 +13,17 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + mxCrypto "github.com/multiversx/mx-chain-crypto-go" "github.com/stretchr/testify/require" ) // constants for the keys store const ( - relayerPemPathFormat = "multiversx%d.pem" - SCCallerFilename = "scCaller.pem" + relayerPemPathFormat = "multiversx%d.pem" + SCCallerFilename = "scCaller.pem" + projectedShardForBridgeSetup = byte(0) + projectedShardForDepositor = byte(1) + projectedShardForTestKeys = byte(2) ) // KeysHolder holds a 2 pk-sk pairs for both chains @@ -63,14 +67,14 @@ func NewKeysStore( } keysStore.generateRelayersKeys(numRelayers) - keysStore.OraclesKeys = keysStore.generateKeys(numOracles, "generated oracle") - keysStore.SCExecutorKeys = keysStore.generateKey("") - keysStore.OwnerKeys = keysStore.generateKey(ethOwnerSK) + keysStore.OraclesKeys = keysStore.generateKeys(numOracles, "generated oracle", projectedShardForBridgeSetup) + keysStore.SCExecutorKeys = keysStore.generateKey("", projectedShardForBridgeSetup) + keysStore.OwnerKeys = keysStore.generateKey(ethOwnerSK, projectedShardForBridgeSetup) log.Info("generated owner", "MvX address", keysStore.OwnerKeys.MvxAddress.Bech32(), "Eth address", keysStore.OwnerKeys.EthAddress.String()) - keysStore.DepositorKeys = keysStore.generateKey(ethDepositorSK) - keysStore.TestKeys = keysStore.generateKey(ethTestSk) + keysStore.DepositorKeys = keysStore.generateKey(ethDepositorSK, projectedShardForDepositor) + keysStore.TestKeys = keysStore.generateKey(ethTestSk, projectedShardForTestKeys) filename := path.Join(keysStore.workingDir, SCCallerFilename) SaveMvxKey(keysStore, filename, keysStore.SCExecutorKeys) @@ -83,7 +87,7 @@ func (keyStore *KeysStore) generateRelayersKeys(numKeys int) { relayerETHSKBytes, err := os.ReadFile(fmt.Sprintf(relayerETHKeyPathFormat, i)) require.Nil(keyStore, err) - relayerKeys := keyStore.generateKey(string(relayerETHSKBytes)) + relayerKeys := keyStore.generateKey(string(relayerETHSKBytes), projectedShardForBridgeSetup) log.Info("generated relayer", "index", i, "MvX address", relayerKeys.MvxAddress.Bech32(), "Eth address", relayerKeys.EthAddress.String()) @@ -96,14 +100,14 @@ func (keyStore *KeysStore) generateRelayersKeys(numKeys int) { } } -func (keyStore *KeysStore) generateKeys(numKeys int, message string) []KeysHolder { +func (keyStore *KeysStore) generateKeys(numKeys int, message string, projectedShard byte) []KeysHolder { keys := make([]KeysHolder, 0, numKeys) for i := 0; i < numKeys; i++ { ethPrivateKeyBytes := make([]byte, 32) _, _ = rand.Read(ethPrivateKeyBytes) - key := keyStore.generateKey(hex.EncodeToString(ethPrivateKeyBytes)) + key := keyStore.generateKey(hex.EncodeToString(ethPrivateKeyBytes), projectedShard) log.Info(message, "index", i, "MvX address", key.MvxAddress.Bech32(), "Eth address", key.EthAddress.String()) @@ -114,10 +118,10 @@ func (keyStore *KeysStore) generateKeys(numKeys int, message string) []KeysHolde return keys } -func (keyStore *KeysStore) generateKey(ethSkHex string) KeysHolder { +func (keyStore *KeysStore) generateKey(ethSkHex string, projectedShard byte) KeysHolder { var err error - keys := GenerateMvxPrivatePublicKey(keyStore) + keys := GenerateMvxPrivatePublicKey(keyStore, projectedShard) if len(ethSkHex) == 0 { // eth keys not required return keys @@ -169,21 +173,34 @@ func (keyStore *KeysStore) WalletsToFundOnMultiversX() []string { } // GenerateMvxPrivatePublicKey will generate a new keys holder instance that will hold only the MultiversX generated keys -func GenerateMvxPrivatePublicKey(tb testing.TB) KeysHolder { - sk, pk := keyGenerator.GeneratePair() +func GenerateMvxPrivatePublicKey(tb testing.TB, projectedShard byte) KeysHolder { + sk, pkBytes := generateSkPkInShard(tb, projectedShard) skBytes, err := sk.ToByteArray() require.Nil(tb, err) - pkBytes, err := pk.ToByteArray() - require.Nil(tb, err) - return KeysHolder{ MvxSk: skBytes, MvxAddress: NewMvxAddressFromBytes(tb, pkBytes), } } +func generateSkPkInShard(tb testing.TB, projectedShard byte) (mxCrypto.PrivateKey, []byte) { + var sk mxCrypto.PrivateKey + var pk mxCrypto.PublicKey + + for { + sk, pk = keyGenerator.GeneratePair() + + pkBytes, err := pk.ToByteArray() + require.Nil(tb, err) + + if pkBytes[len(pkBytes)-1] == projectedShard { + return sk, pkBytes + } + } +} + // SaveMvxKey will save the MultiversX key func SaveMvxKey(tb testing.TB, filename string, key KeysHolder) { blk := pem.Block{ diff --git a/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridge-proxy.wasm b/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridge-proxy.wasm old mode 100755 new mode 100644 index 19ddf1f0..7b4a6c37 Binary files a/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridge-proxy.wasm and b/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridge-proxy.wasm differ diff --git a/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridged-tokens-wrapper.wasm b/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridged-tokens-wrapper.wasm old mode 100755 new mode 100644 index f3274c55..05c4f5ac Binary files a/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridged-tokens-wrapper.wasm and b/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridged-tokens-wrapper.wasm differ diff --git a/integrationTests/relayers/slowTests/testdata/contracts/mvx/esdt-safe.wasm b/integrationTests/relayers/slowTests/testdata/contracts/mvx/esdt-safe.wasm old mode 100755 new mode 100644 index bf9ad838..ad1cc816 Binary files a/integrationTests/relayers/slowTests/testdata/contracts/mvx/esdt-safe.wasm and b/integrationTests/relayers/slowTests/testdata/contracts/mvx/esdt-safe.wasm differ diff --git a/integrationTests/relayers/slowTests/testdata/contracts/mvx/multi-transfer-esdt.wasm b/integrationTests/relayers/slowTests/testdata/contracts/mvx/multi-transfer-esdt.wasm old mode 100755 new mode 100644 index 1091f110..e7ebbe99 Binary files a/integrationTests/relayers/slowTests/testdata/contracts/mvx/multi-transfer-esdt.wasm and b/integrationTests/relayers/slowTests/testdata/contracts/mvx/multi-transfer-esdt.wasm differ diff --git a/integrationTests/relayers/slowTests/testdata/contracts/mvx/multisig.wasm b/integrationTests/relayers/slowTests/testdata/contracts/mvx/multisig.wasm old mode 100755 new mode 100644 index 35fa02bd..f80f6c14 Binary files a/integrationTests/relayers/slowTests/testdata/contracts/mvx/multisig.wasm and b/integrationTests/relayers/slowTests/testdata/contracts/mvx/multisig.wasm differ diff --git a/integrationTests/relayers/slowTests/testdata/contracts/mvx/multiversx-price-aggregator-sc.abi.json b/integrationTests/relayers/slowTests/testdata/contracts/mvx/multiversx-price-aggregator-sc.abi.json index 112ce329..97906b85 100644 --- a/integrationTests/relayers/slowTests/testdata/contracts/mvx/multiversx-price-aggregator-sc.abi.json +++ b/integrationTests/relayers/slowTests/testdata/contracts/mvx/multiversx-price-aggregator-sc.abi.json @@ -10,7 +10,7 @@ "contractCrate": { "name": "multiversx-price-aggregator-sc", "version": "0.47.1", - "gitVersion": "v0.45.2.1-reproducible-361-g5e42362" + "gitVersion": "v0.45.2.1-reproducible-375-gda17d9d" }, "framework": { "name": "multiversx-sc", @@ -48,6 +48,10 @@ ], "outputs": [] }, + "upgradeConstructor": { + "inputs": [], + "outputs": [] + }, "endpoints": [ { "name": "changeAmounts", @@ -376,8 +380,8 @@ "indexed": true }, { - "name": "epoch", - "type": "u64", + "name": "round", + "type": "u32", "indexed": true }, { @@ -385,11 +389,96 @@ "type": "NewRoundEvent" } ] + }, + { + "identifier": "discard_submission", + "inputs": [ + { + "name": "from", + "type": "bytes", + "indexed": true + }, + { + "name": "to", + "type": "bytes", + "indexed": true + }, + { + "name": "round", + "type": "u32", + "indexed": true + }, + { + "name": "discard_submission_event", + "type": "DiscardSubmissionEvent" + } + ] + }, + { + "identifier": "discard_round", + "inputs": [ + { + "name": "from", + "type": "bytes", + "indexed": true + }, + { + "name": "to", + "type": "bytes", + "indexed": true + }, + { + "name": "round", + "type": "u32", + "indexed": true + } + ] + }, + { + "identifier": "add_submission", + "inputs": [ + { + "name": "from", + "type": "bytes", + "indexed": true + }, + { + "name": "to", + "type": "bytes", + "indexed": true + }, + { + "name": "round", + "type": "u32", + "indexed": true + }, + { + "name": "price", + "type": "BigUint" + } + ] } ], "esdtAttributes": [], "hasCallback": false, "types": { + "DiscardSubmissionEvent": { + "type": "struct", + "fields": [ + { + "name": "submission_timestamp", + "type": "u64" + }, + { + "name": "first_submission_timestamp", + "type": "u64" + }, + { + "name": "has_caller_already_submitted", + "type": "bool" + } + ] + }, "NewRoundEvent": { "type": "struct", "fields": [ diff --git a/integrationTests/relayers/slowTests/testdata/contracts/mvx/multiversx-price-aggregator-sc.wasm b/integrationTests/relayers/slowTests/testdata/contracts/mvx/multiversx-price-aggregator-sc.wasm old mode 100755 new mode 100644 index dea6107b..2c820924 Binary files a/integrationTests/relayers/slowTests/testdata/contracts/mvx/multiversx-price-aggregator-sc.wasm and b/integrationTests/relayers/slowTests/testdata/contracts/mvx/multiversx-price-aggregator-sc.wasm differ diff --git a/integrationTests/relayers/slowTests/testdata/contracts/mvx/test-caller.wasm b/integrationTests/relayers/slowTests/testdata/contracts/mvx/test-caller.wasm old mode 100755 new mode 100644 index 8419ee51..ce986241 Binary files a/integrationTests/relayers/slowTests/testdata/contracts/mvx/test-caller.wasm and b/integrationTests/relayers/slowTests/testdata/contracts/mvx/test-caller.wasm differ