-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
298 additions
and
264 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) Aptos Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use crate::state_store::{state_delta::StateDelta, state_update::StateWrite, NUM_STATE_SHARDS}; | ||
use aptos_experimental_layered_map::MapLayer; | ||
use aptos_types::{ | ||
state_store::{state_key::StateKey, state_storage_usage::StateStorageUsage}, | ||
transaction::Version, | ||
}; | ||
use std::sync::Arc; | ||
|
||
/// Represents the blockchain state at a given version. | ||
/// n.b. the state can be either persisted or speculative. | ||
#[derive(Clone, Debug)] | ||
pub struct State { | ||
/// The next version. If this is 0, the state is the "pre-genesis" empty state. | ||
next_version: Version, | ||
/// The updates made to the state at the current version. | ||
/// N.b. this is not directly iteratable, one needs to make a `StateDelta` | ||
/// between this and a `base_version` to list the updates or create a | ||
/// new `State` at a descendant version. | ||
shards: Arc<[MapLayer<StateKey, StateWrite>; NUM_STATE_SHARDS]>, | ||
/// The total usage of the state at the current version. | ||
usage: StateStorageUsage, | ||
} | ||
|
||
impl State { | ||
pub fn new_empty() -> Self { | ||
// FIXME(aldenhu): check call site and implement | ||
todo!() | ||
} | ||
|
||
pub fn next_version(&self) -> Version { | ||
self.next_version | ||
} | ||
|
||
pub fn usage(&self) -> StateStorageUsage { | ||
self.usage | ||
} | ||
|
||
pub fn shards(&self) -> &[MapLayer<StateKey, StateWrite>; NUM_STATE_SHARDS] { | ||
&self.shards | ||
} | ||
|
||
pub fn into_delta(self, _base: State) -> StateDelta { | ||
// FIXME(aldnehu) | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
storage/storage-interface/src/state_store/state_summary.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) Aptos Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use crate::state_store::state_delta::StateDelta; | ||
use aptos_crypto::HashValue; | ||
use aptos_scratchpad::SparseMerkleTree; | ||
use aptos_types::{state_store::state_value::StateValue, transaction::Version}; | ||
|
||
/// The data structure through which the entire state at a given | ||
/// version can be summarized to a concise digest (the root hash). | ||
pub struct StateSummary { | ||
/// The next version. If this is 0, the state is the "pre-genesis" empty state. | ||
next_version: Version, | ||
pub global_state_summary: SparseMerkleTree<StateValue>, | ||
} | ||
|
||
impl StateSummary { | ||
pub fn new(next_version: Version, global_state_summary: SparseMerkleTree<StateValue>) -> Self { | ||
Self { | ||
next_version, | ||
global_state_summary, | ||
} | ||
} | ||
|
||
pub fn update(&self, _persisted: &StateSummary, _state_delta: &StateDelta) -> Self { | ||
// FIXME(aldenhu) | ||
todo!() | ||
} | ||
|
||
pub fn root_hash(&self) -> HashValue { | ||
self.global_state_summary.root_hash() | ||
} | ||
|
||
pub fn next_version(&self) -> Version { | ||
self.next_version | ||
} | ||
|
||
pub fn is_the_same(&self, _rhs: &Self) -> bool { | ||
// FIXME(aldenhu) | ||
todo!() | ||
} | ||
} |
Oops, something went wrong.