From fc5763e4bf922c88a20021989827ab1b3cb5608f Mon Sep 17 00:00:00 2001 From: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Date: Fri, 12 Jul 2024 14:27:21 +0800 Subject: [PATCH] ChainConfig: update `DescartesBlock` to `DarwinTime` (#900) update chainconfig: DescartesBlock -> DarwinTime --- core/blockchain_test.go | 2 +- core/state_processor_test.go | 2 +- core/vm/interpreter.go | 4 ++-- core/vm/jump_table.go | 8 ++++---- core/vm/runtime/runtime.go | 2 +- eth/gasprice/gasprice_test.go | 2 +- params/config.go | 38 +++++++++++++++++------------------ 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/core/blockchain_test.go b/core/blockchain_test.go index 60a559650b..1f27d0ca2e 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -4727,7 +4727,7 @@ func TestCurieTransition(t *testing.T) { b, _ := json.Marshal(params.AllEthashProtocolChanges) json.Unmarshal(b, &config) config.CurieBlock = big.NewInt(2) - config.DescartesBlock = nil + config.DarwinTime = nil var ( db = rawdb.NewMemoryDatabase() diff --git a/core/state_processor_test.go b/core/state_processor_test.go index c314c2a15e..6359605c78 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -66,7 +66,7 @@ func TestStateProcessorErrors(t *testing.T) { CancunTime: new(uint64), BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0), - DescartesBlock: big.NewInt(0), + DarwinTime: new(uint64), } signer = types.LatestSigner(config) key1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index c9627ac693..c7cc6baede 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -56,8 +56,8 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter { // If jump table was not initialised we set the default one. var table *JumpTable switch { - case evm.chainRules.IsDescartes: - table = &descartesInstructionSet + case evm.chainRules.IsDarwin: + table = &darwinInstructionSet case evm.chainRules.IsCurie: table = &curieInstructionSet case evm.chainRules.IsCancun: diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go index 7a4abccb4f..0de81816e4 100644 --- a/core/vm/jump_table.go +++ b/core/vm/jump_table.go @@ -58,7 +58,7 @@ var ( shanghaiInstructionSet = newShanghaiInstructionSet() cancunInstructionSet = newCancunInstructionSet() curieInstructionSet = newCurieInstructionSet() - descartesInstructionSet = newDescartesInstructionSet() + darwinInstructionSet = newDarwinInstructionSet() ) // JumpTable contains the EVM opcodes supported at a given fork. @@ -82,9 +82,9 @@ func validate(jt JumpTable) JumpTable { return jt } -// newDescartesInstructionSet returns the frontier, homestead, byzantium, -// contantinople, istanbul, petersburg, berlin, london, shanghai, curie, and descartes instructions. -func newDescartesInstructionSet() JumpTable { +// newDarwinInstructionSet returns the frontier, homestead, byzantium, +// contantinople, istanbul, petersburg, berlin, london, shanghai, curie, and darwin instructions. +func newDarwinInstructionSet() JumpTable { instructionSet := newCurieInstructionSet() return instructionSet } diff --git a/core/vm/runtime/runtime.go b/core/vm/runtime/runtime.go index f42c3fcee6..e6e6d3f5d0 100644 --- a/core/vm/runtime/runtime.go +++ b/core/vm/runtime/runtime.go @@ -74,7 +74,7 @@ func setDefaults(cfg *Config) { ShanghaiTime: new(uint64), BernoulliBlock: new(big.Int), CurieBlock: new(big.Int), - DescartesBlock: new(big.Int), + DarwinTime: new(uint64), } } diff --git a/eth/gasprice/gasprice_test.go b/eth/gasprice/gasprice_test.go index 105b5f411b..6077e84511 100644 --- a/eth/gasprice/gasprice_test.go +++ b/eth/gasprice/gasprice_test.go @@ -142,11 +142,11 @@ func newTestBackend(t *testing.T, londonBlock *big.Int, pending bool) *testBacke config.ArchimedesBlock = londonBlock config.BernoulliBlock = londonBlock config.CurieBlock = londonBlock - config.DescartesBlock = londonBlock config.ShanghaiTime = nil if londonBlock != nil { shanghaiTime := londonBlock.Uint64() * 12 config.ShanghaiTime = &shanghaiTime + config.DarwinTime = &shanghaiTime } config.TerminalTotalDifficulty = common.Big0 diff --git a/params/config.go b/params/config.go index 4b59267411..5e0947f607 100644 --- a/params/config.go +++ b/params/config.go @@ -168,7 +168,7 @@ var ( ArchimedesBlock: big.NewInt(0), BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0), - DescartesBlock: big.NewInt(0), + DarwinTime: newUint64(0), Scroll: ScrollConfig{ UseZktrie: false, FeeVaultAddress: nil, @@ -204,7 +204,7 @@ var ( ArchimedesBlock: big.NewInt(2646311), BernoulliBlock: nil, CurieBlock: nil, - DescartesBlock: nil, + DarwinTime: nil, Clique: &CliqueConfig{ Period: 3, Epoch: 30000, @@ -242,7 +242,7 @@ var ( ArchimedesBlock: big.NewInt(0), BernoulliBlock: big.NewInt(3747132), CurieBlock: big.NewInt(4740239), - DescartesBlock: nil, + DarwinTime: nil, Clique: &CliqueConfig{ Period: 3, Epoch: 30000, @@ -280,7 +280,7 @@ var ( ArchimedesBlock: big.NewInt(0), BernoulliBlock: big.NewInt(5220340), CurieBlock: big.NewInt(7096836), - DescartesBlock: nil, + DarwinTime: nil, Clique: &CliqueConfig{ Period: 3, Epoch: 30000, @@ -351,7 +351,7 @@ var ( ArchimedesBlock: big.NewInt(0), BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0), - DescartesBlock: big.NewInt(0), + DarwinTime: newUint64(0), Scroll: ScrollConfig{ UseZktrie: false, FeeVaultAddress: nil, @@ -397,7 +397,7 @@ var ( ArchimedesBlock: big.NewInt(0), BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0), - DescartesBlock: big.NewInt(0), + DarwinTime: newUint64(0), Scroll: ScrollConfig{ UseZktrie: false, FeeVaultAddress: &common.Address{123}, @@ -441,7 +441,7 @@ var ( ArchimedesBlock: big.NewInt(0), BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0), - DescartesBlock: big.NewInt(0), + DarwinTime: newUint64(0), Scroll: ScrollConfig{ UseZktrie: false, FeeVaultAddress: nil, @@ -532,7 +532,6 @@ type ChainConfig struct { ArchimedesBlock *big.Int `json:"archimedesBlock,omitempty"` // Archimedes switch block (nil = no fork, 0 = already on archimedes) BernoulliBlock *big.Int `json:"bernoulliBlock,omitempty"` // Bernoulli switch block (nil = no fork, 0 = already on bernoulli) CurieBlock *big.Int `json:"curieBlock,omitempty"` // Curie switch block (nil = no fork, 0 = already on curie) - DescartesBlock *big.Int `json:"descartesBlock,omitempty"` // Descartes switch block (nil = no fork, 0 = already on descartes) // Fork scheduling was switched from blocks to timestamps here @@ -540,6 +539,7 @@ type ChainConfig struct { 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) VerkleTime *uint64 `json:"verkleTime,omitempty"` // Verkle switch time (nil = no fork, 0 = already on verkle) + DarwinTime *uint64 `json:"darwinTime,omitempty"` // Darwin switch time (nil = no fork, 0 = already on darwin) // TerminalTotalDifficulty is the amount of total difficulty reached by // the network that triggers the consensus upgrade. @@ -717,9 +717,6 @@ func (c *ChainConfig) Description() string { if c.CurieBlock != nil { banner += fmt.Sprintf(" - Curie: #%-8v\n", c.CurieBlock) // TODO: add Curie execution-specs } - if c.DescartesBlock != nil { - banner += fmt.Sprintf(" - Descartes: #%-8v\n", c.DescartesBlock) // TODO: add Descartes execution-specs - } banner += "\n" // Add a special section for the merge as it's non-obvious @@ -751,6 +748,9 @@ func (c *ChainConfig) Description() string { if c.VerkleTime != nil { banner += fmt.Sprintf(" - Verkle: @%-10v\n", *c.VerkleTime) } + if c.DarwinTime != nil { + banner += fmt.Sprintf(" - Darwin: @%-10v\n", *c.DarwinTime) + } banner += "\n" banner += "Scroll Config:\n" @@ -875,9 +875,9 @@ func (c *ChainConfig) IsCurie(num *big.Int) bool { return isBlockForked(c.CurieBlock, num) } -// IsDescartes returns whether num is either equal to the Descartes fork block or greater. -func (c *ChainConfig) IsDescartes(num *big.Int) bool { - return isBlockForked(c.DescartesBlock, num) +// IsDarwin returns whether num is either equal to the Darwin fork block or greater. +func (c *ChainConfig) IsDarwin(num *big.Int, time uint64) bool { + return c.IsLondon(num) && isTimestampForked(c.DarwinTime, time) } // CheckCompatible checks whether scheduled fork transitions have been imported @@ -939,7 +939,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error { {name: "bernoulliBlock", block: c.BernoulliBlock, optional: true}, {name: "shanghaiTime", timestamp: c.ShanghaiTime}, {name: "curieBlock", block: c.CurieBlock, optional: true}, - {name: "descartesBlock", block: c.DescartesBlock, optional: true}, + {name: "darwinTime", timestamp: c.DarwinTime, optional: true}, } { if lastFork.name != "" { switch { @@ -1058,8 +1058,8 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int, if isForkBlockIncompatible(c.CurieBlock, newcfg.CurieBlock, headNumber) { return newBlockCompatError("Curie fork block", c.CurieBlock, newcfg.CurieBlock) } - if isForkBlockIncompatible(c.DescartesBlock, newcfg.DescartesBlock, headNumber) { - return newBlockCompatError("Descartes fork block", c.DescartesBlock, newcfg.DescartesBlock) + if isForkTimestampIncompatible(c.DarwinTime, newcfg.DarwinTime, headTimestamp) { + return newTimestampCompatError("Darwin fork timestamp", c.DarwinTime, newcfg.DarwinTime) } return nil } @@ -1207,7 +1207,7 @@ type Rules struct { IsBerlin, IsLondon bool IsMerge, IsShanghai, IsCancun, IsPrague bool IsVerkle bool - IsArchimedes, IsBernoulli, IsCurie, IsDescartes bool + IsArchimedes, IsBernoulli, IsCurie, IsDarwin bool } // Rules ensures c's ChainID is not nil. @@ -1236,6 +1236,6 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules IsArchimedes: c.IsArchimedes(num), IsBernoulli: c.IsBernoulli(num), IsCurie: c.IsCurie(num), - IsDescartes: c.IsDescartes(num), + IsDarwin: c.IsDarwin(num, timestamp), } }