Skip to content

Commit

Permalink
Add precision state updates to resim
Browse files Browse the repository at this point in the history
  • Loading branch information
talekhinezh committed Jan 11, 2024
1 parent 743edcc commit 81bd985
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
13 changes: 11 additions & 2 deletions radix-engine/src/system/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use crate::transaction::{
SubstateSchemaMapper, SubstateSystemStructures, TransactionOutcome, TransactionReceipt,
TransactionResult,
};
use crate::utils::generate_seconds_precision_state_updates;
use lazy_static::lazy_static;
use radix_engine_common::crypto::Secp256k1PublicKey;
use radix_engine_common::types::ComponentAddress;
Expand Down Expand Up @@ -314,7 +315,7 @@ where
}

pub fn bootstrap_test_default(&mut self) -> Option<GenesisReceipts> {
self.bootstrap_with_genesis_data(
let receipts = self.bootstrap_with_genesis_data(
vec![],
Epoch::of(1),
ConsensusManagerConfig {
Expand All @@ -334,7 +335,15 @@ where
1,
Some(0),
*DEFAULT_TESTING_FAUCET_SUPPLY,
)
);

if receipts.is_some() {
let state_updates = generate_seconds_precision_state_updates(self.substate_db);
let db_updates = state_updates.create_database_updates::<SpreadPrefixKeyMapper>();
self.substate_db.commit(&db_updates);
}

receipts
}

pub fn bootstrap_with_genesis_data(
Expand Down
6 changes: 3 additions & 3 deletions simulator/src/resim/cmd_show_ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl ShowLedger {
)
.map_err(Error::IOError)?;

let instant = Self::get_current_time(out, TimePrecisionV1::Minute)?;
let instant = Self::get_current_time(out, TimePrecision::Minute)?;
let date_time = UtcDateTime::from_instant(&instant).unwrap();
writeln!(
out,
Expand Down Expand Up @@ -127,12 +127,12 @@ impl ShowLedger {

pub fn get_current_time<O: std::io::Write>(
out: &mut O,
precision: TimePrecisionV1,
precision: TimePrecision,
) -> Result<Instant, Error> {
let instructions = vec![InstructionV1::CallMethod {
address: CONSENSUS_MANAGER.into(),
method_name: CONSENSUS_MANAGER_GET_CURRENT_TIME_IDENT.to_string(),
args: to_manifest_value_and_unwrap!(&ConsensusManagerGetCurrentTimeInputV1 {
args: to_manifest_value_and_unwrap!(&ConsensusManagerGetCurrentTimeInputV2 {
precision
}),
}];
Expand Down

0 comments on commit 81bd985

Please sign in to comment.