-
Notifications
You must be signed in to change notification settings - Fork 784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
block: fix the block body parsing as well as save/load from blockchain #3392
Conversation
@@ -43,14 +43,7 @@ function DBSetBlockOrHeader(blockBody: Block | BlockHeader): DBOp[] { | |||
|
|||
const isGenesis = header.number === BIGINT_0 | |||
|
|||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the optimization of not saving the body when there aren't non zero fields is not worth it compared to the body load complexity where we would push empty []
to resconstruct the body
@@ -107,40 +104,6 @@ export class DBManager { | |||
if (hash === undefined || number === undefined) return undefined | |||
const header = await this.getHeader(hash, number) | |||
const body = await this.getBody(hash, number) | |||
if (body[0].length === 0 && body[1].length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need this reconstruction now because we now just simply write the body array as is
@@ -217,10 +220,22 @@ export class Block { | |||
|
|||
// First try to load header so that we can use its common (in case of setHardfork being activated) | |||
// to correctly make checks on the hardforks | |||
const [headerData, txsData, uhsData, withdrawalBytes, requestBytes, executionWitnessBytes] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't do a simple assignment because this sequence is dependent on the eip activation
@@ -375,8 +375,8 @@ export class Blockchain implements BlockchainInterface { | |||
async getCanonicalHeadHeader(): Promise<BlockHeader> { | |||
return this.runWithLock<BlockHeader>(async () => { | |||
if (!this._headHeaderHash) throw new Error('No head header set') | |||
const block = await this.getBlock(this._headHeaderHash) | |||
return block.header | |||
const header = await this._getHeader(this._headHeaderHash) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
various fixes in this class to not refer block for header based functionality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
fixes the block body parsing and removes the body save optimization making the body load simple enough
tested kaustinen6 network and confimed working (so in general all post merge networks) as well as mainnet pow first few thousand blocks