diff --git a/Makefile b/Makefile index 34a3c4e4..87345d8b 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ test-coverage: slow-tests: clean-test @docker compose -f docker/docker-compose.yml build - @docker compose -f docker/docker-compose.yml up & go test ./integrationTests/... -v -tags slow + @docker compose -f docker/docker-compose.yml up & go test ./integrationTests/... -v -timeout 40m -tags slow @docker compose -f docker/docker-compose.yml down -v lint-install: diff --git a/bridges/ethMultiversX/bridgeExecutor.go b/bridges/ethMultiversX/bridgeExecutor.go index c9b52dfd..db9aa9a6 100644 --- a/bridges/ethMultiversX/bridgeExecutor.go +++ b/bridges/ethMultiversX/bridgeExecutor.go @@ -38,6 +38,13 @@ type ArgsBridgeExecutor struct { MaxRestriesOnWasProposed uint64 } +var emtpyCallData = parsers.CallData{ + Type: parsers.DataPresentProtocolMarker, + Function: "", + GasLimit: 0, + Arguments: nil, +} + type bridgeExecutor struct { log logger.Logger topologyProvider TopologyProvider @@ -486,7 +493,12 @@ func (executor *bridgeExecutor) addMetadataToTransfer(transfer *bridgeCommon.Dep var err error transfer.DisplayableData, err = ConvertToDisplayableData(transfer.Data) if err != nil { - executor.log.Warn("failed to convert call data to displayable data", "error", err) + executor.log.Warn("failed to convert call data to displayable data, will alter and call with an empty call data struct", + "error", err, + "call data", fmt.Sprintf("%+v", emtpyCallData)) + + codec := parsers.MultiversxCodec{} + transfer.Data = codec.EncodeCallData(emtpyCallData) } return transfer diff --git a/bridges/ethMultiversX/bridgeExecutor_test.go b/bridges/ethMultiversX/bridgeExecutor_test.go index 7da6d87d..7cd2f1c3 100644 --- a/bridges/ethMultiversX/bridgeExecutor_test.go +++ b/bridges/ethMultiversX/bridgeExecutor_test.go @@ -16,6 +16,7 @@ import ( bridgeCommon "github.com/multiversx/mx-bridge-eth-go/common" "github.com/multiversx/mx-bridge-eth-go/core" "github.com/multiversx/mx-bridge-eth-go/core/batchProcessor" + "github.com/multiversx/mx-bridge-eth-go/parsers" "github.com/multiversx/mx-bridge-eth-go/testsCommon" bridgeTests "github.com/multiversx/mx-bridge-eth-go/testsCommon/bridge" "github.com/multiversx/mx-chain-core-go/core/check" @@ -27,6 +28,7 @@ import ( var expectedErr = errors.New("expected error") var providedBatch = &bridgeCommon.TransferBatch{} var expectedMaxRetries = uint64(3) +var codec = parsers.MultiversxCodec{} func createMockExecutorArgs() ArgsBridgeExecutor { return ArgsBridgeExecutor{ @@ -399,36 +401,80 @@ func TestEthToMultiversXBridgeExecutor_GetAndStoreBatchFromEthereum(t *testing.T assert.True(t, expectedBatch == executor.batch) }) t.Run("should add deposits metadata for sc calls", func(t *testing.T) { - args := createMockExecutorArgs() - providedNonce := uint64(8346) - depositNonce := uint64(100) - depositData := "testData" - expectedBatch := &bridgeCommon.TransferBatch{ - ID: providedNonce, - Deposits: []*bridgeCommon.DepositTransfer{ - { - Nonce: depositNonce, + t.Run("invalid data", func(t *testing.T) { + t.Parallel() + + args := createMockExecutorArgs() + providedNonce := uint64(8346) + depositNonce := uint64(100) + depositData := "testData" + expectedBatch := &bridgeCommon.TransferBatch{ + ID: providedNonce, + Deposits: []*bridgeCommon.DepositTransfer{ + { + Nonce: depositNonce, + }, }, - }, - } - args.EthereumClient = &bridgeTests.EthereumClientStub{ - GetBatchCalled: func(ctx context.Context, nonce uint64) (*bridgeCommon.TransferBatch, bool, error) { - assert.Equal(t, providedNonce, nonce) - return expectedBatch, true, nil - }, - GetBatchSCMetadataCalled: func(ctx context.Context, nonce uint64) ([]*contract.ERC20SafeERC20SCDeposit, error) { - return []*contract.ERC20SafeERC20SCDeposit{{ - DepositNonce: big.NewInt(0).SetUint64(depositNonce), - CallData: depositData, - }}, nil - }, - } - executor, _ := NewBridgeExecutor(args) - err := executor.GetAndStoreBatchFromEthereum(context.Background(), providedNonce) + } + args.EthereumClient = &bridgeTests.EthereumClientStub{ + GetBatchCalled: func(ctx context.Context, nonce uint64) (*bridgeCommon.TransferBatch, bool, error) { + assert.Equal(t, providedNonce, nonce) + return expectedBatch, true, nil + }, + GetBatchSCMetadataCalled: func(ctx context.Context, nonce uint64) ([]*contract.ERC20SafeERC20SCDeposit, error) { + return []*contract.ERC20SafeERC20SCDeposit{{ + DepositNonce: big.NewInt(0).SetUint64(depositNonce), + CallData: depositData, + }}, nil + }, + } + executor, _ := NewBridgeExecutor(args) + err := executor.GetAndStoreBatchFromEthereum(context.Background(), providedNonce) + + assert.Nil(t, err) + assert.True(t, expectedBatch == executor.GetStoredBatch()) // pointer testing + expectedDepositData := codec.EncodeCallData(emtpyCallData) + assert.Equal(t, string(expectedDepositData), string(executor.batch.Deposits[0].Data)) + }) + t.Run("correct data", func(t *testing.T) { + t.Parallel() + + args := createMockExecutorArgs() + providedNonce := uint64(8346) + depositNonce := uint64(100) + depositData := string(codec.EncodeCallData(parsers.CallData{ + Type: parsers.DataPresentProtocolMarker, + Function: "function", + GasLimit: 37, + Arguments: []string{"arg1", "arg2"}, + })) + expectedBatch := &bridgeCommon.TransferBatch{ + ID: providedNonce, + Deposits: []*bridgeCommon.DepositTransfer{ + { + Nonce: depositNonce, + }, + }, + } + args.EthereumClient = &bridgeTests.EthereumClientStub{ + GetBatchCalled: func(ctx context.Context, nonce uint64) (*bridgeCommon.TransferBatch, bool, error) { + assert.Equal(t, providedNonce, nonce) + return expectedBatch, true, nil + }, + GetBatchSCMetadataCalled: func(ctx context.Context, nonce uint64) ([]*contract.ERC20SafeERC20SCDeposit, error) { + return []*contract.ERC20SafeERC20SCDeposit{{ + DepositNonce: big.NewInt(0).SetUint64(depositNonce), + CallData: depositData, + }}, nil + }, + } + executor, _ := NewBridgeExecutor(args) + err := executor.GetAndStoreBatchFromEthereum(context.Background(), providedNonce) - assert.Nil(t, err) - assert.True(t, expectedBatch == executor.GetStoredBatch()) // pointer testing - assert.Equal(t, depositData, string(executor.batch.Deposits[0].Data)) + assert.Nil(t, err) + assert.True(t, expectedBatch == executor.GetStoredBatch()) // pointer testing + assert.Equal(t, depositData, string(executor.batch.Deposits[0].Data)) + }) }) t.Run("should add deposits metadata for sc calls even if with no data", func(t *testing.T) { args := createMockExecutorArgs() @@ -460,7 +506,8 @@ func TestEthToMultiversXBridgeExecutor_GetAndStoreBatchFromEthereum(t *testing.T assert.Nil(t, err) assert.True(t, expectedBatch == executor.GetStoredBatch()) // pointer testing - assert.Equal(t, "", string(executor.batch.Deposits[0].Data)) + expectedDepositData := codec.EncodeCallData(emtpyCallData) + assert.Equal(t, string(expectedDepositData), string(executor.batch.Deposits[0].Data)) }) } diff --git a/clients/multiversx/client.go b/clients/multiversx/client.go index a955cc53..8ecd9cd7 100644 --- a/clients/multiversx/client.go +++ b/clients/multiversx/client.go @@ -324,7 +324,7 @@ func (c *client) ProposeSetStatus(ctx context.Context, batch *common.TransferBat gasLimit := c.gasMapConfig.ProposeStatusBase + uint64(len(batch.Deposits))*c.gasMapConfig.ProposeStatusForEach hash, err := c.txHandler.SendTransactionReturnHash(ctx, txBuilder, gasLimit) if err == nil { - c.log.Info("proposed set statuses"+batch.String(), "transaction hash", hash) + c.log.Info("proposed set statuses "+batch.String(), "transaction hash", hash) } return hash, err diff --git a/cmd/scCallsExecutor/config/config.toml b/cmd/scCallsExecutor/config/config.toml index 976833a8..17673137 100644 --- a/cmd/scCallsExecutor/config/config.toml +++ b/cmd/scCallsExecutor/config/config.toml @@ -1,5 +1,5 @@ ScProxyBech32Address = "erd1qqqqqqqqqqqqqpgqnef5f5aq32d63kljld8w5vnvz4gk5sy9hrrq2ld08s" -ExtraGasToExecute = 50000000 +ExtraGasToExecute = 60000000 #this value allow the SC calls without provided gas limit to be refunded NetworkAddress = "127.0.0.1:8085" ProxyMaxNoncesDelta = 7 ProxyFinalityCheck = true diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 243e9a32..ece35b11 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,8 +1,8 @@ version: "3.9" services: - multiversx: - image: multiversx/chainsimulator:v1.7.13-fix3 + chain-simulator: + image: multiversx/chainsimulator:v1.7.13-patch1 ports: - 8085:8085 volumes: diff --git a/executors/multiversx/module/interface.go b/executors/multiversx/module/interface.go index 853b1bc9..69fab4b3 100644 --- a/executors/multiversx/module/interface.go +++ b/executors/multiversx/module/interface.go @@ -19,3 +19,9 @@ type pollingHandler interface { Close() error IsInterfaceNil() bool } + +type executor interface { + Execute(ctx context.Context) error + GetNumSentTransaction() uint32 + IsInterfaceNil() bool +} diff --git a/executors/multiversx/module/scCallsModule.go b/executors/multiversx/module/scCallsModule.go index 1adc3dce..444252fa 100644 --- a/executors/multiversx/module/scCallsModule.go +++ b/executors/multiversx/module/scCallsModule.go @@ -23,8 +23,9 @@ var keyGen = signing.NewKeyGenerator(suite) var singleSigner = &singlesig.Ed25519Signer{} type scCallsModule struct { - nonceTxsHandler nonceTransactionsHandler - pollingHandler pollingHandler + nonceTxsHandler nonceTransactionsHandler + pollingHandler pollingHandler + executorInstance executor } // NewScCallsModule creates a starts a new scCallsModule instance @@ -82,7 +83,7 @@ func NewScCallsModule(cfg config.ScCallsModuleConfig, log logger.Logger) (*scCal PrivateKey: privateKey, SingleSigner: singleSigner, } - executor, err := multiversx.NewScCallExecutor(argsExecutor) + module.executorInstance, err = multiversx.NewScCallExecutor(argsExecutor) if err != nil { return nil, err } @@ -92,7 +93,7 @@ func NewScCallsModule(cfg config.ScCallsModuleConfig, log logger.Logger) (*scCal Name: "MultiversX SC calls", PollingInterval: time.Duration(cfg.PollingIntervalInMillis) * time.Millisecond, PollingWhenError: time.Duration(cfg.PollingIntervalInMillis) * time.Millisecond, - Executor: executor, + Executor: module.executorInstance, } module.pollingHandler, err = polling.NewPollingHandler(argsPollingHandler) @@ -108,6 +109,11 @@ func NewScCallsModule(cfg config.ScCallsModuleConfig, log logger.Logger) (*scCal return module, nil } +// GetNumSentTransaction returns the total sent transactions +func (module *scCallsModule) GetNumSentTransaction() uint32 { + return module.executorInstance.GetNumSentTransaction() +} + // Close closes any components started func (module *scCallsModule) Close() error { errPollingHandler := module.pollingHandler.Close() diff --git a/executors/multiversx/scCallsExecutor.go b/executors/multiversx/scCallsExecutor.go index 1404f0a0..4c52c912 100644 --- a/executors/multiversx/scCallsExecutor.go +++ b/executors/multiversx/scCallsExecutor.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "math/big" + "sync/atomic" "github.com/ethereum/go-ethereum/log" "github.com/multiversx/mx-bridge-eth-go/errors" @@ -49,6 +50,7 @@ type scCallExecutor struct { privateKey crypto.PrivateKey singleSigner crypto.SingleSigner senderAddress core.AddressHandler + numSentTransactions uint32 } // NewScCallExecutor creates a new instance of type scCallExecutor @@ -244,6 +246,8 @@ func (executor *scCallExecutor) executeOperation( "extra gas", executor.extraGasToExecute, "sender", bech32Address) + atomic.AddUint32(&executor.numSentTransactions, 1) + return nil } @@ -265,6 +269,11 @@ func (executor *scCallExecutor) signTransactionWithPrivateKey(tx *transaction.Fr return nil } +// GetNumSentTransaction returns the total sent transactions +func (executor *scCallExecutor) GetNumSentTransaction() uint32 { + return atomic.LoadUint32(&executor.numSentTransactions) +} + // IsInterfaceNil returns true if there is no value under the interface func (executor *scCallExecutor) IsInterfaceNil() bool { return executor == nil diff --git a/executors/multiversx/scCallsExecutor_test.go b/executors/multiversx/scCallsExecutor_test.go index 3dc5b5f9..d388665c 100644 --- a/executors/multiversx/scCallsExecutor_test.go +++ b/executors/multiversx/scCallsExecutor_test.go @@ -187,6 +187,7 @@ func TestScCallExecutor_Execute(t *testing.T) { executor, _ := NewScCallExecutor(args) err := executor.Execute(context.Background()) assert.Equal(t, expectedError, err) + assert.Zero(t, executor.GetNumSentTransaction()) }) t.Run("get pending returns a not ok status, should error", func(t *testing.T) { t.Parallel() @@ -206,6 +207,7 @@ func TestScCallExecutor_Execute(t *testing.T) { err := executor.Execute(context.Background()) assert.NotNil(t, err) assert.Contains(t, err.Error(), "got response code 'NOT OK'") + assert.Zero(t, executor.GetNumSentTransaction()) }) t.Run("get pending returns an odd number of lines, should error", func(t *testing.T) { t.Parallel() @@ -228,6 +230,7 @@ func TestScCallExecutor_Execute(t *testing.T) { err := executor.Execute(context.Background()) assert.ErrorIs(t, err, errInvalidNumberOfResponseLines) assert.Contains(t, err.Error(), "expected an even number, got 1") + assert.Zero(t, executor.GetNumSentTransaction()) }) t.Run("decoder errors, should error", func(t *testing.T) { t.Parallel() @@ -257,6 +260,7 @@ func TestScCallExecutor_Execute(t *testing.T) { executor, _ := NewScCallExecutor(args) err := executor.Execute(context.Background()) assert.ErrorIs(t, err, expectedError) + assert.Zero(t, executor.GetNumSentTransaction()) }) t.Run("get network configs errors, should error", func(t *testing.T) { t.Parallel() @@ -289,6 +293,7 @@ func TestScCallExecutor_Execute(t *testing.T) { executor, _ := NewScCallExecutor(args) err := executor.Execute(context.Background()) assert.ErrorIs(t, err, expectedError) + assert.Zero(t, executor.GetNumSentTransaction()) }) t.Run("ApplyNonceAndGasPrice errors, should error", func(t *testing.T) { t.Parallel() @@ -330,6 +335,7 @@ func TestScCallExecutor_Execute(t *testing.T) { executor, _ := NewScCallExecutor(args) err := executor.Execute(context.Background()) assert.ErrorIs(t, err, expectedError) + assert.Zero(t, executor.GetNumSentTransaction()) }) t.Run("Sign errors, should error", func(t *testing.T) { t.Parallel() @@ -376,6 +382,7 @@ func TestScCallExecutor_Execute(t *testing.T) { executor, _ := NewScCallExecutor(args) err := executor.Execute(context.Background()) assert.ErrorIs(t, err, expectedError) + assert.Zero(t, executor.GetNumSentTransaction()) }) t.Run("SendTransaction errors, should error", func(t *testing.T) { t.Parallel() @@ -409,13 +416,20 @@ func TestScCallExecutor_Execute(t *testing.T) { DecodeProxySCCompleteCallDataCalled: func(buff []byte) (parsers.ProxySCCompleteCallData, error) { assert.Equal(t, []byte{0x03, 0x04}, buff) - return parsers.ProxySCCompleteCallData{}, nil + return parsers.ProxySCCompleteCallData{ + CallData: parsers.CallData{ + Type: parsers.DataPresentProtocolMarker, + Function: "func", + GasLimit: 1000000, + }, + }, nil }, } executor, _ := NewScCallExecutor(args) err := executor.Execute(context.Background()) assert.ErrorIs(t, err, expectedError) + assert.Equal(t, uint32(0), executor.GetNumSentTransaction()) }) t.Run("should work", func(t *testing.T) { t.Parallel() @@ -505,5 +519,6 @@ func TestScCallExecutor_Execute(t *testing.T) { err := executor.Execute(context.Background()) assert.Nil(t, err) assert.True(t, sendWasCalled) + assert.Equal(t, uint32(1), executor.GetNumSentTransaction()) }) } diff --git a/go.mod b/go.mod index bc2151db..396cd1a7 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/multiversx/mx-chain-communication-go v1.0.14 github.com/multiversx/mx-chain-core-go v1.2.20 github.com/multiversx/mx-chain-crypto-go v1.2.11 - github.com/multiversx/mx-chain-go v1.7.12 + github.com/multiversx/mx-chain-go v1.7.13-patch1 github.com/multiversx/mx-chain-logger-go v1.0.14 github.com/multiversx/mx-sdk-go v1.4.1 github.com/pelletier/go-toml v1.9.3 diff --git a/go.sum b/go.sum index a3df2160..04e3b8f5 100644 --- a/go.sum +++ b/go.sum @@ -532,8 +532,8 @@ github.com/multiversx/mx-chain-crypto-go v1.2.11 h1:MNPJoiTJA5/tedYrI0N22OorbsKD github.com/multiversx/mx-chain-crypto-go v1.2.11/go.mod h1:pcZutPdfLiAFytzCU3LxU3s8cXkvpNqquyitFSfoF3o= github.com/multiversx/mx-chain-es-indexer-go v1.4.21 h1:rzxXCkgOsqj67GRYtqzKuf9XgHwnZLTZhU90Ck3VbrE= github.com/multiversx/mx-chain-es-indexer-go v1.4.21/go.mod h1:V9xxOBkfV7GjN4K5SODaOetoGVpQm4snibMVPCjL0Kk= -github.com/multiversx/mx-chain-go v1.7.12 h1:cQ3g5sFZEcQmIRwi/wt+K/3d5nIwCMQRC1ZnJDRuRY4= -github.com/multiversx/mx-chain-go v1.7.12/go.mod h1:HwklJGQfMpv/yyF4oLpxjwdKCawspv1JjdgezlWBpRQ= +github.com/multiversx/mx-chain-go v1.7.13-patch1 h1:x3U0BFpQrwXcXXa81KMgM25hNRGgjsquzq6ot+f9Ot4= +github.com/multiversx/mx-chain-go v1.7.13-patch1/go.mod h1:qyW6EBgsqgZwA+SrAhLVi6cCM6kFqlm6Lh28Re1LrIA= github.com/multiversx/mx-chain-logger-go v1.0.14 h1:PRMpAvXE7Nec2d//QNmbYfKVHMomOKmcN4UXurQWX9o= github.com/multiversx/mx-chain-logger-go v1.0.14/go.mod h1:bDfHSdwqIimn7Gp8w+SH5KlDuGzJ//nlyEANAaTSc3o= github.com/multiversx/mx-chain-scenario-go v1.4.3 h1:9xeVB8TOsolXS4YEr1CZ/VZr5Qk0X+nde8nRGnxJICo= diff --git a/integrationTests/relayers/slowTests/common.go b/integrationTests/relayers/slowTests/common.go index e05f3463..7c8ba6c9 100644 --- a/integrationTests/relayers/slowTests/common.go +++ b/integrationTests/relayers/slowTests/common.go @@ -6,6 +6,7 @@ import ( "math/big" "github.com/multiversx/mx-bridge-eth-go/integrationTests/relayers/slowTests/framework" + "github.com/multiversx/mx-bridge-eth-go/parsers" ) // GenerateTestUSDCToken will generate a test USDC token @@ -33,23 +34,15 @@ func GenerateTestUSDCToken() framework.TestTokenParams { { ValueToTransferToMvx: big.NewInt(5000), ValueToSendFromMvX: big.NewInt(2500), - MvxSCCallMethod: "", - MvxSCCallGasLimit: 0, - MvxSCCallArguments: nil, }, { ValueToTransferToMvx: big.NewInt(7000), ValueToSendFromMvX: big.NewInt(300), - MvxSCCallMethod: "", - MvxSCCallGasLimit: 0, - MvxSCCallArguments: nil, }, { ValueToTransferToMvx: big.NewInt(1000), ValueToSendFromMvX: nil, - MvxSCCallMethod: "callPayable", - MvxSCCallGasLimit: 50000000, - MvxSCCallArguments: nil, + MvxSCCallData: createScCallData("callPayable", 50000000), }, }, ESDTSafeExtraBalance: big.NewInt(100), // extra is just for the fees for the 2 transfers mvx->eth @@ -82,26 +75,30 @@ func GenerateTestMEMEToken() framework.TestTokenParams { { ValueToTransferToMvx: big.NewInt(2400), ValueToSendFromMvX: big.NewInt(4000), - MvxSCCallMethod: "", - MvxSCCallGasLimit: 0, - MvxSCCallArguments: nil, }, { ValueToTransferToMvx: big.NewInt(200), ValueToSendFromMvX: big.NewInt(6000), - MvxSCCallMethod: "", - MvxSCCallGasLimit: 0, - MvxSCCallArguments: nil, }, { ValueToTransferToMvx: big.NewInt(1000), ValueToSendFromMvX: big.NewInt(2000), - MvxSCCallMethod: "callPayable", - MvxSCCallGasLimit: 50000000, - MvxSCCallArguments: nil, + MvxSCCallData: createScCallData("callPayable", 50000000), }, }, ESDTSafeExtraBalance: big.NewInt(4000 + 6000 + 2000), // everything is locked in the safe esdt contract EthTestAddrExtraBalance: big.NewInt(4000 - 50 + 6000 - 50 + 2000 - 50), } } + +func createScCallData(function string, gasLimit uint64, args ...string) []byte { + codec := parsers.MultiversxCodec{} + callData := parsers.CallData{ + Type: parsers.DataPresentProtocolMarker, + Function: function, + GasLimit: gasLimit, + Arguments: args, + } + + return codec.EncodeCallData(callData) +} diff --git a/integrationTests/relayers/slowTests/ethToMultiversXWithChainSimulator_test.go b/integrationTests/relayers/slowTests/ethToMultiversXWithChainSimulator_test.go index 4c155882..7c4cf477 100644 --- a/integrationTests/relayers/slowTests/ethToMultiversXWithChainSimulator_test.go +++ b/integrationTests/relayers/slowTests/ethToMultiversXWithChainSimulator_test.go @@ -95,6 +95,7 @@ func testRelayersWithChainSimulatorAndTokens(tb testing.TB, manualStopChan chan // commit blocks in order to execute incoming txs from relayers setup.EthereumHandler.SimulatedChain.Commit() setup.ChainSimulator.GenerateBlocks(setup.Ctx, 1) + require.LessOrEqual(tb, setup.ScCallerModuleInstance.GetNumSentTransaction(), setup.GetNumScCallsOperations()) return false } @@ -193,23 +194,15 @@ func createBadToken() framework.TestTokenParams { { ValueToTransferToMvx: big.NewInt(5000), ValueToSendFromMvX: big.NewInt(2500), - MvxSCCallMethod: "", - MvxSCCallGasLimit: 0, - MvxSCCallArguments: nil, }, { ValueToTransferToMvx: big.NewInt(7000), ValueToSendFromMvX: big.NewInt(300), - MvxSCCallMethod: "", - MvxSCCallGasLimit: 0, - MvxSCCallArguments: nil, }, { ValueToTransferToMvx: big.NewInt(1000), ValueToSendFromMvX: nil, - MvxSCCallMethod: "callPayable", - MvxSCCallGasLimit: 50000000, - MvxSCCallArguments: nil, + MvxSCCallData: createScCallData("callPayable", 50000000), }, }, ESDTSafeExtraBalance: big.NewInt(0), diff --git a/integrationTests/relayers/slowTests/framework/ethereumHandler.go b/integrationTests/relayers/slowTests/framework/ethereumHandler.go index 286cbf67..0168bb38 100644 --- a/integrationTests/relayers/slowTests/framework/ethereumHandler.go +++ b/integrationTests/relayers/slowTests/framework/ethereumHandler.go @@ -20,7 +20,6 @@ import ( "github.com/multiversx/mx-bridge-eth-go/clients/ethereum/wrappers" "github.com/multiversx/mx-bridge-eth-go/core/converters" "github.com/multiversx/mx-bridge-eth-go/integrationTests" - "github.com/multiversx/mx-bridge-eth-go/parsers" "github.com/multiversx/mx-bridge-eth-go/testsCommon" "github.com/multiversx/mx-sdk-go/core" "github.com/stretchr/testify/require" @@ -355,23 +354,13 @@ func (handler *EthereumHandler) createDepositsOnEthereumForToken( } var tx *types.Transaction - if len(operation.MvxSCCallMethod) > 0 { - codec := parsers.MultiversxCodec{} - callData := parsers.CallData{ - Type: parsers.DataPresentProtocolMarker, - Function: operation.MvxSCCallMethod, - GasLimit: operation.MvxSCCallGasLimit, - Arguments: operation.MvxSCCallArguments, - } - - buff := codec.EncodeCallData(callData) - + if len(operation.MvxSCCallData) > 0 { tx, err = handler.SafeContract.DepositWithSCExecution( auth, token.EthErc20Address, operation.ValueToTransferToMvx, mvxTestCallerAddress.AddressSlice(), - string(buff), + string(operation.MvxSCCallData), ) } else { tx, err = handler.SafeContract.Deposit(auth, token.EthErc20Address, operation.ValueToTransferToMvx, handler.TestKeys.MvxAddress.AddressSlice()) diff --git a/integrationTests/relayers/slowTests/framework/interface.go b/integrationTests/relayers/slowTests/framework/interface.go index b2638085..04bb4d48 100644 --- a/integrationTests/relayers/slowTests/framework/interface.go +++ b/integrationTests/relayers/slowTests/framework/interface.go @@ -69,3 +69,9 @@ type TokensRegistry interface { RegisterUniversalToken(abstractTokenIdentifier string, mvxUniversalToken string) RegisterChainSpecificToken(abstractTokenIdentifier string, mvxChainSpecificToken string) } + +// SCCallerModule defines the operation for the module able to execute smart contract calls +type SCCallerModule interface { + GetNumSentTransaction() uint32 + Close() error +} diff --git a/integrationTests/relayers/slowTests/framework/testSetup.go b/integrationTests/relayers/slowTests/framework/testSetup.go index afc2009c..32261a4e 100644 --- a/integrationTests/relayers/slowTests/framework/testSetup.go +++ b/integrationTests/relayers/slowTests/framework/testSetup.go @@ -3,11 +3,11 @@ package framework import ( "context" "fmt" - "io" "math/big" "os" "path" "sync" + "sync/atomic" "testing" "github.com/multiversx/mx-bridge-eth-go/config" @@ -30,19 +30,20 @@ type TestSetup struct { testing.TB TokensRegistry *KeysStore - Bridge *BridgeComponents - EthereumHandler *EthereumHandler - MultiversxHandler *MultiversxHandler - WorkingDir string - ChainSimulator ChainSimulatorWrapper - ScCallerKeys KeysHolder - ScCallerModule io.Closer + Bridge *BridgeComponents + EthereumHandler *EthereumHandler + MultiversxHandler *MultiversxHandler + WorkingDir string + ChainSimulator ChainSimulatorWrapper + ScCallerKeys KeysHolder + ScCallerModuleInstance SCCallerModule ctxCancel func() Ctx context.Context mutBalances sync.RWMutex esdtBalanceForSafe map[string]*big.Int ethBalanceTestAddress map[string]*big.Int + numScCallsInTest uint32 } // NewTestSetup creates a new e2e test setup @@ -110,7 +111,7 @@ func (setup *TestSetup) StartRelayersAndScModule() { func (setup *TestSetup) startScCallerModule() { cfg := config.ScCallsModuleConfig{ ScProxyBech32Address: setup.MultiversxHandler.ScProxyAddress.Bech32(), - ExtraGasToExecute: 30_000_000, // 30 million (50 mil call -> provided + 20 mil callback + 10 mil extra) + ExtraGasToExecute: 60_000_000, // 60 million: this ensures that a SC call with 0 gas limit is refunded NetworkAddress: setup.ChainSimulator.GetNetworkAddress(), ProxyMaxNoncesDelta: 5, ProxyFinalityCheck: false, @@ -127,7 +128,7 @@ func (setup *TestSetup) startScCallerModule() { } var err error - setup.ScCallerModule, err = module.NewScCallsModule(cfg, log) + setup.ScCallerModuleInstance, err = module.NewScCallsModule(cfg, log) require.Nil(setup, err) log.Info("started SC calls module", "monitoring SC proxy address", setup.MultiversxHandler.ScProxyAddress) } @@ -142,6 +143,7 @@ func (setup *TestSetup) IssueAndConfigureTokens(tokens ...TestTokenParams) { setup.MultiversxHandler.PauseContractsForTokenChanges(setup.Ctx) for _, token := range tokens { + setup.processNumScCallsOperations(token) setup.AddToken(token.IssueTokenParams) setup.EthereumHandler.IssueAndWhitelistToken(setup.Ctx, token.IssueTokenParams) setup.MultiversxHandler.IssueAndWhitelistToken(setup.Ctx, token.IssueTokenParams) @@ -166,6 +168,19 @@ func (setup *TestSetup) IssueAndConfigureTokens(tokens ...TestTokenParams) { } } +func (setup *TestSetup) processNumScCallsOperations(token TestTokenParams) { + for _, op := range token.TestOperations { + if len(op.MvxSCCallData) > 0 { + atomic.AddUint32(&setup.numScCallsInTest, 1) + } + } +} + +// GetNumScCallsOperations returns the number of SC calls in this test setup +func (setup *TestSetup) GetNumScCallsOperations() uint32 { + return atomic.LoadUint32(&setup.numScCallsInTest) +} + // IsTransferDoneFromEthereum returns true if all provided tokens are bridged from Ethereum towards MultiversX func (setup *TestSetup) IsTransferDoneFromEthereum(tokens ...TestTokenParams) bool { isDone := true @@ -184,7 +199,7 @@ func (setup *TestSetup) isTransferDoneFromEthereumForToken(params TestTokenParam continue } - if len(operation.MvxSCCallMethod) > 0 { + if len(operation.MvxSCCallData) > 0 { if !operation.MvxFaultySCCall { expectedValueOnContract.Add(expectedValueOnContract, operation.ValueToTransferToMvx) } @@ -228,7 +243,7 @@ func (setup *TestSetup) isTransferDoneFromEthereumWithRefundForToken(params Test } expectedValueOnReceiver.Add(expectedValueOnReceiver, big.NewInt(0).Sub(valueToSendFromMvX, valueToTransferToMvx)) - if len(operation.MvxSCCallMethod) > 0 { + if len(operation.MvxSCCallData) > 0 { if operation.MvxFaultySCCall { // the balance should be bridged back to the receiver on Ethereum - fee expectedValueOnReceiver.Add(expectedValueOnReceiver, valueToTransferToMvx) @@ -312,5 +327,5 @@ func (setup *TestSetup) Close() { require.NoError(setup, setup.EthereumHandler.Close()) setup.ctxCancel() - _ = setup.ScCallerModule.Close() + _ = setup.ScCallerModuleInstance.Close() } diff --git a/integrationTests/relayers/slowTests/framework/types.go b/integrationTests/relayers/slowTests/framework/types.go index 61697ba4..f494c8bf 100644 --- a/integrationTests/relayers/slowTests/framework/types.go +++ b/integrationTests/relayers/slowTests/framework/types.go @@ -33,9 +33,7 @@ type IssueTokenParams struct { type TokenOperations struct { ValueToTransferToMvx *big.Int ValueToSendFromMvX *big.Int - MvxSCCallMethod string - MvxSCCallGasLimit uint64 - MvxSCCallArguments []string + MvxSCCallData []byte MvxFaultySCCall bool } diff --git a/integrationTests/relayers/slowTests/refundWithChainSimulator_test.go b/integrationTests/relayers/slowTests/refundWithChainSimulator_test.go index b582d94a..73667f3d 100644 --- a/integrationTests/relayers/slowTests/refundWithChainSimulator_test.go +++ b/integrationTests/relayers/slowTests/refundWithChainSimulator_test.go @@ -10,25 +10,125 @@ import ( "testing" "github.com/multiversx/mx-bridge-eth-go/integrationTests/relayers/slowTests/framework" + "github.com/multiversx/mx-bridge-eth-go/parsers" + "github.com/stretchr/testify/require" ) func TestRelayersShouldExecuteTransfersWithRefund(t *testing.T) { - usdcToken := GenerateTestUSDCToken() - usdcToken.TestOperations[2].MvxSCCallMethod = "unknownFunction" - usdcToken.TestOperations[2].MvxFaultySCCall = true - usdcToken.EthTestAddrExtraBalance = big.NewInt(-5000 + 2500 - 50 - 7000 + 300 - 50 - 1000 + 950) // -(eth->mvx) + (mvx->eth) - fees + revert after bad SC call - usdcToken.ESDTSafeExtraBalance = big.NewInt(150) // extra is just for the fees for the 2 transfers mvx->eth and the failed eth->mvx that needed refund - - memeToken := GenerateTestMEMEToken() - memeToken.TestOperations[2].MvxSCCallMethod = "unknownFunction" - memeToken.TestOperations[2].MvxFaultySCCall = true - - testRelayersWithChainSimulatorAndTokensAndRefund( - t, - make(chan error), - usdcToken, - memeToken, - ) + t.Run("unknown marker and malformed SC call data should refund", func(t *testing.T) { + callData := []byte{5, 4, 55} + usdcToken := GenerateTestUSDCToken() + usdcToken.TestOperations[2].MvxSCCallData = callData + usdcToken.TestOperations[2].MvxFaultySCCall = true + usdcToken.EthTestAddrExtraBalance = big.NewInt(-5000 + 2500 - 50 - 7000 + 300 - 50 - 1000 + 950) // -(eth->mvx) + (mvx->eth) - fees + revert after bad SC call + usdcToken.ESDTSafeExtraBalance = big.NewInt(150) // extra is just for the fees for the 2 transfers mvx->eth and the failed eth->mvx that needed refund + + memeToken := GenerateTestMEMEToken() + memeToken.TestOperations[2].MvxSCCallData = callData + memeToken.TestOperations[2].MvxFaultySCCall = true + + testRelayersWithChainSimulatorAndTokensAndRefund( + t, + make(chan error), + usdcToken, + memeToken, + ) + }) + t.Run("malformed SC call data should refund", func(t *testing.T) { + callData := []byte{parsers.DataPresentProtocolMarker, 4, 55} + usdcToken := GenerateTestUSDCToken() + usdcToken.TestOperations[2].MvxSCCallData = callData + usdcToken.TestOperations[2].MvxFaultySCCall = true + usdcToken.EthTestAddrExtraBalance = big.NewInt(-5000 + 2500 - 50 - 7000 + 300 - 50 - 1000 + 950) // -(eth->mvx) + (mvx->eth) - fees + revert after bad SC call + usdcToken.ESDTSafeExtraBalance = big.NewInt(150) // extra is just for the fees for the 2 transfers mvx->eth and the failed eth->mvx that needed refund + + memeToken := GenerateTestMEMEToken() + memeToken.TestOperations[2].MvxSCCallData = callData + memeToken.TestOperations[2].MvxFaultySCCall = true + + testRelayersWithChainSimulatorAndTokensAndRefund( + t, + make(chan error), + usdcToken, + memeToken, + ) + }) + t.Run("unknown function should refund", func(t *testing.T) { + callData := createScCallData("unknownFunction", 50000000) + usdcToken := GenerateTestUSDCToken() + usdcToken.TestOperations[2].MvxSCCallData = callData + usdcToken.TestOperations[2].MvxFaultySCCall = true + usdcToken.EthTestAddrExtraBalance = big.NewInt(-5000 + 2500 - 50 - 7000 + 300 - 50 - 1000 + 950) // -(eth->mvx) + (mvx->eth) - fees + revert after bad SC call + usdcToken.ESDTSafeExtraBalance = big.NewInt(150) // extra is just for the fees for the 2 transfers mvx->eth and the failed eth->mvx that needed refund + + memeToken := GenerateTestMEMEToken() + memeToken.TestOperations[2].MvxSCCallData = callData + memeToken.TestOperations[2].MvxFaultySCCall = true + + testRelayersWithChainSimulatorAndTokensAndRefund( + t, + make(chan error), + usdcToken, + memeToken, + ) + }) + t.Run("0 gas limit should refund", func(t *testing.T) { + callData := createScCallData("callPayable", 0) + usdcToken := GenerateTestUSDCToken() + usdcToken.TestOperations[2].MvxSCCallData = callData + usdcToken.TestOperations[2].MvxFaultySCCall = true + usdcToken.EthTestAddrExtraBalance = big.NewInt(-5000 + 2500 - 50 - 7000 + 300 - 50 - 1000 + 950) // -(eth->mvx) + (mvx->eth) - fees + revert after bad SC call + usdcToken.ESDTSafeExtraBalance = big.NewInt(150) // extra is just for the fees for the 2 transfers mvx->eth and the failed eth->mvx that needed refund + + memeToken := GenerateTestMEMEToken() + memeToken.TestOperations[2].MvxSCCallData = callData + memeToken.TestOperations[2].MvxFaultySCCall = true + + testRelayersWithChainSimulatorAndTokensAndRefund( + t, + make(chan error), + usdcToken, + memeToken, + ) + }) + t.Run("small gas limit should refund", func(t *testing.T) { + callData := createScCallData("callPayable", 2000) + usdcToken := GenerateTestUSDCToken() + usdcToken.TestOperations[2].MvxSCCallData = callData + usdcToken.TestOperations[2].MvxFaultySCCall = true + usdcToken.EthTestAddrExtraBalance = big.NewInt(-5000 + 2500 - 50 - 7000 + 300 - 50 - 1000 + 950) // -(eth->mvx) + (mvx->eth) - fees + revert after bad SC call + usdcToken.ESDTSafeExtraBalance = big.NewInt(150) // extra is just for the fees for the 2 transfers mvx->eth and the failed eth->mvx that needed refund + + memeToken := GenerateTestMEMEToken() + memeToken.TestOperations[2].MvxSCCallData = callData + memeToken.TestOperations[2].MvxFaultySCCall = true + + testRelayersWithChainSimulatorAndTokensAndRefund( + t, + make(chan error), + usdcToken, + memeToken, + ) + }) + t.Run("extra parameter should refund", func(t *testing.T) { + callData := createScCallData("callPayable", 50000000, "extra parameter") + usdcToken := GenerateTestUSDCToken() + usdcToken.TestOperations[2].MvxSCCallData = callData + usdcToken.TestOperations[2].MvxFaultySCCall = true + usdcToken.EthTestAddrExtraBalance = big.NewInt(-5000 + 2500 - 50 - 7000 + 300 - 50 - 1000 + 950) // -(eth->mvx) + (mvx->eth) - fees + revert after bad SC call + usdcToken.ESDTSafeExtraBalance = big.NewInt(150) // extra is just for the fees for the 2 transfers mvx->eth and the failed eth->mvx that needed refund + + memeToken := GenerateTestMEMEToken() + memeToken.TestOperations[2].MvxSCCallData = callData + memeToken.TestOperations[2].MvxFaultySCCall = true + + testRelayersWithChainSimulatorAndTokensAndRefund( + t, + make(chan error), + usdcToken, + memeToken, + ) + }) } func testRelayersWithChainSimulatorAndTokensAndRefund(tb testing.TB, manualStopChan chan error, tokens ...framework.TestTokenParams) { @@ -56,6 +156,7 @@ func testRelayersWithChainSimulatorAndTokensAndRefund(tb testing.TB, manualStopC // commit blocks in order to execute incoming txs from relayers setup.EthereumHandler.SimulatedChain.Commit() setup.ChainSimulator.GenerateBlocks(setup.Ctx, 1) + require.LessOrEqual(tb, setup.ScCallerModuleInstance.GetNumSentTransaction(), setup.GetNumScCallsOperations()) return false } diff --git a/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridge-proxy.abi.json b/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridge-proxy.abi.json index 5db4331c..bc9152ac 100644 --- a/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridge-proxy.abi.json +++ b/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridge-proxy.abi.json @@ -1,11 +1,11 @@ { "buildInfo": { "rustc": { - "version": "1.80.0", - "commitHash": "051478957371ee0084a7c0913941d2a8c4757bb9", - "commitDate": "2024-07-21", + "version": "1.78.0", + "commitHash": "9b00956e56009bab2aa15d7bff10916599e3d6d6", + "commitDate": "2024-04-29", "channel": "Stable", - "short": "rustc 1.80.0 (051478957 2024-07-21)" + "short": "rustc 1.78.0 (9b00956e5 2024-04-29)" }, "contractCrate": { "name": "bridge-proxy", @@ -13,7 +13,7 @@ }, "framework": { "name": "multiversx-sc", - "version": "0.52.2" + "version": "0.52.3" } }, "name": "BridgeProxyContract", @@ -157,6 +157,16 @@ "promisesCallbackNames": [ "execution_callback" ], + "events": [ + { + "identifier": "pauseContract", + "inputs": [] + }, + { + "identifier": "unpauseContract", + "inputs": [] + } + ], "esdtAttributes": [], "hasCallback": false, "types": { diff --git a/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridge-proxy.wasm b/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridge-proxy.wasm index 3549ae01..94ccf995 100755 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.abi.json b/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridged-tokens-wrapper.abi.json index 249c77c0..1287c24b 100644 --- a/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridged-tokens-wrapper.abi.json +++ b/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridged-tokens-wrapper.abi.json @@ -1,11 +1,11 @@ { "buildInfo": { "rustc": { - "version": "1.80.0", - "commitHash": "051478957371ee0084a7c0913941d2a8c4757bb9", - "commitDate": "2024-07-21", + "version": "1.78.0", + "commitHash": "9b00956e56009bab2aa15d7bff10916599e3d6d6", + "commitDate": "2024-04-29", "channel": "Stable", - "short": "rustc 1.80.0 (051478957 2024-07-21)" + "short": "rustc 1.78.0 (9b00956e5 2024-04-29)" }, "contractCrate": { "name": "bridged-tokens-wrapper", @@ -13,7 +13,7 @@ }, "framework": { "name": "multiversx-sc", - "version": "0.52.2" + "version": "0.52.3" } }, "name": "BridgedTokensWrapper", @@ -281,6 +281,14 @@ } ], "events": [ + { + "identifier": "pauseContract", + "inputs": [] + }, + { + "identifier": "unpauseContract", + "inputs": [] + }, { "identifier": "wrap_tokens", "inputs": [ diff --git a/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridged-tokens-wrapper.wasm b/integrationTests/relayers/slowTests/testdata/contracts/mvx/bridged-tokens-wrapper.wasm index 615c5f77..ea8a30cc 100755 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.abi.json b/integrationTests/relayers/slowTests/testdata/contracts/mvx/esdt-safe.abi.json index bef93d51..68049513 100644 --- a/integrationTests/relayers/slowTests/testdata/contracts/mvx/esdt-safe.abi.json +++ b/integrationTests/relayers/slowTests/testdata/contracts/mvx/esdt-safe.abi.json @@ -1,11 +1,11 @@ { "buildInfo": { "rustc": { - "version": "1.80.0", - "commitHash": "051478957371ee0084a7c0913941d2a8c4757bb9", - "commitDate": "2024-07-21", + "version": "1.78.0", + "commitHash": "9b00956e56009bab2aa15d7bff10916599e3d6d6", + "commitDate": "2024-04-29", "channel": "Stable", - "short": "rustc 1.80.0 (051478957 2024-07-21)" + "short": "rustc 1.78.0 (9b00956e5 2024-04-29)" }, "contractCrate": { "name": "esdt-safe", @@ -13,7 +13,7 @@ }, "framework": { "name": "multiversx-sc", - "version": "0.52.2" + "version": "0.52.3" } }, "name": "EsdtSafe", @@ -84,10 +84,10 @@ }, { "docs": [ - "Converts failed Ethereum -> Elrond transactions to Elrond -> Ethereum transaction.", + "Converts failed Ethereum -> MultiversX transactions to MultiversX -> Ethereum transaction.", "This is done every now and then to refund the tokens.", "", - "As with normal Elrond -> Ethereum transactions, a part of the tokens will be", + "As with normal MultiversX -> Ethereum transactions, a part of the tokens will be", "subtracted to pay for the fees" ], "name": "addRefundBatch", @@ -105,7 +105,7 @@ }, { "docs": [ - "Create an Elrond -> Ethereum transaction. Only fungible tokens are accepted.", + "Create an MultiversX -> Ethereum transaction. Only fungible tokens are accepted.", "", "Every transfer will have a part of the tokens subtracted as fees.", "The fee amount depends on the global eth_tx_gas_limit", @@ -128,7 +128,7 @@ }, { "docs": [ - "Claim funds for failed Elrond -> Ethereum transactions.", + "Claim funds for failed MultiversX -> Ethereum transactions.", "These are not sent automatically to prevent the contract getting stuck.", "For example, if the receiver is a SC, a frozen account, etc." ], @@ -796,6 +796,14 @@ "indexed": true } ] + }, + { + "identifier": "pauseContract", + "inputs": [] + }, + { + "identifier": "unpauseContract", + "inputs": [] } ], "esdtAttributes": [], diff --git a/integrationTests/relayers/slowTests/testdata/contracts/mvx/esdt-safe.wasm b/integrationTests/relayers/slowTests/testdata/contracts/mvx/esdt-safe.wasm index 95f39fe7..55d0266a 100755 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.abi.json b/integrationTests/relayers/slowTests/testdata/contracts/mvx/multi-transfer-esdt.abi.json index 16b24e0f..c4350975 100644 --- a/integrationTests/relayers/slowTests/testdata/contracts/mvx/multi-transfer-esdt.abi.json +++ b/integrationTests/relayers/slowTests/testdata/contracts/mvx/multi-transfer-esdt.abi.json @@ -1,11 +1,11 @@ { "buildInfo": { "rustc": { - "version": "1.80.0", - "commitHash": "051478957371ee0084a7c0913941d2a8c4757bb9", - "commitDate": "2024-07-21", + "version": "1.78.0", + "commitHash": "9b00956e56009bab2aa15d7bff10916599e3d6d6", + "commitDate": "2024-04-29", "channel": "Stable", - "short": "rustc 1.80.0 (051478957 2024-07-21)" + "short": "rustc 1.78.0 (9b00956e5 2024-04-29)" }, "contractCrate": { "name": "multi-transfer-esdt", @@ -13,7 +13,7 @@ }, "framework": { "name": "multiversx-sc", - "version": "0.52.2" + "version": "0.52.3" } }, "name": "MultiTransferEsdt", @@ -36,8 +36,8 @@ "type": "u64" }, { - "name": "transfers", - "type": "List" + "name": "raw_transfers", + "type": "bytes" } ], "outputs": [] @@ -393,35 +393,6 @@ "type": "array20" } ] - }, - "EthTransaction": { - "type": "struct", - "fields": [ - { - "name": "from", - "type": "EthAddress" - }, - { - "name": "to", - "type": "Address" - }, - { - "name": "token_id", - "type": "TokenIdentifier" - }, - { - "name": "amount", - "type": "BigUint" - }, - { - "name": "tx_nonce", - "type": "u64" - }, - { - "name": "call_data", - "type": "Option" - } - ] } } } diff --git a/integrationTests/relayers/slowTests/testdata/contracts/mvx/multi-transfer-esdt.wasm b/integrationTests/relayers/slowTests/testdata/contracts/mvx/multi-transfer-esdt.wasm index 9a8de4ca..617d357d 100755 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.abi.json b/integrationTests/relayers/slowTests/testdata/contracts/mvx/multisig.abi.json index efab9d6d..afc35103 100644 --- a/integrationTests/relayers/slowTests/testdata/contracts/mvx/multisig.abi.json +++ b/integrationTests/relayers/slowTests/testdata/contracts/mvx/multisig.abi.json @@ -1,11 +1,11 @@ { "buildInfo": { "rustc": { - "version": "1.80.0", - "commitHash": "051478957371ee0084a7c0913941d2a8c4757bb9", - "commitDate": "2024-07-21", + "version": "1.78.0", + "commitHash": "9b00956e56009bab2aa15d7bff10916599e3d6d6", + "commitDate": "2024-04-29", "channel": "Stable", - "short": "rustc 1.80.0 (051478957 2024-07-21)" + "short": "rustc 1.78.0 (9b00956e5 2024-04-29)" }, "contractCrate": { "name": "multisig", @@ -13,7 +13,7 @@ }, "framework": { "name": "multiversx-sc", - "version": "0.52.2" + "version": "0.52.3" } }, "docs": [ @@ -131,7 +131,7 @@ }, { "docs": [ - "Proposes a batch of Ethereum -> Elrond transfers.", + "Proposes a batch of Ethereum -> MultiversX transfers.", "Transactions have to be separated by fields, in the following order:", "Sender Address, Destination Address, Token ID, Amount, Tx Nonce" ], @@ -143,8 +143,8 @@ "type": "u64" }, { - "name": "transfers", - "type": "List" + "name": "raw_transfers", + "type": "bytes" } ], "outputs": [ @@ -155,11 +155,11 @@ }, { "docs": [ - "Failed Ethereum -> Elrond transactions are saved in the MultiTransfer SC", + "Failed Ethereum -> MultiversX transactions are saved in the MultiTransfer SC", "as \"refund transactions\", and stored in batches, using the same mechanism as EsdtSafe.", "", "This function moves the first refund batch into the EsdtSafe SC,", - "converting the transactions into Elrond -> Ethereum transactions", + "converting the transactions into MultiversX -> Ethereum transactions", "and adding them into EsdtSafe batches" ], "name": "moveRefundBatchToSafeFromChildContract", @@ -366,7 +366,7 @@ "", "where price_per_gas_unit is queried from the aggregator (fee estimator SC)" ], - "name": "changeElrondToEthGasLimit", + "name": "changeMultiversXToEthGasLimit", "onlyOwner": true, "mutability": "mutable", "inputs": [ @@ -507,7 +507,7 @@ }, { "docs": [ - "Sets the maximum bridged amount for the token for the Elrond -> Ethereum direction.", + "Sets the maximum bridged amount for the token for the MultiversX -> Ethereum direction.", "Any attempt to transfer over this amount will be rejected." ], "name": "esdtSafeSetMaxBridgedAmountForToken", @@ -527,7 +527,7 @@ }, { "docs": [ - "Same as the function above, but for Ethereum -> Elrond transactions." + "Same as the function above, but for Ethereum -> MultiversX transactions." ], "name": "multiTransferEsdtSetMaxBridgedAmountForToken", "onlyOwner": true, @@ -546,7 +546,7 @@ }, { "docs": [ - "Any failed Ethereum -> Elrond transactions are added into so-called \"refund batches\\", + "Any failed Ethereum -> MultiversX transactions are added into so-called \"refund batches\\", "This configures the size of a batch." ], "name": "multiTransferEsdtSetMaxRefundTxBatchSize", @@ -704,7 +704,7 @@ }, { "docs": [ - "Mapping between ERC20 Ethereum address and Elrond ESDT Token Identifiers" + "Mapping between ERC20 Ethereum address and MultiversX ESDT Token Identifiers" ], "name": "getErc20AddressForTokenId", "mutability": "readonly", @@ -800,7 +800,7 @@ }, { "docs": [ - "Returns a batch of failed Ethereum -> Elrond transactions.", + "Returns a batch of failed Ethereum -> MultiversX transactions.", "The result format is the same as getCurrentTxBatch" ], "name": "getCurrentRefundBatch", @@ -834,7 +834,7 @@ }, { "docs": [ - "Used for Ethereum -> Elrond batches.", + "Used for Ethereum -> MultiversX batches.", "If the mapping was made, it means that the transfer action was proposed in the past.", "To check if it was executed as well, use the wasActionExecuted view" ], @@ -846,8 +846,8 @@ "type": "u64" }, { - "name": "transfers", - "type": "List" + "name": "raw_transfers", + "type": "bytes" } ], "outputs": [ @@ -870,8 +870,8 @@ "type": "u64" }, { - "name": "transfers", - "type": "List" + "name": "raw_transfers", + "type": "bytes" } ], "outputs": [ @@ -1159,6 +1159,14 @@ { "identifier": "unpause_esdt_safe", "inputs": [] + }, + { + "identifier": "pauseContract", + "inputs": [] + }, + { + "identifier": "unpauseContract", + "inputs": [] } ], "esdtAttributes": [], diff --git a/integrationTests/relayers/slowTests/testdata/contracts/mvx/multisig.wasm b/integrationTests/relayers/slowTests/testdata/contracts/mvx/multisig.wasm index 779cdb07..30a8d34e 100755 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/test-caller.abi.json b/integrationTests/relayers/slowTests/testdata/contracts/mvx/test-caller.abi.json index 43eeab2d..b09cd36c 100644 --- a/integrationTests/relayers/slowTests/testdata/contracts/mvx/test-caller.abi.json +++ b/integrationTests/relayers/slowTests/testdata/contracts/mvx/test-caller.abi.json @@ -1,11 +1,11 @@ { "buildInfo": { "rustc": { - "version": "1.80.0", - "commitHash": "051478957371ee0084a7c0913941d2a8c4757bb9", - "commitDate": "2024-07-21", + "version": "1.78.0", + "commitHash": "9b00956e56009bab2aa15d7bff10916599e3d6d6", + "commitDate": "2024-04-29", "channel": "Stable", - "short": "rustc 1.80.0 (051478957 2024-07-21)" + "short": "rustc 1.78.0 (9b00956e5 2024-04-29)" }, "contractCrate": { "name": "test-caller", @@ -13,7 +13,7 @@ }, "framework": { "name": "multiversx-sc", - "version": "0.52.2" + "version": "0.52.3" } }, "name": "TestCallerContract",