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

Force upgrade stdlib with v13 for consensus update #4402

Open
wants to merge 8 commits into
base: dag-master
Choose a base branch
from

Conversation

sanlee42
Copy link
Member

@sanlee42 sanlee42 commented Feb 18, 2025

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Other information

Summary by CodeRabbit

  • Refactor

    • Streamlined the forced upgrade process by removing legacy initialization steps and simplifying transaction validations.
  • Chore

    • Updated dependency versions and reorganized module paths for greater consistency.
    • Removed outdated deployment configuration options.
  • Tests

    • Revised test cases to align with the updated standard library version.
  • New Features

    • Integrated a mandatory runtime component to enhance upgrade management.
    • Added a new module for force upgrade management to improve functionality.

Copy link

coderabbitai bot commented Feb 18, 2025

Walkthrough

This pull request reorganizes and updates the force-upgrade functionality. It moves the force-upgrade module from the vm directory to the chain directory and adjusts related dependency paths. The changes also include version bumps, dependency adjustments (such as removing the force-deploy feature and altering dependency declarations), and modifications to the forced upgrade control flow in several modules, ensuring unambiguous execution without conditional flags.

Changes

File(s) Change Summary
Root Cargo.toml Updated member and dependency paths from "vm/force-upgrade" to "chain/force-upgrade"; revised starcoin-framework dependency revision hash.
chain/Cargo.toml, chain/open-block/Cargo.toml, node/Cargo.toml, cmd/starcoin/Cargo.toml, executor/Cargo.toml Removed the force-deploy feature; modified the starcoin-vm-runtime dependency (removed optional attribute) and added it to dependencies where necessary.
chain/force-upgrade/Cargo.toml, chain/force-upgrade/src/lib.rs Bumped version from "1.13.10" to "2.0.2"; updated bcs-ext dependency declaration; added starcoin-vm-runtime dependency; removed hex dependency and the force-deploy feature logic and init script construction.
chain/open-block/src/lib.rs, chain/src/chain.rs, chain/tests/test_force_upgrade.rs, executor/src/block_executor.rs Modified force-upgrade control flow by removing conditional compilation flags, updating version checks (from 11 to 12/13), simplifying logging, and updating transaction validation logic.
vm/vm-runtime/src/force_upgrade_management.rs, vm/vm-runtime/src/lib.rs Changed FORCE_UPGRADE_BLOCK_NUMBER from 17500000 to 100; adjusted force-upgrade account creation logic; exposed the force_upgrade_management module publicly.

Sequence Diagram(s)

sequenceDiagram
    participant BC as BlockChain
    participant FE as ForceUpgradeManagement
    participant BE as BlockExecutor
    participant OB as OpenedBlock
    BC->>FE: Request force upgrade block number
    FE-->>BC: Return block number (100)
    BC->>BE: Validate transaction count & decide on extra txn execution
    BE->>FE: Verify force upgrade parameters (version, metadata)
    BE->>BC: Execute extra transaction for force upgrade
    OB->>FE: Utilize new force upgrade flow directly (no conditional flags)
Loading

Possibly related PRs

Suggested reviewers

  • nkysg
  • jackzhhuang
  • welbon
  • simonjiao

Poem

I'm a rabbit, hopping through the code,
Shuffling paths where force upgrades now abode.
Modules have moved with a skip and a bound,
Version bumps and features cleanly unwound.
In the land of Rust my heart sings anew,
A joyful hop to celebrate changes true!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@sanlee42 sanlee42 requested review from welbon and nkysg February 18, 2025 02:42
@sanlee42 sanlee42 requested a review from jackzhhuang February 21, 2025 06:46
@sanlee42 sanlee42 marked this pull request as ready for review February 21, 2025 06:47
@sanlee42 sanlee42 requested a review from jolestar as a code owner February 21, 2025 06:47
@sanlee42 sanlee42 removed the request for review from jolestar February 21, 2025 06:47
Copy link

@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 comments (1)
vm/vm-runtime/src/force_upgrade_management.rs (1)

75-83: ⚠️ Potential issue

Fix failing test assertions for Dev and Test chains.

The test assertions for Dev and Test chains are failing. The test expects the same address for both chains but uses different chain IDs (254).

Apply this diff to fix the test:

-            get_force_upgrade_account(&ChainId::new(254))?.address(),
+            get_force_upgrade_account(&ChainId::new(255))?.address(),
🧰 Tools
🪛 GitHub Actions: Code Coverage Report

[error] 75-75: Assertion left == right failed in test force_upgrade_management::tests::test_get_force_upgrade_account.

🧹 Nitpick comments (5)
executor/src/block_executor.rs (1)

170-170: Address TODO comment regarding execute_extra_txn.

The TODO comment indicates a need to check and merge execute_extra_txn functionality with OpenedBlock.

Would you like me to help analyze the OpenedBlock implementation and propose a merged solution?

chain/open-block/src/lib.rs (1)

312-322: Consider making the stdlib version configurable.

The stdlib version is hardcoded to 13, which could make future upgrades more difficult. Consider:

  1. Making the version configurable through a constant or configuration
  2. Adding a comment explaining why version 13 is specifically required
-            let version = on_chain_config::Version { major: 13 };
+            // TODO: Consider making this configurable
+            const STDLIB_VERSION: u64 = 13;
+            let version = on_chain_config::Version { major: STDLIB_VERSION };
chain/open-block/Cargo.toml (1)

1-33: Fix manifest warnings in pipeline.

The pipeline reports warnings about unused manifest key: dependencies.bcs-ext.package. Consider removing the package specification if it's not needed.

-bcs-ext = { package = "bcs-ext", workspace = true }
+bcs-ext = { workspace = true }
🧰 Tools
🪛 GitHub Actions: Code Coverage Report

[warning] 1-1: Unused manifest key: dependencies.bcs-ext.package

🪛 GitHub Actions: benchmark pull requests

[warning] 1-1: Unused manifest key: dependencies.bcs-ext.package

chain/force-upgrade/Cargo.toml (1)

16-16: Fix manifest warnings in pipeline.

Similar to chain/open-block/Cargo.toml, remove the unnecessary package specification to resolve pipeline warnings.

-bcs-ext = { package = "bcs-ext", workspace = true }
+bcs-ext = { workspace = true }
Cargo.toml (1)

1-1: Pipeline Warning: Unused Manifest Key for 'dependencies.bcs-ext.package'
The pipeline reports an unused manifest key (dependencies.bcs-ext.package). Although this issue exists outside the scope of the current PR changes, it may be worth reviewing the configuration for bcs-ext to remove any obsolete keys.

🧰 Tools
🪛 GitHub Actions: Code Coverage Report

[warning] 1-1: Unused manifest key: dependencies.bcs-ext.package

🪛 GitHub Actions: benchmark pull requests

[warning] 1-1: Unused manifest key: dependencies.bcs-ext.package

🪛 GitHub Actions: Build and Test

[warning] 1-1: unused manifest key: dependencies.bcs-ext.package

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc085e9 and 8dd2e46.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (14)
  • Cargo.toml (4 hunks)
  • chain/Cargo.toml (1 hunks)
  • chain/force-upgrade/Cargo.toml (3 hunks)
  • chain/force-upgrade/src/lib.rs (1 hunks)
  • chain/open-block/Cargo.toml (1 hunks)
  • chain/open-block/src/lib.rs (4 hunks)
  • chain/src/chain.rs (2 hunks)
  • chain/tests/test_force_upgrade.rs (7 hunks)
  • cmd/starcoin/Cargo.toml (0 hunks)
  • executor/Cargo.toml (0 hunks)
  • executor/src/block_executor.rs (3 hunks)
  • node/Cargo.toml (0 hunks)
  • vm/vm-runtime/src/force_upgrade_management.rs (2 hunks)
  • vm/vm-runtime/src/lib.rs (1 hunks)
💤 Files with no reviewable changes (3)
  • cmd/starcoin/Cargo.toml
  • executor/Cargo.toml
  • node/Cargo.toml
✅ Files skipped from review due to trivial changes (1)
  • vm/vm-runtime/src/lib.rs
🧰 Additional context used
🪛 GitHub Actions: Code Coverage Report
chain/open-block/Cargo.toml

[warning] 1-1: Unused manifest key: dependencies.bcs-ext.package

chain/Cargo.toml

[warning] 1-1: Unused manifest key: dependencies.bcs-ext.package

vm/vm-runtime/src/force_upgrade_management.rs

[error] 75-75: Assertion left == right failed in test force_upgrade_management::tests::test_get_force_upgrade_account.

chain/force-upgrade/Cargo.toml

[warning] 1-1: Unused manifest key: dependencies.bcs-ext.package

Cargo.toml

[warning] 1-1: Unused manifest key: dependencies.bcs-ext.package

🪛 GitHub Actions: benchmark pull requests
chain/open-block/Cargo.toml

[warning] 1-1: Unused manifest key: dependencies.bcs-ext.package

chain/Cargo.toml

[warning] 1-1: Unused manifest key: dependencies.bcs-ext.package

chain/force-upgrade/Cargo.toml

[warning] 1-1: Unused manifest key: dependencies.bcs-ext.package

Cargo.toml

[warning] 1-1: Unused manifest key: dependencies.bcs-ext.package

🪛 GitHub Actions: Build and Test
chain/force-upgrade/Cargo.toml

[warning] 1-1: unused manifest key: dependencies.bcs-ext.package

Cargo.toml

[warning] 1-1: unused manifest key: dependencies.bcs-ext.package

🔇 Additional comments (15)
chain/force-upgrade/src/lib.rs (1)

27-27: LGTM! Package path updated for v13 upgrade.

The package file path has been correctly updated to reflect the upgrade from version 12 to version 13.

vm/vm-runtime/src/force_upgrade_management.rs (1)

8-8: Verify the significant reduction in force upgrade block number.

The force upgrade block number has been drastically reduced from 17500000 to 100. This could significantly impact the network's upgrade timeline.

Please confirm if this reduction is intentional and aligns with the network's upgrade schedule.

chain/tests/test_force_upgrade.rs (1)

20-20: LGTM! Test cases updated for v12 to v13 upgrade path.

The test cases have been correctly updated to use stdlib version 12 as the starting point for the v13 upgrade.

Also applies to: 36-36, 204-204

executor/src/block_executor.rs (2)

133-141: LGTM! Version check updated for v12 to v13 upgrade.

The version check has been correctly updated to execute extra transactions only when the stdlib version is 12, preparing for the upgrade to v13.


144-147: LGTM! Improved error handling for metadata retrieval.

The code now properly handles metadata retrieval errors using get_block_metadata_v2 with explicit error messaging.

chain/open-block/src/lib.rs (2)

9-9: LGTM! Import changes are well-organized.

The new imports are properly structured and align with the force upgrade functionality changes.

Also applies to: 27-27, 31-41


557-563: LGTM! Transaction validation logic is cleaner.

The simplified validation logic maintains the same functionality while being more readable and maintainable.

chain/src/chain.rs (1)

756-762: LGTM! Consistent transaction validation.

The transaction validation logic matches the changes in open-block/src/lib.rs, maintaining consistency across the codebase.

chain/open-block/Cargo.toml (1)

18-18: LGTM! Required dependency for force upgrade.

The addition of starcoin-vm-runtime is necessary for the force upgrade functionality.

chain/force-upgrade/Cargo.toml (1)

7-7: LGTM! Version bump and dependency addition.

The version update to 2.0.2 and addition of starcoin-vm-runtime align with the force upgrade changes.

Also applies to: 28-28

chain/Cargo.toml (1)

24-24: Dependency Update: 'starcoin-vm-runtime' Now Mandatory
The removal of the optional = true flag for starcoin-vm-runtime is intentional to ensure that the dependency is always included as part of the consensus update. Please verify that all consuming modules are compatible with this stricter dependency requirement.

Cargo.toml (4)

43-43: Workspace Members Update: 'chain/force-upgrade' Module
The workspace members list now includes "chain/force-upgrade" (previously located under "vm/force-upgrade"), reflecting the new module organization. This change improves clarity and aligns with the project’s structural reorganization.


157-157: Default Members Update: 'chain/force-upgrade' Inclusion
Updating the default-members configuration to reference "chain/force-upgrade" ensures that the renamed module is automatically included, which is consistent with the intended restructuring.


457-457: Dependency Revision Update: 'starcoin-framework'
The revision for starcoin-framework has been bumped to 631ddccd5a169f535476a62bd8145782e3d9960a. This update is crucial to maintain compatibility across the codebase as part of the consensus update. Please ensure related tests pass with this new revision.


475-475: Dependency Path Update: 'starcoin-force-upgrade'
The dependency for starcoin-force-upgrade has been updated to use the new path "chain/force-upgrade". This change correctly reflects the move of the force-upgrade module and ensures path consistency across the project.

Copy link

@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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8dd2e46 and 7099de5.

📒 Files selected for processing (1)
  • genesis/src/lib.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Generate code coverage report

Comment on lines +539 to +543
//FIXME: consensus config update by genesis init when stdlib upgrade_from_12_to_13
/*assert_eq!(
consensus_config.as_ref().unwrap(),
&net.genesis_config().consensus_config
);
);*/
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

❓ Verification inconclusive

Verify the consensus config update during stdlib upgrade.

The commented-out assertion suggests that the consensus config will be updated during the stdlib upgrade from v12 to v13. This change needs careful verification to ensure the new consensus config is correctly applied.

Run the following script to verify the consensus config changes:

Additionally, please verify:

  1. What are the specific consensus config changes being introduced?
  2. Are there any migration steps needed for the consensus config update?
  3. Have all dependent components been updated to handle the new consensus config?

🏁 Script executed:

#!/bin/bash
# Description: Check for consensus config changes in the stdlib upgrade

# Search for consensus config related changes
ast-grep --pattern 'consensus_config'

# Search for stdlib upgrade related changes
rg -A 5 'upgrade.*12.*13|v12.*v13'

Length of output: 5077


ACTION: Verify consensus config migration for stdlib upgrade from v12 to v13.

The commented-out assertion indicates that the consensus config verification is intentionally disabled pending the upgrade. Please confirm that:

  • The new consensus config values (e.g., gas limits, time targets, difficulty windows, etc.) are being set as expected.
  • All necessary migration steps for transitioning from v12 to v13 are implemented and documented.
  • All dependent modules (such as genesis initialization and transaction builder logic) correctly handle the updated consensus config.

Once these items are verified, consider adding or re-enabling corresponding tests to ensure the configuration matches post-upgrade requirements.

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.

1 participant