mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 05:14:14 +00:00
Beacon skeleton works with ttdPassed=true flag too (#1826)
This commit is contained in:
parent
ec08907f05
commit
c02c987b3e
@ -429,6 +429,9 @@ func daoForkSupport*(com: CommonRef): bool =
|
||||
func ttd*(com: CommonRef): Option[DifficultyInt] =
|
||||
com.config.terminalTotalDifficulty
|
||||
|
||||
func ttdPassed*(com: CommonRef): bool =
|
||||
com.config.terminalTotalDifficultyPassed.get(false)
|
||||
|
||||
# if you messing with clique period and
|
||||
# and epoch, it likely will fail clique verification
|
||||
# at epoch * blocknumber
|
||||
|
@ -49,8 +49,8 @@ proc new*(_: type SkeletonRef, chain: ChainRef): SkeletonRef =
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
proc open*(sk: SkeletonRef): Result[void, string] =
|
||||
if sk.chain.com.ttd.isNone:
|
||||
return err("Cannot create skeleton as ttd not set")
|
||||
if sk.chain.com.ttd.isNone and sk.chain.com.ttdPassed.not:
|
||||
return err("Cannot create skeleton as ttd and ttdPassed not set")
|
||||
sk.readProgress().isOkOr:
|
||||
return err(error)
|
||||
sk.started = getTime()
|
||||
|
@ -21,7 +21,28 @@ import
|
||||
../../nimbus/sync/beacon/skeleton_main,
|
||||
./setup_env
|
||||
|
||||
proc ccm(cc: NetworkParams) =
|
||||
proc noTtdAndNoTtdPassed(cc: NetworkParams) =
|
||||
cc.config.terminalTotalDifficultyPassed = none(bool)
|
||||
cc.config.terminalTotalDifficulty = none(UInt256)
|
||||
cc.genesis.difficulty = 1.u256
|
||||
|
||||
proc ttdPassedNoTtd(cc: NetworkParams) =
|
||||
cc.config.terminalTotalDifficultyPassed = some(true)
|
||||
cc.config.terminalTotalDifficulty = none(UInt256)
|
||||
cc.genesis.difficulty = 1.u256
|
||||
|
||||
proc ttdNoTtdPassed(cc: NetworkParams) =
|
||||
cc.config.terminalTotalDifficultyPassed = none(bool)
|
||||
cc.config.terminalTotalDifficulty = some(0.u256)
|
||||
cc.genesis.difficulty = 1.u256
|
||||
|
||||
proc ttdAndTtdPassed(cc: NetworkParams) =
|
||||
cc.config.terminalTotalDifficultyPassed = some(true)
|
||||
cc.config.terminalTotalDifficulty = some(0.u256)
|
||||
cc.genesis.difficulty = 1.u256
|
||||
|
||||
proc ttdPassedFalseNoTtd(cc: NetworkParams) =
|
||||
cc.config.terminalTotalDifficultyPassed = some(false)
|
||||
cc.config.terminalTotalDifficulty = none(UInt256)
|
||||
cc.genesis.difficulty = 1.u256
|
||||
|
||||
@ -35,11 +56,34 @@ proc skeletonMain*() =
|
||||
test7()
|
||||
test8()
|
||||
|
||||
suite "skeleton open should error if ttd not set":
|
||||
let env = setupEnv(extraValidation = true, ccm)
|
||||
let skel = SkeletonRef.new(env.chain)
|
||||
suite "test skeleton open":
|
||||
test "skeleton open should error if both ttd and ttdPassed not set":
|
||||
let env = setupEnv(extraValidation = true, noTtdAndNoTtdPassed)
|
||||
let skel = SkeletonRef.new(env.chain)
|
||||
let res = skel.open()
|
||||
check res.isErr
|
||||
|
||||
test "skel open error":
|
||||
test "skeleton open should ok if ttdPassed is set":
|
||||
let env = setupEnv(extraValidation = true, ttdPassedNoTtd)
|
||||
let skel = SkeletonRef.new(env.chain)
|
||||
let res = skel.open()
|
||||
check res.isOk
|
||||
|
||||
test "skeleton open should ok if ttd is set":
|
||||
let env = setupEnv(extraValidation = true, ttdNoTtdPassed)
|
||||
let skel = SkeletonRef.new(env.chain)
|
||||
let res = skel.open()
|
||||
check res.isOk
|
||||
|
||||
test "skeleton open should ok if both ttd and ttdPassed are set":
|
||||
let env = setupEnv(extraValidation = true, ttdAndTtdPassed)
|
||||
let skel = SkeletonRef.new(env.chain)
|
||||
let res = skel.open()
|
||||
check res.isOk
|
||||
|
||||
test "skeleton open should error if ttd not set and ttdPassed are false":
|
||||
let env = setupEnv(extraValidation = true, ttdPassedFalseNoTtd)
|
||||
let skel = SkeletonRef.new(env.chain)
|
||||
let res = skel.open()
|
||||
check res.isErr
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user