-
Notifications
You must be signed in to change notification settings - Fork 128
fCU early notification of finalized hash to FC. #3204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
420ba07
fCU early notification of finalized hash to FC.
jangko 2a3e973
Merge branch 'master' into fcu-fc-notify
jangko b2cfe44
Merge branch 'master' into fcu-fc-notify
jangko d71dd20
Merge branch 'master' into fcu-fc-notify
jangko 0d031bd
Refine fcu head, safe, and finalized hash in FC, engine API, and RPC
jangko cbe96b8
c.latestFinalizedBlockNumber = max(blk.header.number, c.latestFinaliz…
jangko b2b74e9
Update forked_chain test
jangko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# nimbus-execution-client | ||
# Copyright (c) 2025 Status Research & Development GmbH | ||
# Licensed under either of | ||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE)) | ||
# * MIT license ([LICENSE-MIT](LICENSE-MIT)) | ||
# at your option. | ||
# This file may not be copied, modified, or distributed except according to | ||
# those terms. | ||
|
||
{.push raises: [].} | ||
|
||
import | ||
eth/common/hashes, | ||
stew/endians2, | ||
stew/assign2, | ||
results, | ||
./core_db/base, | ||
./storage_types | ||
|
||
type | ||
FcuHashAndNumber* = object | ||
hash*: Hash32 | ||
number*: uint64 | ||
|
||
const | ||
headKey = fcuKey 0 | ||
finKey = fcuKey 1 | ||
safeKey = fcuKey 2 | ||
DataLen = sizeof(Hash32) + sizeof(uint64) | ||
|
||
template fcuReadImpl(key: DbKey, name: string): auto = | ||
let data = db.getOrEmpty(key.toOpenArray).valueOr: | ||
return err($error) | ||
if data.len != DataLen: | ||
return err("no " & name & " block hash and number") | ||
ok(FcuHashAndNumber( | ||
hash: Hash32.copyFrom(data.toOpenArray(sizeof(uint64), data.len-1)), | ||
number: uint64.fromBytesBE(data), | ||
)) | ||
|
||
template fcuWriteImpl(key: DbKey, hash: Hash32, number: uint64): auto = | ||
var data: array[DataLen, byte] | ||
assign(data.toOpenArray(0, sizeof(uint64)-1), number.toBytesBE) | ||
assign(data.toOpenArray(sizeof(uint64), data.len-1), hash.data) | ||
db.put(key.toOpenArray, data).isOkOr: | ||
return err($error) | ||
ok() | ||
|
||
proc fcuHead*(db: CoreDbTxRef): Result[FcuHashAndNumber, string] = | ||
fcuReadImpl(headKey, "head") | ||
|
||
proc fcuHead*(db: CoreDbTxRef, hash: Hash32, number: uint64): Result[void, string] = | ||
fcuWriteImpl(headKey, hash, number) | ||
|
||
template fcuHead*(db: CoreDbTxRef, head: FcuHashAndNumber): auto = | ||
fcuHead(db, head.hash, head.number) | ||
|
||
proc fcuFinalized*(db: CoreDbTxRef): Result[FcuHashAndNumber, string] = | ||
fcuReadImpl(finKey, "finalized") | ||
|
||
proc fcuFinalized*(db: CoreDbTxRef, hash: Hash32, number: uint64): Result[void, string] = | ||
fcuWriteImpl(finKey, hash, number) | ||
|
||
template fcuFinalized*(db: CoreDbTxRef, finalized: FcuHashAndNumber): auto = | ||
fcuFinalized(db, finalized.hash, finalized.number) | ||
|
||
proc fcuSafe*(db: CoreDbTxRef): Result[FcuHashAndNumber, string] = | ||
fcuReadImpl(safeKey, "safe") | ||
|
||
proc fcuSafe*(db: CoreDbTxRef, hash: Hash32, number: uint64): Result[void, string] = | ||
fcuWriteImpl(safeKey, hash, number) | ||
|
||
template fcuSafe*(db: CoreDbTxRef, safe: FcuHashAndNumber): auto = | ||
fcuSafe(db, safe.hash, safe.number) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should also update
latestFinalizedBlockNumber
withmax(latestFinalizedBlockNumber, newNumber)
..also, should set
latestFCU
even if we can't find the numberThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cbe96b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not quite done here: need to look up the block number of
update.finalizedBlockHash
in the quarantine - the syncer will not do it if it's already syncing something else.