mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
E upgrade config (#1135)
* introduce e upgrade * map upgrades * check if upgrade is non-nil * fix checkForks * Fix tests * revert test changes * fix tests * remove block no param from IsCancun * add UT * use avalanche defaults for timestamps * use non-zero timestamps in genesis configs * fix test timestamps * add timestamp to ethapi genesis * fix blockchain test genesis timestamp * fix test * review fixes
This commit is contained in:
+1
-53
@@ -105,56 +105,4 @@ Tests are written for a local network which runs a Subnet-EVM Blockchain.
|
||||
|
||||
E.g `RPC_URI=http://127.0.0.1:9650/ext/bc/28N1Tv5CZziQ3FKCaXmo8xtxoFtuoVA6NvZykAT5MtGjF4JkGs/rpc CHAIN_ID=77777 npx hardhat test --network local`.
|
||||
|
||||
Subnet-EVM must activate any precompiles used in the test in the genesis:
|
||||
|
||||
```json
|
||||
{
|
||||
"config": {
|
||||
"chainId": 43214,
|
||||
"homesteadBlock": 0,
|
||||
"eip150Block": 0,
|
||||
"eip155Block": 0,
|
||||
"eip158Block": 0,
|
||||
"byzantiumBlock": 0,
|
||||
"constantinopleBlock": 0,
|
||||
"petersburgBlock": 0,
|
||||
"istanbulBlock": 0,
|
||||
"muirGlacierBlock": 0,
|
||||
"subnetEVMTimestamp": 0,
|
||||
"feeConfig": {
|
||||
"gasLimit": 8000000,
|
||||
"minBaseFee": 25000000000,
|
||||
"targetGas": 15000000,
|
||||
"baseFeeChangeDenominator": 36,
|
||||
"minBlockGasCost": 0,
|
||||
"maxBlockGasCost": 1000000,
|
||||
"targetBlockRate": 2,
|
||||
"blockGasCostStep": 200000
|
||||
},
|
||||
"contractDeployerAllowListConfig": {
|
||||
"blockTimestamp": 0,
|
||||
"adminAddresses": ["0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC"]
|
||||
},
|
||||
"contractNativeMinterConfig": {
|
||||
"blockTimestamp": 0,
|
||||
"adminAddresses": ["0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC"]
|
||||
},
|
||||
"allowFeeRecipients": false
|
||||
},
|
||||
"alloc": {
|
||||
"8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC": {
|
||||
"balance": "0x295BE96E64066972000000"
|
||||
}
|
||||
},
|
||||
"nonce": "0x0",
|
||||
"timestamp": "0x0",
|
||||
"extraData": "0x00",
|
||||
"gasLimit": "0x7A1200",
|
||||
"difficulty": "0x0",
|
||||
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"coinbase": "0x0000000000000000000000000000000000000000",
|
||||
"number": "0x0",
|
||||
"gasUsed": "0x0",
|
||||
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
|
||||
}
|
||||
```
|
||||
Subnet-EVM must activate any precompiles used in the test in the genesis.
|
||||
|
||||
@@ -1215,7 +1215,8 @@ func TestEIP3651(t *testing.T) {
|
||||
addr2 = crypto.PubkeyToAddress(key2.PublicKey)
|
||||
funds = new(big.Int).Mul(common.Big1, big.NewInt(params.Ether))
|
||||
gspec = &Genesis{
|
||||
Config: params.TestChainConfig,
|
||||
Config: params.TestChainConfig,
|
||||
Timestamp: uint64(params.DefaultGenesisTime.Unix()),
|
||||
Alloc: GenesisAlloc{
|
||||
addr1: {Balance: funds},
|
||||
addr2: {Balance: funds},
|
||||
|
||||
@@ -109,7 +109,8 @@ func TestStateProcessorErrors(t *testing.T) {
|
||||
var (
|
||||
db = rawdb.NewMemoryDatabase()
|
||||
gspec = &Genesis{
|
||||
Config: config,
|
||||
Config: config,
|
||||
Timestamp: uint64(params.DefaultGenesisTime.Unix()),
|
||||
Alloc: GenesisAlloc{
|
||||
common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7"): GenesisAccount{
|
||||
Balance: big.NewInt(4000000000000000000), // 4 ether
|
||||
|
||||
@@ -1359,8 +1359,6 @@ func TestRPCGetBlockOrHeader(t *testing.T) {
|
||||
|
||||
func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Hash) {
|
||||
config := *params.TestChainConfig
|
||||
// config.ShanghaiTime = new(uint64)
|
||||
config.CancunTime = new(uint64)
|
||||
var (
|
||||
acc1Key, _ = crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a")
|
||||
acc2Key, _ = crypto.HexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee")
|
||||
@@ -1371,6 +1369,7 @@ func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Ha
|
||||
Config: &config,
|
||||
ExcessBlobGas: new(uint64),
|
||||
BlobGasUsed: new(uint64),
|
||||
Timestamp: uint64(params.DefaultGenesisTime.Unix()),
|
||||
Alloc: core.GenesisAlloc{
|
||||
acc1Addr: {Balance: big.NewInt(params.Ether)},
|
||||
acc2Addr: {Balance: big.NewInt(params.Ether)},
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"blobGasPrice": "0x1",
|
||||
"blobGasUsed": "0x20000",
|
||||
"blockHash": "0x77d5e4ffb415ca53742a37e4bf7bb1522d99dcce1c90e9957eb6d267a0c7e5a1",
|
||||
"blockHash": "0x264b5f62e2900dd39a6c68af3ba656cffa3fe209614ca857af1f5702c6e2ba7e",
|
||||
"blockNumber": "0x6",
|
||||
"contractAddress": null,
|
||||
"cumulativeGasUsed": "0x5208",
|
||||
@@ -17,4 +17,4 @@
|
||||
"transactionIndex": "0x0",
|
||||
"type": "0x3"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[
|
||||
{
|
||||
"blockHash": "0xa4eb72463332ae8ad98317466a6cc3c61c5ca4d884dd488c44edec166ff1b495",
|
||||
"blockHash": "0x0524420ca4d3974c72883de6ccdeca2e8be7eafeac88ff03d144ed16fe78063a",
|
||||
"blockNumber": "0x2",
|
||||
"contractAddress": "0xae9bea628c4ce503dcfd7e305cab4e29e7476592",
|
||||
"cumulativeGasUsed": "0xcf50",
|
||||
@@ -15,4 +15,4 @@
|
||||
"transactionIndex": "0x0",
|
||||
"type": "0x0"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[
|
||||
{
|
||||
"blockHash": "0x2dcd37090523d8d1ec308edec7d25eced1e26b96c4784f5f362ac58f9b33b2a1",
|
||||
"blockHash": "0x0b7437b9229f72a563918ee8c73e9a8f5e294f9d0e17db6bf8408cdf6fbc84b7",
|
||||
"blockNumber": "0x4",
|
||||
"contractAddress": null,
|
||||
"cumulativeGasUsed": "0x538d",
|
||||
@@ -15,4 +15,4 @@
|
||||
"transactionIndex": "0x0",
|
||||
"type": "0x2"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
[
|
||||
{
|
||||
"blockHash": "0xbeee747a45ccfe51c6da7ac72f585e813a74669528a59ff590d9ce7433938c9d",
|
||||
"blockHash": "0x587918ec6a2187a54418dc5334d02a53b61c39578d095f4845be8d4f25dea5b5",
|
||||
"blockNumber": "0x3",
|
||||
"contractAddress": null,
|
||||
"cumulativeGasUsed": "0x5e28",
|
||||
@@ -19,7 +19,7 @@
|
||||
"blockNumber": "0x3",
|
||||
"transactionHash": "0x7366a7738f47e32f5b6d292ca064b6b66f295d3931533a3745975be1191fccdf",
|
||||
"transactionIndex": "0x0",
|
||||
"blockHash": "0xbeee747a45ccfe51c6da7ac72f585e813a74669528a59ff590d9ce7433938c9d",
|
||||
"blockHash": "0x587918ec6a2187a54418dc5334d02a53b61c39578d095f4845be8d4f25dea5b5",
|
||||
"logIndex": "0x0",
|
||||
"removed": false
|
||||
}
|
||||
@@ -31,4 +31,4 @@
|
||||
"transactionIndex": "0x0",
|
||||
"type": "0x0"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[
|
||||
{
|
||||
"blockHash": "0xe387aa64524bf1712ce0640d1fbdab0992005cfa0d8cd124c526c66a87786359",
|
||||
"blockHash": "0x2918b59e4b455614c1b83c0281e2b8462af47ca9726fff31789cb168793015d7",
|
||||
"blockNumber": "0x1",
|
||||
"contractAddress": null,
|
||||
"cumulativeGasUsed": "0x5208",
|
||||
@@ -15,4 +15,4 @@
|
||||
"transactionIndex": "0x0",
|
||||
"type": "0x0"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"blobGasPrice": "0x1",
|
||||
"blobGasUsed": "0x20000",
|
||||
"blockHash": "0x77d5e4ffb415ca53742a37e4bf7bb1522d99dcce1c90e9957eb6d267a0c7e5a1",
|
||||
"blockHash": "0x264b5f62e2900dd39a6c68af3ba656cffa3fe209614ca857af1f5702c6e2ba7e",
|
||||
"blockNumber": "0x6",
|
||||
"contractAddress": null,
|
||||
"cumulativeGasUsed": "0x5208",
|
||||
@@ -17,4 +17,4 @@
|
||||
"transactionIndex": "0x0",
|
||||
"type": "0x3"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"blobGasPrice": "0x1",
|
||||
"blobGasUsed": "0x20000",
|
||||
"blockHash": "0x77d5e4ffb415ca53742a37e4bf7bb1522d99dcce1c90e9957eb6d267a0c7e5a1",
|
||||
"blockHash": "0x264b5f62e2900dd39a6c68af3ba656cffa3fe209614ca857af1f5702c6e2ba7e",
|
||||
"blockNumber": "0x6",
|
||||
"contractAddress": null,
|
||||
"cumulativeGasUsed": "0x5208",
|
||||
@@ -15,4 +15,4 @@
|
||||
"transactionHash": "0x7e71344129674f4bbfdaa86313d005a96581993d93ae3a30d81b13fa25579eb2",
|
||||
"transactionIndex": "0x0",
|
||||
"type": "0x3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"blockHash": "0xa4eb72463332ae8ad98317466a6cc3c61c5ca4d884dd488c44edec166ff1b495",
|
||||
"blockHash": "0x0524420ca4d3974c72883de6ccdeca2e8be7eafeac88ff03d144ed16fe78063a",
|
||||
"blockNumber": "0x2",
|
||||
"contractAddress": "0xae9bea628c4ce503dcfd7e305cab4e29e7476592",
|
||||
"cumulativeGasUsed": "0xcf50",
|
||||
@@ -13,4 +13,4 @@
|
||||
"transactionHash": "0x22aa617165f83a9f8c191c2b7724ae43eeb1249bee06c98c03c7624c21d27dc8",
|
||||
"transactionIndex": "0x0",
|
||||
"type": "0x0"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"blockHash": "0x9acfc909e24be0eed69e55e826935be38c9546eea779e0105f465eb6d8d493ad",
|
||||
"blockHash": "0x2bf952c71ce24c68f887c12ecba6f1a36f97f528259fe0574890969e1113187a",
|
||||
"blockNumber": "0x5",
|
||||
"contractAddress": "0xfdaa97661a584d977b4d3abb5370766ff5b86a18",
|
||||
"cumulativeGasUsed": "0xe01c",
|
||||
@@ -13,4 +13,4 @@
|
||||
"transactionHash": "0x8afe030574f663fe5096371d6f58a6287bfb3e0c73a5050220f5775a08e7abc9",
|
||||
"transactionIndex": "0x0",
|
||||
"type": "0x1"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"blockHash": "0x2dcd37090523d8d1ec308edec7d25eced1e26b96c4784f5f362ac58f9b33b2a1",
|
||||
"blockHash": "0x0b7437b9229f72a563918ee8c73e9a8f5e294f9d0e17db6bf8408cdf6fbc84b7",
|
||||
"blockNumber": "0x4",
|
||||
"contractAddress": null,
|
||||
"cumulativeGasUsed": "0x538d",
|
||||
@@ -13,4 +13,4 @@
|
||||
"transactionHash": "0x4e1e9194ca6f9d4e1736e9e441f66104f273548ed6d91b236a5f9c2ea10fa06d",
|
||||
"transactionIndex": "0x0",
|
||||
"type": "0x2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"blockHash": "0xe387aa64524bf1712ce0640d1fbdab0992005cfa0d8cd124c526c66a87786359",
|
||||
"blockHash": "0x2918b59e4b455614c1b83c0281e2b8462af47ca9726fff31789cb168793015d7",
|
||||
"blockNumber": "0x1",
|
||||
"contractAddress": null,
|
||||
"cumulativeGasUsed": "0x5208",
|
||||
@@ -13,4 +13,4 @@
|
||||
"transactionHash": "0xdf92bc7c4c0341ecbdcd2a3ca7011fe9e21df4b8553bf0c8caabe6cb4a1aee26",
|
||||
"transactionIndex": "0x0",
|
||||
"type": "0x0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"blockHash": "0xbeee747a45ccfe51c6da7ac72f585e813a74669528a59ff590d9ce7433938c9d",
|
||||
"blockHash": "0x587918ec6a2187a54418dc5334d02a53b61c39578d095f4845be8d4f25dea5b5",
|
||||
"blockNumber": "0x3",
|
||||
"contractAddress": null,
|
||||
"cumulativeGasUsed": "0x5e28",
|
||||
@@ -18,7 +18,7 @@
|
||||
"blockNumber": "0x3",
|
||||
"transactionHash": "0x7366a7738f47e32f5b6d292ca064b6b66f295d3931533a3745975be1191fccdf",
|
||||
"transactionIndex": "0x0",
|
||||
"blockHash": "0xbeee747a45ccfe51c6da7ac72f585e813a74669528a59ff590d9ce7433938c9d",
|
||||
"blockHash": "0x587918ec6a2187a54418dc5334d02a53b61c39578d095f4845be8d4f25dea5b5",
|
||||
"logIndex": "0x0",
|
||||
"removed": false
|
||||
}
|
||||
@@ -29,4 +29,4 @@
|
||||
"transactionHash": "0x7366a7738f47e32f5b6d292ca064b6b66f295d3931533a3745975be1191fccdf",
|
||||
"transactionIndex": "0x0",
|
||||
"type": "0x0"
|
||||
}
|
||||
}
|
||||
|
||||
+32
-11
@@ -33,6 +33,7 @@ import (
|
||||
"math/big"
|
||||
|
||||
"github.com/ava-labs/avalanchego/utils/constants"
|
||||
"github.com/ava-labs/avalanchego/version"
|
||||
"github.com/ava-labs/subnet-evm/commontype"
|
||||
"github.com/ava-labs/subnet-evm/precompile/modules"
|
||||
"github.com/ava-labs/subnet-evm/precompile/precompileconfig"
|
||||
@@ -55,6 +56,8 @@ var (
|
||||
DynamicFeeExtraDataSize = 80
|
||||
RollupWindow uint64 = 10
|
||||
|
||||
DefaultGenesisTime = version.DefaultUpgradeTime
|
||||
|
||||
DefaultFeeConfig = commontype.FeeConfig{
|
||||
GasLimit: big.NewInt(8_000_000),
|
||||
TargetBlockRate: 2, // in seconds
|
||||
@@ -104,7 +107,8 @@ var (
|
||||
PetersburgBlock: big.NewInt(0),
|
||||
IstanbulBlock: big.NewInt(0),
|
||||
MuirGlacierBlock: big.NewInt(0),
|
||||
NetworkUpgrades: TestNetworkUpgrades,
|
||||
CancunTime: utils.TimeToNewUint64(version.GetEUpgradeTime(constants.UnitTestID)),
|
||||
NetworkUpgrades: getDefaultNetworkUpgrades(constants.UnitTestID),
|
||||
GenesisPrecompiles: Precompiles{},
|
||||
UpgradeConfig: UpgradeConfig{},
|
||||
}
|
||||
@@ -353,7 +357,7 @@ func (c *ChainConfig) Verify() error {
|
||||
}
|
||||
|
||||
// Verify the network upgrades are internally consistent given the existing chainConfig.
|
||||
if err := c.VerifyNetworkUpgrades(c.SnowCtx.NetworkID); err != nil {
|
||||
if err := c.verifyNetworkUpgrades(c.SnowCtx.NetworkID); err != nil {
|
||||
return fmt.Errorf("invalid network upgrades: %w", err)
|
||||
}
|
||||
|
||||
@@ -380,6 +384,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
|
||||
{name: "petersburgBlock", block: c.PetersburgBlock},
|
||||
{name: "istanbulBlock", block: c.IstanbulBlock},
|
||||
{name: "muirGlacierBlock", block: c.MuirGlacierBlock, optional: true},
|
||||
{name: "cancunTime", timestamp: c.CancunTime},
|
||||
}
|
||||
|
||||
// Check that forks are enabled in order
|
||||
@@ -411,20 +416,36 @@ func checkForks(forks []fork, blockFork bool) error {
|
||||
return errNonGenesisForkByHeight
|
||||
}
|
||||
if lastFork.name != "" {
|
||||
// Next one must be higher number
|
||||
if lastFork.timestamp == nil && cur.timestamp != nil {
|
||||
return fmt.Errorf("unsupported fork ordering: %v not enabled, but %v enabled at %v",
|
||||
lastFork.name, cur.name, *cur.timestamp)
|
||||
}
|
||||
if lastFork.timestamp != nil && cur.timestamp != nil {
|
||||
if *lastFork.timestamp > *cur.timestamp {
|
||||
return fmt.Errorf("unsupported fork ordering: %v enabled at %v, but %v enabled at %v",
|
||||
switch {
|
||||
// Non-optional forks must all be present in the chain config up to the last defined fork
|
||||
case lastFork.block == nil && lastFork.timestamp == nil && (cur.block != nil || cur.timestamp != nil):
|
||||
if cur.block != nil {
|
||||
return fmt.Errorf("unsupported fork ordering: %v not enabled, but %v enabled at block %v",
|
||||
lastFork.name, cur.name, cur.block)
|
||||
} else {
|
||||
return fmt.Errorf("unsupported fork ordering: %v not enabled, but %v enabled at timestamp %v",
|
||||
lastFork.name, cur.name, *cur.timestamp)
|
||||
}
|
||||
|
||||
// Fork (whether defined by block or timestamp) must follow the fork definition sequence
|
||||
case (lastFork.block != nil && cur.block != nil) || (lastFork.timestamp != nil && cur.timestamp != nil):
|
||||
if lastFork.block != nil && lastFork.block.Cmp(cur.block) > 0 {
|
||||
return fmt.Errorf("unsupported fork ordering: %v enabled at block %v, but %v enabled at block %v",
|
||||
lastFork.name, lastFork.block, cur.name, cur.block)
|
||||
} else if lastFork.timestamp != nil && *lastFork.timestamp > *cur.timestamp {
|
||||
return fmt.Errorf("unsupported fork ordering: %v enabled at timestamp %v, but %v enabled at timestamp %v",
|
||||
lastFork.name, *lastFork.timestamp, cur.name, *cur.timestamp)
|
||||
}
|
||||
|
||||
// Timestamp based forks can follow block based ones, but not the other way around
|
||||
if lastFork.timestamp != nil && cur.block != nil {
|
||||
return fmt.Errorf("unsupported fork ordering: %v used timestamp ordering, but %v reverted to block ordering",
|
||||
lastFork.name, cur.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
// If it was optional and not set, then ignore it
|
||||
if !cur.optional || cur.timestamp != nil {
|
||||
if !cur.optional || (cur.block != nil || cur.timestamp != nil) {
|
||||
lastFork = cur
|
||||
}
|
||||
}
|
||||
|
||||
+4
-11
@@ -7,9 +7,9 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"github.com/ava-labs/avalanchego/snow"
|
||||
"github.com/ava-labs/subnet-evm/utils"
|
||||
)
|
||||
|
||||
// UpgradeConfig includes the following configs that may be specified in upgradeBytes:
|
||||
@@ -180,16 +180,9 @@ func (c *ChainConfig) SetNetworkUpgradeDefaults() {
|
||||
c.NetworkUpgrades.setDefaults(c.SnowCtx.NetworkID)
|
||||
}
|
||||
|
||||
// SetMappedUpgrades sets the mapped upgrades (usually Avalanche > EVM upgrades) for the chain config.
|
||||
// SetEVMUpgrades sets the mapped upgrades Avalanche > EVM upgrades) for the chain config.
|
||||
func (c *ChainConfig) SetEVMUpgrades(avalancheUpgrades NetworkUpgrades) {
|
||||
// c.CancunTime = utils.NewUint64(*avalancheUpgrades.EUpgradeTimestamp)
|
||||
}
|
||||
|
||||
func getUpgradeTime(networkID uint32, upgradeTimes map[uint32]time.Time) uint64 {
|
||||
if upgradeTime, ok := upgradeTimes[networkID]; ok {
|
||||
return uint64(upgradeTime.Unix())
|
||||
if avalancheUpgrades.EUpgradeTimestamp != nil {
|
||||
c.CancunTime = utils.NewUint64(*avalancheUpgrades.EUpgradeTimestamp)
|
||||
}
|
||||
// If the upgrade time isn't specified, default being enabled in the
|
||||
// genesis.
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -13,11 +13,6 @@ import (
|
||||
|
||||
var (
|
||||
errCannotBeNil = fmt.Errorf("timestamp cannot be nil")
|
||||
|
||||
TestNetworkUpgrades = NetworkUpgrades{
|
||||
SubnetEVMTimestamp: utils.NewUint64(0),
|
||||
DurangoTimestamp: utils.NewUint64(0),
|
||||
}
|
||||
)
|
||||
|
||||
// NetworkUpgrades contains timestamps that enable network upgrades.
|
||||
@@ -29,6 +24,8 @@ type NetworkUpgrades struct {
|
||||
// and Avalanche Warp Messaging.
|
||||
// Note: EIP-4895 is excluded since withdrawals are not relevant to the Avalanche C-Chain or Subnets running the EVM.
|
||||
DurangoTimestamp *uint64 `json:"durangoTimestamp,omitempty"`
|
||||
// Placeholder for EUpgradeTimestamp
|
||||
EUpgradeTimestamp *uint64 `json:"eUpgradeTimestamp,omitempty"`
|
||||
}
|
||||
|
||||
func (n *NetworkUpgrades) Equal(other *NetworkUpgrades) bool {
|
||||
@@ -42,6 +39,9 @@ func (n *NetworkUpgrades) CheckNetworkUpgradesCompatible(newcfg *NetworkUpgrades
|
||||
if isForkTimestampIncompatible(n.DurangoTimestamp, newcfg.DurangoTimestamp, time) {
|
||||
return newTimestampCompatError("Durango fork block timestamp", n.DurangoTimestamp, newcfg.DurangoTimestamp)
|
||||
}
|
||||
if isForkTimestampIncompatible(n.EUpgradeTimestamp, newcfg.EUpgradeTimestamp, time) {
|
||||
return newTimestampCompatError("EUpgrade fork block timestamp", n.EUpgradeTimestamp, newcfg.EUpgradeTimestamp)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ func (n *NetworkUpgrades) forkOrder() []fork {
|
||||
return []fork{
|
||||
{name: "subnetEVMTimestamp", timestamp: n.SubnetEVMTimestamp},
|
||||
{name: "durangoTimestamp", timestamp: n.DurangoTimestamp},
|
||||
{name: "eUpgradeTimestamp", timestamp: n.EUpgradeTimestamp},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,10 +68,13 @@ func (n *NetworkUpgrades) setDefaults(networkID uint32) {
|
||||
if n.DurangoTimestamp == nil || *n.DurangoTimestamp == 0 {
|
||||
n.DurangoTimestamp = defaults.DurangoTimestamp
|
||||
}
|
||||
if n.EUpgradeTimestamp == nil || *n.EUpgradeTimestamp == 0 {
|
||||
n.EUpgradeTimestamp = defaults.EUpgradeTimestamp
|
||||
}
|
||||
}
|
||||
|
||||
// VerifyNetworkUpgrades checks that the network upgrades are well formed.
|
||||
func (n *NetworkUpgrades) VerifyNetworkUpgrades(networkID uint32) error {
|
||||
// verifyNetworkUpgrades checks that the network upgrades are well formed.
|
||||
func (n *NetworkUpgrades) verifyNetworkUpgrades(networkID uint32) error {
|
||||
defaults := getDefaultNetworkUpgrades(networkID)
|
||||
if err := verifyWithDefault(n.SubnetEVMTimestamp, defaults.SubnetEVMTimestamp); err != nil {
|
||||
return fmt.Errorf("SubnetEVM fork block timestamp is invalid: %w", err)
|
||||
@@ -78,6 +82,9 @@ func (n *NetworkUpgrades) VerifyNetworkUpgrades(networkID uint32) error {
|
||||
if err := verifyWithDefault(n.DurangoTimestamp, defaults.DurangoTimestamp); err != nil {
|
||||
return fmt.Errorf("Durango fork block timestamp is invalid: %w", err)
|
||||
}
|
||||
if err := verifyWithDefault(n.EUpgradeTimestamp, defaults.EUpgradeTimestamp); err != nil {
|
||||
return fmt.Errorf("EUpgrade fork block timestamp is invalid: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -88,6 +95,9 @@ func (n *NetworkUpgrades) Override(o *NetworkUpgrades) {
|
||||
if o.DurangoTimestamp != nil {
|
||||
n.DurangoTimestamp = o.DurangoTimestamp
|
||||
}
|
||||
if o.EUpgradeTimestamp != nil {
|
||||
n.EUpgradeTimestamp = o.EUpgradeTimestamp
|
||||
}
|
||||
}
|
||||
|
||||
// IsSubnetEVM returns whether [time] represents a block
|
||||
@@ -102,10 +112,17 @@ func (n *NetworkUpgrades) IsDurango(time uint64) bool {
|
||||
return utils.IsTimestampForked(n.DurangoTimestamp, time)
|
||||
}
|
||||
|
||||
// IsEUpgrade returns whether [time] represents a block
|
||||
// with a timestamp after the EUpgrade upgrade time.
|
||||
func (n *NetworkUpgrades) IsEUpgrade(time uint64) bool {
|
||||
return utils.IsTimestampForked(n.EUpgradeTimestamp, time)
|
||||
}
|
||||
|
||||
func (n *NetworkUpgrades) Description() string {
|
||||
var banner string
|
||||
banner += fmt.Sprintf(" - SubnetEVM Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.10.0)\n", ptrToString(n.SubnetEVMTimestamp))
|
||||
banner += fmt.Sprintf(" - Durango Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.11.0)\n", ptrToString(n.DurangoTimestamp))
|
||||
banner += fmt.Sprintf(" - EUpgrade Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.12.0\n", ptrToString(n.EUpgradeTimestamp))
|
||||
return banner
|
||||
}
|
||||
|
||||
@@ -119,6 +136,7 @@ func (n *NetworkUpgrades) GetAvalancheRules(time uint64) AvalancheRules {
|
||||
return AvalancheRules{
|
||||
IsSubnetEVM: n.IsSubnetEVM(time),
|
||||
IsDurango: n.IsDurango(time),
|
||||
IsEUpgrade: n.IsEUpgrade(time),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +145,8 @@ func (n *NetworkUpgrades) GetAvalancheRules(time uint64) AvalancheRules {
|
||||
func getDefaultNetworkUpgrades(networkID uint32) NetworkUpgrades {
|
||||
return NetworkUpgrades{
|
||||
SubnetEVMTimestamp: utils.NewUint64(0),
|
||||
DurangoTimestamp: utils.NewUint64(getUpgradeTime(networkID, version.DurangoTimes)),
|
||||
DurangoTimestamp: utils.TimeToNewUint64(version.GetDurangoTime(networkID)),
|
||||
EUpgradeTimestamp: utils.TimeToNewUint64(version.GetEUpgradeTime(networkID)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +157,7 @@ func verifyWithDefault(configTimestamp *uint64, defaultTimestamp *uint64) error
|
||||
}
|
||||
|
||||
if *configTimestamp < *defaultTimestamp {
|
||||
return fmt.Errorf("provided timestamp (%d) must be greater than or equal to the default timestamp (%d)", *configTimestamp, defaultTimestamp)
|
||||
return fmt.Errorf("provided timestamp (%d) must be greater than or equal to the default timestamp (%d)", *configTimestamp, *defaultTimestamp)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -181,7 +181,8 @@ func TestVerifyNetworkUpgrades(t *testing.T) {
|
||||
name: "ValidNetworkUpgrades",
|
||||
upgrades: &NetworkUpgrades{
|
||||
SubnetEVMTimestamp: utils.NewUint64(0),
|
||||
DurangoTimestamp: utils.NewUint64(2),
|
||||
DurangoTimestamp: utils.NewUint64(1607144400),
|
||||
EUpgradeTimestamp: utils.NewUint64(1607144400),
|
||||
},
|
||||
networkID: 1111,
|
||||
expected: true,
|
||||
@@ -213,10 +214,30 @@ func TestVerifyNetworkUpgrades(t *testing.T) {
|
||||
networkID: constants.MainnetID,
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid EUpgrade nil",
|
||||
upgrades: &NetworkUpgrades{
|
||||
SubnetEVMTimestamp: utils.NewUint64(0),
|
||||
DurangoTimestamp: utils.NewUint64(2),
|
||||
EUpgradeTimestamp: nil,
|
||||
},
|
||||
networkID: 1,
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid EUpgrade before Durango",
|
||||
upgrades: &NetworkUpgrades{
|
||||
SubnetEVMTimestamp: utils.NewUint64(0),
|
||||
DurangoTimestamp: utils.NewUint64(2),
|
||||
EUpgradeTimestamp: utils.NewUint64(1),
|
||||
},
|
||||
networkID: 1,
|
||||
expected: false,
|
||||
},
|
||||
}
|
||||
for _, test := range testcases {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
err := test.upgrades.VerifyNetworkUpgrades(test.networkID)
|
||||
err := test.upgrades.verifyNetworkUpgrades(test.networkID)
|
||||
if test.expected {
|
||||
require.Nil(t, err)
|
||||
} else {
|
||||
|
||||
+12
-12
@@ -80,11 +80,11 @@ var (
|
||||
password = "CjasdjhiPeirbSenfeI13" // #nosec G101
|
||||
// Use chainId: 43111, so that it does not overlap with any Avalanche ChainIDs, which may have their
|
||||
// config overridden in vm.Initialize.
|
||||
genesisJSONPreSubnetEVM = `{"config":{"chainId":43111,"homesteadBlock":0,"eip150Block":0,"eip155Block":0,"eip158Block":0,"byzantiumBlock":0,"constantinopleBlock":0,"petersburgBlock":0,"istanbulBlock":0,"muirGlacierBlock":0},"nonce":"0x0","timestamp":"0x0","extraData":"0x00","gasLimit":"0x7A1200","difficulty":"0x0","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","coinbase":"0x0000000000000000000000000000000000000000","alloc":{"0x71562b71999873DB5b286dF957af199Ec94617F7": {"balance":"0x4192927743b88000"}, "0x703c4b2bD70c169f5717101CaeE543299Fc946C7": {"balance":"0x4192927743b88000"}},"number":"0x0","gasUsed":"0x0","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000"}`
|
||||
genesisJSONSubnetEVM = `{"config":{"chainId":43111,"homesteadBlock":0,"eip150Block":0,"eip155Block":0,"eip158Block":0,"byzantiumBlock":0,"constantinopleBlock":0,"petersburgBlock":0,"istanbulBlock":0,"muirGlacierBlock":0,"subnetEVMTimestamp":0},"nonce":"0x0","timestamp":"0x0","extraData":"0x00","gasLimit":"0x7A1200","difficulty":"0x0","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","coinbase":"0x0000000000000000000000000000000000000000","alloc":{"0x71562b71999873DB5b286dF957af199Ec94617F7": {"balance":"0x4192927743b88000"}, "0x703c4b2bD70c169f5717101CaeE543299Fc946C7": {"balance":"0x4192927743b88000"}},"number":"0x0","gasUsed":"0x0","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000"}`
|
||||
genesisJSONDurango = `{"config":{"chainId":43111,"homesteadBlock":0,"eip150Block":0,"eip155Block":0,"eip158Block":0,"byzantiumBlock":0,"constantinopleBlock":0,"petersburgBlock":0,"istanbulBlock":0,"muirGlacierBlock":0,"subnetEVMTimestamp":0,"durangoTimestamp":0},"nonce":"0x0","timestamp":"0x0","extraData":"0x00","gasLimit":"0x7A1200","difficulty":"0x0","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","coinbase":"0x0000000000000000000000000000000000000000","alloc":{"0x71562b71999873DB5b286dF957af199Ec94617F7": {"balance":"0x4192927743b88000"}, "0x703c4b2bD70c169f5717101CaeE543299Fc946C7": {"balance":"0x4192927743b88000"}},"number":"0x0","gasUsed":"0x0","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000"}`
|
||||
genesisJSONCancun = `{"config":{"chainId":43111,"homesteadBlock":0,"eip150Block":0,"eip155Block":0,"eip158Block":0,"byzantiumBlock":0,"constantinopleBlock":0,"petersburgBlock":0,"istanbulBlock":0,"muirGlacierBlock":0,"subnetEVMTimestamp":0,"durangoTimestamp":0,"cancunTime":0},"nonce":"0x0","timestamp":"0x0","extraData":"0x00","gasLimit":"0x7A1200","difficulty":"0x0","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","coinbase":"0x0000000000000000000000000000000000000000","alloc":{"0x71562b71999873DB5b286dF957af199Ec94617F7": {"balance":"0x4192927743b88000"}, "0x703c4b2bD70c169f5717101CaeE543299Fc946C7": {"balance":"0x4192927743b88000"}},"number":"0x0","gasUsed":"0x0","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000"}`
|
||||
genesisJSONLatest = genesisJSONDurango
|
||||
genesisJSONPreSubnetEVM = `{"config":{"chainId":43111,"homesteadBlock":0,"eip150Block":0,"eip155Block":0,"eip158Block":0,"byzantiumBlock":0,"constantinopleBlock":0,"petersburgBlock":0,"istanbulBlock":0,"muirGlacierBlock":0,"subnetEVMTimestamp":9999999999,"durangoTimestamp":9999999999,"eUpgradeTimestamp":9999999999},"nonce":"0x0","timestamp":"0x5FCB13D0","extraData":"0x00","gasLimit":"0x7A1200","difficulty":"0x0","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","coinbase":"0x0000000000000000000000000000000000000000","alloc":{"0x71562b71999873DB5b286dF957af199Ec94617F7": {"balance":"0x4192927743b88000"}, "0x703c4b2bD70c169f5717101CaeE543299Fc946C7": {"balance":"0x4192927743b88000"}},"number":"0x0","gasUsed":"0x0","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000"}`
|
||||
genesisJSONSubnetEVM = `{"config":{"chainId":43111,"homesteadBlock":0,"eip150Block":0,"eip155Block":0,"eip158Block":0,"byzantiumBlock":0,"constantinopleBlock":0,"petersburgBlock":0,"istanbulBlock":0,"muirGlacierBlock":0,"subnetEVMTimestamp":0,"durangoTimestamp":9999999999,"eUpgradeTimestamp":9999999999},"nonce":"0x0","timestamp":"0x5FCB13D0","extraData":"0x00","gasLimit":"0x7A1200","difficulty":"0x0","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","coinbase":"0x0000000000000000000000000000000000000000","alloc":{"0x71562b71999873DB5b286dF957af199Ec94617F7": {"balance":"0x4192927743b88000"}, "0x703c4b2bD70c169f5717101CaeE543299Fc946C7": {"balance":"0x4192927743b88000"}},"number":"0x0","gasUsed":"0x0","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000"}`
|
||||
genesisJSONDurango = `{"config":{"chainId":43111,"homesteadBlock":0,"eip150Block":0,"eip155Block":0,"eip158Block":0,"byzantiumBlock":0,"constantinopleBlock":0,"petersburgBlock":0,"istanbulBlock":0,"muirGlacierBlock":0,"subnetEVMTimestamp":0,"durangoTimestamp":0,"eUpgradeTimestamp":9999999999},"nonce":"0x0","timestamp":"0x5FCB13D0","extraData":"0x00","gasLimit":"0x7A1200","difficulty":"0x0","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","coinbase":"0x0000000000000000000000000000000000000000","alloc":{"0x71562b71999873DB5b286dF957af199Ec94617F7": {"balance":"0x4192927743b88000"}, "0x703c4b2bD70c169f5717101CaeE543299Fc946C7": {"balance":"0x4192927743b88000"}},"number":"0x0","gasUsed":"0x0","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000"}`
|
||||
genesisJSONEUpgrade = `{"config":{"chainId":43111,"homesteadBlock":0,"eip150Block":0,"eip155Block":0,"eip158Block":0,"byzantiumBlock":0,"constantinopleBlock":0,"petersburgBlock":0,"istanbulBlock":0,"muirGlacierBlock":0,"subnetEVMTimestamp":0,"durangoTimestamp":0,"eUpgradeTimestamp":0},"nonce":"0x0","timestamp":"0x5FCB13D0","extraData":"0x00","gasLimit":"0x7A1200","difficulty":"0x0","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","coinbase":"0x0000000000000000000000000000000000000000","alloc":{"0x71562b71999873DB5b286dF957af199Ec94617F7": {"balance":"0x4192927743b88000"}, "0x703c4b2bD70c169f5717101CaeE543299Fc946C7": {"balance":"0x4192927743b88000"}},"number":"0x0","gasUsed":"0x0","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000"}`
|
||||
genesisJSONLatest = genesisJSONEUpgrade
|
||||
|
||||
firstTxAmount = new(big.Int).Mul(big.NewInt(testMinGasPrice), big.NewInt(21000*100))
|
||||
genesisBalance = new(big.Int).Mul(big.NewInt(testMinGasPrice), big.NewInt(21000*1000))
|
||||
@@ -2417,7 +2417,7 @@ func TestTxAllowListDisablePrecompile(t *testing.T) {
|
||||
if err := genesis.UnmarshalJSON([]byte(genesisJSONSubnetEVM)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
enableAllowListTimestamp := time.Unix(0, 0) // enable at genesis
|
||||
enableAllowListTimestamp := params.DefaultGenesisTime // enable at default genesis time
|
||||
genesis.Config.GenesisPrecompiles = params.Precompiles{
|
||||
txallowlist.ConfigKey: txallowlist.NewConfig(utils.TimeToNewUint64(enableAllowListTimestamp), testEthAddrs[0:1], nil, nil),
|
||||
}
|
||||
@@ -3299,21 +3299,21 @@ func TestParentBeaconRootBlock(t *testing.T) {
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "non-empty parent beacon root in Cancun",
|
||||
genesisJSON: genesisJSONCancun,
|
||||
name: "non-empty parent beacon root in E-Upgrade (Cancun)",
|
||||
genesisJSON: genesisJSONEUpgrade,
|
||||
beaconRoot: &common.Hash{0x01},
|
||||
expectedError: true,
|
||||
errString: "expected empty hash",
|
||||
},
|
||||
{
|
||||
name: "empty parent beacon root in Cancun",
|
||||
genesisJSON: genesisJSONCancun,
|
||||
name: "empty parent beacon root in E-Upgrade (Cancun)",
|
||||
genesisJSON: genesisJSONEUpgrade,
|
||||
beaconRoot: &common.Hash{},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "nil parent beacon root in Cancun",
|
||||
genesisJSON: genesisJSONCancun,
|
||||
name: "nil parent beacon root in E-Upgrade (Cancun)",
|
||||
genesisJSON: genesisJSONEUpgrade,
|
||||
beaconRoot: nil,
|
||||
expectedError: true,
|
||||
errString: "header is missing parentBeaconRoot",
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
|
||||
"github.com/ava-labs/avalanchego/snow"
|
||||
commonEng "github.com/ava-labs/avalanchego/snow/engine/common"
|
||||
"github.com/ava-labs/avalanchego/version"
|
||||
"github.com/ava-labs/avalanchego/vms/components/chain"
|
||||
"github.com/ava-labs/subnet-evm/core"
|
||||
"github.com/ava-labs/subnet-evm/core/types"
|
||||
@@ -30,9 +31,13 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var (
|
||||
DefaultEUpgradeTime = uint64(version.GetEUpgradeTime(testNetworkID).Unix())
|
||||
)
|
||||
|
||||
func TestVMUpgradeBytesPrecompile(t *testing.T) {
|
||||
// Make a TxAllowListConfig upgrade at genesis and convert it to JSON to apply as upgradeBytes.
|
||||
enableAllowListTimestamp := time.Unix(0, 0) // enable at genesis
|
||||
enableAllowListTimestamp := params.DefaultGenesisTime // enable at default genesis time
|
||||
upgradeConfig := ¶ms.UpgradeConfig{
|
||||
PrecompileUpgrades: []params.PrecompileUpgrade{
|
||||
{
|
||||
@@ -47,6 +52,7 @@ func TestVMUpgradeBytesPrecompile(t *testing.T) {
|
||||
|
||||
// initialize the VM with these upgrade bytes
|
||||
issuer, vm, dbManager, appSender := GenesisVM(t, true, genesisJSONSubnetEVM, "", string(upgradeBytesJSON))
|
||||
vm.clock.Set(enableAllowListTimestamp)
|
||||
|
||||
// Submit a successful transaction
|
||||
tx0 := types.NewTransaction(uint64(0), testEthAddrs[0], big.NewInt(1), 21000, big.NewInt(testMinGasPrice), nil)
|
||||
@@ -75,7 +81,7 @@ func TestVMUpgradeBytesPrecompile(t *testing.T) {
|
||||
}
|
||||
|
||||
// prepare the new upgrade bytes to disable the TxAllowList
|
||||
disableAllowListTimestamp := enableAllowListTimestamp.Add(10 * time.Hour) // arbitrary choice
|
||||
disableAllowListTimestamp := vm.clock.Time().Add(10 * time.Hour) // arbitrary choice
|
||||
upgradeConfig.PrecompileUpgrades = append(
|
||||
upgradeConfig.PrecompileUpgrades,
|
||||
params.PrecompileUpgrade{
|
||||
@@ -171,7 +177,7 @@ func TestNetworkUpgradesOverriden(t *testing.T) {
|
||||
upgradeBytesJSON := `{
|
||||
"networkUpgradeOverrides": {
|
||||
"subnetEVMTimestamp": 2,
|
||||
"durangoTimestamp": 5
|
||||
"durangoTimestamp": 1607144402
|
||||
}
|
||||
}`
|
||||
|
||||
@@ -206,7 +212,8 @@ func TestNetworkUpgradesOverriden(t *testing.T) {
|
||||
require.False(t, vm.chainConfig.IsSubnetEVM(0))
|
||||
require.True(t, vm.chainConfig.IsSubnetEVM(2))
|
||||
require.False(t, vm.chainConfig.IsDurango(0))
|
||||
require.True(t, vm.chainConfig.IsDurango(5))
|
||||
require.False(t, vm.chainConfig.IsDurango(uint64(version.DefaultUpgradeTime.Unix())))
|
||||
require.True(t, vm.chainConfig.IsDurango(1607144402))
|
||||
}
|
||||
|
||||
func mustMarshal(t *testing.T, v interface{}) string {
|
||||
@@ -249,7 +256,7 @@ func TestVMStateUpgrade(t *testing.T) {
|
||||
Code: upgradedCode,
|
||||
}
|
||||
|
||||
upgradeTimestamp := time.Unix(10, 0) // arbitrary timestamp to perform the network upgrade
|
||||
upgradeTimestamp := params.DefaultGenesisTime.Add(10 * time.Hour)
|
||||
upgradeBytesJSON := fmt.Sprintf(
|
||||
`{
|
||||
"stateUpgrades": [
|
||||
@@ -318,3 +325,63 @@ func TestVMStateUpgrade(t *testing.T) {
|
||||
require.Equal(t, state.GetNonce(newAccount), uint64(1)) // Nonce should be set to 1 when code is set if nonce was 0
|
||||
require.Equal(t, state.GetState(newAccount, storageKey), newAccountUpgrade.Storage[storageKey])
|
||||
}
|
||||
|
||||
func TestVMEupgradeActivatesCancun(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
genesisJSON string
|
||||
upgradeJSON string
|
||||
check func(*testing.T, *VM) // function to check the VM state
|
||||
}{
|
||||
{
|
||||
name: "EUpgrade activates Cancun",
|
||||
genesisJSON: genesisJSONEUpgrade,
|
||||
check: func(t *testing.T, vm *VM) {
|
||||
require.True(t, vm.chainConfig.IsCancun(common.Big0, DefaultEUpgradeTime))
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Later EUpgrade activates Cancun",
|
||||
genesisJSON: genesisJSONDurango,
|
||||
upgradeJSON: func() string {
|
||||
upgrade := ¶ms.UpgradeConfig{
|
||||
NetworkUpgradeOverrides: ¶ms.NetworkUpgrades{
|
||||
EUpgradeTimestamp: utils.NewUint64(DefaultEUpgradeTime + 2),
|
||||
},
|
||||
}
|
||||
b, err := json.Marshal(upgrade)
|
||||
require.NoError(t, err)
|
||||
return string(b)
|
||||
}(),
|
||||
check: func(t *testing.T, vm *VM) {
|
||||
require.False(t, vm.chainConfig.IsCancun(common.Big0, DefaultEUpgradeTime))
|
||||
require.True(t, vm.chainConfig.IsCancun(common.Big0, DefaultEUpgradeTime+2))
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Changed EUpgrade changes Cancun",
|
||||
genesisJSON: genesisJSONEUpgrade,
|
||||
upgradeJSON: func() string {
|
||||
upgrade := ¶ms.UpgradeConfig{
|
||||
NetworkUpgradeOverrides: ¶ms.NetworkUpgrades{
|
||||
EUpgradeTimestamp: utils.NewUint64(DefaultEUpgradeTime + 2),
|
||||
},
|
||||
}
|
||||
b, err := json.Marshal(upgrade)
|
||||
require.NoError(t, err)
|
||||
return string(b)
|
||||
}(),
|
||||
check: func(t *testing.T, vm *VM) {
|
||||
require.False(t, vm.chainConfig.IsCancun(common.Big0, DefaultEUpgradeTime))
|
||||
require.True(t, vm.chainConfig.IsCancun(common.Big0, DefaultEUpgradeTime+2))
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
_, vm, _, _ := GenesisVM(t, true, test.genesisJSON, "", test.upgradeJSON)
|
||||
defer func() { require.NoError(t, vm.Shutdown(context.Background())) }()
|
||||
test.check(t, vm)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func TestSendWarpMessage(t *testing.T) {
|
||||
genesis := &core.Genesis{}
|
||||
require.NoError(genesis.UnmarshalJSON([]byte(genesisJSONDurango)))
|
||||
genesis.Config.GenesisPrecompiles = params.Precompiles{
|
||||
warp.ConfigKey: warp.NewDefaultConfig(utils.NewUint64(0)),
|
||||
warp.ConfigKey: warp.NewDefaultConfig(utils.TimeToNewUint64(params.DefaultGenesisTime)),
|
||||
}
|
||||
genesisJSON, err := genesis.MarshalJSON()
|
||||
require.NoError(err)
|
||||
@@ -249,7 +249,7 @@ func testWarpVMTransaction(t *testing.T, unsignedMessage *avalancheWarp.Unsigned
|
||||
genesis := &core.Genesis{}
|
||||
require.NoError(genesis.UnmarshalJSON([]byte(genesisJSONDurango)))
|
||||
genesis.Config.GenesisPrecompiles = params.Precompiles{
|
||||
warp.ConfigKey: warp.NewDefaultConfig(utils.NewUint64(0)),
|
||||
warp.ConfigKey: warp.NewDefaultConfig(utils.TimeToNewUint64(params.DefaultGenesisTime)),
|
||||
}
|
||||
genesisJSON, err := genesis.MarshalJSON()
|
||||
require.NoError(err)
|
||||
@@ -406,7 +406,7 @@ func TestReceiveWarpMessage(t *testing.T) {
|
||||
genesis := &core.Genesis{}
|
||||
require.NoError(genesis.UnmarshalJSON([]byte(genesisJSONDurango)))
|
||||
genesis.Config.GenesisPrecompiles = params.Precompiles{
|
||||
warp.ConfigKey: warp.NewDefaultConfig(utils.NewUint64(0)),
|
||||
warp.ConfigKey: warp.NewDefaultConfig(utils.TimeToNewUint64(params.DefaultGenesisTime)),
|
||||
}
|
||||
genesisJSON, err := genesis.MarshalJSON()
|
||||
require.NoError(err)
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
{
|
||||
"config": {
|
||||
"chainId": 99999,
|
||||
"homesteadBlock": 0,
|
||||
"eip150Block": 0,
|
||||
"eip155Block": 0,
|
||||
"eip158Block": 0,
|
||||
"byzantiumBlock": 0,
|
||||
"constantinopleBlock": 0,
|
||||
"petersburgBlock": 0,
|
||||
"istanbulBlock": 0,
|
||||
"muirGlacierBlock": 0,
|
||||
"subnetEVMTimestamp": 0,
|
||||
"feeConfig": {
|
||||
"gasLimit": 200000000,
|
||||
"minBaseFee": 1000000000,
|
||||
@@ -31,7 +21,7 @@
|
||||
}
|
||||
},
|
||||
"nonce": "0x0",
|
||||
"timestamp": "0x0",
|
||||
"timestamp": "0x5FCB13D0",
|
||||
"extraData": "0x00",
|
||||
"gasLimit": "0xBEBC200",
|
||||
"difficulty": "0x0",
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
}
|
||||
},
|
||||
"nonce": "0x0",
|
||||
"timestamp": "0x0",
|
||||
"timestamp": "0x5FCB13D0",
|
||||
"extraData": "0x00",
|
||||
"gasLimit": "0x1312D00",
|
||||
"difficulty": "0x0",
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
}
|
||||
},
|
||||
"nonce": "0x0",
|
||||
"timestamp": "0x0",
|
||||
"timestamp": "0x5FCB13D0",
|
||||
"extraData": "0x00",
|
||||
"gasLimit": "0x1312D00",
|
||||
"difficulty": "0x0",
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
}
|
||||
},
|
||||
"nonce": "0x0",
|
||||
"timestamp": "0x0",
|
||||
"timestamp": "0x5FCB13D0",
|
||||
"extraData": "0x00",
|
||||
"gasLimit": "0x1312D00",
|
||||
"difficulty": "0x0",
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
}
|
||||
},
|
||||
"nonce": "0x0",
|
||||
"timestamp": "0x0",
|
||||
"timestamp": "0x5FCB13D0",
|
||||
"extraData": "0x00",
|
||||
"gasLimit": "0x1312D00",
|
||||
"difficulty": "0x0",
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
}
|
||||
},
|
||||
"nonce": "0x0",
|
||||
"timestamp": "0x0",
|
||||
"timestamp": "0x5FCB13D0",
|
||||
"extraData": "0x00",
|
||||
"gasLimit": "0x1312D00",
|
||||
"difficulty": "0x0",
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
"blockGasCostStep": 500000
|
||||
},
|
||||
"warpConfig": {
|
||||
"blockTimestamp": 0
|
||||
"blockTimestamp": 1607144400
|
||||
}
|
||||
},
|
||||
"alloc": {
|
||||
@@ -33,7 +33,7 @@
|
||||
}
|
||||
},
|
||||
"nonce": "0x0",
|
||||
"timestamp": "0x0",
|
||||
"timestamp": "0x5FCB13D0",
|
||||
"extraData": "0x00",
|
||||
"gasLimit": "0x1312D00",
|
||||
"difficulty": "0x0",
|
||||
|
||||
Reference in New Issue
Block a user