From 85b971de1ff4a01b614c85c767c493d91e1af0dc Mon Sep 17 00:00:00 2001 From: runtianz Date: Thu, 1 Jun 2023 17:43:36 -0700 Subject: [PATCH 1/2] [features] Force reconfigruation after feature change (#8471) * [features] Force reconfigruation after feature change * fixup! [features] Force reconfigruation after feature change --- .../src/components/consensus_config.rs | 2 +- .../src/components/execution_config.rs | 2 +- .../src/components/feature_flags.rs | 10 +++- .../src/components/gas.rs | 2 +- .../src/components/transaction_fee.rs | 2 +- .../src/components/version.rs | 2 +- aptos-move/aptos-release-builder/src/utils.rs | 20 +++++--- .../aptos-framework/doc/reconfiguration.md | 50 +++++++++++++++++++ .../sources/reconfiguration.move | 6 +++ .../sources/reconfiguration.spec.move | 17 +++++++ 10 files changed, 99 insertions(+), 14 deletions(-) diff --git a/aptos-move/aptos-release-builder/src/components/consensus_config.rs b/aptos-move/aptos-release-builder/src/components/consensus_config.rs index 4d4f6e890978a..d21499e138fd9 100644 --- a/aptos-move/aptos-release-builder/src/components/consensus_config.rs +++ b/aptos-move/aptos-release-builder/src/components/consensus_config.rs @@ -23,7 +23,7 @@ pub fn generate_consensus_upgrade_proposal( &writer, is_testnet, next_execution_hash.clone(), - "aptos_framework::consensus_config", + &["aptos_framework::consensus_config"], |writer| { let consensus_config_blob = bcs::to_bytes(consensus_config).unwrap(); assert!(consensus_config_blob.len() < 65536); diff --git a/aptos-move/aptos-release-builder/src/components/execution_config.rs b/aptos-move/aptos-release-builder/src/components/execution_config.rs index 457d20485e954..4bc5db4364468 100644 --- a/aptos-move/aptos-release-builder/src/components/execution_config.rs +++ b/aptos-move/aptos-release-builder/src/components/execution_config.rs @@ -23,7 +23,7 @@ pub fn generate_execution_config_upgrade_proposal( &writer, is_testnet, next_execution_hash.clone(), - "aptos_framework::execution_config", + &["aptos_framework::execution_config"], |writer| { let execution_config_blob = bcs::to_bytes(execution_config).unwrap(); assert!(execution_config_blob.len() < 65536); diff --git a/aptos-move/aptos-release-builder/src/components/feature_flags.rs b/aptos-move/aptos-release-builder/src/components/feature_flags.rs index 4876fc6977a04..ced7ff6cc6903 100644 --- a/aptos-move/aptos-release-builder/src/components/feature_flags.rs +++ b/aptos-move/aptos-release-builder/src/components/feature_flags.rs @@ -91,7 +91,7 @@ pub fn generate_feature_upgrade_proposal( &writer, is_testnet, next_execution_hash.clone(), - "std::features", + &["std::features", "aptos_framework::reconfiguration"], |writer| { emit!(writer, "let enabled_blob: vector = "); generate_features_blob(writer, &enabled); @@ -106,11 +106,19 @@ pub fn generate_feature_upgrade_proposal( writer, "features::change_feature_flags(framework_signer, enabled_blob, disabled_blob);" ); + emitln!( + writer, + "reconfiguration::reconfigure_with_signer(framework_signer);" + ); } else { emitln!( writer, "features::change_feature_flags(&framework_signer, enabled_blob, disabled_blob);" ); + emitln!( + writer, + "reconfiguration::reconfigure_with_signer(&framework_signer);" + ); } }, ); diff --git a/aptos-move/aptos-release-builder/src/components/gas.rs b/aptos-move/aptos-release-builder/src/components/gas.rs index 592b10b53cd02..64a8044c44626 100644 --- a/aptos-move/aptos-release-builder/src/components/gas.rs +++ b/aptos-move/aptos-release-builder/src/components/gas.rs @@ -44,7 +44,7 @@ pub fn generate_gas_upgrade_proposal( &writer, is_testnet, next_execution_hash.clone(), - "aptos_framework::gas_schedule", + &["aptos_framework::gas_schedule"], |writer| { let gas_schedule_blob = bcs::to_bytes(gas_schedule).unwrap(); assert!(gas_schedule_blob.len() < 65536); diff --git a/aptos-move/aptos-release-builder/src/components/transaction_fee.rs b/aptos-move/aptos-release-builder/src/components/transaction_fee.rs index 5508dd3bf0437..9b4b17dce06c7 100644 --- a/aptos-move/aptos-release-builder/src/components/transaction_fee.rs +++ b/aptos-move/aptos-release-builder/src/components/transaction_fee.rs @@ -19,7 +19,7 @@ pub fn generate_fee_distribution_proposal( &writer, is_testnet, next_execution_hash, - "aptos_framework::transaction_fee", + &["aptos_framework::transaction_fee"], |writer| { emitln!( writer, diff --git a/aptos-move/aptos-release-builder/src/components/version.rs b/aptos-move/aptos-release-builder/src/components/version.rs index 75ea9440515c0..6e88d5174e279 100644 --- a/aptos-move/aptos-release-builder/src/components/version.rs +++ b/aptos-move/aptos-release-builder/src/components/version.rs @@ -19,7 +19,7 @@ pub fn generate_version_upgrade_proposal( &writer, is_testnet, next_execution_hash.clone(), - "aptos_framework::version", + &["aptos_framework::version"], |writer| { if is_testnet && next_execution_hash.is_empty() { emitln!( diff --git a/aptos-move/aptos-release-builder/src/utils.rs b/aptos-move/aptos-release-builder/src/utils.rs index 195140e02688c..2b49469918a0b 100644 --- a/aptos-move/aptos-release-builder/src/utils.rs +++ b/aptos-move/aptos-release-builder/src/utils.rs @@ -55,7 +55,7 @@ pub(crate) fn generate_next_execution_hash_blob( pub(crate) fn generate_governance_proposal_header( writer: &CodeWriter, - deps_name: &str, + deps_names: &[&str], is_multi_step: bool, next_execution_hash: Vec, ) { @@ -63,7 +63,9 @@ pub(crate) fn generate_governance_proposal_header( writer.indent(); emitln!(writer, "use aptos_framework::aptos_governance;"); - emitln!(writer, "use {};", deps_name); + for deps_name in deps_names { + emitln!(writer, "use {};", deps_name); + } if next_execution_hash == "vector::empty()".as_bytes() { emitln!(writer, "use std::vector;"); } @@ -83,12 +85,14 @@ pub(crate) fn generate_governance_proposal_header( } } -pub(crate) fn generate_testnet_header(writer: &CodeWriter, deps_name: &str) { +pub(crate) fn generate_testnet_header(writer: &CodeWriter, deps_names: &[&str]) { emitln!(writer, "script {"); writer.indent(); emitln!(writer, "use aptos_framework::aptos_governance;"); - emitln!(writer, "use {};", deps_name); + for deps_name in deps_names { + emitln!(writer, "use {};", deps_name); + } emitln!(writer); emitln!(writer, "fun main(core_resources: &signer) {"); @@ -116,7 +120,7 @@ pub(crate) fn generate_governance_proposal( writer: &CodeWriter, is_testnet: bool, next_execution_hash: Vec, - deps_name: &str, + deps_names: &[&str], body: F, ) -> String where @@ -124,17 +128,17 @@ where { if next_execution_hash.is_empty() { if is_testnet { - generate_testnet_header(writer, deps_name); + generate_testnet_header(writer, deps_names); } else { generate_governance_proposal_header( writer, - deps_name, + deps_names, false, "".to_owned().into_bytes(), ); } } else { - generate_governance_proposal_header(writer, deps_name, true, next_execution_hash); + generate_governance_proposal_header(writer, deps_names, true, next_execution_hash); }; body(writer); diff --git a/aptos-move/framework/aptos-framework/doc/reconfiguration.md b/aptos-move/framework/aptos-framework/doc/reconfiguration.md index 42e7249c37903..82cc29779f9cf 100644 --- a/aptos-move/framework/aptos-framework/doc/reconfiguration.md +++ b/aptos-move/framework/aptos-framework/doc/reconfiguration.md @@ -15,6 +15,7 @@ to synchronize configuration changes for the validators. - [Function `disable_reconfiguration`](#0x1_reconfiguration_disable_reconfiguration) - [Function `enable_reconfiguration`](#0x1_reconfiguration_enable_reconfiguration) - [Function `reconfiguration_enabled`](#0x1_reconfiguration_reconfiguration_enabled) +- [Function `reconfigure_with_signer`](#0x1_reconfiguration_reconfigure_with_signer) - [Function `reconfigure`](#0x1_reconfiguration_reconfigure) - [Function `last_reconfiguration_time`](#0x1_reconfiguration_last_reconfiguration_time) - [Function `current_epoch`](#0x1_reconfiguration_current_epoch) @@ -23,6 +24,7 @@ to synchronize configuration changes for the validators. - [Function `initialize`](#@Specification_1_initialize) - [Function `disable_reconfiguration`](#@Specification_1_disable_reconfiguration) - [Function `enable_reconfiguration`](#@Specification_1_enable_reconfiguration) + - [Function `reconfigure_with_signer`](#@Specification_1_reconfigure_with_signer) - [Function `reconfigure`](#@Specification_1_reconfigure) - [Function `last_reconfiguration_time`](#@Specification_1_last_reconfiguration_time) - [Function `current_epoch`](#@Specification_1_current_epoch) @@ -314,6 +316,32 @@ This function should only be used for offline WriteSet generation purpose and sh + + + + +## Function `reconfigure_with_signer` + +Signal validators to start using new configuration. Must be called from aptos_framework signer. + + +
public fun reconfigure_with_signer(aptos_framework: &signer)
+
+ + + +
+Implementation + + +
public fun reconfigure_with_signer(aptos_framework: &signer) acquires Configuration {
+    system_addresses::assert_aptos_framework(aptos_framework);
+    reconfigure();
+}
+
+ + +
@@ -565,6 +593,28 @@ Make sure the caller is admin and check the resource DisableReconfiguration. + + +### Function `reconfigure_with_signer` + + +
public fun reconfigure_with_signer(aptos_framework: &signer)
+
+ + + + +
pragma verify_duration_estimate = 120;
+requires exists<stake::ValidatorFees>(@aptos_framework);
+requires exists<CoinInfo<AptosCoin>>(@aptos_framework);
+include transaction_fee::RequiresCollectedFeesPerValueLeqBlockAptosSupply;
+include AbortsIfNotAptosFramework;
+include staking_config::StakingRewardsConfigRequirement;
+aborts_if false;
+
+ + + ### Function `reconfigure` diff --git a/aptos-move/framework/aptos-framework/sources/reconfiguration.move b/aptos-move/framework/aptos-framework/sources/reconfiguration.move index deec0364228c8..92812d1c56545 100644 --- a/aptos-move/framework/aptos-framework/sources/reconfiguration.move +++ b/aptos-move/framework/aptos-framework/sources/reconfiguration.move @@ -92,6 +92,12 @@ module aptos_framework::reconfiguration { !exists(@aptos_framework) } + /// Signal validators to start using new configuration. Must be called from aptos_framework signer. + public fun reconfigure_with_signer(aptos_framework: &signer) acquires Configuration { + system_addresses::assert_aptos_framework(aptos_framework); + reconfigure(); + } + /// Signal validators to start using new configuration. Must be called from friend config modules. public(friend) fun reconfigure() acquires Configuration { // Do not do anything if genesis has not finished. diff --git a/aptos-move/framework/aptos-framework/sources/reconfiguration.spec.move b/aptos-move/framework/aptos-framework/sources/reconfiguration.spec.move index 8336c7cc0a823..9b0440e5f1708 100644 --- a/aptos-move/framework/aptos-framework/sources/reconfiguration.spec.move +++ b/aptos-move/framework/aptos-framework/sources/reconfiguration.spec.move @@ -61,6 +61,23 @@ spec aptos_framework::reconfiguration { aborts_if !exists(@aptos_framework); } + spec reconfigure_with_signer { + use aptos_framework::coin::CoinInfo; + use aptos_framework::aptos_coin::AptosCoin; + use aptos_framework::transaction_fee; + use aptos_framework::staking_config; + + pragma verify_duration_estimate = 120; // TODO: set because of timeout (property proved) + + requires exists(@aptos_framework); + requires exists>(@aptos_framework); + + include transaction_fee::RequiresCollectedFeesPerValueLeqBlockAptosSupply; + include AbortsIfNotAptosFramework; + include staking_config::StakingRewardsConfigRequirement; + aborts_if false; + } + spec reconfigure { use aptos_framework::coin::CoinInfo; use aptos_framework::aptos_coin::AptosCoin; From 2350dafa0258171c0bec8943162386880bf9b79d Mon Sep 17 00:00:00 2001 From: Kevin <105028215+movekevin@users.noreply.github.com> Date: Tue, 6 Jun 2023 14:16:52 -0500 Subject: [PATCH 2/2] Update release builder to use the correct reconfigure function (#8536) --- .../src/components/feature_flags.rs | 12 ++--- .../aptos-framework/doc/reconfiguration.md | 50 ------------------- .../sources/reconfiguration.move | 6 --- .../sources/reconfiguration.spec.move | 17 ------- 4 files changed, 3 insertions(+), 82 deletions(-) diff --git a/aptos-move/aptos-release-builder/src/components/feature_flags.rs b/aptos-move/aptos-release-builder/src/components/feature_flags.rs index ced7ff6cc6903..0dbc07b984529 100644 --- a/aptos-move/aptos-release-builder/src/components/feature_flags.rs +++ b/aptos-move/aptos-release-builder/src/components/feature_flags.rs @@ -91,7 +91,7 @@ pub fn generate_feature_upgrade_proposal( &writer, is_testnet, next_execution_hash.clone(), - &["std::features", "aptos_framework::reconfiguration"], + &["std::features"], |writer| { emit!(writer, "let enabled_blob: vector = "); generate_features_blob(writer, &enabled); @@ -106,19 +106,13 @@ pub fn generate_feature_upgrade_proposal( writer, "features::change_feature_flags(framework_signer, enabled_blob, disabled_blob);" ); - emitln!( - writer, - "reconfiguration::reconfigure_with_signer(framework_signer);" - ); + emitln!(writer, "aptos_governance::reconfigure(framework_signer);"); } else { emitln!( writer, "features::change_feature_flags(&framework_signer, enabled_blob, disabled_blob);" ); - emitln!( - writer, - "reconfiguration::reconfigure_with_signer(&framework_signer);" - ); + emitln!(writer, "aptos_governance::reconfigure(&framework_signer);"); } }, ); diff --git a/aptos-move/framework/aptos-framework/doc/reconfiguration.md b/aptos-move/framework/aptos-framework/doc/reconfiguration.md index 82cc29779f9cf..42e7249c37903 100644 --- a/aptos-move/framework/aptos-framework/doc/reconfiguration.md +++ b/aptos-move/framework/aptos-framework/doc/reconfiguration.md @@ -15,7 +15,6 @@ to synchronize configuration changes for the validators. - [Function `disable_reconfiguration`](#0x1_reconfiguration_disable_reconfiguration) - [Function `enable_reconfiguration`](#0x1_reconfiguration_enable_reconfiguration) - [Function `reconfiguration_enabled`](#0x1_reconfiguration_reconfiguration_enabled) -- [Function `reconfigure_with_signer`](#0x1_reconfiguration_reconfigure_with_signer) - [Function `reconfigure`](#0x1_reconfiguration_reconfigure) - [Function `last_reconfiguration_time`](#0x1_reconfiguration_last_reconfiguration_time) - [Function `current_epoch`](#0x1_reconfiguration_current_epoch) @@ -24,7 +23,6 @@ to synchronize configuration changes for the validators. - [Function `initialize`](#@Specification_1_initialize) - [Function `disable_reconfiguration`](#@Specification_1_disable_reconfiguration) - [Function `enable_reconfiguration`](#@Specification_1_enable_reconfiguration) - - [Function `reconfigure_with_signer`](#@Specification_1_reconfigure_with_signer) - [Function `reconfigure`](#@Specification_1_reconfigure) - [Function `last_reconfiguration_time`](#@Specification_1_last_reconfiguration_time) - [Function `current_epoch`](#@Specification_1_current_epoch) @@ -316,32 +314,6 @@ This function should only be used for offline WriteSet generation purpose and sh - - - - -## Function `reconfigure_with_signer` - -Signal validators to start using new configuration. Must be called from aptos_framework signer. - - -
public fun reconfigure_with_signer(aptos_framework: &signer)
-
- - - -
-Implementation - - -
public fun reconfigure_with_signer(aptos_framework: &signer) acquires Configuration {
-    system_addresses::assert_aptos_framework(aptos_framework);
-    reconfigure();
-}
-
- - -
@@ -593,28 +565,6 @@ Make sure the caller is admin and check the resource DisableReconfiguration. - - -### Function `reconfigure_with_signer` - - -
public fun reconfigure_with_signer(aptos_framework: &signer)
-
- - - - -
pragma verify_duration_estimate = 120;
-requires exists<stake::ValidatorFees>(@aptos_framework);
-requires exists<CoinInfo<AptosCoin>>(@aptos_framework);
-include transaction_fee::RequiresCollectedFeesPerValueLeqBlockAptosSupply;
-include AbortsIfNotAptosFramework;
-include staking_config::StakingRewardsConfigRequirement;
-aborts_if false;
-
- - - ### Function `reconfigure` diff --git a/aptos-move/framework/aptos-framework/sources/reconfiguration.move b/aptos-move/framework/aptos-framework/sources/reconfiguration.move index 92812d1c56545..deec0364228c8 100644 --- a/aptos-move/framework/aptos-framework/sources/reconfiguration.move +++ b/aptos-move/framework/aptos-framework/sources/reconfiguration.move @@ -92,12 +92,6 @@ module aptos_framework::reconfiguration { !exists(@aptos_framework) } - /// Signal validators to start using new configuration. Must be called from aptos_framework signer. - public fun reconfigure_with_signer(aptos_framework: &signer) acquires Configuration { - system_addresses::assert_aptos_framework(aptos_framework); - reconfigure(); - } - /// Signal validators to start using new configuration. Must be called from friend config modules. public(friend) fun reconfigure() acquires Configuration { // Do not do anything if genesis has not finished. diff --git a/aptos-move/framework/aptos-framework/sources/reconfiguration.spec.move b/aptos-move/framework/aptos-framework/sources/reconfiguration.spec.move index 9b0440e5f1708..8336c7cc0a823 100644 --- a/aptos-move/framework/aptos-framework/sources/reconfiguration.spec.move +++ b/aptos-move/framework/aptos-framework/sources/reconfiguration.spec.move @@ -61,23 +61,6 @@ spec aptos_framework::reconfiguration { aborts_if !exists(@aptos_framework); } - spec reconfigure_with_signer { - use aptos_framework::coin::CoinInfo; - use aptos_framework::aptos_coin::AptosCoin; - use aptos_framework::transaction_fee; - use aptos_framework::staking_config; - - pragma verify_duration_estimate = 120; // TODO: set because of timeout (property proved) - - requires exists(@aptos_framework); - requires exists>(@aptos_framework); - - include transaction_fee::RequiresCollectedFeesPerValueLeqBlockAptosSupply; - include AbortsIfNotAptosFramework; - include staking_config::StakingRewardsConfigRequirement; - aborts_if false; - } - spec reconfigure { use aptos_framework::coin::CoinInfo; use aptos_framework::aptos_coin::AptosCoin;