Skip to content

Commit

Permalink
disable relayed v3
Browse files Browse the repository at this point in the history
  • Loading branch information
sstanculeanu committed Oct 25, 2024
1 parent 0ef7d5d commit 0aba981
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cmd/node/config/enableEpochs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions common/enablers/enableEpochsHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions common/enablers/enableEpochsHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func createEnableEpochsConfig() config.EnableEpochs {
MultiESDTNFTTransferAndExecuteByUserEnableEpoch: 107,
FixRelayedMoveBalanceToNonPayableSCEnableEpoch: 108,
UseGasBoundedShouldFailExecutionEnableEpoch: 110,
RelayedTransactionsV3DisableEpoch: 111,
}
}

Expand Down Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions config/epochConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ type EnableEpochs struct {
CryptoOpcodesV2EnableEpoch uint32
UnJailCleanupEnableEpoch uint32
RelayedTransactionsV3EnableEpoch uint32
RelayedTransactionsV3DisableEpoch uint32
FixRelayedBaseCostEnableEpoch uint32
MultiESDTNFTTransferAndExecuteByUserEnableEpoch uint32
FixRelayedMoveBalanceToNonPayableSCEnableEpoch uint32
Expand Down
4 changes: 4 additions & 0 deletions config/tomlConfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1005,6 +1008,7 @@ func TestEnableEpochConfig(t *testing.T) {
EGLDInMultiTransferEnableEpoch: 97,
CryptoOpcodesV2EnableEpoch: 98,
RelayedTransactionsV3EnableEpoch: 99,
RelayedTransactionsV3DisableEpoch: 100,
FixRelayedBaseCostEnableEpoch: 100,
MultiESDTNFTTransferAndExecuteByUserEnableEpoch: 101,
FixRelayedMoveBalanceToNonPayableSCEnableEpoch: 102,
Expand Down
2 changes: 2 additions & 0 deletions integrationTests/chainSimulator/relayedTx/relayedTx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
)

Expand Down
3 changes: 3 additions & 0 deletions integrationTests/multiShard/relayedTx/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions node/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 2 additions & 0 deletions node/metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ func TestInitConfigMetrics(t *testing.T) {
FixRelayedBaseCostEnableEpoch: 105,
MultiESDTNFTTransferAndExecuteByUserEnableEpoch: 106,
FixRelayedMoveBalanceToNonPayableSCEnableEpoch: 107,
RelayedTransactionsV3DisableEpoch: 108,
MaxNodesChangeEnableEpoch: []config.MaxNodesChangeConfig{
{
EpochEnable: 0,
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion process/transaction/interceptedTransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion process/transaction/shardProcess.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func NewTxProcessor(args ArgsNewTxProcessor) (*txProcessor, error) {
common.RelayedTransactionsV2Flag,
common.RelayedNonceFixFlag,
common.RelayedTransactionsV3Flag,
common.RelayedTransactionsV3DisableFlag,
common.FixRelayedBaseCostFlag,
})
if err != nil {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 0aba981

Please sign in to comment.