Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 1 addition & 53 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
3 changes: 2 additions & 1 deletion core/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
3 changes: 2 additions & 1 deletion core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions internal/ethapi/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"blobGasPrice": "0x1",
"blobGasUsed": "0x20000",
"blockHash": "0x77d5e4ffb415ca53742a37e4bf7bb1522d99dcce1c90e9957eb6d267a0c7e5a1",
"blockHash": "0x264b5f62e2900dd39a6c68af3ba656cffa3fe209614ca857af1f5702c6e2ba7e",
"blockNumber": "0x6",
"contractAddress": null,
"cumulativeGasUsed": "0x5208",
Expand All @@ -17,4 +17,4 @@
"transactionIndex": "0x0",
"type": "0x3"
}
]
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"blockHash": "0xa4eb72463332ae8ad98317466a6cc3c61c5ca4d884dd488c44edec166ff1b495",
"blockHash": "0x0524420ca4d3974c72883de6ccdeca2e8be7eafeac88ff03d144ed16fe78063a",
"blockNumber": "0x2",
"contractAddress": "0xae9bea628c4ce503dcfd7e305cab4e29e7476592",
"cumulativeGasUsed": "0xcf50",
Expand All @@ -15,4 +15,4 @@
"transactionIndex": "0x0",
"type": "0x0"
}
]
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"blockHash": "0x2dcd37090523d8d1ec308edec7d25eced1e26b96c4784f5f362ac58f9b33b2a1",
"blockHash": "0x0b7437b9229f72a563918ee8c73e9a8f5e294f9d0e17db6bf8408cdf6fbc84b7",
"blockNumber": "0x4",
"contractAddress": null,
"cumulativeGasUsed": "0x538d",
Expand All @@ -15,4 +15,4 @@
"transactionIndex": "0x0",
"type": "0x2"
}
]
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"blockHash": "0xbeee747a45ccfe51c6da7ac72f585e813a74669528a59ff590d9ce7433938c9d",
"blockHash": "0x587918ec6a2187a54418dc5334d02a53b61c39578d095f4845be8d4f25dea5b5",
"blockNumber": "0x3",
"contractAddress": null,
"cumulativeGasUsed": "0x5e28",
Expand All @@ -19,7 +19,7 @@
"blockNumber": "0x3",
"transactionHash": "0x7366a7738f47e32f5b6d292ca064b6b66f295d3931533a3745975be1191fccdf",
"transactionIndex": "0x0",
"blockHash": "0xbeee747a45ccfe51c6da7ac72f585e813a74669528a59ff590d9ce7433938c9d",
"blockHash": "0x587918ec6a2187a54418dc5334d02a53b61c39578d095f4845be8d4f25dea5b5",
"logIndex": "0x0",
"removed": false
}
Expand All @@ -31,4 +31,4 @@
"transactionIndex": "0x0",
"type": "0x0"
}
]
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"blockHash": "0xe387aa64524bf1712ce0640d1fbdab0992005cfa0d8cd124c526c66a87786359",
"blockHash": "0x2918b59e4b455614c1b83c0281e2b8462af47ca9726fff31789cb168793015d7",
"blockNumber": "0x1",
"contractAddress": null,
"cumulativeGasUsed": "0x5208",
Expand All @@ -15,4 +15,4 @@
"transactionIndex": "0x0",
"type": "0x0"
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"blobGasPrice": "0x1",
"blobGasUsed": "0x20000",
"blockHash": "0x77d5e4ffb415ca53742a37e4bf7bb1522d99dcce1c90e9957eb6d267a0c7e5a1",
"blockHash": "0x264b5f62e2900dd39a6c68af3ba656cffa3fe209614ca857af1f5702c6e2ba7e",
"blockNumber": "0x6",
"contractAddress": null,
"cumulativeGasUsed": "0x5208",
Expand All @@ -17,4 +17,4 @@
"transactionIndex": "0x0",
"type": "0x3"
}
]
]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"blobGasPrice": "0x1",
"blobGasUsed": "0x20000",
"blockHash": "0x77d5e4ffb415ca53742a37e4bf7bb1522d99dcce1c90e9957eb6d267a0c7e5a1",
"blockHash": "0x264b5f62e2900dd39a6c68af3ba656cffa3fe209614ca857af1f5702c6e2ba7e",
"blockNumber": "0x6",
"contractAddress": null,
"cumulativeGasUsed": "0x5208",
Expand All @@ -15,4 +15,4 @@
"transactionHash": "0x7e71344129674f4bbfdaa86313d005a96581993d93ae3a30d81b13fa25579eb2",
"transactionIndex": "0x0",
"type": "0x3"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"blockHash": "0xa4eb72463332ae8ad98317466a6cc3c61c5ca4d884dd488c44edec166ff1b495",
"blockHash": "0x0524420ca4d3974c72883de6ccdeca2e8be7eafeac88ff03d144ed16fe78063a",
"blockNumber": "0x2",
"contractAddress": "0xae9bea628c4ce503dcfd7e305cab4e29e7476592",
"cumulativeGasUsed": "0xcf50",
Expand All @@ -13,4 +13,4 @@
"transactionHash": "0x22aa617165f83a9f8c191c2b7724ae43eeb1249bee06c98c03c7624c21d27dc8",
"transactionIndex": "0x0",
"type": "0x0"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"blockHash": "0x9acfc909e24be0eed69e55e826935be38c9546eea779e0105f465eb6d8d493ad",
"blockHash": "0x2bf952c71ce24c68f887c12ecba6f1a36f97f528259fe0574890969e1113187a",
"blockNumber": "0x5",
"contractAddress": "0xfdaa97661a584d977b4d3abb5370766ff5b86a18",
"cumulativeGasUsed": "0xe01c",
Expand All @@ -13,4 +13,4 @@
"transactionHash": "0x8afe030574f663fe5096371d6f58a6287bfb3e0c73a5050220f5775a08e7abc9",
"transactionIndex": "0x0",
"type": "0x1"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"blockHash": "0x2dcd37090523d8d1ec308edec7d25eced1e26b96c4784f5f362ac58f9b33b2a1",
"blockHash": "0x0b7437b9229f72a563918ee8c73e9a8f5e294f9d0e17db6bf8408cdf6fbc84b7",
"blockNumber": "0x4",
"contractAddress": null,
"cumulativeGasUsed": "0x538d",
Expand All @@ -13,4 +13,4 @@
"transactionHash": "0x4e1e9194ca6f9d4e1736e9e441f66104f273548ed6d91b236a5f9c2ea10fa06d",
"transactionIndex": "0x0",
"type": "0x2"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"blockHash": "0xe387aa64524bf1712ce0640d1fbdab0992005cfa0d8cd124c526c66a87786359",
"blockHash": "0x2918b59e4b455614c1b83c0281e2b8462af47ca9726fff31789cb168793015d7",
"blockNumber": "0x1",
"contractAddress": null,
"cumulativeGasUsed": "0x5208",
Expand All @@ -13,4 +13,4 @@
"transactionHash": "0xdf92bc7c4c0341ecbdcd2a3ca7011fe9e21df4b8553bf0c8caabe6cb4a1aee26",
"transactionIndex": "0x0",
"type": "0x0"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"blockHash": "0xbeee747a45ccfe51c6da7ac72f585e813a74669528a59ff590d9ce7433938c9d",
"blockHash": "0x587918ec6a2187a54418dc5334d02a53b61c39578d095f4845be8d4f25dea5b5",
"blockNumber": "0x3",
"contractAddress": null,
"cumulativeGasUsed": "0x5e28",
Expand All @@ -18,7 +18,7 @@
"blockNumber": "0x3",
"transactionHash": "0x7366a7738f47e32f5b6d292ca064b6b66f295d3931533a3745975be1191fccdf",
"transactionIndex": "0x0",
"blockHash": "0xbeee747a45ccfe51c6da7ac72f585e813a74669528a59ff590d9ce7433938c9d",
"blockHash": "0x587918ec6a2187a54418dc5334d02a53b61c39578d095f4845be8d4f25dea5b5",
"logIndex": "0x0",
"removed": false
}
Expand All @@ -29,4 +29,4 @@
"transactionHash": "0x7366a7738f47e32f5b6d292ca064b6b66f295d3931533a3745975be1191fccdf",
"transactionIndex": "0x0",
"type": "0x0"
}
}
43 changes: 32 additions & 11 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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{},
}
Expand Down Expand Up @@ -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)
}

Expand All @@ -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
Expand Down Expand Up @@ -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
}
}
Expand Down
Loading