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

reconfiguration with dkg #10328

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions aptos-move/aptos-gas-schedule-updator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ fn generate_script(gas_schedule: &GasScheduleV2) -> Result<String> {
"gas_schedule::set_gas_schedule(&framework_signer, gas_schedule_blob);"
);

emitln!(
writer,
"aptos_governance::reconfigure(&framework_signer);"
);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this approach consensus_config::set no longer calls reconfigure, I think the proposal script should call reconfigure explicitly. (Same below for some other configs)

@zekun000 @movekevin @sherry-x could you confirm if these release builder updates are also needed?

writer.unindent();
emitln!(writer, "}");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,19 @@ pub fn generate_consensus_upgrade_proposal(
writer,
"consensus_config::set(framework_signer, consensus_blob);"
);
emitln!(
writer,
"aptos_governance::reconfigure(framework_signer);"
);
} else {
emitln!(
writer,
"consensus_config::set(&framework_signer, consensus_blob);"
);
emitln!(
writer,
"aptos_governance::reconfigure(&framework_signer);"
);
}
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,19 @@ pub fn generate_execution_config_upgrade_proposal(
writer,
"execution_config::set(framework_signer, execution_blob);"
);
emitln!(
writer,
"aptos_governance::reconfigure(framework_signer);"
);
} else {
emitln!(
writer,
"execution_config::set(&framework_signer, execution_blob);"
);
emitln!(
writer,
"aptos_governance::reconfigure(&framework_signer);"
);
}
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ pub enum FeatureFlag {
Secp256k1ECDSAAuthenticator,
SponsoredAutomaticAccountCreation,
FeePayerAccountOptional,
ReconfigureWithDKG,
}

fn generate_features_blob(writer: &CodeWriter, data: &[u64]) {
Expand Down Expand Up @@ -226,6 +227,7 @@ impl From<FeatureFlag> for AptosFeatureFlag {
AptosFeatureFlag::SPONSORED_AUTOMATIC_ACCOUNT_CREATION
},
FeatureFlag::FeePayerAccountOptional => AptosFeatureFlag::FEE_PAYER_ACCOUNT_OPTIONAL,
FeatureFlag::ReconfigureWithDKG => AptosFeatureFlag::RECONFIGURE_WITH_DKG,
}
}
}
Expand Down Expand Up @@ -289,6 +291,7 @@ impl From<AptosFeatureFlag> for FeatureFlag {
FeatureFlag::SponsoredAutomaticAccountCreation
},
AptosFeatureFlag::FEE_PAYER_ACCOUNT_OPTIONAL => FeatureFlag::FeePayerAccountOptional,
AptosFeatureFlag::RECONFIGURE_WITH_DKG => FeatureFlag::ReconfigureWithDKG,
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions aptos-move/aptos-release-builder/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ async fn execute_release(

// Execute proposals
for proposal in &release_config.proposals {
println!("[TTT] proposal.name={}", proposal.name);
let mut proposal_path = proposal_folder.to_path_buf();
proposal_path.push("sources");
proposal_path.push(&release_config.name);
Expand Down Expand Up @@ -465,6 +466,7 @@ async fn execute_release(
}
},
};
println!("[TTT] about to verify proposal.name={}", proposal.name);
if validate_release {
release_config.validate_upgrade(&network_config.endpoint, proposal)?;
}
Expand Down
18 changes: 16 additions & 2 deletions aptos-move/framework/aptos-framework/doc/aptos_governance.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ on a proposal multiple times as long as the total voting power of these votes do
<pre><code><b>use</b> <a href="account.md#0x1_account">0x1::account</a>;
<b>use</b> <a href="aptos_coin.md#0x1_aptos_coin">0x1::aptos_coin</a>;
<b>use</b> <a href="coin.md#0x1_coin">0x1::coin</a>;
<b>use</b> <a href="../../aptos-stdlib/../move-stdlib/doc/config_for_next_epoch.md#0x1_config_for_next_epoch">0x1::config_for_next_epoch</a>;
<b>use</b> <a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error">0x1::error</a>;
<b>use</b> <a href="event.md#0x1_event">0x1::event</a>;
<b>use</b> <a href="../../aptos-stdlib/../move-stdlib/doc/features.md#0x1_features">0x1::features</a>;
Expand Down Expand Up @@ -1472,7 +1473,13 @@ Force reconfigure. To be called at the end of a proposal that alters on-chain co

<pre><code><b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_reconfigure">reconfigure</a>(aptos_framework: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>) {
<a href="system_addresses.md#0x1_system_addresses_assert_aptos_framework">system_addresses::assert_aptos_framework</a>(aptos_framework);
<a href="reconfiguration.md#0x1_reconfiguration_reconfigure">reconfiguration::reconfigure</a>();
<b>if</b> (<a href="../../aptos-stdlib/../move-stdlib/doc/features.md#0x1_features_reconfigure_with_dkg_enabled">features::reconfigure_with_dkg_enabled</a>()) {
<a href="reconfiguration.md#0x1_reconfiguration_start_slow_reconfigure">reconfiguration::start_slow_reconfigure</a>(aptos_framework);
} <b>else</b> {
<a href="../../aptos-stdlib/../move-stdlib/doc/config_for_next_epoch.md#0x1_config_for_next_epoch_enable_extracts">config_for_next_epoch::enable_extracts</a>(aptos_framework);
<a href="reconfiguration.md#0x1_reconfiguration_reconfigure">reconfiguration::reconfigure</a>();
<a href="../../aptos-stdlib/../move-stdlib/doc/config_for_next_epoch.md#0x1_config_for_next_epoch_disable_extracts">config_for_next_epoch::disable_extracts</a>(aptos_framework);
}
}
</code></pre>

Expand All @@ -1499,7 +1506,14 @@ Update feature flags and also trigger reconfiguration.
<pre><code><b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_toggle_features">toggle_features</a>(aptos_framework: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, enable: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u64&gt;, disable: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u64&gt;) {
<a href="system_addresses.md#0x1_system_addresses_assert_aptos_framework">system_addresses::assert_aptos_framework</a>(aptos_framework);
<a href="../../aptos-stdlib/../move-stdlib/doc/features.md#0x1_features_change_feature_flags">features::change_feature_flags</a>(aptos_framework, enable, disable);
<a href="reconfiguration.md#0x1_reconfiguration_reconfigure">reconfiguration::reconfigure</a>();

<b>if</b> (<a href="../../aptos-stdlib/../move-stdlib/doc/features.md#0x1_features_reconfigure_with_dkg_enabled">features::reconfigure_with_dkg_enabled</a>()) {
<a href="reconfiguration.md#0x1_reconfiguration_start_slow_reconfigure">reconfiguration::start_slow_reconfigure</a>(aptos_framework);
} <b>else</b> {
<a href="../../aptos-stdlib/../move-stdlib/doc/config_for_next_epoch.md#0x1_config_for_next_epoch_enable_extracts">config_for_next_epoch::enable_extracts</a>(aptos_framework);
<a href="reconfiguration.md#0x1_reconfiguration_reconfigure">reconfiguration::reconfigure</a>();
<a href="../../aptos-stdlib/../move-stdlib/doc/config_for_next_epoch.md#0x1_config_for_next_epoch_disable_extracts">config_for_next_epoch::disable_extracts</a>(aptos_framework);
}
}
</code></pre>

Expand Down
91 changes: 91 additions & 0 deletions aptos-move/framework/aptos-framework/doc/block.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This module defines a struct storing the metadata of the block and new block eve
- [Function `update_epoch_interval_microsecs`](#0x1_block_update_epoch_interval_microsecs)
- [Function `get_epoch_interval_secs`](#0x1_block_get_epoch_interval_secs)
- [Function `block_prologue`](#0x1_block_block_prologue)
- [Function `block_prologue_v2`](#0x1_block_block_prologue_v2)
- [Function `get_current_block_height`](#0x1_block_get_current_block_height)
- [Function `emit_new_block_event`](#0x1_block_emit_new_block_event)
- [Function `emit_genesis_block_event`](#0x1_block_emit_genesis_block_event)
Expand All @@ -31,6 +32,7 @@ This module defines a struct storing the metadata of the block and new block eve


<pre><code><b>use</b> <a href="account.md#0x1_account">0x1::account</a>;
<b>use</b> <a href="../../aptos-stdlib/../move-stdlib/doc/config_for_next_epoch.md#0x1_config_for_next_epoch">0x1::config_for_next_epoch</a>;
<b>use</b> <a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error">0x1::error</a>;
<b>use</b> <a href="event.md#0x1_event">0x1::event</a>;
<b>use</b> <a href="../../aptos-stdlib/../move-stdlib/doc/features.md#0x1_features">0x1::features</a>;
Expand Down Expand Up @@ -411,7 +413,96 @@ The runtime always runs this before executing the transactions in a block.
<a href="state_storage.md#0x1_state_storage_on_new_block">state_storage::on_new_block</a>(<a href="reconfiguration.md#0x1_reconfiguration_current_epoch">reconfiguration::current_epoch</a>());

<b>if</b> (<a href="timestamp.md#0x1_timestamp">timestamp</a> - <a href="reconfiguration.md#0x1_reconfiguration_last_reconfiguration_time">reconfiguration::last_reconfiguration_time</a>() &gt;= block_metadata_ref.epoch_interval) {
<a href="../../aptos-stdlib/../move-stdlib/doc/config_for_next_epoch.md#0x1_config_for_next_epoch_enable_extracts">config_for_next_epoch::enable_extracts</a>(&vm);
<a href="reconfiguration.md#0x1_reconfiguration_reconfigure">reconfiguration::reconfigure</a>();
<a href="../../aptos-stdlib/../move-stdlib/doc/config_for_next_epoch.md#0x1_config_for_next_epoch_disable_extracts">config_for_next_epoch::disable_extracts</a>(&vm);
};
}
</code></pre>



</details>

<a name="0x1_block_block_prologue_v2"></a>

## Function `block_prologue_v2`

Set the metadata for the current block.
The runtime always runs this before executing the transactions in a block.


<pre><code><b>fun</b> <a href="block.md#0x1_block_block_prologue_v2">block_prologue_v2</a>(vm: <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, <a href="../../aptos-stdlib/../move-stdlib/doc/hash.md#0x1_hash">hash</a>: <b>address</b>, epoch: u64, round: u64, proposer: <b>address</b>, failed_proposer_indices: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u64&gt;, previous_block_votes_bitvec: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;, <a href="timestamp.md#0x1_timestamp">timestamp</a>: u64, slow_reconfigure_params: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;)
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>fun</b> <a href="block.md#0x1_block_block_prologue_v2">block_prologue_v2</a>(
vm: <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>,
<a href="../../aptos-stdlib/../move-stdlib/doc/hash.md#0x1_hash">hash</a>: <b>address</b>,
epoch: u64,
round: u64,
proposer: <b>address</b>,
failed_proposer_indices: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u64&gt;,
previous_block_votes_bitvec: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
<a href="timestamp.md#0x1_timestamp">timestamp</a>: u64,
slow_reconfigure_params: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
) <b>acquires</b> <a href="block.md#0x1_block_BlockResource">BlockResource</a> {
// Operational constraint: can only be invoked by the VM.
<a href="system_addresses.md#0x1_system_addresses_assert_vm">system_addresses::assert_vm</a>(&vm);

// Blocks can only be produced by a valid proposer or by the VM itself for Nil blocks (no user txs).
<b>assert</b>!(
proposer == @vm_reserved || <a href="stake.md#0x1_stake_is_current_epoch_validator">stake::is_current_epoch_validator</a>(proposer),
<a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_permission_denied">error::permission_denied</a>(<a href="block.md#0x1_block_EINVALID_PROPOSER">EINVALID_PROPOSER</a>),
);

<b>let</b> proposer_index = <a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_none">option::none</a>();
<b>if</b> (proposer != @vm_reserved) {
proposer_index = <a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_some">option::some</a>(<a href="stake.md#0x1_stake_get_validator_index">stake::get_validator_index</a>(proposer));
};

<b>let</b> block_metadata_ref = <b>borrow_global_mut</b>&lt;<a href="block.md#0x1_block_BlockResource">BlockResource</a>&gt;(@aptos_framework);
block_metadata_ref.height = <a href="event.md#0x1_event_counter">event::counter</a>(&block_metadata_ref.new_block_events);

<b>let</b> new_block_event = <a href="block.md#0x1_block_NewBlockEvent">NewBlockEvent</a> {
<a href="../../aptos-stdlib/../move-stdlib/doc/hash.md#0x1_hash">hash</a>,
epoch,
round,
height: block_metadata_ref.height,
previous_block_votes_bitvec,
proposer,
failed_proposer_indices,
time_microseconds: <a href="timestamp.md#0x1_timestamp">timestamp</a>,
};
<a href="block.md#0x1_block_emit_new_block_event">emit_new_block_event</a>(&vm, &<b>mut</b> block_metadata_ref.new_block_events, new_block_event);

<b>if</b> (<a href="../../aptos-stdlib/../move-stdlib/doc/features.md#0x1_features_collect_and_distribute_gas_fees">features::collect_and_distribute_gas_fees</a>()) {
// Assign the fees collected from the previous <a href="block.md#0x1_block">block</a> <b>to</b> the previous <a href="block.md#0x1_block">block</a> proposer.
// If for <a href="../../aptos-stdlib/doc/any.md#0x1_any">any</a> reason the fees cannot be assigned, this function burns the collected coins.
<a href="transaction_fee.md#0x1_transaction_fee_process_collected_fees">transaction_fee::process_collected_fees</a>();
// Set the proposer of this <a href="block.md#0x1_block">block</a> <b>as</b> the receiver of the fees, so that the fees for this
// <a href="block.md#0x1_block">block</a> are assigned <b>to</b> the right <a href="account.md#0x1_account">account</a>.
<a href="transaction_fee.md#0x1_transaction_fee_register_proposer_for_fee_collection">transaction_fee::register_proposer_for_fee_collection</a>(proposer);
};

// Performance scores have <b>to</b> be updated before the epoch transition <b>as</b> the transaction that triggers the
// transition is the last <a href="block.md#0x1_block">block</a> in the previous epoch.
<a href="stake.md#0x1_stake_update_performance_statistics">stake::update_performance_statistics</a>(proposer_index, failed_proposer_indices);
<a href="state_storage.md#0x1_state_storage_on_new_block">state_storage::on_new_block</a>(<a href="reconfiguration.md#0x1_reconfiguration_current_epoch">reconfiguration::current_epoch</a>());

<b>if</b> (<a href="reconfiguration.md#0x1_reconfiguration_slow_reconfigure_in_progress">reconfiguration::slow_reconfigure_in_progress</a>()) {
<b>if</b> (<a href="timestamp.md#0x1_timestamp">timestamp</a> &gt;= <a href="reconfiguration.md#0x1_reconfiguration_current_slow_reconfigure_deadline">reconfiguration::current_slow_reconfigure_deadline</a>()) {
<a href="reconfiguration.md#0x1_reconfiguration_abort_slow_reconfigure">reconfiguration::abort_slow_reconfigure</a>(&vm);
} <b>else</b> {
<a href="reconfiguration.md#0x1_reconfiguration_update_slow_reconfigure">reconfiguration::update_slow_reconfigure</a>(&vm, slow_reconfigure_params);
}
} <b>else</b> <b>if</b> (<a href="timestamp.md#0x1_timestamp">timestamp</a> - <a href="reconfiguration.md#0x1_reconfiguration_last_reconfiguration_time">reconfiguration::last_reconfiguration_time</a>() &gt;= block_metadata_ref.epoch_interval) {
<a href="reconfiguration.md#0x1_reconfiguration_start_slow_reconfigure">reconfiguration::start_slow_reconfigure</a>(&vm);
};
}
</code></pre>
Expand Down
Loading
Loading