From 0aba9812d61cb767861341d8ffe142bd5058db4d Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Fri, 25 Oct 2024 11:44:42 +0300 Subject: [PATCH] disable relayed v3 --- cmd/node/config/enableEpochs.toml | 3 +++ common/constants.go | 4 ++++ common/enablers/enableEpochsHandler.go | 6 ++++++ common/enablers/enableEpochsHandler_test.go | 2 ++ config/epochConfig.go | 1 + config/tomlConfig_test.go | 4 ++++ integrationTests/chainSimulator/relayedTx/relayedTx_test.go | 2 ++ integrationTests/multiShard/relayedTx/common.go | 3 +++ node/metrics/metrics.go | 1 + node/metrics/metrics_test.go | 2 ++ process/transaction/interceptedTransaction.go | 3 ++- process/transaction/shardProcess.go | 4 +++- 12 files changed, 33 insertions(+), 2 deletions(-) diff --git a/cmd/node/config/enableEpochs.toml b/cmd/node/config/enableEpochs.toml index 7f41c21468a..7d6d5a9c2b0 100644 --- a/cmd/node/config/enableEpochs.toml +++ b/cmd/node/config/enableEpochs.toml @@ -327,6 +327,9 @@ # RelayedTransactionsV3EnableEpoch represents the epoch when the relayed transactions V3 will be enabled RelayedTransactionsV3EnableEpoch = 7 + # RelayedTransactionsV3DisableEpoch represents the epoch when the relayed transactions V3 will be disabled + RelayedTransactionsV3DisableEpoch = 8 + # FixRelayedBaseCostEnableEpoch represents the epoch when the fix for relayed base cost will be enabled FixRelayedBaseCostEnableEpoch = 7 diff --git a/common/constants.go b/common/constants.go index cbcd0caa6c8..5bf9d11b1ec 100644 --- a/common/constants.go +++ b/common/constants.go @@ -498,6 +498,9 @@ const ( // MetricRelayedTransactionsV3EnableEpoch represents the epoch when the relayed transactions v3 is enabled MetricRelayedTransactionsV3EnableEpoch = "erd_relayed_transactions_v3_enable_epoch" + // MetricRelayedTransactionsV3DisableEpoch represents the epoch when the relayed transactions v3 are disabled + MetricRelayedTransactionsV3DisableEpoch = "erd_relayed_transaction_v3_disable_epoch" + // MetricFixRelayedBaseCostEnableEpoch represents the epoch when the fix for relayed base cost is enabled MetricFixRelayedBaseCostEnableEpoch = "erd_fix_relayed_base_cost_enable_epoch" @@ -1235,6 +1238,7 @@ const ( CryptoOpcodesV2Flag core.EnableEpochFlag = "CryptoOpcodesV2Flag" UnJailCleanupFlag core.EnableEpochFlag = "UnJailCleanupFlag" RelayedTransactionsV3Flag core.EnableEpochFlag = "RelayedTransactionsV3Flag" + RelayedTransactionsV3DisableFlag core.EnableEpochFlag = "RelayedTransactionsV3DisableFlag" FixRelayedBaseCostFlag core.EnableEpochFlag = "FixRelayedBaseCostFlag" MultiESDTNFTTransferAndExecuteByUserFlag core.EnableEpochFlag = "MultiESDTNFTTransferAndExecuteByUserFlag" FixRelayedMoveBalanceToNonPayableSCFlag core.EnableEpochFlag = "FixRelayedMoveBalanceToNonPayableSCFlag" diff --git a/common/enablers/enableEpochsHandler.go b/common/enablers/enableEpochsHandler.go index cba4bb4fb4a..8bd5bfa0cc3 100644 --- a/common/enablers/enableEpochsHandler.go +++ b/common/enablers/enableEpochsHandler.go @@ -768,6 +768,12 @@ func (handler *enableEpochsHandler) createAllFlagsMap() { }, activationEpoch: handler.enableEpochsConfig.RelayedTransactionsV3EnableEpoch, }, + common.RelayedTransactionsV3DisableFlag: { + isActiveInEpoch: func(epoch uint32) bool { + return epoch >= handler.enableEpochsConfig.RelayedTransactionsV3DisableEpoch + }, + activationEpoch: handler.enableEpochsConfig.RelayedTransactionsV3DisableEpoch, + }, common.FixRelayedBaseCostFlag: { isActiveInEpoch: func(epoch uint32) bool { return epoch >= handler.enableEpochsConfig.FixRelayedBaseCostEnableEpoch diff --git a/common/enablers/enableEpochsHandler_test.go b/common/enablers/enableEpochsHandler_test.go index b7d8f27692d..83a80f9a67a 100644 --- a/common/enablers/enableEpochsHandler_test.go +++ b/common/enablers/enableEpochsHandler_test.go @@ -124,6 +124,7 @@ func createEnableEpochsConfig() config.EnableEpochs { MultiESDTNFTTransferAndExecuteByUserEnableEpoch: 107, FixRelayedMoveBalanceToNonPayableSCEnableEpoch: 108, UseGasBoundedShouldFailExecutionEnableEpoch: 110, + RelayedTransactionsV3DisableEpoch: 111, } } @@ -448,6 +449,7 @@ func TestEnableEpochsHandler_GetActivationEpoch(t *testing.T) { require.Equal(t, cfg.EGLDInMultiTransferEnableEpoch, handler.GetActivationEpoch(common.EGLDInESDTMultiTransferFlag)) require.Equal(t, cfg.CryptoOpcodesV2EnableEpoch, handler.GetActivationEpoch(common.CryptoOpcodesV2Flag)) require.Equal(t, cfg.RelayedTransactionsV3EnableEpoch, handler.GetActivationEpoch(common.RelayedTransactionsV3Flag)) + require.Equal(t, cfg.RelayedTransactionsV3DisableEpoch, handler.GetActivationEpoch(common.RelayedTransactionsV3DisableFlag)) require.Equal(t, cfg.FixRelayedBaseCostEnableEpoch, handler.GetActivationEpoch(common.FixRelayedBaseCostFlag)) require.Equal(t, cfg.MultiESDTNFTTransferAndExecuteByUserEnableEpoch, handler.GetActivationEpoch(common.MultiESDTNFTTransferAndExecuteByUserFlag)) require.Equal(t, cfg.FixRelayedMoveBalanceToNonPayableSCEnableEpoch, handler.GetActivationEpoch(common.FixRelayedMoveBalanceToNonPayableSCFlag)) diff --git a/config/epochConfig.go b/config/epochConfig.go index e24c302b7d0..9b5c8cb3773 100644 --- a/config/epochConfig.go +++ b/config/epochConfig.go @@ -120,6 +120,7 @@ type EnableEpochs struct { CryptoOpcodesV2EnableEpoch uint32 UnJailCleanupEnableEpoch uint32 RelayedTransactionsV3EnableEpoch uint32 + RelayedTransactionsV3DisableEpoch uint32 FixRelayedBaseCostEnableEpoch uint32 MultiESDTNFTTransferAndExecuteByUserEnableEpoch uint32 FixRelayedMoveBalanceToNonPayableSCEnableEpoch uint32 diff --git a/config/tomlConfig_test.go b/config/tomlConfig_test.go index f331917c5d0..949eb558719 100644 --- a/config/tomlConfig_test.go +++ b/config/tomlConfig_test.go @@ -878,6 +878,9 @@ func TestEnableEpochConfig(t *testing.T) { # RelayedTransactionsV3EnableEpoch represents the epoch when the relayed transactions V3 will be enabled RelayedTransactionsV3EnableEpoch = 99 + # RelayedTransactionsV3DisableEpoch represents the epoch when the relayed transactions V3 will be disabled + RelayedTransactionsV3DisableEpoch = 100 + # FixRelayedBaseCostEnableEpoch represents the epoch when the fix for relayed base cost will be enabled FixRelayedBaseCostEnableEpoch = 100 @@ -1005,6 +1008,7 @@ func TestEnableEpochConfig(t *testing.T) { EGLDInMultiTransferEnableEpoch: 97, CryptoOpcodesV2EnableEpoch: 98, RelayedTransactionsV3EnableEpoch: 99, + RelayedTransactionsV3DisableEpoch: 100, FixRelayedBaseCostEnableEpoch: 100, MultiESDTNFTTransferAndExecuteByUserEnableEpoch: 101, FixRelayedMoveBalanceToNonPayableSCEnableEpoch: 102, diff --git a/integrationTests/chainSimulator/relayedTx/relayedTx_test.go b/integrationTests/chainSimulator/relayedTx/relayedTx_test.go index fa2b02b9fe3..948d8c5c374 100644 --- a/integrationTests/chainSimulator/relayedTx/relayedTx_test.go +++ b/integrationTests/chainSimulator/relayedTx/relayedTx_test.go @@ -12,6 +12,7 @@ import ( "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/data/transaction" "github.com/multiversx/mx-chain-go/config" + "github.com/multiversx/mx-chain-go/integrationTests" testsChainSimulator "github.com/multiversx/mx-chain-go/integrationTests/chainSimulator" "github.com/multiversx/mx-chain-go/integrationTests/vm/wasm" "github.com/multiversx/mx-chain-go/node/chainSimulator" @@ -42,6 +43,7 @@ var ( alterConfigsFuncRelayedV3EarlyActivation = func(cfg *config.Configs) { cfg.EpochConfig.EnableEpochs.RelayedTransactionsV3EnableEpoch = 1 cfg.EpochConfig.EnableEpochs.FixRelayedBaseCostEnableEpoch = 1 + cfg.EpochConfig.EnableEpochs.RelayedTransactionsV3DisableEpoch = integrationTests.UnreachableEpoch } ) diff --git a/integrationTests/multiShard/relayedTx/common.go b/integrationTests/multiShard/relayedTx/common.go index 6815d12802e..b1410bbd87a 100644 --- a/integrationTests/multiShard/relayedTx/common.go +++ b/integrationTests/multiShard/relayedTx/common.go @@ -22,6 +22,9 @@ func CreateGeneralSetupForRelayTxTest(relayedV3Test bool) ([]*integrationTests.T epochsConfig.RelayedTransactionsV3EnableEpoch = integrationTests.UnreachableEpoch epochsConfig.FixRelayedBaseCostEnableEpoch = integrationTests.UnreachableEpoch epochsConfig.FixRelayedMoveBalanceToNonPayableSCEnableEpoch = integrationTests.UnreachableEpoch + epochsConfig.RelayedTransactionsV3DisableEpoch = 0 + } else { + epochsConfig.RelayedTransactionsV3DisableEpoch = integrationTests.UnreachableEpoch } nodes, idxProposers := createAndMintNodes(initialVal, epochsConfig) diff --git a/node/metrics/metrics.go b/node/metrics/metrics.go index bc84198eca5..4b0c29f96f2 100644 --- a/node/metrics/metrics.go +++ b/node/metrics/metrics.go @@ -122,6 +122,7 @@ func InitConfigMetrics( appStatusHandler.SetUInt64Value(common.MetricSenderInOutTransferEnableEpoch, uint64(enableEpochs.SenderInOutTransferEnableEpoch)) appStatusHandler.SetUInt64Value(common.MetricRelayedTransactionsV2EnableEpoch, uint64(enableEpochs.RelayedTransactionsV2EnableEpoch)) appStatusHandler.SetUInt64Value(common.MetricRelayedTransactionsV3EnableEpoch, uint64(enableEpochs.RelayedTransactionsV3EnableEpoch)) + appStatusHandler.SetUInt64Value(common.MetricRelayedTransactionsV3DisableEpoch, uint64(enableEpochs.RelayedTransactionsV3DisableEpoch)) appStatusHandler.SetUInt64Value(common.MetricFixRelayedBaseCostEnableEpoch, uint64(enableEpochs.FixRelayedBaseCostEnableEpoch)) appStatusHandler.SetUInt64Value(common.MetricUnbondTokensV2EnableEpoch, uint64(enableEpochs.UnbondTokensV2EnableEpoch)) appStatusHandler.SetUInt64Value(common.MetricSaveJailedAlwaysEnableEpoch, uint64(enableEpochs.SaveJailedAlwaysEnableEpoch)) diff --git a/node/metrics/metrics_test.go b/node/metrics/metrics_test.go index bec9f099923..8fa09730f44 100644 --- a/node/metrics/metrics_test.go +++ b/node/metrics/metrics_test.go @@ -212,6 +212,7 @@ func TestInitConfigMetrics(t *testing.T) { FixRelayedBaseCostEnableEpoch: 105, MultiESDTNFTTransferAndExecuteByUserEnableEpoch: 106, FixRelayedMoveBalanceToNonPayableSCEnableEpoch: 107, + RelayedTransactionsV3DisableEpoch: 108, MaxNodesChangeEnableEpoch: []config.MaxNodesChangeConfig{ { EpochEnable: 0, @@ -334,6 +335,7 @@ func TestInitConfigMetrics(t *testing.T) { "erd_fix_relayed_base_cost_enable_epoch": uint32(105), "erd_multi_esdt_transfer_execute_by_user_enable_epoch": uint32(106), "erd_fix_relayed_move_balance_to_non_payable_sc_enable_epoch": uint32(107), + "erd_relayed_transaction_v3_disable_epoch": uint32(108), "erd_max_nodes_change_enable_epoch": nil, "erd_total_supply": "12345", "erd_hysteresis": "0.100000", diff --git a/process/transaction/interceptedTransaction.go b/process/transaction/interceptedTransaction.go index 831afdcbcbc..db976c5ec01 100644 --- a/process/transaction/interceptedTransaction.go +++ b/process/transaction/interceptedTransaction.go @@ -257,7 +257,8 @@ func (inTx *InterceptedTransaction) verifyIfRelayedTxV3(tx *transaction.Transact if len(tx.InnerTransactions) == 0 { return nil } - if !inTx.enableEpochsHandler.IsFlagEnabled(common.RelayedTransactionsV3Flag) { + if !inTx.enableEpochsHandler.IsFlagEnabled(common.RelayedTransactionsV3Flag) || + inTx.enableEpochsHandler.IsFlagEnabled(common.RelayedTransactionsV3DisableFlag) { return process.ErrRelayedTxV3Disabled } err := inTx.relayedTxV3Processor.CheckRelayedTx(tx) diff --git a/process/transaction/shardProcess.go b/process/transaction/shardProcess.go index 6d2fbeb80f3..121173e57b2 100644 --- a/process/transaction/shardProcess.go +++ b/process/transaction/shardProcess.go @@ -135,6 +135,7 @@ func NewTxProcessor(args ArgsNewTxProcessor) (*txProcessor, error) { common.RelayedTransactionsV2Flag, common.RelayedNonceFixFlag, common.RelayedTransactionsV3Flag, + common.RelayedTransactionsV3DisableFlag, common.FixRelayedBaseCostFlag, }) if err != nil { @@ -710,7 +711,8 @@ func (txProc *txProcessor) processRelayedTxV3( tx *transaction.Transaction, relayerAcnt state.UserAccountHandler, ) (vmcommon.ReturnCode, error) { - if !txProc.enableEpochsHandler.IsFlagEnabled(common.RelayedTransactionsV3Flag) { + if !txProc.enableEpochsHandler.IsFlagEnabled(common.RelayedTransactionsV3Flag) || + txProc.enableEpochsHandler.IsFlagEnabled(common.RelayedTransactionsV3DisableFlag) { return vmcommon.UserError, txProc.executingFailedTransaction(tx, relayerAcnt, process.ErrRelayedTxV3Disabled) } if check.IfNil(relayerAcnt) {