Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
msmouse committed Nov 28, 2024
1 parent 9add85f commit ddaade9
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 15 deletions.
43 changes: 29 additions & 14 deletions execution/executor-types/src/execution_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ use crate::{
transactions_with_output::{TransactionsToKeep, TransactionsWithOutput},
};
use aptos_drop_helper::DropHelper;
use aptos_storage_interface::state_store::{
state_delta::StateDelta, state_view::cached_state_view::StateCache,
};
use aptos_types::{
contract_event::ContractEvent,
epoch_state::EpochState,
Expand All @@ -21,6 +18,8 @@ use aptos_types::{
};
use derive_more::Deref;
use std::sync::Arc;
use aptos_storage_interface::state_store::state::State;
use aptos_storage_interface::state_store::state_view::cached_state_view::ShardedStateCache;

#[derive(Clone, Debug, Deref)]
pub struct ExecutionOutput {
Expand All @@ -36,14 +35,20 @@ impl ExecutionOutput {
to_commit: TransactionsToKeep,
to_discard: TransactionsWithOutput,
to_retry: TransactionsWithOutput,
state_cache: StateCache,
last_checkpoint_state: Option<State>,
result_state: State,
state_reads: ShardedStateCache,
block_end_info: Option<BlockEndInfo>,
next_epoch_state: Option<EpochState>,
subscribable_events: Planned<Vec<ContractEvent>>,
) -> Self {
let next_version = first_version + to_commit.len() as Version;
assert_eq!(next_version, result_state.next_version());
if is_block {
// If it's a block, ensure it ends with state checkpoint.
assert!(to_commit.is_empty() || to_commit.ends_with_sole_checkpoint());
assert!(last_checkpoint_state.is_some());
assert!(last_checkpoint_state.as_ref().unwrap().is_the_same(&result_state));
} else {
// If it's not, there shouldn't be any transaction to be discarded or retried.
assert!(to_discard.is_empty() && to_retry.is_empty());
Expand All @@ -56,22 +61,26 @@ impl ExecutionOutput {
to_commit,
to_discard,
to_retry,
state_cache,
last_checkpoint_state,
result_state,
state_reads,
block_end_info,
next_epoch_state,
subscribable_events,
})
}

pub fn new_empty(state: Arc<StateDelta>) -> Self {
pub fn new_empty(parent_state: &State) -> Self {
Self::new_impl(Inner {
is_block: false,
first_version: state.next_version(),
first_version: parent_state.next_version(),
statuses_for_input_txns: vec![],
to_commit: TransactionsToKeep::new_empty(),
to_discard: TransactionsWithOutput::new_empty(),
to_retry: TransactionsWithOutput::new_empty(),
state_cache: StateCache::new_empty(state.current.clone()),
last_checkpoint_state: None,
result_state: parent_state.clone(),
state_reads: ShardedStateCache::default(),
block_end_info: None,
next_epoch_state: None,
subscribable_events: Planned::ready(vec![]),
Expand All @@ -88,7 +97,9 @@ impl ExecutionOutput {
to_commit: TransactionsToKeep::new_dummy_success(txns),
to_discard: TransactionsWithOutput::new_empty(),
to_retry: TransactionsWithOutput::new_empty(),
state_cache: StateCache::new_dummy(),
last_checkpoint_state: None,
result_state: State::new_empty(),
state_reads: ShardedStateCache::default(),
block_end_info: None,
next_epoch_state: None,
subscribable_events: Planned::ready(vec![]),
Expand All @@ -107,7 +118,9 @@ impl ExecutionOutput {
to_commit: TransactionsToKeep::new_empty(),
to_discard: TransactionsWithOutput::new_empty(),
to_retry: TransactionsWithOutput::new_empty(),
state_cache: StateCache::new_dummy(),
last_checkpoint_state: None,
result_state: self.result_state.clone(),
state_reads: ShardedStateCache::default(),
block_end_info: None,
next_epoch_state: self.next_epoch_state.clone(),
subscribable_events: Planned::ready(vec![]),
Expand Down Expand Up @@ -146,10 +159,12 @@ pub struct Inner {
pub to_discard: TransactionsWithOutput,
pub to_retry: TransactionsWithOutput,

/// Carries the frozen base state view, so all in-mem nodes involved won't drop before the
/// execution result is processed; as well as all the accounts touched during execution, together
/// with their proofs.
pub state_cache: StateCache,
pub last_checkpoint_state: Option<State>,
pub result_state: State,
/// State items read during execution, useful for calculating the state storge usage and
/// indices used by the db pruner.
pub state_reads: ShardedStateCache,

/// Optional StateCheckpoint payload
pub block_end_info: Option<BlockEndInfo>,
/// Optional EpochState payload.
Expand Down
6 changes: 5 additions & 1 deletion execution/executor-types/src/state_compute_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ impl StateComputeResult {
}

pub fn as_chunk_to_commit(&self) -> ChunkToCommit {
todo!()

/* FIXME(aldenhu): sharded_state_cache
ChunkToCommit {
first_version: self.ledger_update_output.first_version(),
transactions: &self.execution_output.to_commit.transactions,
Expand All @@ -168,8 +171,9 @@ impl StateComputeResult {
.state_checkpoint_output
.state_updates_before_last_checkpoint
.as_ref(),
sharded_state_cache: Some(&self.execution_output.state_cache.sharded_state_cache),
sharded_state_cache,
is_reconfig: self.execution_output.next_epoch_state.is_some(),
}
*/
}
}
3 changes: 3 additions & 0 deletions execution/executor/src/types/in_memory_state_calculator_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ impl InMemoryStateCalculatorV2 {
parent_state: &Arc<StateDelta>,
known_state_checkpoints: Option<impl IntoIterator<Item = Option<HashValue>>>,
) -> Result<StateCheckpointOutput> {
todo!()
/*
if execution_output.is_block {
Self::validate_input_for_block(parent_state, &execution_output.to_commit)?;
}
Expand All @@ -49,6 +51,7 @@ impl InMemoryStateCalculatorV2 {
execution_output.is_block,
known_state_checkpoints,
)
*/
}

pub fn calculate_for_write_sets_after_snapshot(
Expand Down
5 changes: 5 additions & 0 deletions storage/storage-interface/src/state_store/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ impl State {
// FIXME(aldnehu)
todo!()
}

pub fn is_the_same(&self, _rhs: &Self) -> bool {
// FIXME(aldenhu)
todo!()
}
}

0 comments on commit ddaade9

Please sign in to comment.