Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 blocksAlso introduces SSZ types for Pre and Post Shanghai block bodies, as well as SSZ encoded
Withdrawals
and SSZ encoded withdrawal arrays (allWithdrawals
)encodeSSZBlockBody
anddecodeSSZBlockBody
were updated to handle both versions.the
encode
function determines the block type based on theBlock
object input.decode
, whose input is an ambiguous Uint8Array, now accepts an optionalwithdrawals: boolean = false
input parameter. By default it will behave as it did previously. Ifwithdrawals
is set totrue
, 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 wheredecode
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.