Skip to content

feat: post merge upgrade #1214

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

Draft
wants to merge 65 commits into
base: main
Choose a base branch
from
Draft

feat: post merge upgrade #1214

wants to merge 65 commits into from

Conversation

0xmovses
Copy link
Collaborator

@0xmovses 0xmovses commented Apr 25, 2025

Summary

  • RFCs: Link to RFC, Link to RFC, or $\emptyset$.
  • Categories: any of protocol-units, networks, scripts, util, cicd, or misc.

Description

This PR implements a full on-chain governance flow for the Post-L1-Merge feature flags (notably DECOMMISSION_CORE_RESOURCES), adds support for a partial-voting feature, and wires up CI to run the post-merge migration.

  • Introduces propose_post_l1_merge_with_full_governance and PROPOSAL_SCRIPTS for on-chain feature-flag proposals.
  • Adds execution_hash to the feature-flags release bundle to ensure proposal immutability.
  • Updates migration modules and CI configuration to support end-to-end Post-L1-Merge upgrades.

Changelog

Show a summary per file
File Description
protocol-units/execution/maptos/framework/releases/post-l1-merge/src/vote.rs Adds governance proposal builder, partial/full voting functions, and tests
protocol-units/execution/maptos/framework/releases/post-l1-merge/src/tests/vote.data/enable_partial_governance_voting/sources/main.move Move script to enable partial governance voting
protocol-units/execution/maptos/framework/releases/post-l1-merge/src/tests/vote.data/enable_partial_governance_voting/Move.toml Defines the Move package for partial voting script
protocol-units/execution/maptos/framework/releases/post-l1-merge/src/lib.rs Registers cached and vote modules and commit-hash macros
protocol-units/execution/maptos/framework/releases/post-l1-merge/src/cached.rs Sets up MRB release and empty script stub
protocol-units/execution/maptos/framework/releases/post-l1-merge/build.rs Adds commit_hash_with_script! for the release tool
protocol-units/execution/maptos/framework/releases/post-l1-merge/Cargo.toml Introduces the post-l1-merge release crate
protocol-units/execution/maptos/framework/releases/feature-flags/src/lib.rs Implements execution_hash for feature-flag proposals
protocol-units/execution/maptos/framework/migrations/pre-l1-merge-to-post-l1-merge/src/lib.rs Defines the Post-L1-Merge migration struct and errors
protocol-units/execution/maptos/framework/migrations/pre-l1-merge-to-post-l1-merge/src/dot_movement.rs Integrates the migration into the DotMovement CLI
process-compose/movement-full-node/process-compose.test-migrate-post-l1-merge.yml Adds a process for running the migration test
Cargo.toml Adds aptos-framework-post-l1-merge-release to the workspace and updates Aptos dependency revisions

Testing

just movement-full-node native build.setup.eth-local.celestia-local.test-migrate-post-l1-merge --keep-tui

🧠 Overview

This PR introduces a fully on-chain governance flow to propose and activate feature flags — specifically targeting the DECOMMISSION_CORE_RESOURCES feature — without relying on the core_resources signer. This replaces the macro-based fast-path that used core_resources to directly sign proposals.

🧱 Full Governance Flow

The flow implemented in propose_post_l1_merge_with_full_governance does the following:

  1. Construct the Feature Flags Proposal

    • Builds a SetFeatureFlags<PostL1Merge> wrapper using the existing release logic.
    • Prepares a Features struct with the desired feature flags (e.g., DECOMMISSION_CORE_RESOURCES).
    • Generates the compiled bytecode and computes the execution_hash using sha2::Sha256.
  2. Submit a Governance Proposal

    • Encodes and submits a create_proposal_v2 transaction using a validator's stake pool address.
    • Uses the execution hash as the target of the proposal to ensure immutability and validation.
  3. Live Chain Integration

    • Operates against a real, externally running chain (connected via rest_client).
    • Uses a real validator account (LocalAccount) from the maptos_config to sign and submit the transaction.

🗳 Why This Matters

  • No Core Signer Required: Works even when core_resources is inactive, enabling governance upgrades on a live, decentralized network.
  • Auditable: Uses full governance lifecycle with stake-based voting, eliminating opaque upgrade paths.
  • Composable: Can be extended to support multi-step proposals, voting, and resolution.

✅ Example Usage

propose_post_l1_merge_with_full_governance(
    &mut validator_account,
    &rest_client,
    chain_id
).await?;

Partial Voting Mechanism test

This test verifies the behavior of the partial voting mechanism in the on-chain governance system.

It simulates the following:

  1. Initial Setup

    • Creates a test harness and two validator accounts.
    • Stakes tokens for both validators and locks them up (required for voting).
  2. Proposal Creation & Pre-Upgrade Voting

    • Validator 2 creates a proposal (proposal_id = 0).
    • Validator 1 votes on this proposal before partial voting is officially enabled.
    • Since partial voting isn't enabled yet, the voting_power argument is ignored, and validator 1 uses their full voting power.
    • The test verifies that validator 1 has no voting power left after the vote.
  3. Enable Partial Voting

    • A special script is executed to enable partial governance voting (as would be done via governance in production).
    • After enabling, the test ensures that a voter cannot re-vote on a proposal they already voted on before the feature was enabled.
  4. New Proposal & Edge Case Handling

    • Validator 1 creates a new proposal (proposal_id = 1).
    • The test confirms that voting on a non-existent proposal fails with the correct error.
  5. Partial Voting Behavior

    • Validator 1 and Validator 2 both have full voting power on the new proposal.
    • Validator 1 votes incrementally:
      • First, uses 100 votes with a "yes" vote.
      • Then, uses 1000 more votes with a "no" vote.
      • The test checks that remaining voting power is reduced correctly after each vote.
    • Finally, validator 1 tries to vote using their full stake, but only the remaining voting power is used.
    • The test ensures a voter cannot exceed their available voting power.

@Copilot Copilot AI review requested due to automatic review settings April 25, 2025 14:31
@0xmovses 0xmovses marked this pull request as draft April 25, 2025 14:32
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new release module for pre-L1-merge along with associated migrations and tooling for upgrading the Aptos framework. Key changes include:

  • The addition of the pre-L1-merge release module with gas upgrade and MRB build script generation.
  • New migration modules to transition between release versions, including biarritz-rc1-to-pre-l1-merge and pre-l1-merge-to-post-l1-merge.
  • Updates to the Cargo.toml file and process-compose files to integrate the new release and migration workflows.

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
protocol-units/execution/maptos/framework/releases/pre-l1-merge/src/lib.rs Introduces gas upgrade module generation and commit hash-based build script generation.
protocol-units/execution/maptos/framework/releases/pre-l1-merge/src/cached.rs Adds MRB release handling and gas upgrade configuration with an additional macro usage.
protocol-units/execution/maptos/framework/releases/pre-l1-merge/build.rs Provides a build script for generating Elsa’s build assets.
protocol-units/execution/maptos/framework/migrations/pre-l1-merge-to-post-l1-merge/ Creates migration utilities to transition from pre-L1-merge to post-L1-merge modules.
protocol-units/execution/maptos/framework/migrations/biarritz-rc1-to-pre-l1-merge/ Adds migration code to facilitate the upgrade from biarritz-rc1 to pre-L1-merge.
process-compose/movement-full-node/process-compose.test-migrate-biarritz-rc1-to-pre-l1-merge.yml Updates process compose configuration for testing the new migration flow.
Cargo.toml Integrates the new pre-L1-merge release into the workspace dependencies.
Comments suppressed due to low confidence (3)

protocol-units/execution/maptos/framework/releases/pre-l1-merge/src/cached.rs:4

  • [nitpick] The identifier 'BIARRTIZ_RC1' appears to be misspelled. Consider renaming it to 'BiarritzRc1' for consistency with other references.
mrb_release!(PreL1Merge, BIARRTIZ_RC1, "d00f5e5ef3179919b3fc8245ac774f8509ed6a3e-biarritz-rc1.mrb");

protocol-units/execution/maptos/framework/migrations/pre-l1-merge-to-post-l1-merge/src/dot_movement.rs:40

  • [nitpick] The comment references a migration from Elsa to Biarritz RC1, which is inconsistent with the pre-L1-merge to post-L1-merge migration context. Please update the comment to accurately reflect the intended migration path.
// migrate the framework from Elsa to Biarritz RC1

protocol-units/execution/maptos/framework/migrations/biarritz-rc1-to-pre-l1-merge/src/lib.rs:19

  • [nitpick] The TODO comment mentions validating that the current release is Elsa, which may be outdated or incorrect in this context. Consider updating the comment to clarify the correct release criteria.
// todo: validate that the current release is Elsa

@0xmovses 0xmovses changed the base branch from main to andygolay/framework-upgrade-tests April 25, 2025 16:05
@andygolay
Copy link
Contributor

@0xmovses locally I got

error[E0433]: failed to resolve: use of undeclared crate or module `common`
  --> protocol-units/execution/maptos/framework/releases/post-l1-merge/src/vote.rs:13:2
   |
13 |     common::build_scripts(package_folder, package_names)
   |     ^^^^^^ use of undeclared crate or module `common`

For more information about this error, try `rustc --explain E0433`.
error: could not compile `aptos-framework-post-l1-merge-release` (lib) due to 1 previous error
image

and see the same in CI as well.

@0xmovses
Copy link
Collaborator Author

@andygolay ah sorry still im draft.

@0xmovses 0xmovses marked this pull request as draft May 19, 2025 10:14
@0xmovses 0xmovses requested a review from Copilot June 4, 2025 23:42
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a full on-chain governance flow for the Post-L1-Merge feature flags (notably DECOMMISSION_CORE_RESOURCES), adds support for a partial-voting feature, and wires up CI to run the post-merge migration.

  • Introduces propose_post_l1_merge_with_full_governance and PROPOSAL_SCRIPTS for on-chain feature-flag proposals.
  • Adds execution_hash to the feature-flags release bundle to ensure proposal immutability.
  • Updates migration modules and CI configuration to support end-to-end Post-L1-Merge upgrades.

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
protocol-units/execution/maptos/framework/releases/post-l1-merge/src/vote.rs Adds governance proposal builder, partial/full voting functions, and tests
protocol-units/execution/maptos/framework/releases/post-l1-merge/src/tests/vote.data/enable_partial_governance_voting/sources/main.move Move script to enable partial governance voting
protocol-units/execution/maptos/framework/releases/post-l1-merge/src/tests/vote.data/enable_partial_governance_voting/Move.toml Defines the Move package for partial voting script
protocol-units/execution/maptos/framework/releases/post-l1-merge/src/lib.rs Registers cached and vote modules and commit-hash macros
protocol-units/execution/maptos/framework/releases/post-l1-merge/src/cached.rs Sets up MRB release and empty script stub
protocol-units/execution/maptos/framework/releases/post-l1-merge/build.rs Adds commit_hash_with_script! for the release tool
protocol-units/execution/maptos/framework/releases/post-l1-merge/Cargo.toml Introduces the post-l1-merge release crate
protocol-units/execution/maptos/framework/releases/feature-flags/src/lib.rs Implements execution_hash for feature-flag proposals
protocol-units/execution/maptos/framework/migrations/pre-l1-merge-to-post-l1-merge/src/lib.rs Defines the Post-L1-Merge migration struct and errors
protocol-units/execution/maptos/framework/migrations/pre-l1-merge-to-post-l1-merge/src/dot_movement.rs Integrates the migration into the DotMovement CLI
process-compose/movement-full-node/process-compose.test-migrate-post-l1-merge.yml Adds a process for running the migration test
Cargo.toml Adds aptos-framework-post-l1-merge-release to the workspace and updates Aptos dependency revisions
Comments suppressed due to low confidence (3)

protocol-units/execution/maptos/framework/migrations/pre-l1-merge-to-post-l1-merge/src/lib.rs:41

  • The method name suggests migrating from Biarritz RC1 to PreL1Merge, but the trait and doc comment indicate migrating from PreL1Merge to PostL1Merge; consider renaming to migrate_framework_from_pre_l1_merge_to_post_l1_merge for clarity.
fn migrate_framework_from_biarritza_rc1_to_pre_l1_merge(

process-compose/movement-full-node/process-compose.test-migrate-post-l1-merge.yml:11

  • The process identifier test-migrate-pre-to-post-l1-merge does not match the filename process-compose.test-migrate-post-l1-merge.yml; aligning these names can reduce confusion.
  test-migrate-pre-to-post-l1-merge:

protocol-units/execution/maptos/framework/releases/post-l1-merge/src/cached.rs:37

  • [nitpick] The main function in the generated script is empty—consider adding a comment or a TODO explaining why it's intentionally blank or what should be implemented here.
fun main(core_resources: &signer) {

@sebtomba
Copy link
Contributor

sebtomba commented Jun 6, 2025

Shouldn't we call update_governance_config() with reasonable governance parameters? Or will this occur later?

@@ -124,6 +125,14 @@ where

Ok(vec![signed_transaction])
}

pub fn execution_hash(&self) -> Result<Vec<u8>, ReleaseBundleError> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

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.

4 participants