Skip to content

Commit

Permalink
Remove totalTerminalDifficultyPassed (#2934)
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko authored Dec 13, 2024
1 parent 2e5ef4f commit a57958f
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 23 deletions.
6 changes: 2 additions & 4 deletions hive_integration/nodocker/engine/engine_tests.nim
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ import
./engine/misc,
./engine/rpc

proc getGenesis(cs: EngineSpec, param: NetworkParams) =
proc getGenesis(cs: EngineSpec, param: NetworkParams) =
# Set the terminal total difficulty
let realTTD = param.genesis.difficulty + cs.ttd.u256
param.config.terminalTotalDifficulty = Opt.some(realTTD)
if param.genesis.difficulty <= realTTD:
param.config.terminalTotalDifficultyPassed = Opt.some(true)

# Set the genesis timestamp if provided
if cs.genesisTimestamp != 0:
Expand All @@ -58,7 +56,7 @@ proc executeEngineSpec*(ws: BaseSpec): bool =
ws.getGenesisFn(ws, conf.networkParams)
else:
cs.getGenesis(conf.networkParams)

let env = TestEnv.new(conf)
env.engine.setRealTTD()
env.setupCLMock()
Expand Down
1 change: 0 additions & 1 deletion nimbus/common/chain_config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@ func chainConfigForNetwork*(id: NetworkId): ChainConfig =
londonBlock: Opt.some(0.BlockNumber),
mergeForkBlock: Opt.some(0.BlockNumber),
terminalTotalDifficulty: Opt.some(0.u256),
terminalTotalDifficultyPassed: Opt.some(true),
shanghaiTime: Opt.some(1_696_000_704.EthTime),
cancunTime: Opt.some(1_707_305_664.EthTime), # 2024-02-07 11:34:24
depositContractAddress: Opt.some(HOLESKYNET_DEPOSIT_CONTRACT_ADDRESS),
Expand Down
3 changes: 0 additions & 3 deletions nimbus/common/common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,6 @@ func daoForkSupport*(com: CommonRef): bool =
func ttd*(com: CommonRef): Opt[DifficultyInt] =
com.config.terminalTotalDifficulty

func ttdPassed*(com: CommonRef): bool =
com.config.terminalTotalDifficultyPassed.get(false)

func pruneHistory*(com: CommonRef): bool =
com.pruneHistory

Expand Down
10 changes: 2 additions & 8 deletions nimbus/common/hardforks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ type
MergeForkTransitionThreshold* = object
number*: Opt[BlockNumber]
ttd*: Opt[DifficultyInt]
ttdPassed*: Opt[bool]

ForkTransitionTable* = object
blockNumberThresholds*: array[Frontier..GrayGlacier, Opt[BlockNumber]]
Expand Down Expand Up @@ -121,11 +120,9 @@ func isGTETransitionThreshold*(map: ForkTransitionTable, forkDeterminer: ForkDet
map.blockNumberThresholds[fork].isSome and forkDeterminer.number >= map.blockNumberThresholds[fork].get
elif fork == MergeFork:
# MergeFork is a special case that can use either block number or ttd;
# ttdPassed > block number > ttd takes precedence.
# block number > ttd takes precedence.
let t = map.mergeForkTransitionThreshold
if t.ttdPassed.isSome:
t.ttdPassed.get
elif t.number.isSome:
if t.number.isSome:
forkDeterminer.number >= t.number.get
elif t.ttd.isSome and forkDeterminer.td.isSome:
forkDeterminer.td.get >= t.ttd.get
Expand Down Expand Up @@ -177,7 +174,6 @@ type
osakaTime* : Opt[EthTime]

terminalTotalDifficulty*: Opt[UInt256]
terminalTotalDifficultyPassed*: Opt[bool]
depositContractAddress*: Opt[Address]

# These are used for checking that the values of the fields
Expand Down Expand Up @@ -241,7 +237,6 @@ func mergeForkTransitionThreshold*(conf: ChainConfig): MergeForkTransitionThresh
MergeForkTransitionThreshold(
number: conf.mergeForkBlock,
ttd: conf.terminalTotalDifficulty,
ttdPassed: conf.terminalTotalDifficultyPassed
)

func toForkTransitionTable*(conf: ChainConfig): ForkTransitionTable =
Expand Down Expand Up @@ -287,7 +282,6 @@ func populateFromForkTransitionTable*(conf: ChainConfig, t: ForkTransitionTable)

conf.mergeForkBlock = t.mergeForkTransitionThreshold.number
conf.terminalTotalDifficulty = t.mergeForkTransitionThreshold.ttd
conf.terminalTotalDifficultyPassed = t.mergeForkTransitionThreshold.ttdPassed

conf.shanghaiTime = t.timeThresholds[HardFork.Shanghai]
conf.cancunTime = t.timeThresholds[HardFork.Cancun]
Expand Down
1 change: 0 additions & 1 deletion tests/customgenesis/cancun123.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"berlinBlock": 0,
"londonBlock": 0,
"terminalTotalDifficulty": 0,
"terminalTotalDifficultyPassed": true,
"shanghaiTime": 0,
"cancunTime": 0
},
Expand Down
3 changes: 1 addition & 2 deletions tests/customgenesis/engine_api_genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"berlinBlock": 0,
"londonBlock": 0,
"mergeNetsplitBlock": 0,
"terminalTotalDifficulty": 0,
"terminalTotalDifficultyPassed": true,
"terminalTotalDifficulty": 0
},
"alloc": {
"0x0000000000000000000000000000000000000000": {
Expand Down
1 change: 0 additions & 1 deletion tests/customgenesis/geth_holesky.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"londonBlock": 0,
"mergeNetsplitBlock": 0,
"terminalTotalDifficulty": 0,
"terminalTotalDifficultyPassed": true,
"shanghaiTime": 1696000704
},
"alloc": {
Expand Down
1 change: 0 additions & 1 deletion tests/customgenesis/holesky.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"londonBlock": 0,
"mergeForkBlock": 0,
"terminalTotalDifficulty": 0,
"terminalTotalDifficultyPassed": true,
"shanghaiTime": 1696000704
},
"genesis": {
Expand Down
1 change: 0 additions & 1 deletion tests/customgenesis/mekong.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"londonBlock": 0,
"mergeNetsplitBlock": 0,
"terminalTotalDifficulty": 0,
"terminalTotalDifficultyPassed": true,
"shanghaiTime": 0,
"cancunTime": 0,
"depositContractAddress": "0x4242424242424242424242424242424242424242",
Expand Down
1 change: 0 additions & 1 deletion tests/test_forkid.nim
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func config(shanghai, cancun: uint64): ChainConfig =
berlinBlock: Opt.some(0'u64),
londonBlock: Opt.some(0'u64),
terminalTotalDifficulty: Opt.some(0.u256),
terminalTotalDifficultyPassed: Opt.some(true),
mergeForkBlock: Opt.some(0'u64),
shanghaiTime: Opt.some(shanghai.EthTime),
cancunTime: Opt.some(cancun.EthTime),
Expand Down

0 comments on commit a57958f

Please sign in to comment.