mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 21:34:33 +00:00
Remove MergeForkBlock alias and use MergeNetSplitBlock only (#2947)
This commit is contained in:
parent
f8a6ed4f5f
commit
b8932d9519
@ -70,7 +70,7 @@ type
|
|||||||
# - `EthTime` uses std/times while chronos Moment is sufficient and more
|
# - `EthTime` uses std/times while chronos Moment is sufficient and more
|
||||||
# sensible
|
# sensible
|
||||||
ChainConfig* = object
|
ChainConfig* = object
|
||||||
mergeForkBlock*: uint64
|
mergeNetsplitBlock*: uint64
|
||||||
shanghaiTime*: Opt[Moment]
|
shanghaiTime*: Opt[Moment]
|
||||||
cancunTime*: Opt[Moment]
|
cancunTime*: Opt[Moment]
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ const
|
|||||||
mergeBlockNumber* {.intdefine.}: uint64 = 15537394
|
mergeBlockNumber* {.intdefine.}: uint64 = 15537394
|
||||||
|
|
||||||
chainConfig* = ChainConfig(
|
chainConfig* = ChainConfig(
|
||||||
mergeForkBlock: mergeBlockNumber,
|
mergeNetsplitBlock: mergeBlockNumber,
|
||||||
shanghaiTime: Opt.some(Moment.init(1681338455'i64, Second)),
|
shanghaiTime: Opt.some(Moment.init(1681338455'i64, Second)),
|
||||||
cancunTime: Opt.none(Moment),
|
cancunTime: Opt.none(Moment),
|
||||||
)
|
)
|
||||||
@ -93,7 +93,7 @@ func isTimestampForked(forkTime: Opt[Moment], timestamp: Moment): bool =
|
|||||||
forkTime.get() <= timestamp
|
forkTime.get() <= timestamp
|
||||||
|
|
||||||
func isPoSBlock*(c: ChainConfig, blockNumber: uint64): bool =
|
func isPoSBlock*(c: ChainConfig, blockNumber: uint64): bool =
|
||||||
c.mergeForkBlock <= blockNumber
|
c.mergeNetsplitBlock <= blockNumber
|
||||||
|
|
||||||
func isShanghai*(c: ChainConfig, timestamp: Moment): bool =
|
func isShanghai*(c: ChainConfig, timestamp: Moment): bool =
|
||||||
isTimestampForked(c.shanghaiTime, timestamp)
|
isTimestampForked(c.shanghaiTime, timestamp)
|
||||||
|
@ -40,7 +40,7 @@ method getForkConfig*(cs: ForkIDSpec): ChainConfig =
|
|||||||
# Merge fork happen at block 0
|
# Merge fork happen at block 0
|
||||||
let mainFork = cs.getMainFork()
|
let mainFork = cs.getMainFork()
|
||||||
if mainFork == ForkParis:
|
if mainFork == ForkParis:
|
||||||
forkConfig.mergeForkBlock = Opt.some(0'u64)
|
forkConfig.mergeNetsplitBlock = Opt.some(0'u64)
|
||||||
return forkConfig
|
return forkConfig
|
||||||
|
|
||||||
method execute(cs: ForkIDSpec, env: TestEnv): bool =
|
method execute(cs: ForkIDSpec, env: TestEnv): bool =
|
||||||
|
@ -31,7 +31,7 @@ method getForkConfig*(cs: NonZeroPreMergeFork): ChainConfig =
|
|||||||
|
|
||||||
# Merge fork & pre-merge happen at block 1
|
# Merge fork & pre-merge happen at block 1
|
||||||
forkConfig.londonBlock = Opt.some(1'u64)
|
forkConfig.londonBlock = Opt.some(1'u64)
|
||||||
forkConfig.mergeForkBlock = Opt.some(1'u64)
|
forkConfig.mergeNetsplitBlock = Opt.some(1'u64)
|
||||||
|
|
||||||
# Post-merge fork happens at block 2
|
# Post-merge fork happens at block 2
|
||||||
let mainFork = BaseSpec(cs).getMainFork()
|
let mainFork = BaseSpec(cs).getMainFork()
|
||||||
|
@ -307,10 +307,6 @@ func toHardFork*(map: ForkTransitionTable, forkDeterminer: ForkDeterminationInfo
|
|||||||
proc validateChainConfig*(conf: ChainConfig): bool =
|
proc validateChainConfig*(conf: ChainConfig): bool =
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
if conf.mergeNetsplitBlock.isSome:
|
|
||||||
# geth compatibility
|
|
||||||
conf.mergeForkBlock = conf.mergeNetsplitBlock
|
|
||||||
|
|
||||||
# FIXME: factor this to remove the duplication between the
|
# FIXME: factor this to remove the duplication between the
|
||||||
# block-based ones and the time-based ones.
|
# block-based ones and the time-based ones.
|
||||||
|
|
||||||
@ -491,7 +487,7 @@ func chainConfigForNetwork*(id: NetworkId): ChainConfig =
|
|||||||
muirGlacierBlock: Opt.some(0.BlockNumber),
|
muirGlacierBlock: Opt.some(0.BlockNumber),
|
||||||
berlinBlock: Opt.some(0.BlockNumber),
|
berlinBlock: Opt.some(0.BlockNumber),
|
||||||
londonBlock: Opt.some(0.BlockNumber),
|
londonBlock: Opt.some(0.BlockNumber),
|
||||||
mergeForkBlock: Opt.some(1450409.BlockNumber),
|
mergeNetsplitBlock: Opt.some(1450409.BlockNumber),
|
||||||
terminalTotalDifficulty: Opt.some(sepoliaTTD),
|
terminalTotalDifficulty: Opt.some(sepoliaTTD),
|
||||||
shanghaiTime: Opt.some(1_677_557_088.EthTime),
|
shanghaiTime: Opt.some(1_677_557_088.EthTime),
|
||||||
cancunTime: Opt.some(1_706_655_072.EthTime), # 2024-01-30 22:51:12
|
cancunTime: Opt.some(1_706_655_072.EthTime), # 2024-01-30 22:51:12
|
||||||
@ -512,7 +508,7 @@ func chainConfigForNetwork*(id: NetworkId): ChainConfig =
|
|||||||
istanbulBlock: Opt.some(0.BlockNumber),
|
istanbulBlock: Opt.some(0.BlockNumber),
|
||||||
berlinBlock: Opt.some(0.BlockNumber),
|
berlinBlock: Opt.some(0.BlockNumber),
|
||||||
londonBlock: Opt.some(0.BlockNumber),
|
londonBlock: Opt.some(0.BlockNumber),
|
||||||
mergeForkBlock: Opt.some(0.BlockNumber),
|
mergeNetsplitBlock: Opt.some(0.BlockNumber),
|
||||||
terminalTotalDifficulty: Opt.some(0.u256),
|
terminalTotalDifficulty: Opt.some(0.u256),
|
||||||
shanghaiTime: Opt.some(1_696_000_704.EthTime),
|
shanghaiTime: Opt.some(1_696_000_704.EthTime),
|
||||||
cancunTime: Opt.some(1_707_305_664.EthTime), # 2024-02-07 11:34:24
|
cancunTime: Opt.some(1_707_305_664.EthTime), # 2024-02-07 11:34:24
|
||||||
|
@ -336,8 +336,8 @@ proc proofOfStake*(com: CommonRef, header: Header): bool =
|
|||||||
if com.config.posBlock.isSome:
|
if com.config.posBlock.isSome:
|
||||||
# see comments of posBlock in common/hardforks.nim
|
# see comments of posBlock in common/hardforks.nim
|
||||||
header.number >= com.config.posBlock.get
|
header.number >= com.config.posBlock.get
|
||||||
elif com.config.mergeForkBlock.isSome:
|
elif com.config.mergeNetsplitBlock.isSome:
|
||||||
header.number >= com.config.mergeForkBlock.get
|
header.number >= com.config.mergeNetsplitBlock.get
|
||||||
else:
|
else:
|
||||||
# This costly check is only executed from test suite
|
# This costly check is only executed from test suite
|
||||||
com.isBlockAfterTtd(header)
|
com.isBlockAfterTtd(header)
|
||||||
|
@ -163,11 +163,8 @@ type
|
|||||||
posBlock*
|
posBlock*
|
||||||
{.dontSerialize.} : Opt[BlockNumber]
|
{.dontSerialize.} : Opt[BlockNumber]
|
||||||
|
|
||||||
# mergeNetsplitBlock is an alias to mergeForkBlock
|
|
||||||
# and is used for geth compatibility layer
|
|
||||||
mergeNetsplitBlock* : Opt[BlockNumber]
|
mergeNetsplitBlock* : Opt[BlockNumber]
|
||||||
|
|
||||||
mergeForkBlock* : Opt[BlockNumber]
|
|
||||||
shanghaiTime* : Opt[EthTime]
|
shanghaiTime* : Opt[EthTime]
|
||||||
cancunTime* : Opt[EthTime]
|
cancunTime* : Opt[EthTime]
|
||||||
pragueTime* : Opt[EthTime]
|
pragueTime* : Opt[EthTime]
|
||||||
@ -194,11 +191,7 @@ func countTimeFields(): int {.compileTime.} =
|
|||||||
func countBlockFields(): int {.compileTime.} =
|
func countBlockFields(): int {.compileTime.} =
|
||||||
var z = ChainConfig()
|
var z = ChainConfig()
|
||||||
for name, _ in fieldPairs(z[]):
|
for name, _ in fieldPairs(z[]):
|
||||||
if name == "mergeNetsplitBlock":
|
if name.endsWith("Block"):
|
||||||
# skip mergeForkBlock alias
|
|
||||||
# continue is not supported
|
|
||||||
discard
|
|
||||||
elif name.endsWith("Block"):
|
|
||||||
inc result
|
inc result
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -217,11 +210,7 @@ func collectBlockFields(): array[blockFieldsCount, string] =
|
|||||||
var z = ChainConfig()
|
var z = ChainConfig()
|
||||||
var i = 0
|
var i = 0
|
||||||
for name, _ in fieldPairs(z[]):
|
for name, _ in fieldPairs(z[]):
|
||||||
if name == "mergeNetsplitBlock":
|
if name.endsWith("Block"):
|
||||||
# skip mergeForkBlock alias
|
|
||||||
# continue is not supported
|
|
||||||
discard
|
|
||||||
elif name.endsWith("Block"):
|
|
||||||
result[i] = name
|
result[i] = name
|
||||||
inc i
|
inc i
|
||||||
|
|
||||||
@ -235,7 +224,7 @@ const
|
|||||||
|
|
||||||
func mergeForkTransitionThreshold*(conf: ChainConfig): MergeForkTransitionThreshold =
|
func mergeForkTransitionThreshold*(conf: ChainConfig): MergeForkTransitionThreshold =
|
||||||
MergeForkTransitionThreshold(
|
MergeForkTransitionThreshold(
|
||||||
number: conf.mergeForkBlock,
|
number: conf.mergeNetsplitBlock,
|
||||||
ttd: conf.terminalTotalDifficulty,
|
ttd: conf.terminalTotalDifficulty,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -280,7 +269,7 @@ func populateFromForkTransitionTable*(conf: ChainConfig, t: ForkTransitionTable)
|
|||||||
conf.arrowGlacierBlock = t.blockNumberThresholds[HardFork.ArrowGlacier]
|
conf.arrowGlacierBlock = t.blockNumberThresholds[HardFork.ArrowGlacier]
|
||||||
conf.grayGlacierBlock = t.blockNumberThresholds[HardFork.GrayGlacier]
|
conf.grayGlacierBlock = t.blockNumberThresholds[HardFork.GrayGlacier]
|
||||||
|
|
||||||
conf.mergeForkBlock = t.mergeForkTransitionThreshold.number
|
conf.mergeNetsplitBlock = t.mergeForkTransitionThreshold.number
|
||||||
conf.terminalTotalDifficulty = t.mergeForkTransitionThreshold.ttd
|
conf.terminalTotalDifficulty = t.mergeForkTransitionThreshold.ttd
|
||||||
|
|
||||||
conf.shanghaiTime = t.timeThresholds[HardFork.Shanghai]
|
conf.shanghaiTime = t.timeThresholds[HardFork.Shanghai]
|
||||||
|
@ -96,7 +96,7 @@ func config(shanghai, cancun: uint64): ChainConfig =
|
|||||||
berlinBlock: Opt.some(0'u64),
|
berlinBlock: Opt.some(0'u64),
|
||||||
londonBlock: Opt.some(0'u64),
|
londonBlock: Opt.some(0'u64),
|
||||||
terminalTotalDifficulty: Opt.some(0.u256),
|
terminalTotalDifficulty: Opt.some(0.u256),
|
||||||
mergeForkBlock: Opt.some(0'u64),
|
mergeNetsplitBlock: Opt.some(0'u64),
|
||||||
shanghaiTime: Opt.some(shanghai.EthTime),
|
shanghaiTime: Opt.some(shanghai.EthTime),
|
||||||
cancunTime: Opt.some(cancun.EthTime),
|
cancunTime: Opt.some(cancun.EthTime),
|
||||||
)
|
)
|
||||||
|
@ -109,7 +109,6 @@ proc customGenesisTest() =
|
|||||||
check com.proofOfStake(com.genesisHeader) == false
|
check com.proofOfStake(com.genesisHeader) == false
|
||||||
check cg.config.mergeNetsplitBlock.isSome
|
check cg.config.mergeNetsplitBlock.isSome
|
||||||
check cg.config.mergeNetsplitBlock.get == 14660963.BlockNumber
|
check cg.config.mergeNetsplitBlock.get == 14660963.BlockNumber
|
||||||
check cg.config.mergeNetsplitBlock == cg.config.mergeForkBlock
|
|
||||||
|
|
||||||
test "Holesky":
|
test "Holesky":
|
||||||
var cg: NetworkParams
|
var cg: NetworkParams
|
||||||
|
@ -113,7 +113,7 @@ proc initEnv(envFork: HardFork): TestEnv =
|
|||||||
conf.networkParams.genesis.alloc[recipient] = GenesisAccount(code: contractCode)
|
conf.networkParams.genesis.alloc[recipient] = GenesisAccount(code: contractCode)
|
||||||
|
|
||||||
if envFork >= MergeFork:
|
if envFork >= MergeFork:
|
||||||
conf.networkParams.config.mergeForkBlock = Opt.some(0'u64)
|
conf.networkParams.config.mergeNetsplitBlock = Opt.some(0'u64)
|
||||||
conf.networkParams.config.terminalTotalDifficulty = Opt.some(100.u256)
|
conf.networkParams.config.terminalTotalDifficulty = Opt.some(100.u256)
|
||||||
|
|
||||||
if envFork >= Shanghai:
|
if envFork >= Shanghai:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user