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

fix: add recover to InitChainer to diplay informative message when starting a node from block 1 #2925

Merged
merged 7 commits into from
Sep 30, 2024

Conversation

kingpinXD
Copy link
Contributor

@kingpinXD kingpinXD commented Sep 26, 2024

Description

Closes #2685

How Has This Been Tested?

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Summary by CodeRabbit

  • New Features

    • Introduced a recovery mechanism during the initialization of the chainer, providing clearer feedback when starting a node from block 1.
    • Added a new error message constant for improved user notifications when syncing from block 1.
  • Documentation

    • Updated changelog to reflect the new recovery feature and its impact on user experience.

Copy link
Contributor

coderabbitai bot commented Sep 26, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes introduce a deferred recovery mechanism in the InitChainer function of the App struct, enhancing error handling by logging panic occurrences with detailed stack traces. Additionally, a new constant, InitChainErrorMessage, is added to provide clearer error messaging when syncing from block 1. A corresponding entry is made in the changelog to reflect these improvements.

Changes

File Change Summary
app/app.go Added deferred recovery mechanism in InitChainer to log panics and exit with an error code.
changelog.md Added entry for the recovery feature in the chainer initialization process.
pkg/constant/constant.go Introduced new constant InitChainErrorMessage for clearer error messaging during sync attempts.

Assessment against linked issues

Objective Addressed Explanation
A more informative error message when syncing from block 1 (2685)

Possibly related PRs

Suggested labels

no-changelog

Suggested reviewers

  • lumtis
  • swift1337
  • fbac
  • brewmaster012
  • skosito
  • ws4charlie

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 and nitpick comments (2)
pkg/constant/constant.go (1)

44-45: Approve the new constant with suggestions for improvement.

The addition of InitChainErrorMessage is a valuable improvement that addresses the issue outlined in the PR objectives. It provides clear guidance to users attempting to sync from block 1.

However, consider the following enhancements:

  1. Shorten the message for improved readability in logs.
  2. Include a reference to where users can find appropriate snapshots.

Consider refactoring the constant as follows:

InitChainErrorMessage = "Syncing from block 1 is not supported. Please use a snapshot. For more information, visit: <snapshot_url>"

Replace <snapshot_url> with the actual URL where users can find snapshot information.

app/app.go (1)

882-882: Capitalize the error message for consistency and professionalism.

The error message should start with an uppercase letter to align with standard logging practices.

Apply this diff to correct the log message:

- ctx.Logger().Error("panic occurred during InitGenesis", "error", r)
+ ctx.Logger().Error("Panic occurred during InitGenesis", "error", r)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2892114 and 8137451.

📒 Files selected for processing (3)
  • app/app.go (3 hunks)
  • changelog.md (1 hunks)
  • pkg/constant/constant.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
app/app.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

pkg/constant/constant.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

🔇 Additional comments (8)
changelog.md (5)

Line range hint 1-45: Ensure comprehensive testing for unreleased changes.

The unreleased section contains numerous significant changes, including new features, refactors, and fixes. It's crucial to ensure that each of these changes, especially those affecting core functionality like TSS address handling and chain parameters, undergoes thorough testing before release.

Consider enhancing the changelog entries for more impactful changes. For instance, the changes to TSS address handling and the merging of observer params into chain params could benefit from brief explanations of their implications.

To verify the testing coverage, please run the following command:

#!/bin/bash
# Check test coverage for recently modified files
git diff --name-only HEAD~10 | grep '\.go$' | xargs -I {} sh -c 'go test -coverprofile=/tmp/cover.out ./$(dirname {}) && go tool cover -func=/tmp/cover.out'

Line range hint 85-105: Assess refactoring impacts and ensure comprehensive testing.

The refactoring changes implemented in this release represent significant structural modifications to the codebase. Key points to consider:

  1. The movement of TSS state and related functionalities from the crosschain module to the observer module may have far-reaching effects on system behavior and API usage.
  2. Changes to query endpoints and parameter structures (e.g., merging observer params into chain params) will likely require updates to any external systems or scripts interacting with these APIs.
  3. The reorganization of smoke tests and the addition of pagination to certain queries could affect test coverage and system performance under load.

To mitigate risks associated with these changes:

  1. Conduct comprehensive integration testing to ensure that all system components interact correctly after the refactoring.
  2. Update all relevant documentation, especially API references, to reflect the new structure and endpoints.
  3. Consider creating a migration guide for users of the affected APIs to ease the transition.

To verify the integrity of the refactored code, run integration tests and check for any broken dependencies:

#!/bin/bash
# Run integration tests
go test ./... -tags=integration

# Check for broken imports or unused code
go vet ./...
golangci-lint run

Line range hint 47-56: Document feature impacts and conduct performance testing.

The new features, particularly the addition of monitoring capabilities and dynamic gas pricing, represent significant enhancements to the system. To ensure smooth adoption:

  1. Consider documenting the expected impact of each feature, especially the dynamic gas pricing, on system performance and user experience.
  2. For the dynamic gas pricing feature, it's advisable to conduct thorough performance testing to understand its effects on transaction throughput and cost under various network conditions.

Additionally, for the new snapshots commands, ensure that comprehensive usage documentation is provided to facilitate user adoption.

To verify the performance impact of dynamic gas pricing, consider running the following benchmark:

#!/bin/bash
# Run benchmark tests for gas pricing
go test -bench=GasPricing ./... -benchmem -benchtime=10s

Line range hint 107-116: Document CI/CD changes and assess their impact.

The changes to the CI/CD process, particularly the removal of private runners and unused GitHub Actions, could have significant implications for the project's development workflow:

  1. Removal of private runners:

    • Document the rationale behind this decision, addressing any potential impacts on build times, security, or resource allocation.
    • Ensure that all team members are aware of how this change might affect their development and testing processes.
  2. Unused GitHub Action removal:

    • Confirm that the removed action was indeed unused and that its removal doesn't inadvertently break any dependent processes.
    • Update any documentation or team guidelines that may have referenced the removed action.

To maintain the integrity of the CI/CD pipeline:

  1. Conduct a thorough review of the entire CI/CD process to ensure it remains robust after these changes.
  2. Consider implementing monitoring for CI/CD performance to detect any negative impacts from the removal of private runners.

To verify the integrity of the CI/CD pipeline after these changes, run:

#!/bin/bash
# List all current GitHub Actions workflows
gh workflow list

# Show recent workflow runs to check for any failures
gh run list --limit 10

Line range hint 58-83: Emphasize critical fixes and conduct security audit.

The fixes implemented in this release address several critical issues that could significantly impact system stability, security, and correctness. Particularly noteworthy are:

  1. The fixes for transaction handling, including improvements to outbound tx confirmation and inbound tx verification.
  2. Security enhancements like masking the zetaclient config at startup.
  3. Corrections to core functionalities such as TSS address handling and chain parameter management.

Given the security-sensitive nature of many of these changes, it is strongly recommended to:

  1. Conduct a comprehensive security audit, focusing on the changes related to transaction handling, config masking, and TSS address management.
  2. Perform thorough regression testing to ensure that these fixes do not inadvertently introduce new issues.

To assist with security verification, consider running a static analysis tool:

app/app.go (3)

7-7: Necessary import of 'runtime/debug' for capturing stack traces.

The inclusion of "runtime/debug" is essential for retrieving stack traces during panic recovery, which enhances error logging and debugging capabilities.


95-95: Importing 'zetaconstant' package to provide informative error messages.

Importing zetaconstant allows access to predefined constants like InitChainErrorMessage, improving code maintainability and consistency in error messaging.


880-888: Effective panic recovery in 'InitChainer' enhances initialization error handling.

The deferred function appropriately handles panics during InitGenesis, logs the error and stack trace, and provides users with a clear, informative message. This aligns with the objective to improve user experience when starting a node from block 1.

Copy link
Contributor

@swift1337 swift1337 left a comment

Choose a reason for hiding this comment

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

Pre-approved. Left some minor comments

pkg/constant/constant.go Outdated Show resolved Hide resolved
pkg/constant/constant.go Outdated Show resolved Hide resolved
app/app.go Show resolved Hide resolved
Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

Would be great to get a review from @zeta-chain/devops on this one (trying syncing with the error)

app/app.go Outdated Show resolved Hide resolved
@lumtis lumtis requested a review from a team September 26, 2024 10:47
@kingpinXD
Copy link
Contributor Author

Would be great to get a review from @zeta-chain/devops on this one (trying syncing with the error)

Yeah , I did not face the error mentioned
#2685 (comment)

@kingpinXD kingpinXD requested a review from lumtis September 26, 2024 18:10
app/app.go Outdated Show resolved Hide resolved
kingpinXD and others added 2 commits September 30, 2024 15:07
Co-authored-by: Francisco de Borja Aranda Castillejo <[email protected]>
@kingpinXD kingpinXD requested a review from fbac September 30, 2024 09:44
@kingpinXD kingpinXD enabled auto-merge September 30, 2024 09:44
@kingpinXD kingpinXD added this pull request to the merge queue Sep 30, 2024
Merged via the queue into develop with commit ec64772 Sep 30, 2024
35 checks passed
@kingpinXD kingpinXD deleted the fix-handle-panic-init-genesis branch September 30, 2024 10:10
morde08 pushed a commit that referenced this pull request Oct 2, 2024
…arting a node from block 1 (#2925)

* add recover to InitChainer

* generate files

* add docs link to error message

* move InitChainErrorMessage to app.go

* Update app/app.go

Co-authored-by: Francisco de Borja Aranda Castillejo <[email protected]>

* use const for message

---------

Co-authored-by: Francisco de Borja Aranda Castillejo <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Oct 3, 2024
…guration (#2953)

* update artillery config

* more fixes

* feat: integrate authenticated calls smart contract functionality into protocol (#2904)

* e2e tests and modifications for authenticated call

* extend test with sender check and revert case

* separate tests into separate files

* cleanup

* withdraw and call support and tests

* bump protocol contracts

* split tests into separate files

* small cleanup

* fmt

* generate

* lint

* changelog

* PR  comments

* fix case in proto

* bump vote inbound gas limit in zetaclient

* fix test

* generate

* fixing tests

* call options non empty

* generate

* test fix

* rename gateway caller

* pr comments rename tests

* PR comment

* generate

* tests

* update tests fixes

* tests fixes

* fix

* test fix

* feat!: bank precompile (#2860)

* feat: bank precompile

* feat: add deposit

* feat: extend deposit

* PoC: spend amount on behalf of EOA

* feat: expand deposit with transferFrom

* use CallEVM instead on ZRC20 bindings

* divide the contract into different files

* initialize e2e testing

* remove duplicated funding

* add codecov

* expand e2e

* fix: wait for deposit tx to be mined

* apply first round of reviews

* cover al error types test

* fixes using time.Since

* Include CallContract interface

* fix eth events in deposit precompile method

* emit Deposit event

* add withdraw function

* finalize withdraw

* pack event arguments generically

* add high level event function

* first round of review fixes

* second round of reviews

* create bank account when instantiating bank

* e2e: add good and bad scenarios

* modify fmt

* chore: group input into eventData struct

* docs: document bank's methods

* chore: generate files with suffix .gen.go

* chore: assert errors with errorIs

* chore: reset e2e test by resetting allowance

* test: add first batch of unit test

* test: cover all cases

* test: complete unit test cases

* include review suggestions

* include e2e through contract

* test: add e2e through contract complete

* test: revert balance between tests

* Update precompiles/bank/const.go

Co-authored-by: Lucas Bertrand <[email protected]>

* fix: changed coin denom

---------

Co-authored-by: skosito <[email protected]>
Co-authored-by: Lucas Bertrand <[email protected]>

* feat: add sender to revert context (#2919)

* e2e tests and modifications for authenticated call

* extend test with sender check and revert case

* separate tests into separate files

* cleanup

* withdraw and call support and tests

* bump protocol contracts

* split tests into separate files

* small cleanup

* fmt

* generate

* lint

* changelog

* PR  comments

* fix case in proto

* bump vote inbound gas limit in zetaclient

* fix test

* generate

* fixing tests

* call options non empty

* generate

* test fix

* rename gateway caller

* pr comments rename tests

* PR comment

* generate

* tests

* add sender in test contract

* extend e2e tests

* generate

* changelog

* PR comment

* generate

* update tests fixes

* tests fixes

* fix

* test fix

* gas limit fixes

* PR comment fix

* fix bad merge

* ci: add option to enable monitoring stack (#2927)

* ci: add option to enable monitoring stack

* start prometheus faster

* update

* ci: add rpcimportable test (#2817)

* ci: add rpcimportable test

* add ci

* fmt

* use github.com/btcsuite/btcd/btcutil in pkg/chains

* remove app imports types tests

* use standalone sdkconfig package

* fix policies test

* move crosschain keeper tests from types to keeper

* never seal config in tests

* use zeta-chain/ethermint#126

* add some comments

* use merged ethermint hash

* show resulting go.mod

* ci: Add SARIF upload to GitHub Security Dashboard (#2929)

* add semgrep sarif upload to GHAS

* added comment to clairfy the usage of the utility script

* use ghcr.io instead

* add tag to image

* bad org name

---------

Co-authored-by: jkan2 <[email protected]>

* fix: add recover to InitChainer to diplay informative message when starting a node from block 1 (#2925)

* add recover to InitChainer

* generate files

* add docs link to error message

* move InitChainErrorMessage to app.go

* Update app/app.go

Co-authored-by: Francisco de Borja Aranda Castillejo <[email protected]>

* use const for message

---------

Co-authored-by: Francisco de Borja Aranda Castillejo <[email protected]>

* test: add wait for block to tss migration test (#2931)

* add wait for block to tss migration test

* add comments

* refactor identifiers

* rename checkNumberOfTssGenerated to checkNumberOfTSSGenerated

* chore: allow full zetaclient config overlay (#2945)

* test(e2e): add gateway upgrade in upgrade test (#2932)

* add gateway upgrade

* change reference

* add v2 setup for all tests

* test v2 in light upgrade

* refactor setup to use custody v2 directly

* chore: improve localnet build performance (#2928)

* chore: improve localnet build performance

* propagate NODE_VERSION and NODE_COMMIT

* update hashes

---------

Co-authored-by: skosito <[email protected]>
Co-authored-by: Francisco de Borja Aranda Castillejo <[email protected]>
Co-authored-by: Lucas Bertrand <[email protected]>
Co-authored-by: Alex Gartner <[email protected]>
Co-authored-by: jkan2 <[email protected]>
Co-authored-by: jkan2 <[email protected]>
Co-authored-by: Tanmay <[email protected]>
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.

A more informative error message when syncing from block 1
5 participants