Skip to content

Commit 3a41ec8

Browse files
committed
Check for empty header payload
1 parent 4cefc9f commit 3a41ec8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,10 @@ export class HistoryNetwork extends BaseNetwork {
566566

567567
case HistoryNetworkContentType.EphemeralHeader: {
568568
const payload = EphemeralHeaderPayload.deserialize(value)
569+
if (payload.length === 0) {
570+
this.logger.extend('STORE')('Received empty ephemeral header payload')
571+
return
572+
}
569573
try {
570574
// Verify first header matches requested header
571575
const firstHeader = BlockHeader.fromRLPSerializedHeader(payload[0], { setHardfork: true })

packages/portalnetwork/test/integration/ephemeralHeaders.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ describe('should be able to retrieve ephemeral headers from a peer', () => {
8787
assert.fail('Expected content in response')
8888
}
8989

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

0 commit comments

Comments
 (0)