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 7 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
13 changes: 11 additions & 2 deletions aptos-move/framework/aptos-framework/doc/aptos_governance.md
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,11 @@ 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_slow_reconfigure_enabled">features::slow_reconfigure_enabled</a>()) {
<a href="reconfiguration.md#0x1_reconfiguration_start_slow_reconfigure">reconfiguration::start_slow_reconfigure</a>(aptos_framework);
} <b>else</b> {
<a href="reconfiguration.md#0x1_reconfiguration_reconfigure">reconfiguration::reconfigure</a>();
}
}
</code></pre>

Expand All @@ -1499,7 +1503,12 @@ 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_slow_reconfigure_enabled">features::slow_reconfigure_enabled</a>()) {
<a href="reconfiguration.md#0x1_reconfiguration_start_slow_reconfigure">reconfiguration::start_slow_reconfigure</a>(aptos_framework);
} <b>else</b> {
<a href="reconfiguration.md#0x1_reconfiguration_reconfigure">reconfiguration::reconfigure</a>();
}
}
</code></pre>

Expand Down
88 changes: 88 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 Down Expand Up @@ -418,6 +419,93 @@ The runtime always runs this before executing the transactions in a block.



</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_terminate_slow_reconfigure">reconfiguration::terminate_slow_reconfigure</a>(&vm);
} <b>else</b> {
<a href="reconfiguration.md#0x1_reconfiguration_update_slow_reconfigure">reconfiguration::update_slow_reconfigure</a>(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>



</details>

<a name="0x1_block_get_current_block_height"></a>
Expand Down
37 changes: 28 additions & 9 deletions aptos-move/framework/aptos-framework/doc/consensus_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ Reconfiguration, and may be updated by root.
- [Constants](#@Constants_0)
- [Function `initialize`](#0x1_consensus_config_initialize)
- [Function `set`](#0x1_consensus_config_set)
- [Function `on_new_epoch`](#0x1_consensus_config_on_new_epoch)
- [Specification](#@Specification_1)
- [Function `initialize`](#@Specification_1_initialize)
- [Function `set`](#@Specification_1_set)


<pre><code><b>use</b> <a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error">0x1::error</a>;
<b>use</b> <a href="reconfiguration.md#0x1_reconfiguration">0x1::reconfiguration</a>;
<pre><code><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="system_addresses.md#0x1_system_addresses">0x1::system_addresses</a>;
</code></pre>

Expand All @@ -29,7 +30,7 @@ Reconfiguration, and may be updated by root.



<pre><code><b>struct</b> <a href="consensus_config.md#0x1_consensus_config_ConsensusConfig">ConsensusConfig</a> <b>has</b> key
<pre><code><b>struct</b> <a href="consensus_config.md#0x1_consensus_config_ConsensusConfig">ConsensusConfig</a> <b>has</b> drop, store, key
</code></pre>


Expand Down Expand Up @@ -108,15 +109,34 @@ This can be called by on-chain governance to update on-chain consensus configs.
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="consensus_config.md#0x1_consensus_config_set">set</a>(<a href="account.md#0x1_account">account</a>: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, config: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;) <b>acquires</b> <a href="consensus_config.md#0x1_consensus_config_ConsensusConfig">ConsensusConfig</a> {
<pre><code><b>public</b> <b>fun</b> <a href="consensus_config.md#0x1_consensus_config_set">set</a>(<a href="account.md#0x1_account">account</a>: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, config: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;) {
<a href="system_addresses.md#0x1_system_addresses_assert_aptos_framework">system_addresses::assert_aptos_framework</a>(<a href="account.md#0x1_account">account</a>);
<b>assert</b>!(<a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector_length">vector::length</a>(&config) &gt; 0, <a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_invalid_argument">error::invalid_argument</a>(<a href="consensus_config.md#0x1_consensus_config_EINVALID_CONFIG">EINVALID_CONFIG</a>));
std::config_for_next_epoch::upsert&lt;<a href="consensus_config.md#0x1_consensus_config_ConsensusConfig">ConsensusConfig</a>&gt;(<a href="account.md#0x1_account">account</a>, <a href="consensus_config.md#0x1_consensus_config_ConsensusConfig">ConsensusConfig</a> {config});
}
</code></pre>



</details>

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

## Function `on_new_epoch`



<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="consensus_config.md#0x1_consensus_config_on_new_epoch">on_new_epoch</a>(<a href="account.md#0x1_account">account</a>: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>)
</code></pre>



<details>
<summary>Implementation</summary>

<b>let</b> config_ref = &<b>mut</b> <b>borrow_global_mut</b>&lt;<a href="consensus_config.md#0x1_consensus_config_ConsensusConfig">ConsensusConfig</a>&gt;(@aptos_framework).config;
*config_ref = config;

// Need <b>to</b> trigger <a href="reconfiguration.md#0x1_reconfiguration">reconfiguration</a> so validator nodes can sync on the updated configs.
<a href="reconfiguration.md#0x1_reconfiguration_reconfigure">reconfiguration::reconfigure</a>();
<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="consensus_config.md#0x1_consensus_config_on_new_epoch">on_new_epoch</a>(<a href="account.md#0x1_account">account</a>: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>) <b>acquires</b> <a href="consensus_config.md#0x1_consensus_config_ConsensusConfig">ConsensusConfig</a> {
*<b>borrow_global_mut</b>&lt;<a href="consensus_config.md#0x1_consensus_config_ConsensusConfig">ConsensusConfig</a>&gt;(@aptos_framework) = std::config_for_next_epoch::extract(<a href="account.md#0x1_account">account</a>);
}
</code></pre>

Expand Down Expand Up @@ -178,7 +198,6 @@ When setting now time must be later than last_reconfiguration_time.
<b>aborts_if</b> !<b>exists</b>&lt;<a href="consensus_config.md#0x1_consensus_config_ConsensusConfig">ConsensusConfig</a>&gt;(@aptos_framework);
<b>aborts_if</b> !(len(config) &gt; 0);
<b>requires</b> <a href="chain_status.md#0x1_chain_status_is_operating">chain_status::is_operating</a>();
<b>requires</b> <a href="timestamp.md#0x1_timestamp_spec_now_microseconds">timestamp::spec_now_microseconds</a>() &gt;= <a href="reconfiguration.md#0x1_reconfiguration_last_reconfiguration_time">reconfiguration::last_reconfiguration_time</a>();
<b>requires</b> <b>exists</b>&lt;<a href="stake.md#0x1_stake_ValidatorFees">stake::ValidatorFees</a>&gt;(@aptos_framework);
<b>requires</b> <b>exists</b>&lt;CoinInfo&lt;AptosCoin&gt;&gt;(@aptos_framework);
</code></pre>
Expand Down
Loading
Loading