diff --git a/README.md b/README.md index d713c5e..17a2969 100644 --- a/README.md +++ b/README.md @@ -252,6 +252,7 @@ Optional: generate sample data (transactions): ``` PYTHONPATH=. python3 ./systemtests/generate_testdata_on_network.py setup --network testnet PYTHONPATH=. python3 ./systemtests/generate_testdata_on_network.py run --network testnet +PYTHONPATH=. python3 ./systemtests/generate_testdata_on_network.py run-for-relayed-v1-v2 --network testnet ``` Run the checks: diff --git a/cmd/rosetta/cli.go b/cmd/rosetta/cli.go index b001cd6..cc5a195 100644 --- a/cmd/rosetta/cli.go +++ b/cmd/rosetta/cli.go @@ -182,10 +182,10 @@ VERSION: } cliFlagActivationEpochSpica = cli.UintFlag{ - Name: "activation-epoch-spica", - Usage: "Specifies the activation epoch for Spica release.", - Required: false, - Value: 1575, + Name: "activation-epoch-spica", + Usage: "Deprecated (not used anymore).", + Hidden: true, + Value: 0, } cliFlagShouldEnablePprofEndpoints = cli.BoolFlag{ @@ -254,7 +254,6 @@ type parsedCliFlags struct { numHistoricalEpochs uint32 shouldHandleContracts bool configFileCustomCurrencies string - activationEpochSpica uint32 shouldEnablePprofEndpoints bool } @@ -286,7 +285,6 @@ func getParsedCliFlags(ctx *cli.Context) parsedCliFlags { numHistoricalEpochs: uint32(ctx.GlobalUint(cliFlagNumHistoricalEpochs.Name)), shouldHandleContracts: ctx.GlobalBool(cliFlagShouldHandleContracts.Name), configFileCustomCurrencies: ctx.GlobalString(cliFlagConfigFileCustomCurrencies.Name), - activationEpochSpica: uint32(ctx.GlobalUint(cliFlagActivationEpochSpica.Name)), shouldEnablePprofEndpoints: ctx.GlobalBool(cliFlagShouldEnablePprofEndpoints.Name), } } diff --git a/cmd/rosetta/main.go b/cmd/rosetta/main.go index 0df43dc..952f323 100644 --- a/cmd/rosetta/main.go +++ b/cmd/rosetta/main.go @@ -83,7 +83,6 @@ func startRosetta(ctx *cli.Context) error { FirstHistoricalEpoch: cliFlags.firstHistoricalEpoch, NumHistoricalEpochs: cliFlags.numHistoricalEpochs, ShouldHandleContracts: cliFlags.shouldHandleContracts, - ActivationEpochSpica: cliFlags.activationEpochSpica, }) if err != nil { return err diff --git a/requirements-dev.txt b/requirements-dev.txt index ab6c687..2b87ba2 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,2 +1,3 @@ -multiversx_sdk==1.6.2 +# We'll stay on the old version of the SDKs up until ~Supernova (on the purpose of testing the removal of relayed V1 and V2). +multiversx_sdk==1.6.3 requests>=2.32.0,<3.0.0 diff --git a/server/factory/interface.go b/server/factory/interface.go index 861af97..916da7f 100644 --- a/server/factory/interface.go +++ b/server/factory/interface.go @@ -35,6 +35,5 @@ type NetworkProvider interface { ComputeReceiptHash(apiReceipt *transaction.ApiReceipt) (string, error) ComputeTransactionFeeForMoveBalance(tx *transaction.ApiTransactionResult) *big.Int GetMempoolTransactionByHash(hash string) (*transaction.ApiTransactionResult, error) - IsReleaseSpicaActive(epoch uint32) bool LogDescription() } diff --git a/server/factory/provider.go b/server/factory/provider.go index 461ffee..3ba434b 100644 --- a/server/factory/provider.go +++ b/server/factory/provider.go @@ -50,7 +50,6 @@ type ArgsCreateNetworkProvider struct { FirstHistoricalEpoch uint32 NumHistoricalEpochs uint32 ShouldHandleContracts bool - ActivationEpochSpica uint32 } // CreateNetworkProvider creates a network provider @@ -148,7 +147,6 @@ func CreateNetworkProvider(args ArgsCreateNetworkProvider) (NetworkProvider, err FirstHistoricalEpoch: args.FirstHistoricalEpoch, NumHistoricalEpochs: args.NumHistoricalEpochs, ShouldHandleContracts: args.ShouldHandleContracts, - ActivationEpochSpica: args.ActivationEpochSpica, ObserverFacade: &components.ObserverFacade{ Processor: baseProcessor, diff --git a/server/provider/networkProvider.go b/server/provider/networkProvider.go index e0aeff0..b3c79b8 100644 --- a/server/provider/networkProvider.go +++ b/server/provider/networkProvider.go @@ -43,7 +43,6 @@ type ArgsNewNetworkProvider struct { FirstHistoricalEpoch uint32 NumHistoricalEpochs uint32 ShouldHandleContracts bool - ActivationEpochSpica uint32 ObserverFacade observerFacade @@ -66,7 +65,6 @@ type networkProvider struct { firstHistoricalEpoch uint32 numHistoricalEpochs uint32 shouldHandleContracts bool - activationEpochSpica uint32 observerFacade observerFacade @@ -107,7 +105,6 @@ func NewNetworkProvider(args ArgsNewNetworkProvider) (*networkProvider, error) { firstHistoricalEpoch: args.FirstHistoricalEpoch, numHistoricalEpochs: args.NumHistoricalEpochs, shouldHandleContracts: args.ShouldHandleContracts, - activationEpochSpica: args.ActivationEpochSpica, observerFacade: args.ObserverFacade, @@ -473,11 +470,6 @@ func (provider *networkProvider) ComputeTransactionFeeForMoveBalance(tx *transac return fee } -// IsReleaseSpicaActive returns whether the Spica release is active in the provided epoch -func (provider *networkProvider) IsReleaseSpicaActive(epoch uint32) bool { - return epoch >= provider.activationEpochSpica -} - // LogDescription writes a description of the network provider in the log output func (provider *networkProvider) LogDescription() { log.Info("Description of network provider", @@ -491,7 +483,6 @@ func (provider *networkProvider) LogDescription() { "firstHistoricalEpoch", provider.firstHistoricalEpoch, "numHistoricalEpochs", provider.numHistoricalEpochs, "shouldHandleContracts", provider.shouldHandleContracts, - "activationEpochSpica", provider.activationEpochSpica, "nativeCurrency", provider.GetNativeCurrency().Symbol, "customCurrencies", provider.GetCustomCurrenciesSymbols(), ) diff --git a/server/services/interface.go b/server/services/interface.go index ca9630d..271c46a 100644 --- a/server/services/interface.go +++ b/server/services/interface.go @@ -34,5 +34,4 @@ type NetworkProvider interface { ComputeReceiptHash(apiReceipt *transaction.ApiReceipt) (string, error) ComputeTransactionFeeForMoveBalance(tx *transaction.ApiTransactionResult) *big.Int GetMempoolTransactionByHash(hash string) (*transaction.ApiTransactionResult, error) - IsReleaseSpicaActive(epoch uint32) bool } diff --git a/server/services/transactionEventsController_test.go b/server/services/transactionEventsController_test.go index 7888f4a..1f7067d 100644 --- a/server/services/transactionEventsController_test.go +++ b/server/services/transactionEventsController_test.go @@ -176,8 +176,6 @@ func TestTransactionEventsController_ExtractEvents(t *testing.T) { networkProvider := testscommon.NewNetworkProviderMock() controller := newTransactionEventsController(networkProvider) - networkProvider.MockActivationEpochSirius = 42 - t.Run("SCDeploy", func(t *testing.T) { topic0, _ := hex.DecodeString("00000000000000000500def8dad1161f8f0c38f3e6e73515ed81058f0b5606b8") topic1, _ := hex.DecodeString("5cf4abc83e50c5309d807fc3f676988759a1e301001bc9a0265804f42af806b8") diff --git a/server/services/transactionsFeaturesDetector.go b/server/services/transactionsFeaturesDetector.go index f9ab622..cfde671 100644 --- a/server/services/transactionsFeaturesDetector.go +++ b/server/services/transactionsFeaturesDetector.go @@ -77,21 +77,6 @@ func (detector *transactionsFeaturesDetector) isInvalidTransactionOfTypeMoveBala return withSendingValueToNonPayableContract || withMetaTransactionIsInvalid } -func (detector *transactionsFeaturesDetector) isRelayedV1TransactionCompletelyIntrashardWithSignalError(tx *transaction.ApiTransactionResult, innerTx *innerTransactionOfRelayedV1) bool { - innerTxSenderShard := detector.networkProvider.ComputeShardIdOfPubKey(innerTx.SenderPubKey) - innerTxReceiverShard := detector.networkProvider.ComputeShardIdOfPubKey(innerTx.ReceiverPubKey) - - isCompletelyIntrashard := tx.SourceShard == tx.DestinationShard && - innerTxSenderShard == innerTxReceiverShard && - innerTxSenderShard == tx.SourceShard - if !isCompletelyIntrashard { - return false - } - - isWithSignalError := detector.eventsController.hasAnySignalError(tx) - return isWithSignalError -} - func (detector *transactionsFeaturesDetector) isContractDeploymentWithSignalErrorOrIntrashardContractCallWithSignalError(tx *transaction.ApiTransactionResult) bool { return detector.isContractDeploymentWithSignalError(tx) || (detector.isIntrashard(tx) && detector.isContractCallWithSignalError(tx)) } diff --git a/server/services/transactionsFeaturesDetector_test.go b/server/services/transactionsFeaturesDetector_test.go index 552e47b..6d69b6a 100644 --- a/server/services/transactionsFeaturesDetector_test.go +++ b/server/services/transactionsFeaturesDetector_test.go @@ -75,63 +75,6 @@ func TestTransactionsFeaturesDetector_IsInvalidTransactionOfTypeMoveBalanceThatO }) } -func TestTransactionsFeaturesDetector_isRelayedV1TransactionCompletelyIntrashardWithSignalError(t *testing.T) { - networkProvider := testscommon.NewNetworkProviderMock() - detector := newTransactionsFeaturesDetector(networkProvider) - - t.Run("arbitrary relayed tx", func(t *testing.T) { - tx := &transaction.ApiTransactionResult{ - SourceShard: 0, - DestinationShard: 1, - } - - innerTx := &innerTransactionOfRelayedV1{ - SenderPubKey: testscommon.TestUserShard1.PubKey, - ReceiverPubKey: testscommon.TestUserShard2.PubKey, - } - - featureDetected := detector.isRelayedV1TransactionCompletelyIntrashardWithSignalError(tx, innerTx) - require.False(t, featureDetected) - }) - - t.Run("completely intrashard relayed tx, but no signal error", func(t *testing.T) { - tx := &transaction.ApiTransactionResult{ - SourceShard: 0, - DestinationShard: 0, - } - - innerTx := &innerTransactionOfRelayedV1{ - SenderPubKey: testscommon.TestUserAShard0.PubKey, - ReceiverPubKey: testscommon.TestUserBShard0.PubKey, - } - - featureDetected := detector.isRelayedV1TransactionCompletelyIntrashardWithSignalError(tx, innerTx) - require.False(t, featureDetected) - }) - - t.Run("completely intrashard relayed tx, with signal error", func(t *testing.T) { - tx := &transaction.ApiTransactionResult{ - SourceShard: 0, - DestinationShard: 0, - Logs: &transaction.ApiLogs{ - Events: []*transaction.Events{ - { - Identifier: transactionEventSignalError, - }, - }, - }, - } - - innerTx := &innerTransactionOfRelayedV1{ - SenderPubKey: testscommon.TestUserAShard0.PubKey, - ReceiverPubKey: testscommon.TestUserBShard0.PubKey, - } - - featureDetected := detector.isRelayedV1TransactionCompletelyIntrashardWithSignalError(tx, innerTx) - require.True(t, featureDetected) - }) -} - func TestTransactionsFeatureDetector_isContractDeploymentWithSignalErrorOrIntrashardContractCallWithSignalError(t *testing.T) { networkProvider := testscommon.NewNetworkProviderMock() detector := newTransactionsFeaturesDetector(networkProvider) diff --git a/server/services/transactionsTransformer_test.go b/server/services/transactionsTransformer_test.go index 1b035a8..ef5f033 100644 --- a/server/services/transactionsTransformer_test.go +++ b/server/services/transactionsTransformer_test.go @@ -19,8 +19,6 @@ func TestTransactionsTransformer_NormalTxToRosettaTx(t *testing.T) { extension := newNetworkProviderExtension(networkProvider) transformer := newTransactionsTransformer(networkProvider) - networkProvider.MockActivationEpochSirius = 42 - t.Run("move balance tx", func(t *testing.T) { tx := &transaction.ApiTransactionResult{ Hash: "aaaa", @@ -1116,7 +1114,6 @@ func TestTransactionsTransformer_TransformBlockTxsHavingNFTBurn(t *testing.T) { func TestTransactionsTransformer_TransformBlockTxsHavingClaimDeveloperRewards(t *testing.T) { networkProvider := testscommon.NewNetworkProviderMock() networkProvider.MockObservedActualShard = 0 - networkProvider.MockActivationEpochSpica = 42 extension := newNetworkProviderExtension(networkProvider) transformer := newTransactionsTransformer(networkProvider) diff --git a/systemtests/check_with_mesh_cli.py b/systemtests/check_with_mesh_cli.py index 939b076..89b03ca 100644 --- a/systemtests/check_with_mesh_cli.py +++ b/systemtests/check_with_mesh_cli.py @@ -75,7 +75,6 @@ def run_rosetta(configuration: Configuration, shard: int): f"--config-custom-currencies={configuration.config_file_custom_currencies}", f"--first-historical-epoch={current_epoch}", f"--num-historical-epochs={configuration.num_historical_epochs}", - f"--activation-epoch-spica={configuration.activation_epoch_spica}", "--log-level=*:DEBUG", "--handle-contracts", "--pprof" diff --git a/systemtests/config.py b/systemtests/config.py index 49c318c..062727b 100644 --- a/systemtests/config.py +++ b/systemtests/config.py @@ -29,8 +29,8 @@ class Configuration: proxy_url: str proxy_adapter_port: int rosetta_port: int - activation_epoch_spica: int - activation_epoch_relayed_v3: int + custom_tokens_completness_epoch: int + deactivation_epoch_relayed_v1v2: int check_construction_native_configuration_file: str check_construction_custom_configuration_file: str check_data_configuration_file: str @@ -56,8 +56,8 @@ class Configuration: proxy_url=ENV_MAINNET_PROXY_URL or DEFAULT_MAINNET_PROXY_URL, proxy_adapter_port=10001, rosetta_port=7091, - activation_epoch_spica=1538, - activation_epoch_relayed_v3=4294967295, + custom_tokens_completness_epoch=0, + deactivation_epoch_relayed_v1v2=4294967295, check_construction_native_configuration_file="", check_construction_custom_configuration_file="", check_data_configuration_file="systemtests/mesh_cli_config/check-data.json", @@ -75,8 +75,8 @@ class Configuration: proxy_url=ENV_DEVNET_PROXY_URL or DEFAULT_DEVNET_PROXY_URL, proxy_adapter_port=10002, rosetta_port=7092, - activation_epoch_spica=2327, - activation_epoch_relayed_v3=1, + custom_tokens_completness_epoch=0, + deactivation_epoch_relayed_v1v2=4294967295, check_construction_native_configuration_file="systemtests/mesh_cli_config/devnet-construction-native.json", check_construction_custom_configuration_file="systemtests/mesh_cli_config/devnet-construction-custom.json", check_data_configuration_file="systemtests/mesh_cli_config/check-data.json", @@ -96,8 +96,8 @@ class Configuration: proxy_url=ENV_TESTNET_PROXY_URL or DEFAULT_TESTNET_PROXY_URL, proxy_adapter_port=10003, rosetta_port=7093, - activation_epoch_spica=1, - activation_epoch_relayed_v3=1, + custom_tokens_completness_epoch=0, + deactivation_epoch_relayed_v1v2=4294967295, check_construction_native_configuration_file="systemtests/mesh_cli_config/testnet-construction-native.json", check_construction_custom_configuration_file="systemtests/mesh_cli_config/testnet-construction-custom.json", check_data_configuration_file="systemtests/mesh_cli_config/check-data.json", @@ -116,8 +116,8 @@ class Configuration: proxy_url="http://localhost:7950", proxy_adapter_port=10004, rosetta_port=7094, - activation_epoch_spica=1, - activation_epoch_relayed_v3=1, + custom_tokens_completness_epoch=1, + deactivation_epoch_relayed_v1v2=2, check_construction_native_configuration_file="systemtests/mesh_cli_config/localnet-construction-native.json", check_construction_custom_configuration_file="systemtests/mesh_cli_config/localnet-construction-custom.json", check_data_configuration_file="systemtests/mesh_cli_config/check-data.json", @@ -137,8 +137,8 @@ class Configuration: proxy_url=os.environ.get("INTERNAL_TESTNET_PROXY_URL", ""), proxy_adapter_port=10005, rosetta_port=7095, - activation_epoch_spica=1, - activation_epoch_relayed_v3=1, + custom_tokens_completness_epoch=1, + deactivation_epoch_relayed_v1v2=2, check_construction_native_configuration_file="systemtests/mesh_cli_config/internal-construction-native.json", check_construction_custom_configuration_file="systemtests/mesh_cli_config/internal-construction-custom.json", check_data_configuration_file="systemtests/mesh_cli_config/check-data.json", diff --git a/systemtests/generate_testdata_on_network.py b/systemtests/generate_testdata_on_network.py index 379cfea..df79f14 100644 --- a/systemtests/generate_testdata_on_network.py +++ b/systemtests/generate_testdata_on_network.py @@ -46,6 +46,11 @@ def main(): subparser_setup.add_argument("--network", choices=CONFIGURATIONS.keys(), required=True) subparser_setup.set_defaults(func=do_setup) + # Remove this after ~Supernova (necessary only for a short period of time). + subparser_run = subparsers.add_parser("run-for-relayed-v1-v2") + subparser_run.add_argument("--network", choices=CONFIGURATIONS.keys(), required=True) + subparser_run.set_defaults(func=do_run_for_relayed_v1_v2) + subparser_run = subparsers.add_parser("run") subparser_run.add_argument("--network", choices=CONFIGURATIONS.keys(), required=True) subparser_run.set_defaults(func=do_run) @@ -81,6 +86,8 @@ def do_setup(args: Any): print("Do contract deployments...") controller.do_create_contract_deployments() + controller.wait_until_epoch(configuration.custom_tokens_completness_epoch) + print("Create some NFTs...") controller.create_non_fungible_tokens("NFT") @@ -96,6 +103,67 @@ def do_setup(args: Any): print("Setup done.") +# Remove this after ~Supernova +def do_run_for_relayed_v1_v2(args: Any): + print("Phase [run_for_relayed_v1_v2] started...") + + network = args.network + configuration = CONFIGURATIONS[network] + memento = Memento(Path(configuration.memento_file)) + accounts = BunchOfAccounts(configuration, memento) + controller = Controller(configuration, accounts, memento) + + controller.send(controller.create_legacy_relayed_transfer_and_execute( + relayer=accounts.get_user(shard=SOME_SHARD, index=0), + sender=accounts.get_user(shard=SOME_SHARD, index=1), + contract=accounts.get_contract_address("dummy", shard=SOME_SHARD, index=0), + function="doSomething", + arguments=[], + gas_limit=3_000_000, + native_amount=0, + custom_amount=0, + relayed_version=1 + ), await_processing_started=True) + + controller.send(controller.create_legacy_relayed_transfer_and_execute( + relayer=accounts.get_user(shard=SOME_SHARD, index=0), + sender=accounts.get_user(shard=SOME_SHARD, index=1), + contract=accounts.get_contract_address("dummy", shard=SOME_SHARD, index=0), + function="doSomething", + arguments=[], + gas_limit=3_000_000, + native_amount=0, + custom_amount=0, + relayed_version=2 + ), await_processing_started=True) + + controller.wait_until_epoch(configuration.deactivation_epoch_relayed_v1v2) + + controller.send(controller.create_legacy_relayed_transfer_and_execute( + relayer=accounts.get_user(shard=SOME_SHARD, index=0), + sender=accounts.get_user(shard=SOME_SHARD, index=1), + contract=accounts.get_contract_address("dummy", shard=SOME_SHARD, index=0), + function="doSomething", + arguments=[], + gas_limit=3_000_000, + native_amount=0, + custom_amount=0, + relayed_version=1 + ), await_processing_started=True) + + controller.send(controller.create_legacy_relayed_transfer_and_execute( + relayer=accounts.get_user(shard=SOME_SHARD, index=0), + sender=accounts.get_user(shard=SOME_SHARD, index=1), + contract=accounts.get_contract_address("dummy", shard=SOME_SHARD, index=0), + function="doSomething", + arguments=[], + gas_limit=3_000_000, + native_amount=0, + custom_amount=0, + relayed_version=2 + ), await_processing_started=True) + + def do_run(args: Any): print("Phase [run] started...") @@ -767,67 +835,71 @@ def do_run(args: Any): additional_gas_limit=0, ), await_completion=True) - print("## Relayed v3, intra-shard, transfer native within multi-transfer (fuzzy, with tx.value != 0)") - controller.send(controller.create_arbitrary_transaction( - sender=accounts.get_user(shard=SOME_SHARD, index=2), - # receiver := sender, since we're using multi-transfer. - receiver=accounts.get_user(shard=SOME_SHARD, index=2).address, - value=42, - data="MultiESDTNFTTransfer@" + Serializer().serialize([ - AddressValue.new_from_address(accounts.get_user(shard=SOME_SHARD, index=3).address), - U32Value(2), - StringValue("EGLD-000000"), - U32Value(0), - U32Value(42), - StringValue("EGLD-000000"), - U32Value(0), - U32Value(43) - ]), - gas_limit=5_000_000, - relayer=accounts.get_user(shard=SOME_SHARD, index=0), - ), await_processing_started=True) + if configuration.generate_relayed_v3: + print("## Relayed, intra-shard, transfer native within multi-transfer (fuzzy, with tx.value != 0)") + controller.send(controller.create_arbitrary_transaction( + sender=accounts.get_user(shard=SOME_SHARD, index=2), + # receiver := sender, since we're using multi-transfer. + receiver=accounts.get_user(shard=SOME_SHARD, index=2).address, + value=42, + data="MultiESDTNFTTransfer@" + Serializer().serialize([ + AddressValue.new_from_address(accounts.get_user(shard=SOME_SHARD, index=3).address), + U32Value(2), + StringValue("EGLD-000000"), + U32Value(0), + U32Value(42), + StringValue("EGLD-000000"), + U32Value(0), + U32Value(43) + ]), + gas_limit=5_000_000, + relayer=accounts.get_user(shard=SOME_SHARD, index=0), + ), await_processing_started=True) - print("## Relayed v3, intra-shard, transfer native within multi-transfer (fuzzy, with tx.value == 0, but transfer to self)") - controller.send(controller.create_arbitrary_transaction( - sender=accounts.get_user(shard=SOME_SHARD, index=3), - # receiver := sender, since we're using multi-transfer. - receiver=accounts.get_user(shard=SOME_SHARD, index=3).address, - value=0, - data="MultiESDTNFTTransfer@" + Serializer().serialize([ - AddressValue.new_from_address(accounts.get_user(shard=SOME_SHARD, index=3).address), - U32Value(2), - StringValue("EGLD-000000"), - U32Value(0), - U32Value(42), - StringValue("EGLD-000000"), - U32Value(0), - U32Value(43) - ]), - gas_limit=5_000_000, - relayer=accounts.get_user(shard=SOME_SHARD, index=0), - ), await_processing_started=True) + if configuration.generate_relayed_v3: + print("## Relayed, intra-shard, transfer native within multi-transfer (fuzzy, with tx.value == 0, but transfer to self)") + controller.send(controller.create_arbitrary_transaction( + sender=accounts.get_user(shard=SOME_SHARD, index=3), + # receiver := sender, since we're using multi-transfer. + receiver=accounts.get_user(shard=SOME_SHARD, index=3).address, + value=0, + data="MultiESDTNFTTransfer@" + Serializer().serialize([ + AddressValue.new_from_address(accounts.get_user(shard=SOME_SHARD, index=3).address), + U32Value(2), + StringValue("EGLD-000000"), + U32Value(0), + U32Value(42), + StringValue("EGLD-000000"), + U32Value(0), + U32Value(43) + ]), + gas_limit=5_000_000, + relayer=accounts.get_user(shard=SOME_SHARD, index=0), + ), await_processing_started=True) - print("## Relayed v3, cross-shard, transfer native within multi-transfer (fuzzy, with tx.value == 0)") - controller.send(controller.create_arbitrary_transaction( - sender=accounts.get_user(shard=SOME_SHARD, index=2), - # receiver := sender, since we're using multi-transfer. - receiver=accounts.get_user(shard=SOME_SHARD, index=2).address, - value=0, - data="MultiESDTNFTTransfer@" + Serializer().serialize([ - AddressValue.new_from_address(accounts.get_user(shard=OTHER_SHARD, index=3).address), - U32Value(2), - StringValue("EGLD-000000"), - U32Value(0), - U32Value(42), - StringValue("EGLD-000000"), - U32Value(0), - U32Value(43) - ]), - gas_limit=5_000_000, - relayer=accounts.get_user(shard=SOME_SHARD, index=0), - ), await_processing_started=True) + if configuration.generate_relayed_v3: + print("## Relayed, cross-shard, transfer native within multi-transfer (fuzzy, with tx.value == 0)") + controller.send(controller.create_arbitrary_transaction( + sender=accounts.get_user(shard=SOME_SHARD, index=2), + # receiver := sender, since we're using multi-transfer. + receiver=accounts.get_user(shard=SOME_SHARD, index=2).address, + value=0, + data="MultiESDTNFTTransfer@" + Serializer().serialize([ + AddressValue.new_from_address(accounts.get_user(shard=OTHER_SHARD, index=3).address), + U32Value(2), + StringValue("EGLD-000000"), + U32Value(0), + U32Value(42), + StringValue("EGLD-000000"), + U32Value(0), + U32Value(43) + ]), + gas_limit=5_000_000, + relayer=accounts.get_user(shard=SOME_SHARD, index=0), + ), await_processing_started=True) - do_run_relayed_builtin_functions(memento, accounts, controller) + if configuration.generate_relayed_v3: + do_run_relayed_builtin_functions(memento, accounts, controller) def do_run_relayed_builtin_functions(memento: "Memento", accounts: "BunchOfAccounts", controller: "Controller"): @@ -1984,6 +2056,71 @@ def create_relayed_transfer_and_execute(self, relayer: "Account", sender: "Accou return transaction + # Remove this after ~Supernova + def create_legacy_relayed_transfer_and_execute(self, relayer: "Account", sender: "Account", contract: Address, function: str, arguments: list[Any], gas_limit: int, native_amount: int, custom_amount: int, relayed_version: int) -> Transaction: + token_transfers: List[TokenTransfer] = [] + + if custom_amount: + custom_currency = self.memento.get_custom_currencies()[0] + token_transfers = [TokenTransfer(Token(custom_currency), custom_amount)] + + if relayed_version == 1: + # Relayer nonce is reserved before sender nonce, to ensure good ordering (if sender and relayer are the same account). + relayer_nonce = self._reserve_nonce(relayer) + + inner_transaction = self.contracts_transactions_factory.create_transaction_for_execute( + sender=sender.address, + contract=contract, + function=function, + gas_limit=gas_limit, + arguments=arguments, + native_transfer_amount=native_amount, + token_transfers=token_transfers + ) + + self.apply_nonce(inner_transaction) + self.sign(inner_transaction) + + transaction = self.relayed_transactions_factory.create_relayed_v1_transaction( + inner_transaction=inner_transaction, + relayer_address=relayer.address, + ) + + transaction.nonce = relayer_nonce + self.sign(transaction) + + return transaction + + if relayed_version == 2: + # Relayer nonce is reserved before sender nonce, to ensure good ordering (if sender and relayer are the same account). + relayer_nonce = self._reserve_nonce(relayer) + + inner_transaction = self.contracts_transactions_factory.create_transaction_for_execute( + sender=sender.address, + contract=contract, + function=function, + gas_limit=0, + arguments=arguments, + native_transfer_amount=native_amount, + token_transfers=token_transfers + ) + + self.apply_nonce(inner_transaction) + self.sign(inner_transaction) + + transaction = self.relayed_transactions_factory.create_relayed_v2_transaction( + inner_transaction=inner_transaction, + inner_transaction_gas_limit=gas_limit, + relayer_address=relayer.address, + ) + + transaction.nonce = relayer_nonce + self.sign(transaction) + + return transaction + + raise ValueError(f"Unsupported legacy relayed version: {relayed_version}") + def apply_nonce(self, transaction: Transaction): sender = self.accounts.get_account_by_bech32(transaction.sender.to_bech32()) transaction.nonce = self.nonces_tracker.get_then_increment_nonce(sender.address) diff --git a/systemtests/localnet.toml b/systemtests/localnet.toml index d7fa3a5..767d137 100644 --- a/systemtests/localnet.toml +++ b/systemtests/localnet.toml @@ -1,7 +1,7 @@ [general] log_level = "*:DEBUG" genesis_delay_seconds = 10 -rounds_per_epoch = 50 +rounds_per_epoch = 70 round_duration_milliseconds = 6000 [metashard] @@ -28,14 +28,14 @@ port_first_validator_rest_api = 10200 [software.mx_chain_go] resolution = "remote" -archive_url = "https://github.com/multiversx/mx-chain-go/archive/refs/tags/v1.8.11.zip" +archive_url = "https://github.com/multiversx/mx-chain-go/archive/refs/heads/rc/teegarden.zip" archive_download_folder = "~/multiversx-sdk/localnet_software_remote/downloaded/mx-chain-go" archive_extraction_folder = "~/multiversx-sdk/localnet_software_remote/extracted/mx-chain-go" local_path = "~/multiversx-sdk/localnet_software_local/mx-chain-go" [software.mx_chain_proxy_go] resolution = "remote" -archive_url = "https://github.com/multiversx/mx-chain-proxy-go/archive/refs/tags/v1.1.57.zip" +archive_url = "https://github.com/multiversx/mx-chain-proxy-go/archive/refs/tags/v1.3.2.zip" archive_download_folder = "~/multiversx-sdk/localnet_software_remote/downloaded/mx-chain-proxy-go" archive_extraction_folder = "~/multiversx-sdk/localnet_software_remote/extracted/mx-chain-proxy-go" local_path = "~/multiversx-sdk/localnet_software_local/mx-chain-proxy-go" diff --git a/testscommon/networkProviderMock.go b/testscommon/networkProviderMock.go index 6025a53..711c568 100644 --- a/testscommon/networkProviderMock.go +++ b/testscommon/networkProviderMock.go @@ -31,8 +31,6 @@ type networkProviderMock struct { MockCustomCurrencies []resources.Currency MockGenesisBlockHash string MockGenesisTimestamp int64 - MockActivationEpochSirius uint32 - MockActivationEpochSpica uint32 MockNetworkConfig *resources.NetworkConfig MockGenesisBalances []*resources.GenesisBalance MockNodeStatus *resources.AggregatedNodeStatus @@ -371,13 +369,3 @@ func (mock *networkProviderMock) GetMempoolTransactionByHash(hash string) (*tran return nil, nil } - -// IsReleaseSiriusActive - -func (mock *networkProviderMock) IsReleaseSiriusActive(epoch uint32) bool { - return epoch >= mock.MockActivationEpochSirius -} - -// IsReleaseSpicaActive - -func (mock *networkProviderMock) IsReleaseSpicaActive(epoch uint32) bool { - return epoch >= mock.MockActivationEpochSpica -} diff --git a/version/constants.go b/version/constants.go index b7edbdc..b73b182 100644 --- a/version/constants.go +++ b/version/constants.go @@ -7,5 +7,5 @@ const ( var ( // RosettaMiddlewareVersion is the version of this package (application) - RosettaMiddlewareVersion = "v0.7.1" + RosettaMiddlewareVersion = "v0.7.2" )