-
Notifications
You must be signed in to change notification settings - Fork 9
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
Empty miner
field on eth_getBlockByNumber
#463
Conversation
WalkthroughThe changes involve updates to the blockchain API to include a Changes
Assessment against linked issues
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? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (1)
api/api.go (1)
969-969
: Issue Found:CoinbaseAddress
is not defined in the codebase.The
CoinbaseAddress
used inapi/api.go
does not have a corresponding definition within the codebase. This could lead to runtime errors. Please ensure thatCoinbaseAddress
is correctly defined or imported from the appropriate package.
- File:
api/api.go
- Line: 969
Analysis chain
LGTM! Verify the correctness of
CoinbaseAddress
.The addition of the
Miner
field to the block response is a positive change that aligns with the PR objectives. Ensure thatevmTypes.CoinbaseAddress
correctly represents the miner's address in all contexts.Run the following script to verify the definition and usage of
CoinbaseAddress
:Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition and usage of `CoinbaseAddress`. # Test: Search for the definition and usage of `CoinbaseAddress`. Expect: Correct definition and usage. rg --type go 'CoinbaseAddress'Length of output: 98
Script:
#!/bin/bash # Description: Search for the definition of `CoinbaseAddress` in the codebase. # Test: Locate the definition of `CoinbaseAddress`. Expect: Definition found. rg --type go 'CoinbaseAddress'Length of output: 98
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
go.sum
is excluded by!**/*.sum
tests/go.sum
is excluded by!**/*.sum
Files selected for processing (7)
- api/api.go (2 hunks)
- go.mod (5 hunks)
- models/block.go (1 hunks)
- models/block_test.go (4 hunks)
- models/events_test.go (1 hunks)
- tests/go.mod (4 hunks)
- tests/web3js/eth_non_interactive_test.js (1 hunks)
Additional comments not posted (17)
models/block.go (1)
63-63
: Addition ofPrevRandao
field inBlock
structure.The addition of the
PrevRandao
field enhances the block data structure by providing additional information. Ensure that this change is consistently handled across the codebase.models/block_test.go (4)
23-23
: Inclusion ofPrevRandao
inTest_DecodeBlockExecutedEvent
.The addition of
PrevRandao
in this test case ensures that the new field is correctly decoded and validated.
48-48
: Update of hash constant inTest_Hash
.The updated hash value reflects changes in the block data or hashing algorithm. Ensure that this change is intentional and documented.
57-57
: Inclusion ofPrevRandao
inTest_Hash
.The addition of
PrevRandao
in this test case ensures that the hash calculation accounts for the new field.
75-75
: Inclusion ofPrevRandao
inTest_EncodingDecoding
.The addition of
PrevRandao
in this test case ensures that encoding and decoding processes handle the new field correctly.models/events_test.go (1)
178-183
: Inclusion ofPrevRandao
innewBlock
function.The addition of the
PrevRandao
parameter in thenewBlock
function ensures that block creation includes the new field, maintaining consistency with the updated block structure.tests/web3js/eth_non_interactive_test.js (2)
28-28
: Update to block size assertion.The expected block size has been updated to
3994n
. Ensure this matches the actual block size returned by the API.
29-29
: Addition of miner assertion.The test now verifies the
block.miner
field. Ensure that the miner address'0x0000000000000000000000030000000000000000'
is correct and consistent with the expected data.go.mod (5)
10-12
: Dependency updates foratree
,cadence
, andflow-go
.These updates reflect a shift to newer versions. Ensure compatibility with the rest of the codebase and check for any breaking changes introduced by these updates.
24-24
: Update togolang.org/x/sync
.The version has been updated to
v0.8.0
. Verify that this update does not introduce any breaking changes.
42-42
: Update tobtcsuite/btcd/btcec/v2
.The version has been updated to
v2.3.4
. Ensure this update is compatible with the existing code.
137-137
: Update toonflow/crypto
.The version has been updated to
v0.25.2
. Verify compatibility with the codebase.
196-200
: Updates togolang.org/x
packages.The versions for
crypto
,net
,sys
, andtext
have been updated. Ensure these updates do not introduce breaking changes.tests/go.mod (4)
7-11
: Dependency updates forcadence
,crypto
, andflow-go
.These updates reflect a shift to newer versions. Ensure compatibility with the test code and check for any breaking changes introduced by these updates.
34-34
: Update tobtcsuite/btcd/btcec/v2
.The version has been updated to
v2.3.4
. Ensure this update is compatible with the test code.
148-148
: Update toonflow/atree
.The version has been updated to
v0.8.0-rc.6
. Verify compatibility with the test code.
215-222
: Updates togolang.org/x
packages.The versions for
crypto
,net
,sync
,sys
,term
, andtext
have been updated. Ensure these updates do not introduce breaking changes in the test code.
We should add logic for backward compatibility. Best, if you make it part of this PR |
a5219e4
to
a3be967
Compare
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
go.sum
is excluded by!**/*.sum
tests/go.sum
is excluded by!**/*.sum
Files selected for processing (2)
- go.mod (5 hunks)
- tests/go.mod (4 hunks)
Files skipped from review due to trivial changes (1)
- tests/go.mod
Files skipped from review as they are similar to previous changes (1)
- go.mod
I have added such a logic in this commit: 5b33fe1. |
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- models/block.go (3 hunks)
- models/block_test.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- models/block_test.go
Additional comments not posted (9)
models/block.go (9)
12-12
: Imports look good.The import statements are appropriate for the operations performed in the file.
32-41
: Backward compatibility logic is well-implemented.The function
NewBlockFromBytes
correctly handles backward compatibility by attempting to decode previous block versions.
49-49
: Addition ofhash
field is appropriate.The
hash
field in theBlock
struct is a necessary addition for storing the block's hash.
53-58
: Efficient hash retrieval method.The
Hash
method provides a clear and efficient way to retrieve the block's hash.
81-81
: Decoding block event is correctly implemented.The
decodeBlockEvent
function accurately decodes a block event into theBlock
type.
86-94
: Backward compatibility structblockV0
is appropriate.The
blockV0
struct is necessary for handling older block versions.
96-106
: Inclusion ofPrevRandao
field inblockV1
is correct.The
blockV1
struct is necessary for handling newer block versions with thePrevRandao
field.
108-111
: Hash computation for past block is correctly implemented.The
pastBlockHash
function correctly encodes the block and computes its hash.
113-148
: Backward compatibility decoding is well-implemented.The
decodeBlockBreakingChanges
function correctly handles decoding of previous block versions.
func (b *Block) Hash() (gethCommon.Hash, error) { | ||
if b.hash != nil { | ||
return *b.hash, nil | ||
} | ||
return b.Block.Hash() | ||
} |
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.
Do we need the caching ?
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.
Is this Block object serialized? if yes are we worried about caching the hash?
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.
This Block object is indeed serialized, but the hash
field is only set for past blocks. Where past block means a block that fails to decode with the current format.
// decodeBlockBreakingChanges will try to decode the bytes into all | ||
// previous versions of block type, if it succeeds it will return the | ||
// migrated block, otherwise it will return nil. | ||
func decodeBlockBreakingChanges(encoded []byte) *Block { |
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.
Isn't this a cop of the code from flow go?
should we just export those methods?
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.
Yeah, this is a copy from that code in flow-go. Though I am not sure if it still exists in the flow-go repo 🤔 .
We used to have these file changes for PreviewNet: 0e520ac. But removed them for testnet launch.
models/block.go
Outdated
b1 := &blockV1{} | ||
if err := rlp.DecodeBytes(encoded, b1); err == nil { | ||
return &Block{ | ||
Block: &types.Block{ | ||
ParentBlockHash: b1.ParentBlockHash, | ||
Height: b1.Height, | ||
Timestamp: b1.Timestamp, | ||
TotalSupply: b1.TotalSupply, | ||
ReceiptRoot: b1.ReceiptRoot, | ||
TransactionHashRoot: b1.TransactionHashRoot, | ||
TotalGasUsed: b1.TotalGasUsed, | ||
PrevRandao: b1.PrevRandao, | ||
}, | ||
} | ||
} |
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.
Do we need this, given the Block itself ? is similar to BlockV1
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.
BlockV1 has the addition of the PrevRandao
field, which BlockV0 does not have. Unless you mean something else which I'm missing 😅
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.
Ah right, now I see what you mean 😇
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.
Removed in 2f97be1
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.
Just added some questions
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
go.sum
is excluded by!**/*.sum
Files selected for processing (1)
- go.mod (5 hunks)
Additional comments not posted (10)
go.mod (10)
10-10
: Dependency update approved forgithub.com/onflow/atree
.The update from
v0.8.0-rc.5
tov0.8.0-rc.6
is likely to include minor improvements or bug fixes.
11-11
: Dependency update approved forgithub.com/onflow/cadence
.The update from
v1.0.0-preview.48
tov1.0.0-preview.49
is likely to include minor improvements or bug fixes.
12-12
: Dependency update approved forgithub.com/onflow/flow-go
.The update from
v0.37.1
tov0.37.6
might include bug fixes or improvements. However, ensure backward compatibility due to the mentioned breaking change in block hash calculation.
24-24
: Dependency update approved forgolang.org/x/sync
.The update from
v0.7.0
tov0.8.0
is likely to include minor improvements or bug fixes.
42-42
: Dependency update approved forgithub.com/btcsuite/btcd/btcec/v2
.The update from
v2.2.1
tov2.3.4
is likely to include minor improvements or bug fixes.
137-137
: Dependency update approved forgithub.com/onflow/crypto
.The update from
v0.25.1
tov0.25.2
is likely to include minor improvements or bug fixes.
196-196
: Dependency update approved forgolang.org/x/crypto
.The update from
v0.22.0
tov0.26.0
is likely to include minor improvements or bug fixes.
197-197
: Dependency update approved forgolang.org/x/net
.The update from
v0.24.0
tov0.25.0
is likely to include minor improvements or bug fixes.
199-199
: Dependency update approved forgolang.org/x/sys
.The update from
v0.20.0
tov0.23.0
is likely to include minor improvements or bug fixes.
200-200
: Dependency update approved forgolang.org/x/text
.The update from
v0.14.0
tov0.17.0
is likely to include minor improvements or bug fixes.
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- models/block.go (3 hunks)
Additional comments not posted (6)
models/block.go (6)
12-12
: Import addition is appropriate.The
gethCrypto
import is necessary for hash calculations.
49-58
: Enhancement of Block data model is appropriate.The addition of the
hash
field and theHash
method improves the block's data model.
81-81
: Addition ofPrevRandao
field is appropriate.The
PrevRandao
field aligns with the changes mentioned in the PR summary and objectives.
86-94
: Introduction ofblockV0
type is necessary for backward compatibility.The
blockV0
type is essential for handling older block versions.
96-121
: Functions for handling past block data are well-implemented.The
pastBlockHash
anddecodeBlockBreakingChanges
functions are correctly implemented for handling past block data.Run the following script to verify the usage of
decodeBlockBreakingChanges
in the codebase:Verification successful
Usage of
decodeBlockBreakingChanges
is appropriate and limited tomodels/block.go
.The function
decodeBlockBreakingChanges
is used correctly within themodels/block.go
file to decode block data and handle errors. There are no other occurrences of this function in the codebase, indicating its specialized use.
- File:
models/block.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `decodeBlockBreakingChanges` in the codebase. # Test: Search for the function usage. Expect: Occurrences of the function being called. rg --type go -A 5 $'decodeBlockBreakingChanges'Length of output: 841
32-41
: Backward compatibility logic is well-implemented.The
NewBlockFromBytes
function effectively handles decoding of previous block versions and assigns the hash correctly.Run the following script to verify the usage of
NewBlockFromBytes
in the codebase:Verification successful
Backward compatibility logic is well-implemented and verified.
The
NewBlockFromBytes
function is used in both test and non-test files, confirming its integration and backward compatibility handling within the codebase.
- Usage Locations:
models/block_test.go
: Tests theNewBlockFromBytes
function.storage/pebble/blocks.go
: Utilizes the function for processing data.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `NewBlockFromBytes` in the codebase. # Test: Search for the function usage. Expect: Occurrences of the function being called. rg --type go -A 5 $'NewBlockFromBytes'Length of output: 631
Closes: #454
Description
Note: The version bump of the
flow-go
dependency, comes with a backwards incompatible change on the block hash calculation.If we want to deploy this change on
testnet
, we'll have to add some custom logic to accommodate that breaking change.For contributor use:
master
branchFiles changed
in the Github PR explorerSummary by CodeRabbit
New Features
Miner
field to block response, providing crucial miner address information.PrevRandao
field in block events for enhanced event tracking.Block
structure with a newhash
field and a method to return the block's hash.Miner
field and updated block sizes.Bug Fixes
Chores