Skip to content

Commit

Permalink
update light client, beacon node, and testnet logic for epbs header c…
Browse files Browse the repository at this point in the history
…ompatibility
  • Loading branch information
Tomi-3-0 committed Dec 31, 2024
1 parent b62119b commit 25c31c2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion beacon_chain/beacon_node_light_client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ proc initLightClient*(
signedBlock: ForkedSignedBeaconBlock
): Future[void] {.async: (raises: [CancelledError]).} =
withBlck(signedBlock):
when consensusFork >= ConsensusFork.Bellatrix:
when consensusFork >= ConsensusFork.Bellatrix and consensusFork != ConsensusFork.Fulu:
if forkyBlck.message.is_execution_block:
template payload(): auto = forkyBlck.message.body.execution_payload
if not payload.block_hash.isZero:
Expand Down
3 changes: 2 additions & 1 deletion beacon_chain/nimbus_beacon_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,8 @@ proc pruneBlobs(node: BeaconNode, slot: Slot) =
for i in startIndex..<SLOTS_PER_EPOCH:
let blck = node.dag.getForkedBlock(blocks[int(i)]).valueOr: continue
withBlck(blck):
when typeof(forkyBlck).kind < ConsensusFork.Deneb: continue
when typeof(forkyBlck).kind < ConsensusFork.Deneb or
typeof(forkyBlck).kind == ConsensusFork.Fulu : continue
else:
for j in 0..len(forkyBlck.message.body.blob_kzg_commitments) - 1:
if node.db.delBlobSidecar(blocks[int(i)].root, BlobIndex(j)):
Expand Down
45 changes: 23 additions & 22 deletions ncli/ncli_testnet.nim
Original file line number Diff line number Diff line change
Expand Up @@ -324,23 +324,16 @@ func `as`(blk: BlockObject, T: type electra.ExecutionPayloadHeader): T =
excess_blob_gas: uint64 blk.excessBlobGas.getOrDefault())

func `as`(blk: BlockObject, T: type fulu.ExecutionPayloadHeader): T =
T(parent_hash: blk.parentHash as Eth2Digest,
fee_recipient: blk.miner as ExecutionAddress,
state_root: blk.stateRoot as Eth2Digest,
receipts_root: blk.receiptsRoot as Eth2Digest,
logs_bloom: BloomLogs(data: distinctBase(blk.logsBloom)),
prev_randao: Eth2Digest(data: blk.difficulty.toByteArrayBE),
block_number: uint64 blk.number,
T(
parent_block_hash: blk.parentHash as Eth2Digest,
# fee_recipient: blk.miner as ExecutionAddress,
parent_block_root: blk.stateRoot as Eth2Digest,
gas_limit: uint64 blk.gasLimit,
gas_used: uint64 blk.gasUsed,
timestamp: uint64 blk.timestamp,
extra_data: List[byte, MAX_EXTRA_DATA_BYTES].init(blk.extraData.bytes),
base_fee_per_gas: blk.baseFeePerGas.getOrDefault(),
block_hash: blk.hash as Eth2Digest,
transactions_root: blk.transactionsRoot as Eth2Digest,
withdrawals_root: blk.withdrawalsRoot.getOrDefault() as Eth2Digest,
blob_gas_used: uint64 blk.blobGasUsed.getOrDefault(),
excess_blob_gas: uint64 blk.excessBlobGas.getOrDefault())
builder_index: 0'u64,
slot: Slot(0),
value: Gwei(0'u64),
blob_kzg_commitments_root: KzgCommitments(@[])
)

func createDepositContractSnapshot(
deposits: seq[DepositData],
Expand Down Expand Up @@ -474,12 +467,20 @@ proc doCreateTestnet*(config: CliConfig,
info "SSZ genesis file written",
path = outSszGenesis, fork = kind(typeof initialState[])

SSZ.saveFile(
config.outputDepositTreeSnapshot.string,
createDepositContractSnapshot(
deposits,
genesisExecutionPayloadHeader.block_hash,
genesisExecutionPayloadHeader.block_number).getTreeSnapshot())
when genesisExecutionPayloadHeader is fulu.ExecutionPayloadHeader:
SSZ.saveFile(
config.outputDepositTreeSnapshot.string,
createDepositContractSnapshot(
deposits,
genesisExecutionPayloadHeader.block_hash,
0'u64).getTreeSnapshot())
else:
SSZ.saveFile(
config.outputDepositTreeSnapshot.string,
createDepositContractSnapshot(
deposits,
genesisExecutionPayloadHeader.block_hash,
genesisExecutionPayloadHeader.block_number).getTreeSnapshot())

initialState[].genesis_validators_root

Expand Down

0 comments on commit 25c31c2

Please sign in to comment.