Skip to content
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

BlockBody Encoding #509

Merged
merged 10 commits into from
Nov 8, 2023
Merged

BlockBody Encoding #509

merged 10 commits into from
Nov 8, 2023

Conversation

ScottyPoi
Copy link
Collaborator

After the addition of withdrawals to the block body in the EIP-4895, clients need to support multiple encodings for the block body content type.

This updates HistoryNetwork code with separate types definitions for Pre and Post Shanghai blocks

Also introduces SSZ types for Pre and Post Shanghai block bodies, as well as SSZ encoded Withdrawals and SSZ encoded withdrawal arrays (allWithdrawals)

encodeSSZBlockBody and decodeSSZBlockBody were updated to handle both versions.

the encode function determines the block type based on the Block object input.

decode, whose input is an ambiguous Uint8Array, now accepts an optional withdrawals: boolean = false input parameter. By default it will behave as it did previously. If withdrawals is set to true, the function will decode the bytes as a post-shanghai block body.

A try/catch is employed as a temporary hack solution to handle cases where decode is called without knowing which type of block body to expect. the function will try to decode as a pre-shanghai blockbody, and then as a post-shanghai blockbody if the deserialize function throws.

For that reason, these changes should be effective and non-breaking without updating any other code.

In practice, a client will always find a header to validate the blockbody, and will know from the header whether the block is pre or post shanghai.

Copy link
Collaborator

@acolytec3 acolytec3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@acolytec3 acolytec3 merged commit 887894f into master Nov 8, 2023
4 checks passed
@acolytec3 acolytec3 deleted the postmerge-blockbody-encoding branch November 8, 2023 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants