-
Notifications
You must be signed in to change notification settings - Fork 14
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
fix: check mainnet genesis hash #667
Conversation
WalkthroughThe changes primarily involve updates to the methods for computing the SHA256 hash of the genesis block across multiple files. The Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Doctor
participant Server
participant Version
User->>Doctor: Request genesis doc and hash
Doctor->>Doctor: Compute hash using tmhash.Sum
Doctor->>User: Return genesisDoc and genesisHash
User->>Server: Start command with genesisDoc and genesisHash
Server->>Server: Validate mainnet and block using provided genesisHash
Server->>User: Command execution result
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 using PR comments)
Other keywords and placeholders
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.
Caution
Inline review comments failed to post
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- cmd/doctor.go (3 hunks)
- server/start.go (5 hunks)
- types/version.go (3 hunks)
Additional comments not posted (8)
types/version.go (2)
13-13
: LGTM!The
MainnetGenesisHash
has been correctly updated to reflect the new mainnet genesis block hash.
26-26
: LGTM!The
TestnetGenesisHash
has been correctly updated to reflect the new testnet genesis block hash.server/start.go (4)
53-53
: LGTM!Passing the computed genesis hash to
checkMainnetAndBlock
enhances clarity and reusability.
83-83
: LGTM!Accepting the genesis hash as a parameter enhances clarity and reusability.
100-100
: LGTM!Using the passed genesis hash is more efficient than recalculating it.
45-46
: Verify the impact of the hash calculation change.The genesis hash calculation method has been updated. This may affect how the genesis hash is validated against the expected value.
Run the following script to verify that the new hash calculation method produces the expected hash for mainnet and testnet configurations:
cmd/doctor.go (2)
534-535
: LGTM!The changes to the
getGenesisDocAndSha256
function look good:
- Directly computing the SHA256 hash from
genesisFileData
usingtmhash.Sum
simplifies the logic and improves performance by removing the intermediate buffer.- Encoding the hash to a hex string using
hex.EncodeToString
is the correct approach.- Returning
genesisHash
alongsidegenesisDoc
improves the function's usability.Overall, the changes enhance the code quality and maintainability. Nice work!
15-15
: LGTM!The import statement for the
tmhash
package is correct and required for usingtmhash.Sum
in thegetGenesisDocAndSha256
function.
Comments failed to post (1)
server/start.go (1)
127-128: Reminder: Remove the TODO comment and the associated error message before the release.
The TODO comment suggests ongoing refinement of the error handling process.
Do you want me to open a GitHub issue to track this task?
(cherry picked from commit 20e5977)
Co-authored-by: zakir <[email protected]>
Summary by CodeRabbit
New Features
Bug Fixes
Chores