diff --git a/integrationTests/relayers/slowTests/framework/chainSimulatorWrapper.go b/integrationTests/relayers/slowTests/framework/chainSimulatorWrapper.go index 5e864877..9631467d 100644 --- a/integrationTests/relayers/slowTests/framework/chainSimulatorWrapper.go +++ b/integrationTests/relayers/slowTests/framework/chainSimulatorWrapper.go @@ -145,14 +145,14 @@ func (instance *chainSimulatorWrapper) DeploySC(ctx context.Context, wasmFilePat Version: 1, } - hash := instance.signAndSend(ctx, ownerSK, ftx) - txResult := instance.getTransactionResult(ctx, hash) + hash := instance.signAndSend(ctx, ownerSK, ftx, 1) + txResult := instance.GetTransactionResult(ctx, hash) 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 { +func (instance *chainSimulatorWrapper) GetTransactionResult(ctx context.Context, hash string) *data.TransactionOnNetwork { instance.GenerateBlocksUntilTxProcessed(ctx, hash) txResult, err := instance.proxyInstance.GetTransactionInfoWithResults(ctx, hash) @@ -170,6 +170,10 @@ func (instance *chainSimulatorWrapper) getTransactionResult(ctx context.Context, // GenerateBlocks calls the chain simulator generate block endpoint func (instance *chainSimulatorWrapper) GenerateBlocks(ctx context.Context, numBlocks int) { + if numBlocks <= 0 { + return + } + _, status, err := instance.clientWrapper.PostHTTP(ctx, fmt.Sprintf(generateBlocksEndpoint, numBlocks), nil) if err != nil || status != http.StatusOK { log.Error("error in chainSimulatorWrapper.GenerateBlocks", "error", err, "status", status) @@ -197,15 +201,33 @@ func (instance *chainSimulatorWrapper) GenerateBlocksUntilTxProcessed(ctx contex // ScCall will make the provided sc call func (instance *chainSimulatorWrapper) ScCall(ctx context.Context, senderSK []byte, contract *MvxAddress, value string, gasLimit uint64, function string, parameters []string) (string, *data.TransactionOnNetwork) { + return instance.SendTx(ctx, senderSK, contract, value, gasLimit, createTxData(function, parameters)) +} + +// ScCallWithoutGenerateBlocks will make the provided sc call and do not trigger the generate blocks command +func (instance *chainSimulatorWrapper) ScCallWithoutGenerateBlocks(ctx context.Context, senderSK []byte, contract *MvxAddress, value string, gasLimit uint64, function string, parameters []string) string { + return instance.SendTxWithoutGenerateBlocks(ctx, senderSK, contract, value, gasLimit, createTxData(function, parameters)) +} + +func createTxData(function string, parameters []string) []byte { params := []string{function} params = append(params, parameters...) txData := strings.Join(params, "@") - return instance.SendTx(ctx, senderSK, contract, value, gasLimit, []byte(txData)) + return []byte(txData) } // SendTx will build and send a transaction func (instance *chainSimulatorWrapper) SendTx(ctx context.Context, senderSK []byte, receiver *MvxAddress, value string, gasLimit uint64, dataField []byte) (string, *data.TransactionOnNetwork) { + hash := instance.SendTxWithoutGenerateBlocks(ctx, senderSK, receiver, value, gasLimit, dataField) + instance.GenerateBlocks(ctx, 1) + txResult := instance.GetTransactionResult(ctx, hash) + + return hash, txResult +} + +// SendTxWithoutGenerateBlocks will build and send a transaction and won't call the generate blocks command +func (instance *chainSimulatorWrapper) SendTxWithoutGenerateBlocks(ctx context.Context, senderSK []byte, receiver *MvxAddress, value string, gasLimit uint64, dataField []byte) string { networkConfig, err := instance.proxyInstance.GetNetworkConfig(ctx) require.Nil(instance, err) @@ -225,10 +247,9 @@ func (instance *chainSimulatorWrapper) SendTx(ctx context.Context, senderSK []by Version: 1, } - hash := instance.signAndSend(ctx, senderSK, ftx) - txResult := instance.getTransactionResult(ctx, hash) + hash := instance.signAndSend(ctx, senderSK, ftx, 0) - return hash, txResult + return hash } // FundWallets sends funds to the provided addresses @@ -300,7 +321,7 @@ func (instance *chainSimulatorWrapper) getNonce(ctx context.Context, bech32Addre return account.Nonce, nil } -func (instance *chainSimulatorWrapper) signAndSend(ctx context.Context, senderSK []byte, ftx *transaction.FrontendTransaction) string { +func (instance *chainSimulatorWrapper) signAndSend(ctx context.Context, senderSK []byte, ftx *transaction.FrontendTransaction, numBlocksToGenerate int) string { sig, err := computeTransactionSignature(senderSK, ftx) require.Nil(instance, err) @@ -309,7 +330,7 @@ func (instance *chainSimulatorWrapper) signAndSend(ctx context.Context, senderSK hash, err := instance.proxyInstance.SendTransaction(ctx, ftx) require.Nil(instance, err) - instance.GenerateBlocks(ctx, 1) + instance.GenerateBlocks(ctx, numBlocksToGenerate) return hash } diff --git a/integrationTests/relayers/slowTests/framework/interface.go b/integrationTests/relayers/slowTests/framework/interface.go index 04bb4d48..2e879ea4 100644 --- a/integrationTests/relayers/slowTests/framework/interface.go +++ b/integrationTests/relayers/slowTests/framework/interface.go @@ -33,12 +33,15 @@ type ChainSimulatorWrapper interface { GetNetworkAddress() string DeploySC(ctx context.Context, path string, ownerSK []byte, gasLimit uint64, extraParams []string) (*MvxAddress, string, *data.TransactionOnNetwork) ScCall(ctx context.Context, senderSK []byte, contract *MvxAddress, value string, gasLimit uint64, function string, parameters []string) (string, *data.TransactionOnNetwork) + ScCallWithoutGenerateBlocks(ctx context.Context, senderSK []byte, contract *MvxAddress, value string, gasLimit uint64, function string, parameters []string) string SendTx(ctx context.Context, senderSK []byte, receiver *MvxAddress, value string, gasLimit uint64, dataField []byte) (string, *data.TransactionOnNetwork) + SendTxWithoutGenerateBlocks(ctx context.Context, senderSK []byte, receiver *MvxAddress, value string, gasLimit uint64, dataField []byte) string FundWallets(ctx context.Context, wallets []string) GenerateBlocksUntilEpochReached(ctx context.Context, epoch uint32) GenerateBlocks(ctx context.Context, numBlocks int) GetESDTBalance(ctx context.Context, address *MvxAddress, token string) string GetBlockchainTimeStamp(ctx context.Context) uint64 + GetTransactionResult(ctx context.Context, hash string) *data.TransactionOnNetwork } // EthereumBlockchainClient defines the operations supported by the Ethereum client diff --git a/integrationTests/relayers/slowTests/framework/multiversxHandler.go b/integrationTests/relayers/slowTests/framework/multiversxHandler.go index 07d861ef..146ca6c2 100644 --- a/integrationTests/relayers/slowTests/framework/multiversxHandler.go +++ b/integrationTests/relayers/slowTests/framework/multiversxHandler.go @@ -810,18 +810,25 @@ func (handler *MultiversxHandler) getTokenNameFromResult(txResult data.Transacti // SubmitAggregatorBatch will submit the aggregator batch func (handler *MultiversxHandler) SubmitAggregatorBatch(ctx context.Context, params IssueTokenParams) { + txHashes := make([]string, 0, len(handler.OraclesKeys)) for _, key := range handler.OraclesKeys { - handler.submitAggregatorBatchForKey(ctx, key, params) + hash := handler.submitAggregatorBatchForKey(ctx, key, params) + txHashes = append(txHashes, hash) + } + + for _, hash := range txHashes { + txResult := handler.ChainSimulator.GetTransactionResult(ctx, hash) + log.Info("submit aggregator batch tx", "hash", hash, "status", txResult.Status) } } -func (handler *MultiversxHandler) submitAggregatorBatchForKey(ctx context.Context, key KeysHolder, params IssueTokenParams) { +func (handler *MultiversxHandler) submitAggregatorBatchForKey(ctx context.Context, key KeysHolder, params IssueTokenParams) string { timestamp := handler.ChainSimulator.GetBlockchainTimeStamp(ctx) require.Greater(handler, timestamp, uint64(0), "something went wrong and the chain simulator returned 0 for the current timestamp") timestampAsBigInt := big.NewInt(0).SetUint64(timestamp) - hash, txResult := handler.ChainSimulator.ScCall( + hash := handler.ChainSimulator.ScCallWithoutGenerateBlocks( ctx, key.MvxSk, handler.AggregatorAddress, @@ -835,7 +842,9 @@ func (handler *MultiversxHandler) submitAggregatorBatchForKey(ctx context.Contex hex.EncodeToString(feeInt.Bytes()), fmt.Sprintf("%02x", params.NumOfDecimalsChainSpecific)}) - log.Info("submit aggregator batch tx executed", "transaction hash", hash, "submitter", key.MvxAddress.Bech32(), "status", txResult.Status) + log.Info("submit aggregator batch tx sent", "transaction hash", hash, "submitter", key.MvxAddress.Bech32()) + + return hash } // CreateDepositsOnMultiversxForToken will send the deposit transactions on MultiversX returning how many tokens should be minted on Ethereum 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 97906b85..ed796fed 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-375-gda17d9d" + "gitVersion": "v0.45.2.1-reproducible-378-ge72c201" }, "framework": { "name": "multiversx-sc", 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 index 2c820924..ac1668fa 100644 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