chg : shanghaiTime to shanghaiBlock

This commit is contained in:
Shivam Sharma 2023-08-18 17:05:13 +05:30
parent f5c4c2e9ac
commit 56ca065961
24 changed files with 2115 additions and 2108 deletions

View file

@ -157,7 +157,7 @@ func Transaction(ctx *cli.Context) error {
} }
// Check intrinsic gas // Check intrinsic gas
if gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, if gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil,
chainConfig.IsHomestead(new(big.Int)), chainConfig.IsIstanbul(new(big.Int)), chainConfig.IsShanghai(0)); err != nil { chainConfig.IsHomestead(new(big.Int)), chainConfig.IsIstanbul(new(big.Int)), chainConfig.IsShanghai(new(big.Int))); err != nil {
r.Error = err r.Error = err
results = append(results, r) results = append(results, r)
@ -192,7 +192,7 @@ func Transaction(ctx *cli.Context) error {
} }
// TODO marcello double check // TODO marcello double check
// Check whether the init code size has been exceeded. // Check whether the init code size has been exceeded.
if chainConfig.IsShanghai(0) && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize { if chainConfig.IsShanghai(new(big.Int)) && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize {
r.Error = errors.New("max initcode size exceeded") r.Error = errors.New("max initcode size exceeded")
} }

View file

@ -286,7 +286,7 @@ func Transition(ctx *cli.Context) error {
} }
} }
// TODO marcello double check // TODO marcello double check
if chainConfig.IsShanghai(prestate.Env.Number) && prestate.Env.Withdrawals == nil { if chainConfig.IsShanghai(big.NewInt(int64(prestate.Env.Number))) && prestate.Env.Withdrawals == nil {
return NewError(ErrorConfig, errors.New("Shanghai config but missing 'withdrawals' in env section")) return NewError(ErrorConfig, errors.New("Shanghai config but missing 'withdrawals' in env section"))
} }

View file

@ -18,6 +18,7 @@ package main
import ( import (
"fmt" "fmt"
"math/big"
"os" "os"
"time" "time"
@ -149,8 +150,8 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
stack, cfg := makeConfigNode(ctx) stack, cfg := makeConfigNode(ctx)
// TODO marcello double check // TODO marcello double check
if ctx.IsSet(utils.OverrideShanghai.Name) { if ctx.IsSet(utils.OverrideShanghai.Name) {
v := ctx.Uint64(utils.OverrideShanghai.Name) v := ctx.Int64(utils.OverrideShanghai.Name)
cfg.Eth.OverrideShanghai = &v cfg.Eth.OverrideShanghai = new(big.Int).SetInt64(v)
} }
backend, eth := utils.RegisterEthService(stack, &cfg.Eth) backend, eth := utils.RegisterEthService(stack, &cfg.Eth)

View file

@ -284,7 +284,7 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa
} }
// Verify existence / non-existence of withdrawalsHash. // Verify existence / non-existence of withdrawalsHash.
// TODO marcello double check // TODO marcello double check
shanghai := chain.Config().IsShanghai(header.Time) shanghai := chain.Config().IsShanghai(header.Number)
if shanghai && header.WithdrawalsHash == nil { if shanghai && header.WithdrawalsHash == nil {
return errors.New("missing withdrawalsHash") return errors.New("missing withdrawalsHash")
} }
@ -293,7 +293,7 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa
return fmt.Errorf("invalid withdrawalsHash: have %x, expected nil", header.WithdrawalsHash) return fmt.Errorf("invalid withdrawalsHash: have %x, expected nil", header.WithdrawalsHash)
} }
// Verify the existence / non-existence of excessDataGas // Verify the existence / non-existence of excessDataGas
cancun := chain.Config().IsCancun(header.Time) cancun := chain.Config().IsCancun(header.Number)
if cancun && header.ExcessDataGas == nil { if cancun && header.ExcessDataGas == nil {
return errors.New("missing excessDataGas") return errors.New("missing excessDataGas")
} }
@ -392,7 +392,7 @@ func (beacon *Beacon) FinalizeAndAssemble(ctx context.Context, chain consensus.C
return beacon.ethone.FinalizeAndAssemble(ctx, chain, header, state, txs, uncles, receipts, nil) return beacon.ethone.FinalizeAndAssemble(ctx, chain, header, state, txs, uncles, receipts, nil)
} }
// TODO marcello double check // TODO marcello double check
shanghai := chain.Config().IsShanghai(header.Time) shanghai := chain.Config().IsShanghai(header.Number)
if shanghai { if shanghai {
// All blocks after Shanghai must include a withdrawals root. // All blocks after Shanghai must include a withdrawals root.
if withdrawals == nil { if withdrawals == nil {

View file

@ -309,11 +309,11 @@ func (c *Clique) verifyHeader(chain consensus.ChainHeaderReader, header *types.H
return fmt.Errorf("invalid gasLimit: have %v, max %v", header.GasLimit, params.MaxGasLimit) return fmt.Errorf("invalid gasLimit: have %v, max %v", header.GasLimit, params.MaxGasLimit)
} }
// TODO marcello double check // TODO marcello double check
if chain.Config().IsShanghai(header.Time) { if chain.Config().IsShanghai(header.Number) {
return fmt.Errorf("clique does not support shanghai fork") return fmt.Errorf("clique does not support shanghai fork")
} }
if chain.Config().IsCancun(header.Time) { if chain.Config().IsCancun(header.Number) {
return fmt.Errorf("clique does not support cancun fork") return fmt.Errorf("clique does not support cancun fork")
} }
// All basic checks passed, verify cascading fields // All basic checks passed, verify cascading fields

View file

@ -334,11 +334,11 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainHeaderReader, header, pa
return consensus.ErrInvalidNumber return consensus.ErrInvalidNumber
} }
// TODO marcello double check // TODO marcello double check
if chain.Config().IsShanghai(header.Time) { if chain.Config().IsShanghai(header.Number) {
return fmt.Errorf("ethash does not support shanghai fork") return fmt.Errorf("ethash does not support shanghai fork")
} }
if chain.Config().IsCancun(header.Time) { if chain.Config().IsCancun(header.Number) {
return fmt.Errorf("ethash does not support cancun fork") return fmt.Errorf("ethash does not support cancun fork")
} }
// Verify the engine specific seal securing the block // Verify the engine specific seal securing the block

View file

@ -4680,7 +4680,7 @@ func TestEIP3651(t *testing.T) {
gspec.Config.LondonBlock = common.Big0 gspec.Config.LondonBlock = common.Big0
gspec.Config.TerminalTotalDifficulty = common.Big0 gspec.Config.TerminalTotalDifficulty = common.Big0
gspec.Config.TerminalTotalDifficultyPassed = true gspec.Config.TerminalTotalDifficultyPassed = true
gspec.Config.ShanghaiTime = u64(0) gspec.Config.ShanghaiBlock = common.Big0
signer := types.LatestSigner(gspec.Config) signer := types.LatestSigner(gspec.Config)
_, blocks, _ := GenerateChainWithGenesis(gspec, engine, 1, func(i int, b *BlockGen) { _, blocks, _ := GenerateChainWithGenesis(gspec, engine, 1, func(i int, b *BlockGen) {

View file

@ -56,7 +56,7 @@ func TestGenerateWithdrawalChain(t *testing.T) {
config.TerminalTotalDifficultyPassed = true config.TerminalTotalDifficultyPassed = true
config.TerminalTotalDifficulty = common.Big0 config.TerminalTotalDifficulty = common.Big0
config.ShanghaiTime = u64(0) config.ShanghaiBlock = common.Big0
// init 0xaa with some storage elements // init 0xaa with some storage elements
storage := make(map[common.Hash]common.Hash) storage := make(map[common.Hash]common.Hash)

View file

@ -119,7 +119,7 @@ func TestCreation(t *testing.T) {
func TestValidation(t *testing.T) { func TestValidation(t *testing.T) {
// Config that has not timestamp enabled // Config that has not timestamp enabled
legacyConfig := *params.MainnetChainConfig legacyConfig := *params.MainnetChainConfig
legacyConfig.ShanghaiTime = nil legacyConfig.ShanghaiBlock = nil
tests := []struct { tests := []struct {
config *params.ChainConfig config *params.ChainConfig

View file

@ -298,7 +298,7 @@ func (e *GenesisMismatchError) Error() string {
// ChainOverrides contains the changes to chain config. // ChainOverrides contains the changes to chain config.
type ChainOverrides struct { type ChainOverrides struct {
OverrideShanghai *uint64 OverrideShanghai *big.Int
} }
// SetupGenesisBlock writes or updates the genesis block in db. // SetupGenesisBlock writes or updates the genesis block in db.
@ -328,7 +328,7 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *trie.Database, gen
if config != nil { if config != nil {
// TODO marcello double check // TODO marcello double check
if overrides != nil && overrides.OverrideShanghai != nil { if overrides != nil && overrides.OverrideShanghai != nil {
config.ShanghaiTime = overrides.OverrideShanghai config.ShanghaiBlock = overrides.OverrideShanghai
} }
} }
} }
@ -529,7 +529,7 @@ func (g *Genesis) ToBlock() *types.Block {
var withdrawals []*types.Withdrawal var withdrawals []*types.Withdrawal
if g.Config != nil && g.Config.IsShanghai(g.Timestamp) { if g.Config != nil && g.Config.IsShanghai(new(big.Int).SetUint64(g.Number)) {
head.WithdrawalsHash = &types.EmptyWithdrawalsHash head.WithdrawalsHash = &types.EmptyWithdrawalsHash
withdrawals = make([]*types.Withdrawal, 0) withdrawals = make([]*types.Withdrawal, 0)
} }

View file

@ -102,7 +102,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
// Fail if Shanghai not enabled and len(withdrawals) is non-zero. // Fail if Shanghai not enabled and len(withdrawals) is non-zero.
withdrawals := block.Withdrawals() withdrawals := block.Withdrawals()
// TODO marcello double check // TODO marcello double check
if len(withdrawals) > 0 && !p.config.IsShanghai(block.Time()) { if len(withdrawals) > 0 && !p.config.IsShanghai(block.Number()) {
return nil, nil, 0, fmt.Errorf("withdrawals before shanghai") return nil, nil, 0, fmt.Errorf("withdrawals before shanghai")
} }
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards) // Finalize the block, applying any consensus engine specific extras (e.g. block rewards)

View file

@ -365,8 +365,8 @@ func TestStateProcessorErrors(t *testing.T) {
TerminalTotalDifficulty: big.NewInt(0), TerminalTotalDifficulty: big.NewInt(0),
TerminalTotalDifficultyPassed: true, TerminalTotalDifficultyPassed: true,
// TODO marcello double check // TODO marcello double check
ShanghaiTime: u64(0), ShanghaiBlock: big.NewInt(0),
Bor: &params.BorConfig{BurntContract: map[string]string{"0": "0x000000000000000000000000000000000000dead"}}, Bor: &params.BorConfig{BurntContract: map[string]string{"0": "0x000000000000000000000000000000000000dead"}},
}, },
Alloc: GenesisAlloc{ Alloc: GenesisAlloc{
common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7"): GenesisAccount{ common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7"): GenesisAccount{
@ -446,7 +446,7 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr
header.BaseFee = misc.CalcBaseFee(config, parent.Header()) header.BaseFee = misc.CalcBaseFee(config, parent.Header())
} }
// TODO marcello double check // TODO marcello double check
if config.IsShanghai(header.Time) { if config.IsShanghai(header.Number) {
header.WithdrawalsHash = &types.EmptyWithdrawalsHash header.WithdrawalsHash = &types.EmptyWithdrawalsHash
} }
@ -472,7 +472,7 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr
header.Root = common.BytesToHash(hasher.Sum(nil)) header.Root = common.BytesToHash(hasher.Sum(nil))
// Assemble and return the final block for sealing // Assemble and return the final block for sealing
// TODO marcello double check // TODO marcello double check
if config.IsShanghai(header.Time) { if config.IsShanghai(header.Number) {
return types.NewBlockWithWithdrawals(header, txs, nil, receipts, []*types.Withdrawal{}, trie.NewStackTrie(nil)) return types.NewBlockWithWithdrawals(header, txs, nil, receipts, []*types.Withdrawal{}, trie.NewStackTrie(nil))
} }

View file

@ -1897,7 +1897,7 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) {
pool.istanbul.Store(pool.chainconfig.IsIstanbul(next)) pool.istanbul.Store(pool.chainconfig.IsIstanbul(next))
pool.eip2718.Store(pool.chainconfig.IsBerlin(next)) pool.eip2718.Store(pool.chainconfig.IsBerlin(next))
pool.eip1559.Store(pool.chainconfig.IsLondon(next)) pool.eip1559.Store(pool.chainconfig.IsLondon(next))
pool.shanghai.Store(pool.chainconfig.IsShanghai(uint64(time.Now().Unix()))) pool.shanghai.Store(pool.chainconfig.IsShanghai(next))
} }
// promoteExecutables moves transactions that have become processable from the // promoteExecutables moves transactions that have become processable from the

View file

@ -165,46 +165,46 @@ func NewConsensusAPI(eth *eth.Ethereum) *ConsensusAPI {
// //
// If there are payloadAttributes: we try to assemble a block with the payloadAttributes // If there are payloadAttributes: we try to assemble a block with the payloadAttributes
// and return its payloadID. // and return its payloadID.
func (api *ConsensusAPI) ForkchoiceUpdatedV1(update engine.ForkchoiceStateV1, payloadAttributes *engine.PayloadAttributes) (engine.ForkChoiceResponse, error) { // func (api *ConsensusAPI) ForkchoiceUpdatedV1(update engine.ForkchoiceStateV1, payloadAttributes *engine.PayloadAttributes) (engine.ForkChoiceResponse, error) {
if payloadAttributes != nil { // if payloadAttributes != nil {
if payloadAttributes.Withdrawals != nil { // if payloadAttributes.Withdrawals != nil {
return engine.STATUS_INVALID, engine.InvalidParams.With(fmt.Errorf("withdrawals not supported in V1")) // return engine.STATUS_INVALID, engine.InvalidParams.With(fmt.Errorf("withdrawals not supported in V1"))
} // }
if api.eth.BlockChain().Config().IsShanghai(payloadAttributes.Timestamp) { // if api.eth.BlockChain().Config().IsShanghai(payloadAttributes.Timestamp) {
return engine.STATUS_INVALID, engine.InvalidParams.With(fmt.Errorf("forkChoiceUpdateV1 called post-shanghai")) // return engine.STATUS_INVALID, engine.InvalidParams.With(fmt.Errorf("forkChoiceUpdateV1 called post-shanghai"))
} // }
} // }
return api.forkchoiceUpdated(update, payloadAttributes) // return api.forkchoiceUpdated(update, payloadAttributes)
} // }
// ForkchoiceUpdatedV2 is equivalent to V1 with the addition of withdrawals in the payload attributes. // ForkchoiceUpdatedV2 is equivalent to V1 with the addition of withdrawals in the payload attributes.
func (api *ConsensusAPI) ForkchoiceUpdatedV2(update engine.ForkchoiceStateV1, payloadAttributes *engine.PayloadAttributes) (engine.ForkChoiceResponse, error) { // func (api *ConsensusAPI) ForkchoiceUpdatedV2(update engine.ForkchoiceStateV1, payloadAttributes *engine.PayloadAttributes) (engine.ForkChoiceResponse, error) {
if payloadAttributes != nil { // if payloadAttributes != nil {
if err := api.verifyPayloadAttributes(payloadAttributes); err != nil { // if err := api.verifyPayloadAttributes(payloadAttributes); err != nil {
return engine.STATUS_INVALID, engine.InvalidParams.With(err) // return engine.STATUS_INVALID, engine.InvalidParams.With(err)
} // }
} // }
return api.forkchoiceUpdated(update, payloadAttributes) // return api.forkchoiceUpdated(update, payloadAttributes)
} // }
func (api *ConsensusAPI) verifyPayloadAttributes(attr *engine.PayloadAttributes) error { // func (api *ConsensusAPI) verifyPayloadAttributes(attr *engine.PayloadAttributes) error {
if !api.eth.BlockChain().Config().IsShanghai(attr.Timestamp) { // if !api.eth.BlockChain().Config().IsShanghai(attr.Timestamp) {
// Reject payload attributes with withdrawals before shanghai // // Reject payload attributes with withdrawals before shanghai
if attr.Withdrawals != nil { // if attr.Withdrawals != nil {
return errors.New("withdrawals before shanghai") // return errors.New("withdrawals before shanghai")
} // }
} else { // } else {
// Reject payload attributes with nil withdrawals after shanghai // // Reject payload attributes with nil withdrawals after shanghai
if attr.Withdrawals == nil { // if attr.Withdrawals == nil {
return errors.New("missing withdrawals list") // return errors.New("missing withdrawals list")
} // }
} // }
return nil // return nil
} // }
// nolint:gocognit // nolint:gocognit
func (api *ConsensusAPI) forkchoiceUpdated(update engine.ForkchoiceStateV1, payloadAttributes *engine.PayloadAttributes) (engine.ForkChoiceResponse, error) { func (api *ConsensusAPI) forkchoiceUpdated(update engine.ForkchoiceStateV1, payloadAttributes *engine.PayloadAttributes) (engine.ForkChoiceResponse, error) {
@ -454,18 +454,18 @@ func (api *ConsensusAPI) NewPayloadV1(params engine.ExecutableData) (engine.Payl
return api.newPayload(params) return api.newPayload(params)
} }
// NewPayloadV2 creates an Eth1 block, inserts it in the chain, and returns the status of the chain. // // NewPayloadV2 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
func (api *ConsensusAPI) NewPayloadV2(params engine.ExecutableData) (engine.PayloadStatusV1, error) { // func (api *ConsensusAPI) NewPayloadV2(params engine.ExecutableData) (engine.PayloadStatusV1, error) {
if api.eth.BlockChain().Config().IsShanghai(params.Timestamp) { // if api.eth.BlockChain().Config().IsShanghai(params.Timestamp) {
if params.Withdrawals == nil { // if params.Withdrawals == nil {
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(fmt.Errorf("nil withdrawals post-shanghai")) // return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(fmt.Errorf("nil withdrawals post-shanghai"))
} // }
} else if params.Withdrawals != nil { // } else if params.Withdrawals != nil {
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(fmt.Errorf("non-nil withdrawals pre-shanghai")) // return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(fmt.Errorf("non-nil withdrawals pre-shanghai"))
} // }
return api.newPayload(params) // return api.newPayload(params)
} // }
func (api *ConsensusAPI) newPayload(params engine.ExecutableData) (engine.PayloadStatusV1, error) { func (api *ConsensusAPI) newPayload(params engine.ExecutableData) (engine.PayloadStatusV1, error) {
// The locking here is, strictly, not required. Without these locks, this can happen: // The locking here is, strictly, not required. Without these locks, this can happen:

File diff suppressed because it is too large Load diff

View file

@ -18,6 +18,7 @@
package ethconfig package ethconfig
import ( import (
"math/big"
"os" "os"
"os/user" "os/user"
"path/filepath" "path/filepath"
@ -220,7 +221,7 @@ type Config struct {
// TODO marcello double check // TODO marcello double check
// OverrideShanghai (TODO: remove after the fork) // OverrideShanghai (TODO: remove after the fork)
OverrideShanghai *uint64 `toml:",omitempty"` OverrideShanghai *big.Int `toml:",omitempty"`
// URL to connect to Heimdall node // URL to connect to Heimdall node
HeimdallURL string HeimdallURL string

View file

@ -3,6 +3,7 @@
package ethconfig package ethconfig
import ( import (
"math/big"
"time" "time"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
@ -48,6 +49,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
TrieTimeout time.Duration TrieTimeout time.Duration
SnapshotCache int SnapshotCache int
Preimages bool Preimages bool
TriesInMemory uint64
FilterLogCacheSize int FilterLogCacheSize int
Miner miner.Config Miner miner.Config
Ethash ethash.Config Ethash ethash.Config
@ -56,13 +58,22 @@ func (c Config) MarshalTOML() (interface{}, error) {
EnablePreimageRecording bool EnablePreimageRecording bool
DocRoot string `toml:"-"` DocRoot string `toml:"-"`
RPCGasCap uint64 RPCGasCap uint64
RPCReturnDataLimit uint64
RPCEVMTimeout time.Duration RPCEVMTimeout time.Duration
RPCTxFeeCap float64 RPCTxFeeCap float64
Checkpoint *params.TrustedCheckpoint `toml:",omitempty"` Checkpoint *params.TrustedCheckpoint `toml:",omitempty"`
CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"` CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"`
OverrideShanghai *uint64 `toml:",omitempty"` OverrideShanghai *big.Int `toml:",omitempty"`
HeimdallURL string
WithoutHeimdall bool
HeimdallgRPCAddress string
RunHeimdall bool
RunHeimdallArgs string
UseHeimdallApp bool
BorLogs bool
ParallelEVM core.ParallelEVMConfig `toml:",omitempty"`
DevFakeAuthor bool `hcl:"devfakeauthor,optional" toml:"devfakeauthor,optional"`
} }
var enc Config var enc Config
enc.Genesis = c.Genesis enc.Genesis = c.Genesis
enc.NetworkId = c.NetworkId enc.NetworkId = c.NetworkId
@ -94,6 +105,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
enc.TrieTimeout = c.TrieTimeout enc.TrieTimeout = c.TrieTimeout
enc.SnapshotCache = c.SnapshotCache enc.SnapshotCache = c.SnapshotCache
enc.Preimages = c.Preimages enc.Preimages = c.Preimages
enc.TriesInMemory = c.TriesInMemory
enc.FilterLogCacheSize = c.FilterLogCacheSize enc.FilterLogCacheSize = c.FilterLogCacheSize
enc.Miner = c.Miner enc.Miner = c.Miner
enc.Ethash = c.Ethash enc.Ethash = c.Ethash
@ -102,12 +114,21 @@ func (c Config) MarshalTOML() (interface{}, error) {
enc.EnablePreimageRecording = c.EnablePreimageRecording enc.EnablePreimageRecording = c.EnablePreimageRecording
enc.DocRoot = c.DocRoot enc.DocRoot = c.DocRoot
enc.RPCGasCap = c.RPCGasCap enc.RPCGasCap = c.RPCGasCap
enc.RPCReturnDataLimit = c.RPCReturnDataLimit
enc.RPCEVMTimeout = c.RPCEVMTimeout enc.RPCEVMTimeout = c.RPCEVMTimeout
enc.RPCTxFeeCap = c.RPCTxFeeCap enc.RPCTxFeeCap = c.RPCTxFeeCap
enc.Checkpoint = c.Checkpoint enc.Checkpoint = c.Checkpoint
enc.CheckpointOracle = c.CheckpointOracle enc.CheckpointOracle = c.CheckpointOracle
enc.OverrideShanghai = c.OverrideShanghai enc.OverrideShanghai = c.OverrideShanghai
enc.HeimdallURL = c.HeimdallURL
enc.WithoutHeimdall = c.WithoutHeimdall
enc.HeimdallgRPCAddress = c.HeimdallgRPCAddress
enc.RunHeimdall = c.RunHeimdall
enc.RunHeimdallArgs = c.RunHeimdallArgs
enc.UseHeimdallApp = c.UseHeimdallApp
enc.BorLogs = c.BorLogs
enc.ParallelEVM = c.ParallelEVM
enc.DevFakeAuthor = c.DevFakeAuthor
return &enc, nil return &enc, nil
} }
@ -144,6 +165,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
TrieTimeout *time.Duration TrieTimeout *time.Duration
SnapshotCache *int SnapshotCache *int
Preimages *bool Preimages *bool
TriesInMemory *uint64
FilterLogCacheSize *int FilterLogCacheSize *int
Miner *miner.Config Miner *miner.Config
Ethash *ethash.Config Ethash *ethash.Config
@ -152,189 +174,187 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
EnablePreimageRecording *bool EnablePreimageRecording *bool
DocRoot *string `toml:"-"` DocRoot *string `toml:"-"`
RPCGasCap *uint64 RPCGasCap *uint64
RPCReturnDataLimit *uint64
RPCEVMTimeout *time.Duration RPCEVMTimeout *time.Duration
RPCTxFeeCap *float64 RPCTxFeeCap *float64
Checkpoint *params.TrustedCheckpoint `toml:",omitempty"` Checkpoint *params.TrustedCheckpoint `toml:",omitempty"`
CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"` CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"`
OverrideShanghai *uint64 `toml:",omitempty"` OverrideShanghai *big.Int `toml:",omitempty"`
HeimdallURL *string
WithoutHeimdall *bool
HeimdallgRPCAddress *string
RunHeimdall *bool
RunHeimdallArgs *string
UseHeimdallApp *bool
BorLogs *bool
ParallelEVM *core.ParallelEVMConfig `toml:",omitempty"`
DevFakeAuthor *bool `hcl:"devfakeauthor,optional" toml:"devfakeauthor,optional"`
} }
var dec Config var dec Config
if err := unmarshal(&dec); err != nil { if err := unmarshal(&dec); err != nil {
return err return err
} }
if dec.Genesis != nil { if dec.Genesis != nil {
c.Genesis = dec.Genesis c.Genesis = dec.Genesis
} }
if dec.NetworkId != nil { if dec.NetworkId != nil {
c.NetworkId = *dec.NetworkId c.NetworkId = *dec.NetworkId
} }
if dec.SyncMode != nil { if dec.SyncMode != nil {
c.SyncMode = *dec.SyncMode c.SyncMode = *dec.SyncMode
} }
if dec.EthDiscoveryURLs != nil { if dec.EthDiscoveryURLs != nil {
c.EthDiscoveryURLs = dec.EthDiscoveryURLs c.EthDiscoveryURLs = dec.EthDiscoveryURLs
} }
if dec.SnapDiscoveryURLs != nil { if dec.SnapDiscoveryURLs != nil {
c.SnapDiscoveryURLs = dec.SnapDiscoveryURLs c.SnapDiscoveryURLs = dec.SnapDiscoveryURLs
} }
if dec.NoPruning != nil { if dec.NoPruning != nil {
c.NoPruning = *dec.NoPruning c.NoPruning = *dec.NoPruning
} }
if dec.NoPrefetch != nil { if dec.NoPrefetch != nil {
c.NoPrefetch = *dec.NoPrefetch c.NoPrefetch = *dec.NoPrefetch
} }
if dec.TxLookupLimit != nil { if dec.TxLookupLimit != nil {
c.TxLookupLimit = *dec.TxLookupLimit c.TxLookupLimit = *dec.TxLookupLimit
} }
if dec.RequiredBlocks != nil { if dec.RequiredBlocks != nil {
c.RequiredBlocks = dec.RequiredBlocks c.RequiredBlocks = dec.RequiredBlocks
} }
if dec.LightServ != nil { if dec.LightServ != nil {
c.LightServ = *dec.LightServ c.LightServ = *dec.LightServ
} }
if dec.LightIngress != nil { if dec.LightIngress != nil {
c.LightIngress = *dec.LightIngress c.LightIngress = *dec.LightIngress
} }
if dec.LightEgress != nil { if dec.LightEgress != nil {
c.LightEgress = *dec.LightEgress c.LightEgress = *dec.LightEgress
} }
if dec.LightPeers != nil { if dec.LightPeers != nil {
c.LightPeers = *dec.LightPeers c.LightPeers = *dec.LightPeers
} }
if dec.LightNoPrune != nil { if dec.LightNoPrune != nil {
c.LightNoPrune = *dec.LightNoPrune c.LightNoPrune = *dec.LightNoPrune
} }
if dec.LightNoSyncServe != nil { if dec.LightNoSyncServe != nil {
c.LightNoSyncServe = *dec.LightNoSyncServe c.LightNoSyncServe = *dec.LightNoSyncServe
} }
if dec.SyncFromCheckpoint != nil { if dec.SyncFromCheckpoint != nil {
c.SyncFromCheckpoint = *dec.SyncFromCheckpoint c.SyncFromCheckpoint = *dec.SyncFromCheckpoint
} }
if dec.UltraLightServers != nil { if dec.UltraLightServers != nil {
c.UltraLightServers = dec.UltraLightServers c.UltraLightServers = dec.UltraLightServers
} }
if dec.UltraLightFraction != nil { if dec.UltraLightFraction != nil {
c.UltraLightFraction = *dec.UltraLightFraction c.UltraLightFraction = *dec.UltraLightFraction
} }
if dec.UltraLightOnlyAnnounce != nil { if dec.UltraLightOnlyAnnounce != nil {
c.UltraLightOnlyAnnounce = *dec.UltraLightOnlyAnnounce c.UltraLightOnlyAnnounce = *dec.UltraLightOnlyAnnounce
} }
if dec.SkipBcVersionCheck != nil { if dec.SkipBcVersionCheck != nil {
c.SkipBcVersionCheck = *dec.SkipBcVersionCheck c.SkipBcVersionCheck = *dec.SkipBcVersionCheck
} }
if dec.DatabaseHandles != nil { if dec.DatabaseHandles != nil {
c.DatabaseHandles = *dec.DatabaseHandles c.DatabaseHandles = *dec.DatabaseHandles
} }
if dec.DatabaseCache != nil { if dec.DatabaseCache != nil {
c.DatabaseCache = *dec.DatabaseCache c.DatabaseCache = *dec.DatabaseCache
} }
if dec.DatabaseFreezer != nil { if dec.DatabaseFreezer != nil {
c.DatabaseFreezer = *dec.DatabaseFreezer c.DatabaseFreezer = *dec.DatabaseFreezer
} }
if dec.TrieCleanCache != nil { if dec.TrieCleanCache != nil {
c.TrieCleanCache = *dec.TrieCleanCache c.TrieCleanCache = *dec.TrieCleanCache
} }
if dec.TrieCleanCacheJournal != nil { if dec.TrieCleanCacheJournal != nil {
c.TrieCleanCacheJournal = *dec.TrieCleanCacheJournal c.TrieCleanCacheJournal = *dec.TrieCleanCacheJournal
} }
if dec.TrieCleanCacheRejournal != nil { if dec.TrieCleanCacheRejournal != nil {
c.TrieCleanCacheRejournal = *dec.TrieCleanCacheRejournal c.TrieCleanCacheRejournal = *dec.TrieCleanCacheRejournal
} }
if dec.TrieDirtyCache != nil { if dec.TrieDirtyCache != nil {
c.TrieDirtyCache = *dec.TrieDirtyCache c.TrieDirtyCache = *dec.TrieDirtyCache
} }
if dec.TrieTimeout != nil { if dec.TrieTimeout != nil {
c.TrieTimeout = *dec.TrieTimeout c.TrieTimeout = *dec.TrieTimeout
} }
if dec.SnapshotCache != nil { if dec.SnapshotCache != nil {
c.SnapshotCache = *dec.SnapshotCache c.SnapshotCache = *dec.SnapshotCache
} }
if dec.Preimages != nil { if dec.Preimages != nil {
c.Preimages = *dec.Preimages c.Preimages = *dec.Preimages
} }
if dec.TriesInMemory != nil {
c.TriesInMemory = *dec.TriesInMemory
}
if dec.FilterLogCacheSize != nil { if dec.FilterLogCacheSize != nil {
c.FilterLogCacheSize = *dec.FilterLogCacheSize c.FilterLogCacheSize = *dec.FilterLogCacheSize
} }
if dec.Miner != nil { if dec.Miner != nil {
c.Miner = *dec.Miner c.Miner = *dec.Miner
} }
if dec.Ethash != nil { if dec.Ethash != nil {
c.Ethash = *dec.Ethash c.Ethash = *dec.Ethash
} }
if dec.TxPool != nil { if dec.TxPool != nil {
c.TxPool = *dec.TxPool c.TxPool = *dec.TxPool
} }
if dec.GPO != nil { if dec.GPO != nil {
c.GPO = *dec.GPO c.GPO = *dec.GPO
} }
if dec.EnablePreimageRecording != nil { if dec.EnablePreimageRecording != nil {
c.EnablePreimageRecording = *dec.EnablePreimageRecording c.EnablePreimageRecording = *dec.EnablePreimageRecording
} }
if dec.DocRoot != nil { if dec.DocRoot != nil {
c.DocRoot = *dec.DocRoot c.DocRoot = *dec.DocRoot
} }
if dec.RPCGasCap != nil { if dec.RPCGasCap != nil {
c.RPCGasCap = *dec.RPCGasCap c.RPCGasCap = *dec.RPCGasCap
} }
if dec.RPCReturnDataLimit != nil {
c.RPCReturnDataLimit = *dec.RPCReturnDataLimit
}
if dec.RPCEVMTimeout != nil { if dec.RPCEVMTimeout != nil {
c.RPCEVMTimeout = *dec.RPCEVMTimeout c.RPCEVMTimeout = *dec.RPCEVMTimeout
} }
if dec.RPCTxFeeCap != nil { if dec.RPCTxFeeCap != nil {
c.RPCTxFeeCap = *dec.RPCTxFeeCap c.RPCTxFeeCap = *dec.RPCTxFeeCap
} }
if dec.Checkpoint != nil { if dec.Checkpoint != nil {
c.Checkpoint = dec.Checkpoint c.Checkpoint = dec.Checkpoint
} }
if dec.CheckpointOracle != nil { if dec.CheckpointOracle != nil {
c.CheckpointOracle = dec.CheckpointOracle c.CheckpointOracle = dec.CheckpointOracle
} }
// TODO marcello double check
if dec.OverrideShanghai != nil { if dec.OverrideShanghai != nil {
c.OverrideShanghai = dec.OverrideShanghai c.OverrideShanghai = dec.OverrideShanghai
} }
if dec.HeimdallURL != nil {
c.HeimdallURL = *dec.HeimdallURL
}
if dec.WithoutHeimdall != nil {
c.WithoutHeimdall = *dec.WithoutHeimdall
}
if dec.HeimdallgRPCAddress != nil {
c.HeimdallgRPCAddress = *dec.HeimdallgRPCAddress
}
if dec.RunHeimdall != nil {
c.RunHeimdall = *dec.RunHeimdall
}
if dec.RunHeimdallArgs != nil {
c.RunHeimdallArgs = *dec.RunHeimdallArgs
}
if dec.UseHeimdallApp != nil {
c.UseHeimdallApp = *dec.UseHeimdallApp
}
if dec.BorLogs != nil {
c.BorLogs = *dec.BorLogs
}
if dec.ParallelEVM != nil {
c.ParallelEVM = *dec.ParallelEVM
}
if dec.DevFakeAuthor != nil {
c.DevFakeAuthor = *dec.DevFakeAuthor
}
return nil return nil
} }

View file

@ -94,7 +94,7 @@ func newTestBackendWithGenerator(blocks int, shanghai bool, generator func(int,
ArrowGlacierBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0),
GrayGlacierBlock: big.NewInt(0), GrayGlacierBlock: big.NewInt(0),
MergeNetsplitBlock: big.NewInt(0), MergeNetsplitBlock: big.NewInt(0),
ShanghaiTime: u64(0), ShanghaiBlock: big.NewInt(0),
TerminalTotalDifficulty: big.NewInt(0), TerminalTotalDifficulty: big.NewInt(0),
TerminalTotalDifficultyPassed: true, TerminalTotalDifficultyPassed: true,
Ethash: new(params.EthashConfig), Ethash: new(params.EthashConfig),

View file

@ -1425,18 +1425,18 @@ func overrideConfig(original *params.ChainConfig, override *params.ChainConfig)
canon = false canon = false
} }
if timestamp := override.ShanghaiTime; timestamp != nil { if timestamp := override.ShanghaiBlock; timestamp != nil {
chainConfigCopy.ShanghaiTime = timestamp chainConfigCopy.ShanghaiBlock = timestamp
canon = false canon = false
} }
if timestamp := override.CancunTime; timestamp != nil { if timestamp := override.CancunBlock; timestamp != nil {
chainConfigCopy.CancunTime = timestamp chainConfigCopy.CancunBlock = timestamp
canon = false canon = false
} }
if timestamp := override.PragueTime; timestamp != nil { if timestamp := override.PragueBlock; timestamp != nil {
chainConfigCopy.PragueTime = timestamp chainConfigCopy.PragueBlock = timestamp
canon = false canon = false
} }

View file

@ -341,7 +341,7 @@ func (pool *TxPool) setNewHead(head *types.Header) {
next := new(big.Int).Add(head.Number, big.NewInt(1)) next := new(big.Int).Add(head.Number, big.NewInt(1))
pool.istanbul = pool.config.IsIstanbul(next) pool.istanbul = pool.config.IsIstanbul(next)
pool.eip2718 = pool.config.IsBerlin(next) pool.eip2718 = pool.config.IsBerlin(next)
pool.shanghai = pool.config.IsShanghai(uint64(time.Now().Unix())) pool.shanghai = pool.config.IsShanghai(next)
} }
// Stop stops the light transaction pool // Stop stops the light transaction pool

File diff suppressed because it is too large Load diff

View file

@ -81,7 +81,6 @@ var (
GrayGlacierBlock: big.NewInt(15_050_000), GrayGlacierBlock: big.NewInt(15_050_000),
TerminalTotalDifficulty: MainnetTerminalTotalDifficulty, // 58_750_000_000_000_000_000_000 TerminalTotalDifficulty: MainnetTerminalTotalDifficulty, // 58_750_000_000_000_000_000_000
TerminalTotalDifficultyPassed: true, TerminalTotalDifficultyPassed: true,
ShanghaiTime: newUint64(1681338455),
Ethash: new(EthashConfig), Ethash: new(EthashConfig),
} }
@ -125,7 +124,6 @@ var (
TerminalTotalDifficulty: big.NewInt(17_000_000_000_000_000), TerminalTotalDifficulty: big.NewInt(17_000_000_000_000_000),
TerminalTotalDifficultyPassed: true, TerminalTotalDifficultyPassed: true,
MergeNetsplitBlock: big.NewInt(1735371), MergeNetsplitBlock: big.NewInt(1735371),
ShanghaiTime: newUint64(1677557088),
Ethash: new(EthashConfig), Ethash: new(EthashConfig),
} }
@ -199,7 +197,6 @@ var (
ArrowGlacierBlock: nil, ArrowGlacierBlock: nil,
TerminalTotalDifficulty: big.NewInt(10_790_000), TerminalTotalDifficulty: big.NewInt(10_790_000),
TerminalTotalDifficultyPassed: true, TerminalTotalDifficultyPassed: true,
ShanghaiTime: newUint64(1678832736),
Clique: &CliqueConfig{ Clique: &CliqueConfig{
Period: 15, Period: 15,
Epoch: 30000, Epoch: 30000,
@ -445,9 +442,9 @@ var (
ArrowGlacierBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0),
GrayGlacierBlock: big.NewInt(0), GrayGlacierBlock: big.NewInt(0),
MergeNetsplitBlock: nil, MergeNetsplitBlock: nil,
ShanghaiTime: nil, ShanghaiBlock: nil,
CancunTime: nil, CancunBlock: nil,
PragueTime: nil, PragueBlock: nil,
TerminalTotalDifficulty: nil, TerminalTotalDifficulty: nil,
TerminalTotalDifficultyPassed: false, TerminalTotalDifficultyPassed: false,
Ethash: new(EthashConfig), Ethash: new(EthashConfig),
@ -475,9 +472,9 @@ var (
ArrowGlacierBlock: nil, ArrowGlacierBlock: nil,
GrayGlacierBlock: nil, GrayGlacierBlock: nil,
MergeNetsplitBlock: nil, MergeNetsplitBlock: nil,
ShanghaiTime: nil, ShanghaiBlock: nil,
CancunTime: nil, CancunBlock: nil,
PragueTime: nil, PragueBlock: nil,
TerminalTotalDifficulty: nil, TerminalTotalDifficulty: nil,
TerminalTotalDifficultyPassed: false, TerminalTotalDifficultyPassed: false,
Ethash: nil, Ethash: nil,
@ -505,9 +502,9 @@ var (
ArrowGlacierBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0),
GrayGlacierBlock: big.NewInt(0), GrayGlacierBlock: big.NewInt(0),
MergeNetsplitBlock: nil, MergeNetsplitBlock: nil,
ShanghaiTime: nil, ShanghaiBlock: nil,
CancunTime: nil, CancunBlock: nil,
PragueTime: nil, PragueBlock: nil,
TerminalTotalDifficulty: nil, TerminalTotalDifficulty: nil,
TerminalTotalDifficultyPassed: false, TerminalTotalDifficultyPassed: false,
Ethash: new(EthashConfig), Ethash: new(EthashConfig),
@ -538,9 +535,9 @@ var (
ArrowGlacierBlock: nil, ArrowGlacierBlock: nil,
GrayGlacierBlock: nil, GrayGlacierBlock: nil,
MergeNetsplitBlock: nil, MergeNetsplitBlock: nil,
ShanghaiTime: nil, ShanghaiBlock: nil,
CancunTime: nil, CancunBlock: nil,
PragueTime: nil, PragueBlock: nil,
TerminalTotalDifficulty: nil, TerminalTotalDifficulty: nil,
TerminalTotalDifficultyPassed: false, TerminalTotalDifficultyPassed: false,
Ethash: new(EthashConfig), Ethash: new(EthashConfig),
@ -640,10 +637,10 @@ type ChainConfig struct {
MergeNetsplitBlock *big.Int `json:"mergeNetsplitBlock,omitempty"` // Virtual fork after The Merge to use as a network splitter MergeNetsplitBlock *big.Int `json:"mergeNetsplitBlock,omitempty"` // Virtual fork after The Merge to use as a network splitter
// Fork scheduling was switched from blocks to timestamps here // Fork scheduling was switched from blocks to timestamps here
// Fork scheduling switched back to blockNumber in Bor
ShanghaiTime *uint64 `json:"shanghaiTime,omitempty"` // Shanghai switch time (nil = no fork, 0 = already on shanghai) ShanghaiBlock *big.Int `json:"shanghaiBlock,omitempty"` // Shanghai switch Block (nil = no fork, 0 = already on shanghai)
CancunTime *uint64 `json:"cancunTime,omitempty"` // Cancun switch time (nil = no fork, 0 = already on cancun) CancunBlock *big.Int `json:"cancunBlock,omitempty"` // Cancun switch Block (nil = no fork, 0 = already on cancun)
PragueTime *uint64 `json:"pragueTime,omitempty"` // Prague switch time (nil = no fork, 0 = already on prague) PragueBlock *big.Int `json:"pragueBlock,omitempty"` // Prague switch Block (nil = no fork, 0 = already on prague)
// TerminalTotalDifficulty is the amount of total difficulty reached by // TerminalTotalDifficulty is the amount of total difficulty reached by
// the network that triggers the consensus upgrade. // the network that triggers the consensus upgrade.
@ -900,16 +897,16 @@ func (c *ChainConfig) Description() string {
// Create a list of forks post-merge // Create a list of forks post-merge
banner += "Post-Merge hard forks (timestamp based):\n" banner += "Post-Merge hard forks (timestamp based):\n"
if c.ShanghaiTime != nil { if c.ShanghaiBlock != nil {
banner += fmt.Sprintf(" - Shanghai: @%-10v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md)\n", *c.ShanghaiTime) banner += fmt.Sprintf(" - Shanghai: @%-10v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md)\n", *c.ShanghaiBlock)
} }
if c.CancunTime != nil { if c.CancunBlock != nil {
banner += fmt.Sprintf(" - Cancun: @%-10v\n", *c.CancunTime) banner += fmt.Sprintf(" - Cancun: @%-10v\n", *c.CancunBlock)
} }
if c.PragueTime != nil { if c.PragueBlock != nil {
banner += fmt.Sprintf(" - Prague: @%-10v\n", *c.PragueTime) banner += fmt.Sprintf(" - Prague: @%-10v\n", *c.PragueBlock)
} }
return banner return banner
@ -998,18 +995,18 @@ func (c *ChainConfig) IsTerminalPoWBlock(parentTotalDiff *big.Int, totalDiff *bi
// IsShanghai returns whether time is either equal to the Shanghai fork time or greater. // IsShanghai returns whether time is either equal to the Shanghai fork time or greater.
// TODO marcello double check // TODO marcello double check
func (c *ChainConfig) IsShanghai(time uint64) bool { func (c *ChainConfig) IsShanghai(num *big.Int) bool {
return isTimestampForked(c.ShanghaiTime, time) return isBlockForked(c.ShanghaiBlock, num)
} }
// IsCancun returns whether num is either equal to the Cancun fork time or greater. // IsCancun returns whether num is either equal to the Cancun fork time or greater.
func (c *ChainConfig) IsCancun(time uint64) bool { func (c *ChainConfig) IsCancun(num *big.Int) bool {
return isTimestampForked(c.CancunTime, time) return isBlockForked(c.CancunBlock, num)
} }
// IsPrague returns whether num is either equal to the Prague fork time or greater. // IsPrague returns whether num is either equal to the Prague fork time or greater.
func (c *ChainConfig) IsPrague(time uint64) bool { func (c *ChainConfig) IsPrague(num *big.Int) bool {
return isTimestampForked(c.PragueTime, time) return isBlockForked(c.PragueBlock, num)
} }
// CheckCompatible checks whether scheduled fork transitions have been imported // CheckCompatible checks whether scheduled fork transitions have been imported
@ -1067,9 +1064,9 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
{name: "arrowGlacierBlock", block: c.ArrowGlacierBlock, optional: true}, {name: "arrowGlacierBlock", block: c.ArrowGlacierBlock, optional: true},
{name: "grayGlacierBlock", block: c.GrayGlacierBlock, optional: true}, {name: "grayGlacierBlock", block: c.GrayGlacierBlock, optional: true},
{name: "mergeNetsplitBlock", block: c.MergeNetsplitBlock, optional: true}, {name: "mergeNetsplitBlock", block: c.MergeNetsplitBlock, optional: true},
{name: "shanghaiTime", timestamp: c.ShanghaiTime}, {name: "shanghaiTime", block: c.ShanghaiBlock},
{name: "cancunTime", timestamp: c.CancunTime, optional: true}, {name: "cancunTime", block: c.CancunBlock, optional: true},
{name: "pragueTime", timestamp: c.PragueTime, optional: true}, {name: "pragueTime", block: c.PragueBlock, optional: true},
} { } {
if lastFork.name != "" { if lastFork.name != "" {
switch { switch {
@ -1182,16 +1179,16 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int,
return newBlockCompatError("Merge netsplit fork block", c.MergeNetsplitBlock, newcfg.MergeNetsplitBlock) return newBlockCompatError("Merge netsplit fork block", c.MergeNetsplitBlock, newcfg.MergeNetsplitBlock)
} }
if isForkTimestampIncompatible(c.ShanghaiTime, newcfg.ShanghaiTime, headTimestamp) { if isForkBlockIncompatible(c.ShanghaiBlock, newcfg.ShanghaiBlock, headNumber) {
return newTimestampCompatError("Shanghai fork timestamp", c.ShanghaiTime, newcfg.ShanghaiTime) return newBlockCompatError("Shanghai fork block", c.ShanghaiBlock, newcfg.ShanghaiBlock)
} }
if isForkTimestampIncompatible(c.CancunTime, newcfg.CancunTime, headTimestamp) { if isForkBlockIncompatible(c.CancunBlock, newcfg.CancunBlock, headNumber) {
return newTimestampCompatError("Cancun fork timestamp", c.CancunTime, newcfg.CancunTime) return newBlockCompatError("Cancun fork block", c.CancunBlock, newcfg.CancunBlock)
} }
if isForkTimestampIncompatible(c.PragueTime, newcfg.PragueTime, headTimestamp) { if isForkBlockIncompatible(c.PragueBlock, newcfg.PragueBlock, headNumber) {
return newTimestampCompatError("Prague fork timestamp", c.PragueTime, newcfg.PragueTime) return newBlockCompatError("Prague fork block", c.PragueBlock, newcfg.PragueBlock)
} }
return nil return nil
@ -1375,8 +1372,8 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
IsBerlin: c.IsBerlin(num), IsBerlin: c.IsBerlin(num),
IsLondon: c.IsLondon(num), IsLondon: c.IsLondon(num),
IsMerge: isMerge, IsMerge: isMerge,
IsShanghai: c.IsShanghai(timestamp), IsShanghai: c.IsShanghai(num),
IsCancun: c.IsCancun(timestamp), IsCancun: c.IsCancun(num),
IsPrague: c.IsPrague(timestamp), IsPrague: c.IsPrague(num),
} }
} }

View file

@ -94,17 +94,17 @@ func TestCheckCompatible(t *testing.T) {
}, },
}, },
{ {
stored: &ChainConfig{ShanghaiTime: newUint64(10)}, stored: &ChainConfig{ShanghaiBlock: big.NewInt(30)},
new: &ChainConfig{ShanghaiTime: newUint64(20)}, new: &ChainConfig{ShanghaiBlock: big.NewInt(30)},
headTimestamp: 9, headTimestamp: 9,
wantErr: nil, wantErr: nil,
}, },
{ {
stored: &ChainConfig{ShanghaiTime: newUint64(10)}, stored: &ChainConfig{ShanghaiBlock: big.NewInt(30)},
new: &ChainConfig{ShanghaiTime: newUint64(20)}, new: &ChainConfig{ShanghaiBlock: big.NewInt(30)},
headTimestamp: 25, headTimestamp: 25,
wantErr: &ConfigCompatError{ wantErr: &ConfigCompatError{
What: "Shanghai fork timestamp", What: "Shanghai fork Block",
StoredTime: newUint64(10), StoredTime: newUint64(10),
NewTime: newUint64(20), NewTime: newUint64(20),
RewindToTime: 9, RewindToTime: 9,
@ -124,24 +124,24 @@ func TestConfigRules(t *testing.T) {
t.Parallel() t.Parallel()
c := &ChainConfig{ c := &ChainConfig{
ShanghaiTime: newUint64(500), ShanghaiBlock: big.NewInt(10),
} }
var stamp uint64 var block *big.Int
if r := c.Rules(big.NewInt(0), true, stamp); r.IsShanghai { if r := c.Rules(block, true, 0); r.IsShanghai {
t.Errorf("expected %v to not be shanghai", stamp) t.Errorf("expected %v to not be shanghai", 0)
} }
stamp = 500 block.SetInt64(10)
if r := c.Rules(big.NewInt(0), true, stamp); !r.IsShanghai { if r := c.Rules(block, true, 0); !r.IsShanghai {
t.Errorf("expected %v to be shanghai", stamp) t.Errorf("expected %v to be shanghai", 0)
} }
stamp = math.MaxInt64 block = block.SetInt64(math.MaxInt64)
if r := c.Rules(big.NewInt(0), true, stamp); !r.IsShanghai { if r := c.Rules(block, true, 0); !r.IsShanghai {
t.Errorf("expected %v to be shanghai", stamp) t.Errorf("expected %v to be shanghai", 0)
} }
} }

View file

@ -302,7 +302,7 @@ var Forks = map[string]*params.ChainConfig{
ArrowGlacierBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0),
MergeNetsplitBlock: big.NewInt(0), MergeNetsplitBlock: big.NewInt(0),
TerminalTotalDifficulty: big.NewInt(0), TerminalTotalDifficulty: big.NewInt(0),
ShanghaiTime: u64(0), ShanghaiBlock: big.NewInt(0),
Bor: params.BorUnittestChainConfig.Bor, Bor: params.BorUnittestChainConfig.Bor,
}, },
"MergeToShanghaiAtTime15k": { "MergeToShanghaiAtTime15k": {
@ -321,7 +321,7 @@ var Forks = map[string]*params.ChainConfig{
ArrowGlacierBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0),
MergeNetsplitBlock: big.NewInt(0), MergeNetsplitBlock: big.NewInt(0),
TerminalTotalDifficulty: big.NewInt(0), TerminalTotalDifficulty: big.NewInt(0),
ShanghaiTime: u64(15_000), ShanghaiBlock: big.NewInt(0),
Bor: params.BorUnittestChainConfig.Bor, Bor: params.BorUnittestChainConfig.Bor,
}, },
} }