@@ -209,39 +209,27 @@ export const reassembleBlock = (rawHeader: Uint8Array, rawBody?: Uint8Array) =>
209209 * @param rlpHex RLP encoded block as hex string
210210 * @param blockHash block hash as 0x prefixed hex string
211211 * @param network a running `PortalNetwork` client
212+ * @param proof the header proof anchoring the block to an accumulator
213+ * (i.e. pre-merge historical accumulator, historical_roots, or historical summaries)
212214 */
213215export const addRLPSerializedBlock = async (
214216 rlpHex : string ,
215217 blockHash : string ,
216218 network : HistoryNetwork ,
217- witnesses : Witnesses ,
219+ proof : Uint8Array ,
218220) => {
219221 const block = Block . fromRLPSerializedBlock ( hexToBytes ( rlpHex ) , {
220222 setHardfork : true ,
221223 } )
222224 const header = block . header
223225 const headerKey = getContentKey ( HistoryNetworkContentType . BlockHeader , hexToBytes ( blockHash ) )
224- const proof = AccumulatorProofType . serialize ( witnesses )
225- if ( header . number < MERGE_BLOCK ) {
226- const headerProof = BlockHeaderWithProof . serialize ( {
227- header : header . serialize ( ) ,
228- proof,
229- } )
230- try {
231- await network . validateHeader ( headerProof , { blockHash } )
232- } catch {
233- network . logger ( 'Header proof failed validation while loading block from RLP' )
234- }
235- await network . store ( headerKey , headerProof )
236- } else {
237- const headerProof = BlockHeaderWithProof . serialize ( {
238- header : header . serialize ( ) ,
239- proof,
240- } )
241- await network . indexBlockHash ( header . number , bytesToHex ( header . hash ( ) ) )
226+ const headerProof = BlockHeaderWithProof . serialize ( {
227+ header : header . serialize ( ) ,
228+ proof,
229+ } )
242230
243- await network . store ( headerKey , headerProof )
244- }
231+ await network . store ( headerKey , headerProof )
232+ await network . indexBlockHash ( header . number , bytesToHex ( header . hash ( ) ) )
245233 const sszBlock = sszEncodeBlockBody ( block )
246234 await network . addBlockBody ( sszBlock , header . hash ( ) , header . serialize ( ) )
247235}
0 commit comments