Skip to content

Commit

Permalink
Engine API: Fix latestValidHash value when invalid timestamp detected
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko committed Nov 5, 2023
1 parent 19f313d commit 7de6199
Show file tree
Hide file tree
Showing 5 changed files with 235 additions and 255 deletions.
18 changes: 13 additions & 5 deletions hive_integration/nodocker/engine/clmock.nim
Original file line number Diff line number Diff line change
Expand Up @@ -438,14 +438,18 @@ proc broadcastNextNewPayload(cl: CLMocker): bool =
cl.executedPayloadHistory[number] = cl.latestPayloadBuilt
return true

proc broadcastForkchoiceUpdated(cl: CLMocker, eng: EngineEnv,
update: ForkchoiceStateV1): Result[ForkchoiceUpdatedResponse, string] =
let version = cl.latestExecutedPayload.version
proc broadcastForkchoiceUpdated(cl: CLMocker,
eng: EngineEnv,
version: Version,
update: ForkchoiceStateV1):
Result[ForkchoiceUpdatedResponse, string] =
eng.client.forkchoiceUpdated(version, update, none(PayloadAttributes))

proc broadcastLatestForkchoice(cl: CLMocker): bool =
proc broadcastForkchoiceUpdated*(cl: CLMocker,
version: Version,
update: ForkchoiceStateV1): bool =
for eng in cl.clients:
let res = cl.broadcastForkchoiceUpdated(eng, cl.latestForkchoice)
let res = cl.broadcastForkchoiceUpdated(eng, version, update)
if res.isErr:
error "CLMocker: broadcastForkchoiceUpdated Error", msg=res.error
return false
Expand Down Expand Up @@ -474,6 +478,10 @@ proc broadcastLatestForkchoice(cl: CLMocker): bool =

return true

proc broadcastLatestForkchoice(cl: CLMocker): bool =
let version = cl.latestExecutedPayload.version
cl.broadcastForkchoiceUpdated(version, cl.latestForkchoice)

func w3Address(x: int): Web3Address =
var res: array[20, byte]
res[^1] = x.byte
Expand Down
24 changes: 4 additions & 20 deletions hive_integration/nodocker/engine/engine/invalid_ancestor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,8 @@ method withMainFork(cs: InvalidMissingAncestorReOrgTest, fork: EngineFork): Base
return res

method getName(cs: InvalidMissingAncestorReOrgTest): string =
var desc = "Invalid Missing Ancestor ReOrg Invalid" & $cs.invalidField

if cs.emptyTransactions:
desc.add ", Empty Txs"

desc.add ", Invalid P" & $cs.invalidIndex & "'"
desc
"Invalid Missing Ancestor ReOrg, $1, EmptyTxs=$2, Invalid P$3" % [
$cs.invalidField, $cs.emptyTransactions, $cs.invalidIndex]

method execute(cs: InvalidMissingAncestorReOrgTest, env: TestEnv): bool =
# Wait until TTD is reached by this client
Expand Down Expand Up @@ -186,25 +181,14 @@ type
# or start chain (if specified).
reOrgFromCanonical*: bool


method withMainFork(cs: InvalidMissingAncestorReOrgSyncTest, fork: EngineFork): BaseSpec =
var res = cs.clone()
res.mainFork = fork
return res

method getName(cs: InvalidMissingAncestorReOrgSyncTest): string =
var name = "Invalid Missing Ancestor ReOrg"
name.add ", Invalid " & $cs.invalidField

if cs.emptyTransactions:
name.add ", Empty Txs"

name.add ", Invalid P" & $cs.invalidIndex & "'"
name.add ", Reveal using sync"

if cs.reOrgFromCanonical:
name.add ", ReOrg from Canonical"
return name
"Invalid Missing Ancestor Syncing ReOrg, $1, EmptyTxs=$2, CanonicalReOrg=$3, Invalid P$4" % [
$cs.invalidField, $cs.emptyTransactions, $cs.reOrgFromCanonical, $cs.invalidIndex]

method execute(cs: InvalidMissingAncestorReOrgSyncTest, env: TestEnv): bool =
var sec = env.addEngine(true, cs.reOrgFromCanonical)
Expand Down
Loading

0 comments on commit 7de6199

Please sign in to comment.