From 08f55b465bd4884717166bc4a4c78f0322730e8e Mon Sep 17 00:00:00 2001 From: Iulian Pascalau Date: Tue, 16 Jul 2024 18:26:44 +0300 Subject: [PATCH] - refactored & simplified the transaction sent status in tests - minor fix in the set status step to avoid some false positives - fixed prints in tests --- .../multiversxToEth/step06ResolveSetStatus.go | 11 +- .../relayers/slowTests/framework/address.go | 5 + .../framework/chainSimulatorWrapper.go | 49 +++--- .../relayers/slowTests/framework/interface.go | 7 +- .../slowTests/framework/multiversxHandler.go | 141 +++++++----------- .../relayers/slowTests/framework/testSetup.go | 2 +- 6 files changed, 98 insertions(+), 117 deletions(-) diff --git a/bridges/ethMultiversX/steps/multiversxToEth/step06ResolveSetStatus.go b/bridges/ethMultiversX/steps/multiversxToEth/step06ResolveSetStatus.go index 4c0b7a18..6ffc9464 100644 --- a/bridges/ethMultiversX/steps/multiversxToEth/step06ResolveSetStatus.go +++ b/bridges/ethMultiversX/steps/multiversxToEth/step06ResolveSetStatus.go @@ -2,8 +2,10 @@ package multiversxtoeth import ( "context" + "errors" "github.com/multiversx/mx-bridge-eth-go/bridges/ethMultiversX/steps" + "github.com/multiversx/mx-bridge-eth-go/clients" "github.com/multiversx/mx-bridge-eth-go/core" logger "github.com/multiversx/mx-chain-logger-go" ) @@ -22,12 +24,13 @@ func (step *resolveSetStatusStep) Execute(ctx context.Context) core.StepIdentifi } batch, err := step.bridge.GetBatchFromMultiversX(ctx) - if err != nil { - step.bridge.PrintInfo(logger.LogError, "error while fetching batch", "error", err) + isEmptyBatch := batch == nil || (err != nil && errors.Is(err, clients.ErrNoPendingBatchAvailable)) + if isEmptyBatch { + step.bridge.PrintInfo(logger.LogDebug, "nil/empty batch fetched") return GettingPendingBatchFromMultiversX } - if batch == nil { - step.bridge.PrintInfo(logger.LogDebug, "nil batch fetched") + if err != nil { + step.bridge.PrintInfo(logger.LogError, "error while fetching batch", "error", err) return GettingPendingBatchFromMultiversX } diff --git a/integrationTests/relayers/slowTests/framework/address.go b/integrationTests/relayers/slowTests/framework/address.go index de1125a0..970df17d 100644 --- a/integrationTests/relayers/slowTests/framework/address.go +++ b/integrationTests/relayers/slowTests/framework/address.go @@ -60,3 +60,8 @@ func (address *MvxAddress) Bech32() string { func (address *MvxAddress) Hex() string { return address.hex } + +// String returns the address in bech32 format +func (address *MvxAddress) String() string { + return address.bech32 +} diff --git a/integrationTests/relayers/slowTests/framework/chainSimulatorWrapper.go b/integrationTests/relayers/slowTests/framework/chainSimulatorWrapper.go index 9b606635..663aab11 100644 --- a/integrationTests/relayers/slowTests/framework/chainSimulatorWrapper.go +++ b/integrationTests/relayers/slowTests/framework/chainSimulatorWrapper.go @@ -36,6 +36,8 @@ const ( generateBlocksUntilEpochReachedEndpoint = "simulator/generate-blocks-until-epoch-reached/%d" numProbeRetries = 10 networkConfigEndpointTemplate = "network/status/%d" + maxNumBlocksToBeProcessed = 15 + minNumBlocksToBeProcessedForEachTx = 5 ) var ( @@ -119,7 +121,7 @@ func (instance *chainSimulatorWrapper) GetNetworkAddress() string { } // DeploySC will deploy the provided smart contract and return its address -func (instance *chainSimulatorWrapper) DeploySC(ctx context.Context, wasmFilePath string, ownerSK []byte, parameters []string) *MvxAddress { +func (instance *chainSimulatorWrapper) DeploySC(ctx context.Context, wasmFilePath string, ownerSK []byte, parameters []string) (*MvxAddress, string, *data.TransactionOnNetwork) { networkConfig, err := instance.proxyInstance.GetNetworkConfig(ctx) require.Nil(instance.TB, err) @@ -145,19 +147,28 @@ func (instance *chainSimulatorWrapper) DeploySC(ctx context.Context, wasmFilePat } hash := instance.signAndSend(ctx, ownerSK, ftx) - log.Info("contract deployed", "hash", hash) + txResult := instance.getTransactionResult(ctx, hash) - txResult := instance.GetTransactionResult(ctx, hash) - - return NewMvxAddressFromBech32(instance.TB, txResult.Logs.Events[0].Address) + return NewMvxAddressFromBech32(instance.TB, txResult.Logs.Events[0].Address), hash, txResult } // GetTransactionResult tries to get a transaction result. It may wait a few blocks -func (instance *chainSimulatorWrapper) GetTransactionResult(ctx context.Context, hash string) *data.TransactionOnNetwork { - // TODO: refactor here - instance.GenerateBlocks(ctx, 10) +func (instance *chainSimulatorWrapper) getTransactionResult(ctx context.Context, hash string) *data.TransactionOnNetwork { + instance.GenerateBlocks(ctx, minNumBlocksToBeProcessedForEachTx) + + for i := 0; i < maxNumBlocksToBeProcessed; i++ { + instance.GenerateBlocks(ctx, 1) + + status, txOnNetwork := instance.getTxInfoWithResultsIfTxProcessingFinished(ctx, hash) + if status == transaction.TxStatusPending { + continue + } + require.Equal(instance.TB, transaction.TxStatusSuccess, status, fmt.Sprintf("status not OK for transaction hash %s", hash)) + return txOnNetwork + } - return instance.getTxInfoWithResultsIfTxProcessingFinished(ctx, hash) + require.Fail(instance.TB, fmt.Sprintf("status still pending for transaction hash %s", hash)) + return nil } // GenerateBlocks calls the chain simulator generate block endpoint @@ -178,27 +189,22 @@ func (instance *chainSimulatorWrapper) GenerateBlocksUntilEpochReached(ctx conte } } -func (instance *chainSimulatorWrapper) getTxInfoWithResultsIfTxProcessingFinished(ctx context.Context, hash string) *data.TransactionOnNetwork { +func (instance *chainSimulatorWrapper) getTxInfoWithResultsIfTxProcessingFinished(ctx context.Context, hash string) (transaction.TxStatus, *data.TransactionOnNetwork) { txStatus, err := instance.proxyInstance.ProcessTransactionStatus(ctx, hash) require.Nil(instance, err) - if txStatus == transaction.TxStatusPending { - return nil - } - if txStatus != transaction.TxStatusSuccess { - log.Warn("something went wrong with the transaction", "hash", hash, "status", txStatus) + return txStatus, nil } txResult, errGet := instance.proxyInstance.GetTransactionInfoWithResults(ctx, hash) require.Nil(instance, errGet) - return &txResult.Data.Transaction - + return txStatus, &txResult.Data.Transaction } // ScCall will make the provided sc call -func (instance *chainSimulatorWrapper) ScCall(ctx context.Context, senderSK []byte, contract *MvxAddress, value string, function string, parameters []string) string { +func (instance *chainSimulatorWrapper) ScCall(ctx context.Context, senderSK []byte, contract *MvxAddress, value string, function string, parameters []string) (string, *data.TransactionOnNetwork) { params := []string{function} params = append(params, parameters...) txData := strings.Join(params, "@") @@ -207,7 +213,7 @@ func (instance *chainSimulatorWrapper) ScCall(ctx context.Context, senderSK []by } // SendTx will build and send a transaction -func (instance *chainSimulatorWrapper) SendTx(ctx context.Context, senderSK []byte, receiver *MvxAddress, value string, dataField []byte) string { +func (instance *chainSimulatorWrapper) SendTx(ctx context.Context, senderSK []byte, receiver *MvxAddress, value string, dataField []byte) (string, *data.TransactionOnNetwork) { networkConfig, err := instance.proxyInstance.GetNetworkConfig(ctx) require.Nil(instance, err) @@ -227,7 +233,10 @@ func (instance *chainSimulatorWrapper) SendTx(ctx context.Context, senderSK []by Version: 1, } - return instance.signAndSend(ctx, senderSK, ftx) + hash := instance.signAndSend(ctx, senderSK, ftx) + txResult := instance.getTransactionResult(ctx, hash) + + return hash, txResult } // FundWallets sends funds to the provided addresses diff --git a/integrationTests/relayers/slowTests/framework/interface.go b/integrationTests/relayers/slowTests/framework/interface.go index 039030a4..d0c39dd5 100644 --- a/integrationTests/relayers/slowTests/framework/interface.go +++ b/integrationTests/relayers/slowTests/framework/interface.go @@ -31,10 +31,9 @@ type Relayer interface { type ChainSimulatorWrapper interface { Proxy() multiversx.Proxy GetNetworkAddress() string - DeploySC(ctx context.Context, path string, ownerSK []byte, extraParams []string) *MvxAddress - ScCall(ctx context.Context, senderSK []byte, contract *MvxAddress, value string, function string, parameters []string) string - SendTx(ctx context.Context, senderSK []byte, receiver *MvxAddress, value string, dataField []byte) string - GetTransactionResult(ctx context.Context, hash string) *data.TransactionOnNetwork + DeploySC(ctx context.Context, path string, ownerSK []byte, extraParams []string) (*MvxAddress, string, *data.TransactionOnNetwork) + ScCall(ctx context.Context, senderSK []byte, contract *MvxAddress, value string, function string, parameters []string) (string, *data.TransactionOnNetwork) + SendTx(ctx context.Context, senderSK []byte, receiver *MvxAddress, value string, dataField []byte) (string, *data.TransactionOnNetwork) FundWallets(ctx context.Context, wallets []string) GenerateBlocksUntilEpochReached(ctx context.Context, epoch uint32) GenerateBlocks(ctx context.Context, numBlocks int) diff --git a/integrationTests/relayers/slowTests/framework/multiversxHandler.go b/integrationTests/relayers/slowTests/framework/multiversxHandler.go index f42908a1..9170724f 100644 --- a/integrationTests/relayers/slowTests/framework/multiversxHandler.go +++ b/integrationTests/relayers/slowTests/framework/multiversxHandler.go @@ -119,37 +119,38 @@ func (handler *MultiversxHandler) DeployContracts(ctx context.Context) { handler.OwnerKeys.MvxAddress.Hex(), } - handler.AggregatorAddress = handler.ChainSimulator.DeploySC( + hash := "" + handler.AggregatorAddress, hash, _ = handler.ChainSimulator.DeploySC( ctx, aggregatorContractPath, handler.OwnerKeys.MvxSk, aggregatorDeployParams, ) require.NotEqual(handler, emptyAddress, handler.AggregatorAddress) - log.Info("aggregator contract deployed", "address", handler.AggregatorAddress.Bech32()) + log.Info("aggregator contract deployed", "address", handler.AggregatorAddress, "transaction hash", hash) // deploy wrapper - handler.WrapperAddress = handler.ChainSimulator.DeploySC( + handler.WrapperAddress, hash, _ = handler.ChainSimulator.DeploySC( ctx, wrapperContractPath, handler.OwnerKeys.MvxSk, []string{}, ) require.NotEqual(handler, emptyAddress, handler.WrapperAddress) - log.Info("wrapper contract deployed", "address", handler.WrapperAddress.Bech32()) + log.Info("wrapper contract deployed", "address", handler.WrapperAddress, "transaction hash", hash) // deploy multi-transfer - multiTransferAddress := handler.ChainSimulator.DeploySC( + multiTransferAddress, hash, _ := handler.ChainSimulator.DeploySC( ctx, multiTransferContractPath, handler.OwnerKeys.MvxSk, []string{}, ) require.NotEqual(handler, emptyAddress, multiTransferAddress) - log.Info("multi-transfer contract deployed", "address", multiTransferAddress.Bech32()) + log.Info("multi-transfer contract deployed", "address", multiTransferAddress, "transaction hash", hash) // deploy safe - handler.SafeAddress = handler.ChainSimulator.DeploySC( + handler.SafeAddress, hash, _ = handler.ChainSimulator.DeploySC( ctx, safeContractPath, handler.OwnerKeys.MvxSk, @@ -160,7 +161,7 @@ func (handler *MultiversxHandler) DeployContracts(ctx context.Context) { }, ) require.NotEqual(handler, emptyAddress, handler.SafeAddress) - log.Info("safe contract deployed", "address", handler.SafeAddress.Bech32()) + log.Info("safe contract deployed", "address", handler.SafeAddress, "transaction hash", hash) // deploy multisig minRelayerStakeInt, _ := big.NewInt(0).SetString(minRelayerStake, 10) @@ -174,17 +175,17 @@ func (handler *MultiversxHandler) DeployContracts(ctx context.Context) { for _, relayerKeys := range handler.RelayersKeys { params = append(params, relayerKeys.MvxAddress.Hex()) } - handler.MultisigAddress = handler.ChainSimulator.DeploySC( + handler.MultisigAddress, hash, _ = handler.ChainSimulator.DeploySC( ctx, multisigContractPath, handler.OwnerKeys.MvxSk, params, ) require.NotEqual(handler, emptyAddress, handler.MultisigAddress) - log.Info("multisig contract deployed", "address", handler.MultisigAddress) + log.Info("multisig contract deployed", "address", handler.MultisigAddress, "transaction hash", hash) // deploy bridge proxy - handler.ScProxyAddress = handler.ChainSimulator.DeploySC( + handler.ScProxyAddress, hash, _ = handler.ChainSimulator.DeploySC( ctx, bridgeProxyContractPath, handler.OwnerKeys.MvxSk, @@ -193,20 +194,20 @@ func (handler *MultiversxHandler) DeployContracts(ctx context.Context) { }, ) require.NotEqual(handler, emptyAddress, handler.ScProxyAddress) - log.Info("bridge proxy contract deployed", "address", handler.ScProxyAddress) + log.Info("bridge proxy contract deployed", "address", handler.ScProxyAddress, "transaction hash", hash) // deploy test-caller - handler.TestCallerAddress = handler.ChainSimulator.DeploySC( + handler.TestCallerAddress, hash, _ = handler.ChainSimulator.DeploySC( ctx, testCallerContractPath, handler.OwnerKeys.MvxSk, []string{}, ) require.NotEqual(handler, emptyAddress, handler.TestCallerAddress) - log.Info("test-caller contract deployed", "address", handler.TestCallerAddress) + log.Info("test-caller contract deployed", "address", handler.TestCallerAddress, "transaction hash", hash) // setBridgeProxyContractAddress - hash := handler.ChainSimulator.ScCall( + hash, txResult := handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, multiTransferAddress, @@ -216,11 +217,10 @@ func (handler *MultiversxHandler) DeployContracts(ctx context.Context) { handler.ScProxyAddress.Hex(), }, ) - txResult := handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("setBridgeProxyContractAddress tx executed", "hash", hash, "status", txResult.Status) // setWrappingContractAddress - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, multiTransferAddress, @@ -230,11 +230,10 @@ func (handler *MultiversxHandler) DeployContracts(ctx context.Context) { handler.WrapperAddress.Hex(), }, ) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("setWrappingContractAddress tx executed", "hash", hash, "status", txResult.Status) // ChangeOwnerAddress for safe - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, handler.SafeAddress, @@ -244,11 +243,10 @@ func (handler *MultiversxHandler) DeployContracts(ctx context.Context) { handler.MultisigAddress.Hex(), }, ) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("ChangeOwnerAddress for safe tx executed", "hash", hash, "status", txResult.Status) // ChangeOwnerAddress for multi-transfer - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, multiTransferAddress, @@ -258,16 +256,14 @@ func (handler *MultiversxHandler) DeployContracts(ctx context.Context) { handler.MultisigAddress.Hex(), }, ) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("ChangeOwnerAddress for multi-transfer tx executed", "hash", hash, "status", txResult.Status) // unpause sc proxy - hash = handler.callContractNoParams(ctx, handler.ScProxyAddress, unpauseFunction) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) + hash, txResult = handler.callContractNoParams(ctx, handler.ScProxyAddress, unpauseFunction) log.Info("unpaused sc proxy executed", "hash", hash, "status", txResult.Status) // ChangeOwnerAddress for bridge proxy - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, handler.ScProxyAddress, @@ -277,11 +273,10 @@ func (handler *MultiversxHandler) DeployContracts(ctx context.Context) { handler.MultisigAddress.Hex(), }, ) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("ChangeOwnerAddress for bridge proxy tx executed", "hash", hash, "status", txResult.Status) // setEsdtSafeOnMultiTransfer - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, handler.MultisigAddress, @@ -289,7 +284,6 @@ func (handler *MultiversxHandler) DeployContracts(ctx context.Context) { setEsdtSafeOnMultiTransferFunction, []string{}, ) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("setEsdtSafeOnMultiTransfer tx executed", "hash", hash, "status", txResult.Status) // stake relayers on multisig @@ -299,8 +293,7 @@ func (handler *MultiversxHandler) DeployContracts(ctx context.Context) { handler.stakeAddressesOnContract(ctx, handler.AggregatorAddress, []KeysHolder{handler.OwnerKeys}) // unpause multisig - hash = handler.callContractNoParams(ctx, handler.MultisigAddress, unpauseFunction) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) + hash, txResult = handler.callContractNoParams(ctx, handler.MultisigAddress, unpauseFunction) log.Info("unpaused multisig executed", "hash", hash, "status", txResult.Status) handler.UnPauseContractsAfterTokenChanges(ctx) @@ -356,7 +349,7 @@ func (handler *MultiversxHandler) GetESDTChainSpecificTokenBalance( return balance } -func (handler *MultiversxHandler) callContractNoParams(ctx context.Context, contract *MvxAddress, endpoint string) string { +func (handler *MultiversxHandler) callContractNoParams(ctx context.Context, contract *MvxAddress, endpoint string) (string, *data.TransactionOnNetwork) { return handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, @@ -370,45 +363,37 @@ func (handler *MultiversxHandler) callContractNoParams(ctx context.Context, cont // UnPauseContractsAfterTokenChanges can unpause contracts after token changes func (handler *MultiversxHandler) UnPauseContractsAfterTokenChanges(ctx context.Context) { // unpause safe - hash := handler.callContractNoParams(ctx, handler.MultisigAddress, unpauseEsdtSafeFunction) - txResult := handler.ChainSimulator.GetTransactionResult(ctx, hash) + hash, txResult := handler.callContractNoParams(ctx, handler.MultisigAddress, unpauseEsdtSafeFunction) log.Info("unpaused safe executed", "hash", hash, "status", txResult.Status) // unpause wrapper - hash = handler.callContractNoParams(ctx, handler.WrapperAddress, unpauseFunction) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) + hash, txResult = handler.callContractNoParams(ctx, handler.WrapperAddress, unpauseFunction) log.Info("unpaused wrapper executed", "hash", hash, "status", txResult.Status) // unpause aggregator - hash = handler.callContractNoParams(ctx, handler.AggregatorAddress, unpauseFunction) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) + hash, txResult = handler.callContractNoParams(ctx, handler.AggregatorAddress, unpauseFunction) log.Info("unpaused aggregator executed", "hash", hash, "status", txResult.Status) } // PauseContractsForTokenChanges can pause contracts for token changes func (handler *MultiversxHandler) PauseContractsForTokenChanges(ctx context.Context) { // pause safe - hash := handler.callContractNoParams(ctx, handler.MultisigAddress, pauseEsdtSafeFunction) - txResult := handler.ChainSimulator.GetTransactionResult(ctx, hash) + hash, txResult := handler.callContractNoParams(ctx, handler.MultisigAddress, pauseEsdtSafeFunction) log.Info("paused safe executed", "hash", hash, "status", txResult.Status) // pause aggregator - hash = handler.callContractNoParams(ctx, handler.AggregatorAddress, pauseFunction) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) + hash, txResult = handler.callContractNoParams(ctx, handler.AggregatorAddress, pauseFunction) log.Info("paused aggregator executed", "hash", hash, "status", txResult.Status) // pause wrapper - hash = handler.callContractNoParams(ctx, handler.WrapperAddress, pauseFunction) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) + hash, txResult = handler.callContractNoParams(ctx, handler.WrapperAddress, pauseFunction) log.Info("paused wrapper executed", "hash", hash, "status", txResult.Status) } func (handler *MultiversxHandler) stakeAddressesOnContract(ctx context.Context, contract *MvxAddress, allKeys []KeysHolder) { for _, keys := range allKeys { - hash := handler.ChainSimulator.SendTx(ctx, keys.MvxSk, contract, minRelayerStake, []byte(stakeFunction)) - txResult := handler.ChainSimulator.GetTransactionResult(ctx, hash) - - log.Info(fmt.Sprintf("address %s staked on contract %s with hash %s, status %s", keys.MvxAddress.Bech32(), contract, hash, txResult.Status)) + hash, txResult := handler.ChainSimulator.SendTx(ctx, keys.MvxSk, contract, minRelayerStake, []byte(stakeFunction)) + log.Info(fmt.Sprintf("address %s staked on contract %s with hash %s, status %s", keys.MvxAddress, contract, hash, txResult.Status)) } } @@ -420,7 +405,7 @@ func (handler *MultiversxHandler) IssueAndWhitelistToken(ctx context.Context, pa esdtAddress := NewMvxAddressFromBech32(handler, esdtSystemSCAddress) // issue universal token - hash := handler.ChainSimulator.ScCall( + hash, txResult := handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, esdtAddress, @@ -433,16 +418,15 @@ func (handler *MultiversxHandler) IssueAndWhitelistToken(ctx context.Context, pa fmt.Sprintf("%02x", params.NumOfDecimalsUniversal), hex.EncodeToString([]byte(canAddSpecialRoles)), hex.EncodeToString([]byte(trueStr))}) - txResult := handler.ChainSimulator.GetTransactionResult(ctx, hash) mvxUniversalToken := handler.getTokenNameFromResult(*txResult) handler.TokensRegistry.RegisterUniversalToken(params.AbstractTokenIdentifier, mvxUniversalToken) - log.Info("issue universal token tx executed", "hash", hash, "status", txResult.Status, "token", mvxUniversalToken, "owner", handler.OwnerKeys.MvxAddress.Bech32()) + log.Info("issue universal token tx executed", "hash", hash, "status", txResult.Status, "token", mvxUniversalToken, "owner", handler.OwnerKeys.MvxAddress) // issue chain specific token valueToMintInt, ok := big.NewInt(0).SetString(params.ValueToMintOnMvx, 10) require.True(handler, ok) - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, esdtAddress, @@ -455,13 +439,12 @@ func (handler *MultiversxHandler) IssueAndWhitelistToken(ctx context.Context, pa fmt.Sprintf("%02x", params.NumOfDecimalsChainSpecific), hex.EncodeToString([]byte(canAddSpecialRoles)), hex.EncodeToString([]byte(trueStr))}) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) mvxChainSpecificToken := handler.getTokenNameFromResult(*txResult) handler.TokensRegistry.RegisterChainSpecificToken(params.AbstractTokenIdentifier, mvxChainSpecificToken) - log.Info("issue chain specific token tx executed", "hash", hash, "status", txResult.Status, "token", mvxChainSpecificToken, "owner", handler.OwnerKeys.MvxAddress.Bech32()) + log.Info("issue chain specific token tx executed", "hash", hash, "status", txResult.Status, "token", mvxChainSpecificToken, "owner", handler.OwnerKeys.MvxAddress) // set local roles bridged tokens wrapper - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, esdtAddress, @@ -472,12 +455,11 @@ func (handler *MultiversxHandler) IssueAndWhitelistToken(ctx context.Context, pa handler.WrapperAddress.Hex(), hex.EncodeToString([]byte(esdtRoleLocalMint)), hex.EncodeToString([]byte(esdtRoleLocalBurn))}) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("set local roles bridged tokens wrapper tx executed", "hash", hash, "status", txResult.Status) // transfer to wrapper sc initialMintValue := valueToMintInt.Div(valueToMintInt, big.NewInt(3)) - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, handler.WrapperAddress, @@ -487,12 +469,10 @@ func (handler *MultiversxHandler) IssueAndWhitelistToken(ctx context.Context, pa hex.EncodeToString([]byte(mvxChainSpecificToken)), hex.EncodeToString(initialMintValue.Bytes()), hex.EncodeToString([]byte(depositLiquidityFunction))}) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) - log.Info("transfer to wrapper sc tx executed", "hash", hash, "status", txResult.Status) // transfer to safe sc - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, handler.SafeAddress, @@ -501,11 +481,10 @@ func (handler *MultiversxHandler) IssueAndWhitelistToken(ctx context.Context, pa []string{ hex.EncodeToString([]byte(mvxChainSpecificToken)), hex.EncodeToString(initialMintValue.Bytes())}) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("transfer to safe sc tx executed", "hash", hash, "status", txResult.Status) // add wrapped token - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, handler.WrapperAddress, @@ -515,11 +494,10 @@ func (handler *MultiversxHandler) IssueAndWhitelistToken(ctx context.Context, pa hex.EncodeToString([]byte(mvxUniversalToken)), fmt.Sprintf("%02x", params.NumOfDecimalsUniversal), }) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("add wrapped token tx executed", "hash", hash, "status", txResult.Status) // wrapper whitelist token - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, handler.WrapperAddress, @@ -529,12 +507,10 @@ func (handler *MultiversxHandler) IssueAndWhitelistToken(ctx context.Context, pa hex.EncodeToString([]byte(mvxChainSpecificToken)), fmt.Sprintf("%02x", params.NumOfDecimalsChainSpecific), hex.EncodeToString([]byte(mvxUniversalToken))}) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) - log.Info("wrapper whitelist token tx executed", "hash", hash, "status", txResult.Status) // set local roles esdt safe - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, esdtAddress, @@ -545,11 +521,10 @@ func (handler *MultiversxHandler) IssueAndWhitelistToken(ctx context.Context, pa handler.SafeAddress.Hex(), hex.EncodeToString([]byte(esdtRoleLocalMint)), hex.EncodeToString([]byte(esdtRoleLocalBurn))}) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("set local roles esdt safe tx executed", "hash", hash, "status", txResult.Status) // add mapping - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, handler.MultisigAddress, @@ -558,11 +533,10 @@ func (handler *MultiversxHandler) IssueAndWhitelistToken(ctx context.Context, pa []string{ hex.EncodeToString(token.EthErc20Address.Bytes()), hex.EncodeToString([]byte(mvxChainSpecificToken))}) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("add mapping tx executed", "hash", hash, "status", txResult.Status) // whitelist token - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, handler.MultisigAddress, @@ -573,11 +547,10 @@ func (handler *MultiversxHandler) IssueAndWhitelistToken(ctx context.Context, pa hex.EncodeToString([]byte(params.MvxChainSpecificTokenTicker)), getHexBool(params.IsMintBurnOnMvX), getHexBool(params.IsNativeOnMvX)}) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("whitelist token tx executed", "hash", hash, "status", txResult.Status) // setPairDecimals on aggregator - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, handler.AggregatorAddress, @@ -587,12 +560,11 @@ func (handler *MultiversxHandler) IssueAndWhitelistToken(ctx context.Context, pa hex.EncodeToString([]byte(gwei)), hex.EncodeToString([]byte(params.MvxChainSpecificTokenTicker)), fmt.Sprintf("%02x", params.NumOfDecimalsChainSpecific)}) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("setPairDecimals tx executed", "hash", hash, "status", txResult.Status) // safe set max bridge amount for token maxBridgedAmountForTokenInt, _ := big.NewInt(0).SetString(maxBridgedAmountForToken, 10) - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, handler.MultisigAddress, @@ -601,11 +573,10 @@ func (handler *MultiversxHandler) IssueAndWhitelistToken(ctx context.Context, pa []string{ hex.EncodeToString([]byte(mvxChainSpecificToken)), hex.EncodeToString(maxBridgedAmountForTokenInt.Bytes())}) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("safe set max bridge amount for token tx executed", "hash", hash, "status", txResult.Status) // multi-transfer set max bridge amount for token - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, handler.MultisigAddress, @@ -614,7 +585,6 @@ func (handler *MultiversxHandler) IssueAndWhitelistToken(ctx context.Context, pa []string{ hex.EncodeToString([]byte(mvxChainSpecificToken)), hex.EncodeToString(maxBridgedAmountForTokenInt.Bytes())}) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("multi-transfer set max bridge amount for token tx executed", "hash", hash, "status", txResult.Status) } @@ -638,7 +608,7 @@ func (handler *MultiversxHandler) SubmitAggregatorBatch(ctx context.Context, par timestampAsBigInt := big.NewInt(0).SetUint64(timestamp) - hash := handler.ChainSimulator.ScCall( + hash, txResult := handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, handler.AggregatorAddress, @@ -650,8 +620,7 @@ func (handler *MultiversxHandler) SubmitAggregatorBatch(ctx context.Context, par hex.EncodeToString(timestampAsBigInt.Bytes()), hex.EncodeToString(feeInt.Bytes()), fmt.Sprintf("%02x", params.NumOfDecimalsChainSpecific)}) - txResult := handler.ChainSimulator.GetTransactionResult(ctx, hash) - log.Info("submit aggregator batch tx executed", "hash", hash, "submitter", handler.OwnerKeys.MvxAddress.Bech32(), "status", txResult.Status) + log.Info("submit aggregator batch tx executed", "hash", hash, "submitter", handler.OwnerKeys.MvxAddress, "status", txResult.Status) } // CreateDepositsOnMultiversxForToken will send the deposit transactions on MultiversX returning how many tokens should be minted on Ethereum @@ -671,7 +640,7 @@ func (handler *MultiversxHandler) CreateDepositsOnMultiversxForToken( valueToMintOnEthereum.Add(valueToMintOnEthereum, operation.ValueToSendFromMvX) // transfer to sender tx - hash := handler.ChainSimulator.ScCall( + hash, txResult := handler.ChainSimulator.ScCall( ctx, handler.OwnerKeys.MvxSk, handler.TestKeys.MvxAddress, @@ -680,7 +649,6 @@ func (handler *MultiversxHandler) CreateDepositsOnMultiversxForToken( []string{ hex.EncodeToString([]byte(token.MvxChainSpecificToken)), hex.EncodeToString(operation.ValueToSendFromMvX.Bytes())}) - txResult := handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("transfer to sender tx executed", "hash", hash, "status", txResult.Status) // send tx to safe contract @@ -690,14 +658,13 @@ func (handler *MultiversxHandler) CreateDepositsOnMultiversxForToken( hex.EncodeToString([]byte(createTransactionFunction)), hex.EncodeToString(handler.TestKeys.EthAddress.Bytes()), } - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.TestKeys.MvxSk, handler.SafeAddress, zeroStringValue, esdtTransferFunction, scCallParams) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("MultiversX->Ethereum transaction sent", "hash", hash, "status", txResult.Status) } @@ -714,7 +681,7 @@ func (handler *MultiversxHandler) SendDepositTransactionFromMultiversx(ctx conte hex.EncodeToString([]byte(token.MvxChainSpecificToken)), } - hash := handler.ChainSimulator.ScCall( + hash, txResult := handler.ChainSimulator.ScCall( ctx, handler.TestKeys.MvxSk, handler.WrapperAddress, @@ -722,7 +689,6 @@ func (handler *MultiversxHandler) SendDepositTransactionFromMultiversx(ctx conte esdtTransferFunction, paramsUnwrap, ) - txResult := handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("unwrap transaction sent", "hash", hash, "token", token.MvxUniversalToken, "status", txResult.Status) // send tx to safe contract @@ -733,14 +699,13 @@ func (handler *MultiversxHandler) SendDepositTransactionFromMultiversx(ctx conte hex.EncodeToString(handler.TestKeys.EthAddress.Bytes()), } - hash = handler.ChainSimulator.ScCall( + hash, txResult = handler.ChainSimulator.ScCall( ctx, handler.TestKeys.MvxSk, handler.SafeAddress, zeroStringValue, esdtTransferFunction, params) - txResult = handler.ChainSimulator.GetTransactionResult(ctx, hash) log.Info("MultiversX->Ethereum transaction sent", "hash", hash, "status", txResult.Status) } diff --git a/integrationTests/relayers/slowTests/framework/testSetup.go b/integrationTests/relayers/slowTests/framework/testSetup.go index c6265156..fe29e79a 100644 --- a/integrationTests/relayers/slowTests/framework/testSetup.go +++ b/integrationTests/relayers/slowTests/framework/testSetup.go @@ -129,7 +129,7 @@ func (setup *TestSetup) startScCallerModule() { var err error setup.ScCallerModule, err = module.NewScCallsModule(cfg, log) require.Nil(setup, err) - log.Info("started SC calls module", "monitoring SC proxy address", setup.MultiversxHandler.ScProxyAddress.Bech32()) + log.Info("started SC calls module", "monitoring SC proxy address", setup.MultiversxHandler.ScProxyAddress) } // IssueAndConfigureTokens will issue and configure the provided tokens on both chains