Skip to content

Conversation

anusha-ctrl
Copy link
Contributor

@anusha-ctrl anusha-ctrl commented Dec 20, 2022

Why this should be merged

  • We should add a requirement that the SubnetEVM upgrade is enabled so that we can deprecate support for it being disabled. It should always be enabled from genesis.

How this works

  • We check the blockTimestamp at genesis and see if it is greater than or equal to SubnetEVMTimestamp. SubnetEVMTimestamp should be set to 0 so the SubnetEVM upgrade is enabled at genesis.
  • This should error if the genesisJSON did not include subnetEVMTimestamp or subnetEVMTimestamp was set to some timestamp > 0
  • We add a config flag so the user can skip this subnetevm upgrade check for the time being.

Here is an example of the chain config

// SubnetEVMDefaultChainConfig is the default configuration
	SubnetEVMDefaultChainConfig = &ChainConfig{
		ChainID:            SubnetEVMChainID,
		FeeConfig:          DefaultFeeConfig,
		AllowFeeRecipients: false,

		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP150Hash:          common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),

		NetworkUpgrades: NetworkUpgrades{
			SubnetEVMTimestamp: big.NewInt(0),
		},
	}

How this was tested

  • 2 unit tests were added

@anusha-ctrl anusha-ctrl added this to the [email protected] milestone Dec 20, 2022
@anusha-ctrl anusha-ctrl linked an issue Dec 20, 2022 that may be closed by this pull request
@anusha-ctrl anusha-ctrl marked this pull request as ready for review December 20, 2022 23:22
}

func TestSubnetEVMUpgradeNotEnabledAtGenesis(t *testing.T) {
ctx, dbManager, genesisBytes, issuer := setupGenesis(t, genesisJSONSubnetEVMLateEnablement)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively we can parse the json for genesisJSONSubnetEVM and modify the value in the test.

@anusha-ctrl anusha-ctrl requested a review from darioush December 20, 2022 23:33
@anusha-ctrl anusha-ctrl requested a review from darioush December 20, 2022 23:45
@anusha-ctrl anusha-ctrl marked this pull request as draft December 21, 2022 00:59
@anusha-ctrl
Copy link
Contributor Author

anusha-ctrl commented Dec 21, 2022

Need to fix some existing tests. With this new guard in place, it should no longer be possible to abort an Subnet-EVM upgrade as it is a requirement

// Get a json specifying a Network upgrade at genesis
// to apply as upgradeBytes.
subnetEVMTimestamp := time.Unix(10, 0)
subnetEVMTimestamp := big.NewInt(0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subnetEVMTimestamp must be 0 to be activated at genesis

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we require that this is set directly in the genesis rather than in the upgrade bytes to make this simpler?


// abort a fork specified in genesis
upgradeConfig.NetworkUpgrades.SubnetEVMTimestamp = nil
upgradeConfig.NetworkUpgrades = nil
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer testing abort, but now testing the fallback genesis bytes

Copy link
Collaborator

@aaronbuchwald aaronbuchwald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@ceyonur ceyonur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code generally lgtm. I just wonder if we should add a flag to avago-chain config to skip this check? We can emphasize this is just for testing purposes and should not be used in producion. it can also still be used for chains that are bot upgraded to subnet-evm.

plugin/evm/vm.go Outdated
Comment on lines 374 to 377
if !vm.chainConfig.IsSubnetEVM(common.Big0) {
return errSubnetEVMUpgradeNotEnabled
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we move this below to upgradeBytes parsing, in case this was activated by a upgrade at genesis? Could this be a possibility? @aaronbuchwald @darioush

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They could include it in the upgrade bytes to activate at timestamp 0, but it SHOULD always be included in the genesis, so I think it's preferable to error here rather than after applying the upgradeBytes. I actually asked @anusha-ctrl to make this change to put it here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just thinking someone might want to fix their genesis via this method (or by removing the checks via config flag).

@aaronbuchwald
Copy link
Collaborator

code generally lgtm. I just wonder if we should add a flag to avago-chain config to skip this check? We can emphasize this is just for testing purposes and should not be used in producion. it can also still be used for chains that are bot upgraded to subnet-evm.

Good idea, this way we do not need to create a new release if anyone runs into this unexpectedly. I confirmed in https://github.com/ava-labs/public-chain-assets/ that none of the networks here should be impacted.

@anusha-ctrl could you add a config flag that will allow a user to override this check in case anyone runs into it along with a TODO to remove once we confirm that there are no complaints after making this change?

Copy link
Collaborator

@ceyonur ceyonur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

@anusha-ctrl anusha-ctrl requested a review from darioush January 12, 2023 00:15
Copy link
Collaborator

@aaronbuchwald aaronbuchwald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aaronbuchwald aaronbuchwald merged commit 880ec77 into master Jan 13, 2023
@aaronbuchwald aaronbuchwald deleted the add-upgrade-requirement branch January 13, 2023 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Requirement that SubnetEVM Upgrade is Enabled
4 participants