Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions config/src/config/storage_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,29 @@ impl Default for RocksdbConfigs {
}
}

#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct HotStateConfig {
/// Max number of items in each shard.
pub max_items_per_shard: usize,
}

impl Default for HotStateConfig {
fn default() -> Self {
Self {
max_items_per_shard: 250_000,
}
}
}

#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(default, deny_unknown_fields)]
pub struct StorageConfig {
pub backup_service_address: SocketAddr,
/// Top level directory to store the RocksDB
pub dir: PathBuf,
/// Hot state configuration
pub hot_state_config: HotStateConfig,
/// Storage pruning configuration
pub storage_pruner_config: PrunerConfig,
/// Subdirectory for storage in tests only
Expand Down Expand Up @@ -406,6 +423,7 @@ impl Default for StorageConfig {
StorageConfig {
backup_service_address: SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 6186),
dir: PathBuf::from("db"),
hot_state_config: HotStateConfig::default(),
// The prune window must at least out live a RPC request because its sub requests are
// to return a consistent view of the DB at exactly same version. Considering a few
// thousand TPS we are potentially going to achieve, and a few minutes a consistent view
Expand Down
1 change: 1 addition & 0 deletions execution/executor-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rust-version = { workspace = true }

[dependencies]
anyhow = { workspace = true }
aptos-config = { workspace = true }
aptos-crypto = { workspace = true }
aptos-drop-helper = { workspace = true }
aptos-infallible = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion execution/executor-types/src/execution_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use crate::{
planned::Planned,
transactions_with_output::{TransactionsToKeep, TransactionsWithOutput},
};
use aptos_config::config::HotStateConfig;
use aptos_drop_helper::DropHelper;
use aptos_storage_interface::state_store::{
state::LedgerState, state_view::cached_state_view::ShardedStateCache,
};
use aptos_types::{
contract_event::ContractEvent,
epoch_state::EpochState,
state_store::hot_state::HotStateConfig,
transaction::{
block_epilogue::BlockEndInfo, ExecutionStatus, Transaction, TransactionStatus, Version,
},
Expand Down
1 change: 1 addition & 0 deletions execution/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ rust-version = { workspace = true }
[dependencies]
anyhow = { workspace = true }
aptos-block-executor = { workspace = true }
aptos-config = { workspace = true }
aptos-consensus-types = { workspace = true }
aptos-crypto = { workspace = true }
aptos-drop-helper = { workspace = true }
Expand Down
6 changes: 2 additions & 4 deletions execution/executor/src/block_executor/block_tree/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ use crate::{
block_executor::block_tree::{epoch_genesis_block_id, BlockLookup, BlockTree},
types::partial_state_compute_result::PartialStateComputeResult,
};
use aptos_config::config::HotStateConfig;
use aptos_crypto::{hash::PRE_GENESIS_BLOCK_ID, HashValue};
use aptos_infallible::Mutex;
use aptos_storage_interface::LedgerSummary;
use aptos_types::{
block_info::BlockInfo, epoch_state::EpochState, ledger_info::LedgerInfo,
state_store::hot_state::HotStateConfig,
};
use aptos_types::{block_info::BlockInfo, epoch_state::EpochState, ledger_info::LedgerInfo};
use std::sync::Arc;

impl BlockTree {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,12 @@ impl TStateView for WriteSetStateView<'_> {
#[cfg(test)]
mod tests {
use super::Parser;
use aptos_config::config::HotStateConfig;
use aptos_storage_interface::state_store::{
state::LedgerState, state_view::cached_state_view::CachedStateView,
};
use aptos_types::{
contract_event::ContractEvent,
state_store::hot_state::HotStateConfig,
transaction::{
AuxiliaryInfo, ExecutionStatus, PersistedAuxiliaryInfo, Transaction,
TransactionAuxiliaryData, TransactionOutput, TransactionStatus,
Expand Down
6 changes: 2 additions & 4 deletions storage/aptosdb/src/state_store/hot_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@

use crate::metrics::{COUNTER, GAUGE, OTHER_TIMERS_SECONDS};
use anyhow::{ensure, Result};
use aptos_config::config::HotStateConfig;
use aptos_infallible::Mutex;
use aptos_logger::prelude::*;
use aptos_metrics_core::{IntCounterVecHelper, IntGaugeVecHelper, TimerHelper};
use aptos_storage_interface::state_store::{
state::State, state_view::hot_state_view::HotStateView,
};
use aptos_types::state_store::{
hot_state::{HotStateConfig, THotStateSlot},
state_key::StateKey,
state_slot::StateSlot,
NUM_STATE_SHARDS,
hot_state::THotStateSlot, state_key::StateKey, state_slot::StateSlot, NUM_STATE_SHARDS,
};
#[cfg(test)]
use aptos_types::transaction::Version;
Expand Down
2 changes: 1 addition & 1 deletion storage/aptosdb/src/state_store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use crate::{
ShardedStateKvSchemaBatch,
},
};
use aptos_config::config::HotStateConfig;
use aptos_crypto::{
hash::{CryptoHash, CORRUPTION_SENTINEL, SPARSE_MERKLE_PLACEHOLDER_HASH},
HashValue,
Expand Down Expand Up @@ -63,7 +64,6 @@ use aptos_storage_interface::{
use aptos_types::{
proof::{definition::LeafCount, SparseMerkleProofExt, SparseMerkleRangeProof},
state_store::{
hot_state::HotStateConfig,
state_key::{prefix::StateKeyPrefix, StateKey},
state_slot::StateSlot,
state_storage_usage::StateStorageUsage,
Expand Down
2 changes: 1 addition & 1 deletion storage/aptosdb/src/state_store/persisted_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Licensed pursuant to the Innovation-Enabling Source Code License, available at https://github.com/aptos-labs/aptos-core/blob/main/LICENSE

use crate::{metrics::OTHER_TIMERS_SECONDS, state_store::hot_state::HotState};
use aptos_config::config::HotStateConfig;
use aptos_infallible::Mutex;
use aptos_metrics_core::TimerHelper;
use aptos_scratchpad::SUBTREE_DROPPER;
use aptos_storage_interface::state_store::{
state::State, state_summary::StateSummary, state_view::hot_state_view::HotStateView,
state_with_summary::StateWithSummary,
};
use aptos_types::state_store::hot_state::HotStateConfig;
use std::sync::Arc;

#[derive(Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use crate::state_store::persisted_state::PersistedState;
use aptos_block_executor::hot_state_op_accumulator::BlockHotStateOpAccumulator;
use aptos_config::config::HotStateConfig;
use aptos_crypto::{hash::CryptoHash, HashValue};
use aptos_infallible::Mutex;
use aptos_scratchpad::test_utils::naive_smt::NaiveSmt;
Expand All @@ -19,12 +20,9 @@ use aptos_storage_interface::{
use aptos_types::{
proof::SparseMerkleProofExt,
state_store::{
hot_state::{HotStateConfig, LRUEntry},
state_key::StateKey,
state_slot::StateSlot,
state_storage_usage::StateStorageUsage,
state_value::StateValue,
StateViewId, StateViewResult, TStateView, NUM_STATE_SHARDS,
hot_state::LRUEntry, state_key::StateKey, state_slot::StateSlot,
state_storage_usage::StateStorageUsage, state_value::StateValue, StateViewId,
StateViewResult, TStateView, NUM_STATE_SHARDS,
},
transaction::Version,
write_set::{BaseStateOp, HotStateOp, WriteOp},
Expand Down
1 change: 1 addition & 0 deletions storage/storage-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rust-version = { workspace = true }

[dependencies]
anyhow = { workspace = true }
aptos-config = { workspace = true }
aptos-crypto = { workspace = true }
aptos-experimental-layered-map = { workspace = true }
aptos-logger = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion storage/storage-interface/src/ledger_summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Licensed pursuant to the Innovation-Enabling Source Code License, available at https://github.com/aptos-labs/aptos-core/blob/main/LICENSE

use crate::state_store::{state::LedgerState, state_summary::LedgerStateSummary};
use aptos_config::config::HotStateConfig;
use aptos_types::{
proof::accumulator::{InMemoryAccumulator, InMemoryTransactionAccumulator},
state_store::hot_state::HotStateConfig,
transaction::Version,
};
use std::sync::Arc;
Expand Down
5 changes: 3 additions & 2 deletions storage/storage-interface/src/state_store/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ use crate::{
DbReader,
};
use anyhow::Result;
use aptos_config::config::HotStateConfig;
use aptos_experimental_layered_map::{LayeredMap, MapLayer};
use aptos_metrics_core::TimerHelper;
use aptos_types::{
state_store::{
hot_state::HotStateConfig, state_key::StateKey, state_slot::StateSlot,
state_storage_usage::StateStorageUsage, StateViewId, NUM_STATE_SHARDS,
state_key::StateKey, state_slot::StateSlot, state_storage_usage::StateStorageUsage,
StateViewId, NUM_STATE_SHARDS,
},
transaction::Version,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ use crate::state_store::{
state::{LedgerState, State},
state_summary::{LedgerStateSummary, StateSummary},
};
use aptos_config::config::HotStateConfig;
use aptos_crypto::HashValue;
use aptos_scratchpad::SparseMerkleTree;
use aptos_types::{
state_store::{hot_state::HotStateConfig, state_storage_usage::StateStorageUsage},
transaction::Version,
};
use aptos_types::{state_store::state_storage_usage::StateStorageUsage, transaction::Version};
use derive_more::{Deref, DerefMut};

#[derive(Clone, Debug, Deref)]
Expand Down
22 changes: 0 additions & 22 deletions types/src/state_store/hot_state.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,6 @@
// Copyright (c) Aptos Foundation
// Licensed pursuant to the Innovation-Enabling Source Code License, available at https://github.com/aptos-labs/aptos-core/blob/main/LICENSE

// 256 MiB per shard
pub const HOT_STATE_MAX_BYTES_PER_SHARD: usize = 256 * 1024 * 1024;
// 250k items per shard
pub const HOT_STATE_MAX_ITEMS_PER_SHARD: usize = 250_000;
// 10KB, worst case the hot state still caches about 400K items (all shards)
pub const HOT_STATE_MAX_SINGLE_VALUE_BYTES: usize = 10 * 1024;

// TODO(HotState): later make this onchain config.
#[derive(Clone, Copy, Debug)]
pub struct HotStateConfig {
pub max_items_per_shard: usize,
}

// TODO(HotState): can be removed once we make it configurable.
impl Default for HotStateConfig {
fn default() -> Self {
Self {
max_items_per_shard: HOT_STATE_MAX_ITEMS_PER_SHARD,
}
}
}

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct LRUEntry<K> {
/// The key that is slightly newer than the current entry. `None` for the newest entry.
Expand Down
Loading