Skip to content

Commit

Permalink
Disable TransformSubnetTx post-Etna (#3152)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrubabasu authored Aug 5, 2024
1 parent 1bcd544 commit 479145a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/stretchr/testify/require"

"github.com/ava-labs/avalanchego/api/info"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/tests/fixture/e2e"
"github.com/ava-labs/avalanchego/utils/constants"
Expand All @@ -24,7 +25,7 @@ import (
ginkgo "github.com/onsi/ginkgo/v2"
)

var _ = e2e.DescribePChain("[Permissionless Subnets]", func() {
var _ = e2e.DescribePChain("[Elastic Subnets]", func() {
tc := e2e.NewTestContext()
require := require.New(tc)

Expand All @@ -34,6 +35,17 @@ var _ = e2e.DescribePChain("[Permissionless Subnets]", func() {

nodeURI := env.GetRandomNodeURI()

infoClient := info.NewClient(nodeURI.URI)

tc.By("get upgrade config")
upgrades, err := infoClient.Upgrades(tc.DefaultContext())
require.NoError(err)

now := time.Now()
if upgrades.IsEtnaActivated(now) {
ginkgo.Skip("Etna is activated. Elastic Subnets are disabled post-Etna, skipping test.")
}

keychain := env.NewKeychain(1)
baseWallet := e2e.NewWallet(tc, keychain, nodeURI)

Expand Down
11 changes: 7 additions & 4 deletions vms/platformvm/txs/executor/standard_tx_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var (
errEmptyNodeID = errors.New("validator nodeID cannot be empty")
errMaxStakeDurationTooLarge = errors.New("max stake duration must be less than or equal to the global max stake duration")
errMissingStartTimePreDurango = errors.New("staker transactions must have a StartTime pre-Durango")
errTransformSubnetTxPostEtna = errors.New("TransformSubnetTx is not permitted post-Etna")
)

type StandardTxExecutor struct {
Expand Down Expand Up @@ -433,14 +434,16 @@ func (e *StandardTxExecutor) RemoveSubnetValidatorTx(tx *txs.RemoveSubnetValidat
}

func (e *StandardTxExecutor) TransformSubnetTx(tx *txs.TransformSubnetTx) error {
currentTimestamp := e.State.GetTimestamp()
if e.Config.UpgradeConfig.IsEtnaActivated(currentTimestamp) {
return errTransformSubnetTxPostEtna
}

if err := e.Tx.SyntacticVerify(e.Ctx); err != nil {
return err
}

var (
currentTimestamp = e.State.GetTimestamp()
isDurangoActive = e.Config.UpgradeConfig.IsDurangoActivated(currentTimestamp)
)
isDurangoActive := e.Config.UpgradeConfig.IsDurangoActivated(currentTimestamp)
if err := avax.VerifyMemoFieldLength(tx.Memo, isDurangoActive); err != nil {
return err
}
Expand Down
23 changes: 23 additions & 0 deletions vms/platformvm/txs/executor/standard_tx_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1597,6 +1597,29 @@ func TestDurangoMemoField(t *testing.T) {
}
}

// Verifies that [TransformSubnetTx] is disabled post-Etna
func TestEtnaDisabledTransactions(t *testing.T) {
require := require.New(t)

env := newEnvironment(t, etna)
env.ctx.Lock.Lock()
defer env.ctx.Lock.Unlock()

onAcceptState, err := state.NewDiff(env.state.GetLastAccepted(), env)
require.NoError(err)

tx := &txs.Tx{
Unsigned: &txs.TransformSubnetTx{},
}

err = tx.Unsigned.Visit(&StandardTxExecutor{
Backend: &env.backend,
State: onAcceptState,
Tx: tx,
})
require.ErrorIs(err, errTransformSubnetTxPostEtna)
}

// Returns a RemoveSubnetValidatorTx that passes syntactic verification.
// Memo field is empty as required post Durango activation
func newRemoveSubnetValidatorTx(t *testing.T) (*txs.RemoveSubnetValidatorTx, *txs.Tx) {
Expand Down

0 comments on commit 479145a

Please sign in to comment.