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
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
results = append(results, r)
@ -192,7 +192,7 @@ func Transaction(ctx *cli.Context) error {
}
// TODO marcello double check
// 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")
}

View file

@ -286,7 +286,7 @@ func Transition(ctx *cli.Context) error {
}
}
// 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"))
}

View file

@ -18,6 +18,7 @@ package main
import (
"fmt"
"math/big"
"os"
"time"
@ -149,8 +150,8 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
stack, cfg := makeConfigNode(ctx)
// TODO marcello double check
if ctx.IsSet(utils.OverrideShanghai.Name) {
v := ctx.Uint64(utils.OverrideShanghai.Name)
cfg.Eth.OverrideShanghai = &v
v := ctx.Int64(utils.OverrideShanghai.Name)
cfg.Eth.OverrideShanghai = new(big.Int).SetInt64(v)
}
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.
// TODO marcello double check
shanghai := chain.Config().IsShanghai(header.Time)
shanghai := chain.Config().IsShanghai(header.Number)
if shanghai && header.WithdrawalsHash == nil {
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)
}
// Verify the existence / non-existence of excessDataGas
cancun := chain.Config().IsCancun(header.Time)
cancun := chain.Config().IsCancun(header.Number)
if cancun && header.ExcessDataGas == nil {
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)
}
// TODO marcello double check
shanghai := chain.Config().IsShanghai(header.Time)
shanghai := chain.Config().IsShanghai(header.Number)
if shanghai {
// All blocks after Shanghai must include a withdrawals root.
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)
}
// 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")
}
if chain.Config().IsCancun(header.Time) {
if chain.Config().IsCancun(header.Number) {
return fmt.Errorf("clique does not support cancun fork")
}
// 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
}
// 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")
}
if chain.Config().IsCancun(header.Time) {
if chain.Config().IsCancun(header.Number) {
return fmt.Errorf("ethash does not support cancun fork")
}
// 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.TerminalTotalDifficulty = common.Big0
gspec.Config.TerminalTotalDifficultyPassed = true
gspec.Config.ShanghaiTime = u64(0)
gspec.Config.ShanghaiBlock = common.Big0
signer := types.LatestSigner(gspec.Config)
_, 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.TerminalTotalDifficulty = common.Big0
config.ShanghaiTime = u64(0)
config.ShanghaiBlock = common.Big0
// init 0xaa with some storage elements
storage := make(map[common.Hash]common.Hash)

View file

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

View file

@ -298,7 +298,7 @@ func (e *GenesisMismatchError) Error() string {
// ChainOverrides contains the changes to chain config.
type ChainOverrides struct {
OverrideShanghai *uint64
OverrideShanghai *big.Int
}
// 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 {
// TODO marcello double check
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
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
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.
withdrawals := block.Withdrawals()
// 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")
}
// 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),
TerminalTotalDifficultyPassed: true,
// TODO marcello double check
ShanghaiTime: u64(0),
Bor: &params.BorConfig{BurntContract: map[string]string{"0": "0x000000000000000000000000000000000000dead"}},
ShanghaiBlock: big.NewInt(0),
Bor: &params.BorConfig{BurntContract: map[string]string{"0": "0x000000000000000000000000000000000000dead"}},
},
Alloc: GenesisAlloc{
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())
}
// TODO marcello double check
if config.IsShanghai(header.Time) {
if config.IsShanghai(header.Number) {
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))
// Assemble and return the final block for sealing
// 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))
}

View file

@ -1897,7 +1897,7 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) {
pool.istanbul.Store(pool.chainconfig.IsIstanbul(next))
pool.eip2718.Store(pool.chainconfig.IsBerlin(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

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
// and return its payloadID.
func (api *ConsensusAPI) ForkchoiceUpdatedV1(update engine.ForkchoiceStateV1, payloadAttributes *engine.PayloadAttributes) (engine.ForkChoiceResponse, error) {
if payloadAttributes != nil {
if payloadAttributes.Withdrawals != nil {
return engine.STATUS_INVALID, engine.InvalidParams.With(fmt.Errorf("withdrawals not supported in V1"))
}
// func (api *ConsensusAPI) ForkchoiceUpdatedV1(update engine.ForkchoiceStateV1, payloadAttributes *engine.PayloadAttributes) (engine.ForkChoiceResponse, error) {
// if payloadAttributes != nil {
// if payloadAttributes.Withdrawals != nil {
// return engine.STATUS_INVALID, engine.InvalidParams.With(fmt.Errorf("withdrawals not supported in V1"))
// }
if api.eth.BlockChain().Config().IsShanghai(payloadAttributes.Timestamp) {
return engine.STATUS_INVALID, engine.InvalidParams.With(fmt.Errorf("forkChoiceUpdateV1 called post-shanghai"))
}
}
// if api.eth.BlockChain().Config().IsShanghai(payloadAttributes.Timestamp) {
// 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.
func (api *ConsensusAPI) ForkchoiceUpdatedV2(update engine.ForkchoiceStateV1, payloadAttributes *engine.PayloadAttributes) (engine.ForkChoiceResponse, error) {
if payloadAttributes != nil {
if err := api.verifyPayloadAttributes(payloadAttributes); err != nil {
return engine.STATUS_INVALID, engine.InvalidParams.With(err)
}
}
// func (api *ConsensusAPI) ForkchoiceUpdatedV2(update engine.ForkchoiceStateV1, payloadAttributes *engine.PayloadAttributes) (engine.ForkChoiceResponse, error) {
// if payloadAttributes != nil {
// if err := api.verifyPayloadAttributes(payloadAttributes); err != nil {
// 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 {
if !api.eth.BlockChain().Config().IsShanghai(attr.Timestamp) {
// Reject payload attributes with withdrawals before shanghai
if attr.Withdrawals != nil {
return errors.New("withdrawals before shanghai")
}
} else {
// Reject payload attributes with nil withdrawals after shanghai
if attr.Withdrawals == nil {
return errors.New("missing withdrawals list")
}
}
// func (api *ConsensusAPI) verifyPayloadAttributes(attr *engine.PayloadAttributes) error {
// if !api.eth.BlockChain().Config().IsShanghai(attr.Timestamp) {
// // Reject payload attributes with withdrawals before shanghai
// if attr.Withdrawals != nil {
// return errors.New("withdrawals before shanghai")
// }
// } else {
// // Reject payload attributes with nil withdrawals after shanghai
// if attr.Withdrawals == nil {
// return errors.New("missing withdrawals list")
// }
// }
return nil
}
// return nil
// }
// nolint:gocognit
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)
}
// 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) {
if api.eth.BlockChain().Config().IsShanghai(params.Timestamp) {
if params.Withdrawals == nil {
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(fmt.Errorf("nil withdrawals post-shanghai"))
}
} else if params.Withdrawals != nil {
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(fmt.Errorf("non-nil withdrawals pre-shanghai"))
}
// // 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) {
// if api.eth.BlockChain().Config().IsShanghai(params.Timestamp) {
// if params.Withdrawals == nil {
// return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(fmt.Errorf("nil withdrawals post-shanghai"))
// }
// } else if params.Withdrawals != nil {
// 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) {
// 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
import (
"math/big"
"os"
"os/user"
"path/filepath"
@ -220,7 +221,7 @@ type Config struct {
// TODO marcello double check
// OverrideShanghai (TODO: remove after the fork)
OverrideShanghai *uint64 `toml:",omitempty"`
OverrideShanghai *big.Int `toml:",omitempty"`
// URL to connect to Heimdall node
HeimdallURL string

View file

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

View file

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

View file

@ -1425,18 +1425,18 @@ func overrideConfig(original *params.ChainConfig, override *params.ChainConfig)
canon = false
}
if timestamp := override.ShanghaiTime; timestamp != nil {
chainConfigCopy.ShanghaiTime = timestamp
if timestamp := override.ShanghaiBlock; timestamp != nil {
chainConfigCopy.ShanghaiBlock = timestamp
canon = false
}
if timestamp := override.CancunTime; timestamp != nil {
chainConfigCopy.CancunTime = timestamp
if timestamp := override.CancunBlock; timestamp != nil {
chainConfigCopy.CancunBlock = timestamp
canon = false
}
if timestamp := override.PragueTime; timestamp != nil {
chainConfigCopy.PragueTime = timestamp
if timestamp := override.PragueBlock; timestamp != nil {
chainConfigCopy.PragueBlock = timestamp
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))
pool.istanbul = pool.config.IsIstanbul(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

File diff suppressed because it is too large Load diff

View file

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

View file

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

View file

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