mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
Merge pull request #63 from ava-labs/ensure-consistent-gasLimit
Ensure gas limit in genesis is consistent
This commit is contained in:
+1
-1
@@ -221,7 +221,7 @@ func TestChain(t *testing.T) {
|
||||
Nonce: 0,
|
||||
Number: 0,
|
||||
ExtraData: hexutil.MustDecode("0x00"),
|
||||
GasLimit: 100000000,
|
||||
GasLimit: chainConfig.FeeConfig.GasLimit.Uint64(),
|
||||
Difficulty: big.NewInt(0),
|
||||
Alloc: core.GenesisAlloc{genKey.Address: {Balance: genBalance}},
|
||||
}
|
||||
|
||||
+2
-1
@@ -63,6 +63,7 @@ func NewDefaultChain(t *testing.T) (*ETHChain, chan core.NewTxPoolHeadEvent, <-c
|
||||
ConstantinopleBlock: big.NewInt(0),
|
||||
PetersburgBlock: big.NewInt(0),
|
||||
IstanbulBlock: big.NewInt(0),
|
||||
FeeConfig: params.DefaultFeeConfig,
|
||||
}
|
||||
|
||||
config.Genesis = &core.Genesis{
|
||||
@@ -70,7 +71,7 @@ func NewDefaultChain(t *testing.T) (*ETHChain, chan core.NewTxPoolHeadEvent, <-c
|
||||
Nonce: 0,
|
||||
Number: 0,
|
||||
ExtraData: hexutil.MustDecode("0x00"),
|
||||
GasLimit: 100000000,
|
||||
GasLimit: chainConfig.FeeConfig.GasLimit.Uint64(),
|
||||
Difficulty: big.NewInt(0),
|
||||
Alloc: core.GenesisAlloc{fundedKey.Address: core.GenesisAccount{Balance: initialBalance}},
|
||||
}
|
||||
|
||||
@@ -184,6 +184,11 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig
|
||||
if genesis.Config == nil {
|
||||
return nil, errGenesisNoConfig
|
||||
}
|
||||
// Make sure genesis gas limit is consistent
|
||||
gasLimitConfig := genesis.Config.FeeConfig.GasLimit.Uint64()
|
||||
if gasLimitConfig != genesis.GasLimit {
|
||||
return nil, fmt.Errorf("gas limit in fee config (%d) does not match gas limit in header (%d)", gasLimitConfig, genesis.GasLimit)
|
||||
}
|
||||
// Just commit the new block if there is no stored genesis block.
|
||||
stored := rawdb.ReadCanonicalHash(db, 0)
|
||||
if (stored == common.Hash{}) {
|
||||
|
||||
@@ -62,12 +62,13 @@ func TestSetupGenesis(t *testing.T) {
|
||||
preSubnetConfig := *params.TestPreSubnetEVMConfig
|
||||
preSubnetConfig.SubnetEVMTimestamp = big.NewInt(100)
|
||||
var (
|
||||
customghash = common.HexToHash("0x89c99d90b79719238d2645c7642f2c9295246e80775b38cfd162b696817fbd50")
|
||||
customghash = common.HexToHash("0x4a12fe7bf8d40d152d7e9de22337b115186a4662aa3a97217b36146202bbfc66")
|
||||
customg = Genesis{
|
||||
Config: &preSubnetConfig,
|
||||
Alloc: GenesisAlloc{
|
||||
{1}: {Balance: big.NewInt(1), Storage: map[common.Hash]common.Hash{{1}: {1}}},
|
||||
},
|
||||
GasLimit: preSubnetConfig.FeeConfig.GasLimit.Uint64(),
|
||||
}
|
||||
oldcustomg = customg
|
||||
)
|
||||
@@ -204,6 +205,7 @@ func TestStatefulPrecompilesConfigure(t *testing.T) {
|
||||
Alloc: GenesisAlloc{
|
||||
{1}: {Balance: big.NewInt(1), Storage: map[common.Hash]common.Hash{{1}: {1}}},
|
||||
},
|
||||
GasLimit: config.FeeConfig.GasLimit.Uint64(),
|
||||
}
|
||||
|
||||
db := rawdb.NewMemoryDatabase()
|
||||
|
||||
@@ -33,6 +33,7 @@ func TestBuildGenesis(t *testing.T) {
|
||||
genesis.Config.FeeConfig = params.DefaultFeeConfig
|
||||
testGasLimit := big.NewInt(999999)
|
||||
genesis.Config.FeeConfig.GasLimit = testGasLimit
|
||||
genesis.GasLimit = testGasLimit.Uint64()
|
||||
|
||||
args := &BuildGenesisArgs{GenesisData: genesis}
|
||||
reply := &BuildGenesisReply{}
|
||||
@@ -70,6 +71,7 @@ func TestDecodeGenesis(t *testing.T) {
|
||||
genesis.Config.FeeConfig = params.DefaultFeeConfig
|
||||
testGasLimit := big.NewInt(999999)
|
||||
genesis.Config.FeeConfig.GasLimit = testGasLimit
|
||||
genesis.GasLimit = testGasLimit.Uint64()
|
||||
|
||||
args := &BuildGenesisArgs{GenesisData: genesis}
|
||||
reply := &BuildGenesisReply{}
|
||||
|
||||
@@ -30,7 +30,7 @@ func fundAddressByGenesis(addrs []common.Address) (string, error) {
|
||||
balance := big.NewInt(0xffffffffffffff)
|
||||
genesis := &core.Genesis{
|
||||
Difficulty: common.Big0,
|
||||
GasLimit: uint64(5000000),
|
||||
GasLimit: uint64(999999),
|
||||
}
|
||||
funds := make(map[common.Address]core.GenesisAccount)
|
||||
for _, addr := range addrs {
|
||||
|
||||
@@ -60,8 +60,8 @@ 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.
|
||||
genesisJSONMuirGlacier = "{\"config\":{\"chainId\":43111,\"homesteadBlock\":0,\"eip150Block\":0,\"eip150Hash\":\"0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0\",\"eip155Block\":0,\"eip158Block\":0,\"byzantiumBlock\":0,\"constantinopleBlock\":0,\"petersburgBlock\":0,\"istanbulBlock\":0,\"muirGlacierBlock\":0},\"nonce\":\"0x0\",\"timestamp\":\"0x0\",\"extraData\":\"0x00\",\"gasLimit\":\"0x5f5e100\",\"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,\"eip150Hash\":\"0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0\",\"eip155Block\":0,\"eip158Block\":0,\"byzantiumBlock\":0,\"constantinopleBlock\":0,\"petersburgBlock\":0,\"istanbulBlock\":0,\"muirGlacierBlock\":0,\"subnetEVMTimestamp\":0},\"nonce\":\"0x0\",\"timestamp\":\"0x0\",\"extraData\":\"0x00\",\"gasLimit\":\"0x5f5e100\",\"difficulty\":\"0x0\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"coinbase\":\"0x0000000000000000000000000000000000000000\",\"alloc\":{\"0x71562b71999873DB5b286dF957af199Ec94617F7\": {\"balance\":\"0x4192927743b88000\"}, \"0x703c4b2bD70c169f5717101CaeE543299Fc946C7\": {\"balance\":\"0x4192927743b88000\"}},\"number\":\"0x0\",\"gasUsed\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\"}"
|
||||
genesisJSONMuirGlacier = "{\"config\":{\"chainId\":43111,\"homesteadBlock\":0,\"eip150Block\":0,\"eip150Hash\":\"0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0\",\"eip155Block\":0,\"eip158Block\":0,\"byzantiumBlock\":0,\"constantinopleBlock\":0,\"petersburgBlock\":0,\"istanbulBlock\":0,\"muirGlacierBlock\":0},\"nonce\":\"0x0\",\"timestamp\":\"0x0\",\"extraData\":\"0x00\",\"gasLimit\":\"0xF423F\",\"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,\"eip150Hash\":\"0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0\",\"eip155Block\":0,\"eip158Block\":0,\"byzantiumBlock\":0,\"constantinopleBlock\":0,\"petersburgBlock\":0,\"istanbulBlock\":0,\"muirGlacierBlock\":0,\"subnetEVMTimestamp\":0},\"nonce\":\"0x0\",\"timestamp\":\"0x0\",\"extraData\":\"0x00\",\"gasLimit\":\"0xF423F\",\"difficulty\":\"0x0\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"coinbase\":\"0x0000000000000000000000000000000000000000\",\"alloc\":{\"0x71562b71999873DB5b286dF957af199Ec94617F7\": {\"balance\":\"0x4192927743b88000\"}, \"0x703c4b2bD70c169f5717101CaeE543299Fc946C7\": {\"balance\":\"0x4192927743b88000\"}},\"number\":\"0x0\",\"gasUsed\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\"}"
|
||||
firstTxAmount *big.Int
|
||||
genesisBalance *big.Int
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user