Closed m-Peter closed 2 months ago
The changes encompass modifications to the NewBlockFromBytes
function and the Block
structure in models/block.go
, enhancing error handling and introducing backward compatibility. A new method, ToBytes
, is added to the Block
structure, while the blockV0
type is introduced for earlier block versions. Corresponding tests are also added in models/block_test.go
to ensure proper functionality and decoding of historical block formats.
Files | Change Summary |
---|---|
models/block.go |
Modified NewBlockFromBytes and decodeBlockBreakingChanges to return errors; added ToBytes method; introduced blockV0 type with a Hash method. |
models/block_test.go |
Added Test_DecodePastBlockFormat to validate decoding of specific block formats and properties. |
sequenceDiagram
participant Client
participant BlockManager
participant BlockDecoder
Client->>BlockManager: Request NewBlockFromBytes
BlockManager->>BlockDecoder: Decode block data
BlockDecoder-->>BlockManager: Return Block, error
BlockManager-->>Client: Return Block, error
π° "In bytes and blocks, we hop and play,
New methods added, hip-hip-hooray!
With backward paths and errors caught,
Our blocks are better, just as we thought!
A test to check, we're all aglow,
Hopping forward, watch us grow!" πβ¨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Description
The block structure has changed, and now includes a new field:
PrevRandao
. Hence, we need to patch the RLP decoding for the blocks with the previous format, which lack thePrevRandao
field. We also need to properly handle the block hash calculation, to not take into account this field, for past blocks.For contributor use:
master
branchFiles changed
in the Github PR explorerSummary by CodeRabbit
New Features
ToBytes
method for theBlock
structure to improve encoding capabilities.blockV0
type.Bug Fixes
Tests