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: block sync on mocha on main #3846

Merged
merged 4 commits into from
Sep 16, 2024

Conversation

rootulp
Copy link
Collaborator

@rootulp rootulp commented Sep 5, 2024

Closes #3840
Forward port of #3843

Testing

I can state sync and block sync on Arabica and Mocha

./scripts/arabica.sh
./scripts/arabica-block-sync.sh
./scripts/mocha.sh
./scripts/mocha-block-sync.sh

@rootulp
Copy link
Collaborator Author

rootulp commented Sep 11, 2024

Moving to draft. Discussion w/ @cmwaters :

  • Delete the Mocha genesis file from this PR
  • Add a unit test with a genesis file that is broken in the same way as the Mocha genesis file
  • Create an issue to track adding a end to end test that starts a testapp with the Mocha genesis file and verifies that the app can get to block 1.

@rootulp rootulp marked this pull request as ready for review September 11, 2024 19:56
@rootulp rootulp requested a review from a team as a code owner September 11, 2024 19:56
@rootulp rootulp requested review from cmwaters and staheri14 and removed request for a team September 11, 2024 19:56
Copy link
Contributor

coderabbitai bot commented Sep 11, 2024

Walkthrough

Walkthrough

The pull request introduces significant changes to the InitChain function in the App struct, refactoring logic into a new helper function for setting the application version. It also updates the logging level in the mountKeysAndInit function. Additionally, new scripts for syncing blocks on the Arabica and Mocha blockchains are added, and the go.mod file is updated to upgrade the Tendermint dependency. Tests for the InitChain method are also introduced to enhance validation of the initialization process.

Changes

File Change Summary
app/app.go Refactored InitChain to include setDefaultAppVersion for app version handling; changed log level.
app/app_test.go Added TestInitChain to validate InitChain behavior under various conditions.
go.mod Updated github.com/tendermint/tendermint from v1.40.0-tm-v0.34.29 to v1.41.0-tm-v0.34.29.
scripts/arabica-block-sync.sh Introduced script to automate consensus node setup for Arabica blockchain.
scripts/arabica.sh Modified command to start celestia-appd with --force-no-bbr flag.
scripts/mocha-block-sync.sh Introduced script to automate consensus node setup for Mocha blockchain.
scripts/mocha.sh Modified command to start celestia-appd with --force-no-bbr flag.

Assessment against linked issues

Objective Addressed Explanation
Modify Mocha genesis.json to include app version (3840) The PR does not modify the genesis file.
Ensure application can start without app version in genesis (3840)
Implement tests for Mocha genesis file (3861)

Possibly related issues

Possibly related PRs

Suggested labels

bug, testing


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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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: 2

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2c53ddb and 69bc3f1.

Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
Files selected for processing (7)
  • app/app.go (3 hunks)
  • app/app_test.go (3 hunks)
  • go.mod (1 hunks)
  • scripts/arabica-block-sync.sh (1 hunks)
  • scripts/arabica.sh (1 hunks)
  • scripts/mocha-block-sync.sh (1 hunks)
  • scripts/mocha.sh (1 hunks)
Additional context used
Shellcheck
scripts/arabica-block-sync.sh

[warning] 24-24: In POSIX sh, read -p is undefined.

(SC3045)

scripts/mocha-block-sync.sh

[warning] 24-24: In POSIX sh, read -p is undefined.

(SC3045)

Additional comments not posted (6)
scripts/arabica.sh (1)

60-60: Verify the purpose and implications of the --force-no-bbr flag.

The new --force-no-bbr flag suggests disabling the Block-Based Reconciliation (BBR) feature during the startup of celestia-appd. While this might speed up the startup process, it's important to consider the potential implications:

  1. Disabling BBR could lead to state inconsistencies if the local state differs significantly from the network state.
  2. It might affect how the application handles block synchronization or reconciliation with the network.

Please provide more context on the reasoning behind this change and ensure that disabling BBR aligns with the desired behavior and doesn't introduce any unintended consequences.

scripts/mocha.sh (1)

60-60: LGTM, but verify the impact of the --force-no-bbr flag.

The change to include the --force-no-bbr flag in the celestia-appd startup command is approved.

However, it's important to verify the impact of this flag on the application's behavior and performance, especially in the context of block processing and upgrade mechanisms.

To verify the impact, consider the following:

  1. Conduct thorough testing to ensure that the application can successfully sync blocks and handle upgrades with the --force-no-bbr flag enabled.
  2. Monitor the application's performance metrics, such as block processing time and resource utilization, to identify any potential regressions or improvements introduced by the flag.
  3. Document the observed behavior and any notable findings in the PR description or relevant documentation.

By verifying the impact of the --force-no-bbr flag, we can ensure that the change achieves the desired outcome of addressing block synchronization issues on the Mocha testnet without introducing unintended side effects.

app/app_test.go (1)

59-112: LGTM!

The new test function TestInitChain is well-structured and enhances the test coverage for the application by validating the initialization process. It follows good practices and covers important scenarios.

Some key points:

  • The test cases are clearly defined with descriptive names and expected outcomes.
  • The assert package is used for validations.
  • Each test case is run in a separate subtest for better isolation.
  • The test cases cover panicking when consensus parameters are not set and not panicking when a genesis state without an application version is provided.

Great job on adding this comprehensive test function!

go.mod (1)

255-255: Approve Tendermint version update, but verify changelog.

The Tendermint dependency has been updated from v1.40.0-tm-v0.34.29 to v1.41.0-tm-v0.34.29. This is a minor version update, which typically includes bug fixes, performance improvements, and backward-compatible features.

Please verify the Tendermint changelog for any breaking changes or important updates that may affect the codebase. Pay special attention to any modifications in the Tendermint APIs or behaviors used by the Celestia app.

app/app.go (2)

561-575: LGTM!

The setDefaultAppVersion function is correctly implemented and handles the case where the app version is not explicitly set in the genesis file. The panics are appropriate as the function expects the consensus params and version to be set.


544-544: LGTM!

The changes to InitChain are correctly implemented and ensure that the app version is properly set and stored by calling the new setDefaultAppVersion function. Setting the initial app version in the consensus params and the app version in the store for versions other than v1 is appropriate.


# Ask the user for confirmation before deleting the existing celestia-app home
# directory.
read -p "Are you sure you want to delete: $CELESTIA_APP_HOME? [y/n] " response
Copy link
Contributor

Choose a reason for hiding this comment

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

Use a POSIX-compatible alternative for the read -p command.

Shellcheck has flagged a warning for the read -p command being undefined in POSIX sh.

To ensure compatibility with POSIX sh, consider using the following alternative:

-read -p "Are you sure you want to delete: $CELESTIA_APP_HOME? [y/n] " response
+printf "Are you sure you want to delete: $CELESTIA_APP_HOME? [y/n] "
+read response

This alternative uses printf to display the prompt and read to capture the user's response, which is POSIX-compatible.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
read -p "Are you sure you want to delete: $CELESTIA_APP_HOME? [y/n] " response
printf "Are you sure you want to delete: $CELESTIA_APP_HOME? [y/n] "
read response
Tools
Shellcheck

[warning] 24-24: In POSIX sh, read -p is undefined.

(SC3045)

Comment on lines +1 to +46
#!/bin/sh

# This script starts a consensus node on Mocha and block syncs from genesis to
# the tip of the chain. This is expected to take a few weeks.

# Stop script execution if an error is encountered
set -o errexit
# Stop script execution if an undefined variable is used
set -o nounset

CHAIN_ID="mocha-4"
NODE_NAME="node-name"
SEEDS="[email protected]:26656,258f523c96efde50d5fe0a9faeea8a3e83be22ca@seed.mocha-4.celestia.aviaone.com:20279,5d0bf034d6e6a8b5ee31a2f42f753f1107b3a00e@celestia-testnet-seed.itrocket.net:11656,7da0fb48d6ef0823bc9770c0c8068dd7c89ed4ee@celest-test-seed.theamsolutions.info:443"

CELESTIA_APP_HOME="${HOME}/.celestia-app"
CELESTIA_APP_VERSION=$(celestia-appd version 2>&1)

echo "celestia-app home: ${CELESTIA_APP_HOME}"
echo "celestia-app version: ${CELESTIA_APP_VERSION}"
echo ""

# Ask the user for confirmation before deleting the existing celestia-app home
# directory.
read -p "Are you sure you want to delete: $CELESTIA_APP_HOME? [y/n] " response

# Check the user's response
if [ "$response" != "y" ]; then
# Exit if the user did not respond with "y"
echo "You must delete $CELESTIA_APP_HOME to continue."
exit 1
fi

echo "Deleting $CELESTIA_APP_HOME..."
rm -r "$CELESTIA_APP_HOME"

echo "Initializing config files..."
celestia-appd init ${NODE_NAME} --chain-id ${CHAIN_ID} > /dev/null 2>&1 # Hide output to reduce terminal noise

echo "Settings seeds in config.toml..."
sed -i.bak -e "s/^seeds *=.*/seeds = \"$SEEDS\"/" $CELESTIA_APP_HOME/config/config.toml

echo "Downloading genesis file..."
celestia-appd download-genesis ${CHAIN_ID} > /dev/null 2>&1 # Hide output to reduce terminal noise

echo "Starting celestia-appd..."
celestia-appd start --v2-upgrade-height 2585031 --force-no-bbr
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM, but address the Shellcheck warning.

The script is well-structured and follows best practices. The code changes are approved.

However, the Shellcheck warning for the usage of read -p in POSIX sh is valid and should be addressed.

To address the Shellcheck warning, you can use the following alternative that is compatible with POSIX sh:

-read -p "Are you sure you want to delete: $CELESTIA_APP_HOME? [y/n] " response
+printf "Are you sure you want to delete: $CELESTIA_APP_HOME? [y/n] "
+read response
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#!/bin/sh
# This script starts a consensus node on Mocha and block syncs from genesis to
# the tip of the chain. This is expected to take a few weeks.
# Stop script execution if an error is encountered
set -o errexit
# Stop script execution if an undefined variable is used
set -o nounset
CHAIN_ID="mocha-4"
NODE_NAME="node-name"
SEEDS="[email protected]:26656,258f523c96efde50d5fe0a9faeea8a3e83be22ca@seed.mocha-4.celestia.aviaone.com:20279,5d0bf034d6e6a8b5ee31a2f42f753f1107b3a00e@celestia-testnet-seed.itrocket.net:11656,7da0fb48d6ef0823bc9770c0c8068dd7c89ed4ee@celest-test-seed.theamsolutions.info:443"
CELESTIA_APP_HOME="${HOME}/.celestia-app"
CELESTIA_APP_VERSION=$(celestia-appd version 2>&1)
echo "celestia-app home: ${CELESTIA_APP_HOME}"
echo "celestia-app version: ${CELESTIA_APP_VERSION}"
echo ""
# Ask the user for confirmation before deleting the existing celestia-app home
# directory.
read -p "Are you sure you want to delete: $CELESTIA_APP_HOME? [y/n] " response
# Check the user's response
if [ "$response" != "y" ]; then
# Exit if the user did not respond with "y"
echo "You must delete $CELESTIA_APP_HOME to continue."
exit 1
fi
echo "Deleting $CELESTIA_APP_HOME..."
rm -r "$CELESTIA_APP_HOME"
echo "Initializing config files..."
celestia-appd init ${NODE_NAME} --chain-id ${CHAIN_ID} > /dev/null 2>&1 # Hide output to reduce terminal noise
echo "Settings seeds in config.toml..."
sed -i.bak -e "s/^seeds *=.*/seeds = \"$SEEDS\"/" $CELESTIA_APP_HOME/config/config.toml
echo "Downloading genesis file..."
celestia-appd download-genesis ${CHAIN_ID} > /dev/null 2>&1 # Hide output to reduce terminal noise
echo "Starting celestia-appd..."
celestia-appd start --v2-upgrade-height 2585031 --force-no-bbr
#!/bin/sh
# This script starts a consensus node on Mocha and block syncs from genesis to
# the tip of the chain. This is expected to take a few weeks.
# Stop script execution if an error is encountered
set -o errexit
# Stop script execution if an undefined variable is used
set -o nounset
CHAIN_ID="mocha-4"
NODE_NAME="node-name"
SEEDS="[email protected]:26656,258f523c96efde50d5fe0a9faeea8a3e83be22ca@seed.mocha-4.celestia.aviaone.com:20279,5d0bf034d6e6a8b5ee31a2f42f753f1107b3a00e@celestia-testnet-seed.itrocket.net:11656,7da0fb48d6ef0823bc9770c0c8068dd7c89ed4ee@celest-test-seed.theamsolutions.info:443"
CELESTIA_APP_HOME="${HOME}/.celestia-app"
CELESTIA_APP_VERSION=$(celestia-appd version 2>&1)
echo "celestia-app home: ${CELESTIA_APP_HOME}"
echo "celestia-app version: ${CELESTIA_APP_VERSION}"
echo ""
# Ask the user for confirmation before deleting the existing celestia-app home
# directory.
printf "Are you sure you want to delete: $CELESTIA_APP_HOME? [y/n] "
read response
# Check the user's response
if [ "$response" != "y" ]; then
# Exit if the user did not respond with "y"
echo "You must delete $CELESTIA_APP_HOME to continue."
exit 1
fi
echo "Deleting $CELESTIA_APP_HOME..."
rm -r "$CELESTIA_APP_HOME"
echo "Initializing config files..."
celestia-appd init ${NODE_NAME} --chain-id ${CHAIN_ID} > /dev/null 2>&1 # Hide output to reduce terminal noise
echo "Settings seeds in config.toml..."
sed -i.bak -e "s/^seeds *=.*/seeds = \"$SEEDS\"/" $CELESTIA_APP_HOME/config/config.toml
echo "Downloading genesis file..."
celestia-appd download-genesis ${CHAIN_ID} > /dev/null 2>&1 # Hide output to reduce terminal noise
echo "Starting celestia-appd..."
celestia-appd start --v2-upgrade-height 2585031 --force-no-bbr
Tools
Shellcheck

[warning] 24-24: In POSIX sh, read -p is undefined.

(SC3045)

Copy link
Contributor

@cmwaters cmwaters left a comment

Choose a reason for hiding this comment

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

👍

@rootulp rootulp merged commit 628fb99 into celestiaorg:main Sep 16, 2024
31 of 32 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Oct 28, 2024
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.

mocha-4 genesis file does not define an app version
3 participants