Skip to content

Commit

Permalink
fix upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
lightmark committed Oct 26, 2024
1 parent 346202c commit 63f1d2a
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
[]
[
{
"version": "0",
"guid": {
"creation_number": "2",
"account_address": "0x1"
},
"sequence_number": "0",
"type": "0x1::reconfiguration::NewEpochEvent",
"data": {
"epoch": "1"
}
}
]
26 changes: 12 additions & 14 deletions aptos-move/framework/aptos-framework/doc/reconfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,13 @@ Signal validators to start using new configuration. Must be called from friend c
epoch: config_ref.epoch,
},
);
} <b>else</b> {
<a href="event.md#0x1_event_emit_event">event::emit_event</a>&lt;<a href="reconfiguration.md#0x1_reconfiguration_NewEpochEvent">NewEpochEvent</a>&gt;(
&<b>mut</b> config_ref.events,
<a href="reconfiguration.md#0x1_reconfiguration_NewEpochEvent">NewEpochEvent</a> {
epoch: config_ref.epoch,
},
);
};
<a href="event.md#0x1_event_emit_event">event::emit_event</a>&lt;<a href="reconfiguration.md#0x1_reconfiguration_NewEpochEvent">NewEpochEvent</a>&gt;(
&<b>mut</b> config_ref.events,
<a href="reconfiguration.md#0x1_reconfiguration_NewEpochEvent">NewEpochEvent</a> {
epoch: config_ref.epoch,
},
);

<a href="reconfiguration_state.md#0x1_reconfiguration_state_on_reconfig_finish">reconfiguration_state::on_reconfig_finish</a>();
}
Expand Down Expand Up @@ -505,14 +504,13 @@ reconfiguration event.
epoch: config_ref.epoch,
},
);
} <b>else</b> {
<a href="event.md#0x1_event_emit_event">event::emit_event</a>&lt;<a href="reconfiguration.md#0x1_reconfiguration_NewEpochEvent">NewEpochEvent</a>&gt;(
&<b>mut</b> config_ref.events,
<a href="reconfiguration.md#0x1_reconfiguration_NewEpochEvent">NewEpochEvent</a> {
epoch: config_ref.epoch,
},
);
};
<a href="event.md#0x1_event_emit_event">event::emit_event</a>&lt;<a href="reconfiguration.md#0x1_reconfiguration_NewEpochEvent">NewEpochEvent</a>&gt;(
&<b>mut</b> config_ref.events,
<a href="reconfiguration.md#0x1_reconfiguration_NewEpochEvent">NewEpochEvent</a> {
epoch: config_ref.epoch,
},
);
}
</code></pre>

Expand Down
3 changes: 2 additions & 1 deletion aptos-move/framework/aptos-framework/doc/stake.md
Original file line number Diff line number Diff line change
Expand Up @@ -5198,7 +5198,8 @@ Returns validator's next epoch voting power, including pending_active, active, a



<pre><code><b>pragma</b> disable_invariants_in_body;
<pre><code><b>pragma</b> verify_duration_estimate = 60;
<b>pragma</b> disable_invariants_in_body;
<b>aborts_if</b> !<a href="staking_config.md#0x1_staking_config_get_allow_validator_set_change">staking_config::get_allow_validator_set_change</a>(<a href="staking_config.md#0x1_staking_config_get">staking_config::get</a>());
<b>aborts_if</b> !<b>exists</b>&lt;<a href="stake.md#0x1_stake_StakePool">StakePool</a>&gt;(pool_address);
<b>aborts_if</b> !<b>exists</b>&lt;<a href="stake.md#0x1_stake_ValidatorConfig">ValidatorConfig</a>&gt;(pool_address);
Expand Down
26 changes: 12 additions & 14 deletions aptos-move/framework/aptos-framework/sources/reconfiguration.move
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,13 @@ module aptos_framework::reconfiguration {
epoch: config_ref.epoch,
},
);
} else {
event::emit_event<NewEpochEvent>(
&mut config_ref.events,
NewEpochEvent {
epoch: config_ref.epoch,
},
);
};
event::emit_event<NewEpochEvent>(
&mut config_ref.events,
NewEpochEvent {
epoch: config_ref.epoch,
},
);

reconfiguration_state::on_reconfig_finish();
}
Expand All @@ -180,14 +179,13 @@ module aptos_framework::reconfiguration {
epoch: config_ref.epoch,
},
);
} else {
event::emit_event<NewEpochEvent>(
&mut config_ref.events,
NewEpochEvent {
epoch: config_ref.epoch,
},
);
};
event::emit_event<NewEpochEvent>(
&mut config_ref.events,
NewEpochEvent {
epoch: config_ref.epoch,
},
);
}

// For tests, skips the guid validation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ spec aptos_framework::stake {
)
{
// This function casue timeout (property proved)
// pragma verify_duration_estimate = 120;
pragma verify_duration_estimate = 60;
pragma disable_invariants_in_body;
aborts_if !staking_config::get_allow_validator_set_change(staking_config::get());
aborts_if !exists<StakePool>(pool_address);
Expand Down
14 changes: 6 additions & 8 deletions aptos-move/vm-genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ use aptos_gas_schedule::{
AptosGasParameters, InitialGasSchedule, ToOnChainGasSchedule, LATEST_GAS_FEATURE_VERSION,
};
use aptos_types::{
account_config::{self, aptos_test_root_address, CORE_CODE_ADDRESS},
account_config::{self, aptos_test_root_address, events::NewEpochEvent, CORE_CODE_ADDRESS},
chain_id::ChainId,
contract_event::ContractEvent,
contract_event::{ContractEvent, ContractEventV1},
jwks::{
patch::{PatchJWKMoveStruct, PatchUpsertJWK},
secure_test_rsa_jwk,
Expand Down Expand Up @@ -804,11 +804,11 @@ fn emit_new_block_and_epoch_event(session: &mut SessionExt) {

/// Verify the consistency of the genesis `WriteSet`
fn verify_genesis_write_set(events: &[(ContractEvent, Option<MoveTypeLayout>)]) {
let new_epoch_events: Vec<&ContractEvent> = events
let new_epoch_events: Vec<&ContractEventV1> = events
.iter()
.filter_map(|(e, _)| {
if e.is_new_epoch_event() {
Some(e)
if e.event_key() == Some(&NewEpochEvent::event_key()) {
Some(e.v1().unwrap())
} else {
None
}
Expand All @@ -819,9 +819,7 @@ fn verify_genesis_write_set(events: &[(ContractEvent, Option<MoveTypeLayout>)])
1,
"There should only be exactly one NewEpochEvent"
);
if let Ok(e) = new_epoch_events[0].v1() {
assert_eq!(e.sequence_number(), 0);
}
assert_eq!(new_epoch_events[0].sequence_number(), 0);
}

/// An enum specifying whether the compiled stdlib/scripts should be used or freshly built versions
Expand Down
2 changes: 1 addition & 1 deletion execution/executor/tests/internal_indexer_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ fn test_db_indexer_data() {

let x = internal_indexer_db.get_event_by_key_iter().unwrap();
let res: Vec<_> = x.collect();
assert_eq!(res.len(), 2);
assert_eq!(res.len(), 4);

let core_kv_iter = db_indexer
.get_prefixed_state_value_iterator(
Expand Down
5 changes: 5 additions & 0 deletions types/src/account_config/events/new_epoch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Parts of the project are originally copyright © Meta Platforms, Inc.
// SPDX-License-Identifier: Apache-2.0

use crate::event::EventKey;
use anyhow::Result;
use move_core_types::{
ident_str, identifier::IdentStr, language_storage::TypeTag, move_resource::MoveStructType,
Expand Down Expand Up @@ -29,6 +30,10 @@ impl NewEpochEvent {
pub fn try_from_bytes(bytes: &[u8]) -> Result<Self> {
bcs::from_bytes(bytes).map_err(Into::into)
}

pub fn event_key() -> EventKey {
crate::on_chain_config::new_epoch_event_key()
}
}

impl MoveStructType for NewEpochEvent {
Expand Down

0 comments on commit 63f1d2a

Please sign in to comment.