Skip to content
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

Refactor beacon skeleton #1761

Merged
merged 3 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fluffy/eth_data/history_data_json_store.nim
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ proc getGenesisHeader*(id: NetworkId = MainNet): BlockHeader =

try:
toGenesisHeader(params)
except RlpError:
except RlpError, CatchableError:
raise (ref Defect)(msg: "Genesis should be valid")

# Reading JSON Portal content and content keys
Expand Down
6 changes: 3 additions & 3 deletions fluffy/network/history/history_network.nim
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ proc calcRootHash(items: Transactions | PortalReceipts | Withdrawals): Hash256 =
for i, item in items:
try:
tr.put(rlp.encode(i), item.asSeq())
except RlpError as e:
# TODO: Investigate this RlpError as it doesn't sound like this is
# something that can actually occur.
except CatchableError as e:
# tr.put now is a generic interface to whatever underlying db
# and it can raise exception if the backend db is something like aristo
raiseAssert(e.msg)

return tr.rootHash
Expand Down
7 changes: 3 additions & 4 deletions fluffy/tools/beacon_lc_bridge/beacon_lc_bridge.nim
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,8 @@ proc calculateTransactionData(
try:
let tx = distinctBase(t)
tr.put(rlp.encode(i), tx)
except RlpError as e:
# TODO: Investigate this RlpError as it doesn't sound like this is
# something that can actually occur.
except CatchableError as e:
# tr.put interface can raise exception
raiseAssert(e.msg)

return tr.rootHash()
Expand All @@ -218,7 +217,7 @@ proc calculateWithdrawalsRoot(
amount: distinctBase(w.amount)
)
tr.put(rlp.encode(i), rlp.encode(withdrawal))
except RlpError as e:
except CatchableError as e:
raiseAssert(e.msg)

return tr.rootHash()
Expand Down
17 changes: 8 additions & 9 deletions nimbus/db/storage_types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ type
finalizedHash
skeletonProgress
skeletonBlockHashToNumber
skeletonBlock
skeletonTransaction
skeletonHeader
skeletonBody
snapSyncAccount
snapSyncStorageSlot
snapSyncStateRoot
Expand Down Expand Up @@ -100,17 +100,16 @@ proc skeletonBlockHashToNumberKey*(h: Hash256): DbKey {.inline.} =
result.data[1 .. 32] = h.data
result.dataEndPos = uint8 32

proc skeletonBlockKey*(u: BlockNumber): DbKey {.inline.} =
result.data[0] = byte ord(skeletonBlock)
proc skeletonHeaderKey*(u: BlockNumber): DbKey {.inline.} =
result.data[0] = byte ord(skeletonHeader)
doAssert sizeof(u) <= 32
copyMem(addr result.data[1], unsafeAddr u, sizeof(u))
result.dataEndPos = uint8 sizeof(u)

proc skeletonTransactionKey*(u: BlockNumber): DbKey {.inline.} =
result.data[0] = byte ord(skeletonTransaction)
doAssert sizeof(u) <= 32
copyMem(addr result.data[1], unsafeAddr u, sizeof(u))
result.dataEndPos = uint8 sizeof(u)
proc skeletonBodyKey*(h: Hash256): DbKey {.inline.} =
result.data[0] = byte ord(skeletonBody)
result.data[1 .. 32] = h.data
result.dataEndPos = uint8 32

proc snapSyncAccountKey*(h: openArray[byte]): DbKey {.inline.} =
doAssert(h.len == 32)
Expand Down
Loading