Skip to content

Commit

Permalink
Check for empty header payload
Browse files Browse the repository at this point in the history
  • Loading branch information
acolytec3 committed Feb 28, 2025
1 parent 4cefc9f commit 3a41ec8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/portalnetwork/src/networks/history/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,10 @@ export class HistoryNetwork extends BaseNetwork {

case HistoryNetworkContentType.EphemeralHeader: {
const payload = EphemeralHeaderPayload.deserialize(value)
if (payload.length === 0) {
this.logger.extend('STORE')('Received empty ephemeral header payload')
return
}
try {
// Verify first header matches requested header
const firstHeader = BlockHeader.fromRLPSerializedHeader(payload[0], { setHardfork: true })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ describe('should be able to retrieve ephemeral headers from a peer', () => {
assert.fail('Expected content in response')
}

// Verify that we get a single ancestor for a content key with an ancestor count of 1
const contentKeyForOneAncestor = getContentKey(HistoryNetworkContentType.EphemeralHeader, {
blockHash: headers[0].hash(),
ancestorCount: 1,
Expand Down Expand Up @@ -116,5 +117,5 @@ describe('should be able to retrieve ephemeral headers from a peer', () => {
} else {
assert.fail('Expected content in response')
}
}, 10000)
})
})

0 comments on commit 3a41ec8

Please sign in to comment.