Skip to content

Commit 14c804b

Browse files
committed
Finish out post capella block header verification
1 parent 626d09a commit 14c804b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/cli/scripts/postCapellaBlockBridge.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ const main = async () => {
148148
beaconBlockRoot: bytesToHex(ssz[blockFork].BeaconBlock.value_toTree(fullBlock).root),
149149
})
150150
const execPayload = executionPayloadFromBeaconPayload(fullBlockJson.data.message.body.execution_payload)
151+
execPayload['number'] = execPayload.blockNumber
151152
const header = BlockHeader.fromHeaderData(execPayload, { common: new Common({ chain: 'mainnet', hardfork: 'cancun' }) })
152153
const headerWithProof = BlockHeaderWithProof.serialize({
153154
header: header.serialize(),

packages/portalnetwork/src/networks/history/history.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import type { ENR } from '@chainsafe/enr'
3131
import type { Debugger } from 'debug'
3232
import type { BaseNetworkConfig, ContentLookupResponse, FindContentMessage } from '../../index.js'
3333
import { RunStatusCode } from '@lodestar/light-client'
34+
3435
export class HistoryNetwork extends BaseNetwork {
3536
networkId: NetworkId.HistoryNetwork
3637
networkName = 'HistoryNetwork'
@@ -182,17 +183,15 @@ export class HistoryNetwork extends BaseNetwork {
182183
}
183184
}
184185
else {
186+
// TODO: Check proof slot to ensure header is from previous sync period and handle ephemeral headers separately
185187
if (proof.value === null) {
186188
this.logger('Received post-merge block without proof')
187189
}
188190
const beacon = this.portal.network()['0x500c']
189191
if (beacon !== undefined && beacon.lightClient?.status === RunStatusCode.started) {
190-
// TODO: Determine how to only require proofs for blocsk from previous sync periods
191-
// We don't currently have a mapping of EL block numbers to slots so cannot determine precisely
192-
// if a given EL block is from a previous period or not
193-
// TODO: Add handlng for ephemeral blocks in the current sync period
194192
try {
195193
verifyPostCapellaHeaderProof(proof.value as any, header.hash(), beacon.historicalSummaries, beacon.beaconConfig)
194+
this.logger(`Successfully verified proof for block header ${header.number}`)
196195
} catch {
197196
this.logger('Received post-capella block header with invalid proof')
198197
// TODO: throw new Error('Received post-merge block header with invalid proof')

0 commit comments

Comments
 (0)