Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
damip committed Jul 4, 2023
1 parent cf14f01 commit 9c68d96
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions massa-execution-worker/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ impl ExecutionContext {
module_cache,
vesting_manager,
mip_store,
execution_trail_hash,
)
}
}
Expand Down
14 changes: 8 additions & 6 deletions massa-execution-worker/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,13 @@ impl ExecutionState {
) -> ExecutionState {
// Get the slot at the output of which the final state is attached.
// This should be among the latest final slots.
let last_final_slot = final_state
.read()
.db
.read()
.get_change_id()
.expect("Critical error: Final state has no slot attached");
let last_final_slot;
let execution_trail_hash;
{
let final_state_read = final_state.read();
last_final_slot = final_state_read.get_slot();
execution_trail_hash = final_state_read.get_execution_trail_hash();
}

// Create default active history
let active_history: Arc<RwLock<ActiveHistory>> = Default::default();
Expand Down Expand Up @@ -160,6 +161,7 @@ impl ExecutionState {
module_cache.clone(),
vesting_manager.clone(),
mip_store.clone(),
execution_trail_hash,
)));

// Instantiate the interface providing ABI access to the VM, share the execution context with it
Expand Down
21 changes: 21 additions & 0 deletions massa-final-state/src/final_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use massa_db_exports::{
use massa_executed_ops::ExecutedDenunciations;
use massa_executed_ops::ExecutedOps;
use massa_ledger_exports::LedgerController;
use massa_ledger_exports::SetOrKeep;
use massa_models::slot::Slot;
use massa_pos_exports::{PoSFinalState, SelectorController};
use massa_versioning::versioning::MipStore;
Expand All @@ -25,6 +26,8 @@ use tracing::{debug, info, warn};
use massa_models::config::PERIODS_BETWEEN_BACKUPS;
use massa_models::timeslots::get_block_slot_timestamp;

// TODO when creating a final ledger at genesis, initialize the execution hash trail to Hash::zero()

/// Represents a final state `(ledger, async pool, executed_ops, executed_de and the state of the PoS)`
pub struct FinalState {
/// execution state configuration
Expand Down Expand Up @@ -141,6 +144,20 @@ impl FinalState {
massa_hash::Hash::compute_from(internal_hash.to_bytes())
}

/// Get the slot at the end of which the final state is attached
pub fn get_slot(&self) -> Slot {
self.db
.read()
.get_change_id()
.expect("Critical error: Final state has no slot attached")
}

/// Gets the hash of the execution trail
pub fn get_execution_trail_hash(&self) -> massa_hash::Hash {
// TODO return the execution trail hash
unimplemented!()
}

/// Initializes a `FinalState` from a snapshot. Currently, we do not use the final_state from the ledger,
/// we just create a new one. This will be changed in the follow-up.
///
Expand Down Expand Up @@ -616,6 +633,10 @@ impl FinalState {
)
});

if let SetOrKeep::Set(new_hash) = changes.execution_trail_hash_change {
// TODO update execution trail hash in batch
}

self.db
.write()
.write_batch(db_batch, db_versioning_batch, Some(slot));
Expand Down

0 comments on commit 9c68d96

Please sign in to comment.