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
3 changes: 1 addition & 2 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/optimism/bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ otlp = ["reth-optimism-cli/otlp"]

js-tracer = [
"reth-optimism-node/js-tracer",
"reth-node-builder/js-tracer",
]

jemalloc = ["reth-cli-util/jemalloc", "reth-optimism-cli/jemalloc"]
Expand Down
1 change: 0 additions & 1 deletion crates/optimism/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ reth-node-builder.workspace = true
reth-chainspec.workspace = true
reth-chain-state.workspace = true
reth-rpc-engine-api.workspace = true
reth-rpc-convert.workspace = true
reth-payload-util.workspace = true
reth-provider.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/rpc/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ where
let config = PayloadConfig { parent_header: Arc::new(parent_header), attributes };
let ctx = OpPayloadBuilderCtx {
evm_config: this.evm_config.clone(),
da_config: Default::default(), // doesn't matter if no txpool
chain_spec: this.provider.chain_spec(),
config,
cancel: Default::default(),
best_payload: Default::default(),
builder_config: Default::default(),
};

let state_provider = this
Expand Down
28 changes: 20 additions & 8 deletions crates/optimism/trie/src/cursor_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ impl<'tx, S> TrieCursorFactory for OpProofsTrieCursorFactory<'tx, S>
where
S: OpProofsStore + 'tx,
{
type AccountTrieCursor = OpProofsTrieCursor<S::AccountTrieCursor<'tx>>;
type StorageTrieCursor = OpProofsTrieCursor<S::StorageTrieCursor<'tx>>;
type AccountTrieCursor<'a>
= OpProofsTrieCursor<S::AccountTrieCursor<'a>>
where
Self: 'a;
type StorageTrieCursor<'a>
= OpProofsTrieCursor<S::StorageTrieCursor<'a>>
where
Self: 'a;

fn account_trie_cursor(&self) -> Result<Self::AccountTrieCursor, DatabaseError> {
fn account_trie_cursor(&self) -> Result<Self::AccountTrieCursor<'_>, DatabaseError> {
Ok(OpProofsTrieCursor::new(
self.storage
.account_trie_cursor(self.block_number)
Expand All @@ -42,7 +48,7 @@ where
fn storage_trie_cursor(
&self,
hashed_address: B256,
) -> Result<Self::StorageTrieCursor, DatabaseError> {
) -> Result<Self::StorageTrieCursor<'_>, DatabaseError> {
Ok(OpProofsTrieCursor::new(
self.storage
.storage_trie_cursor(hashed_address, self.block_number)
Expand Down Expand Up @@ -70,17 +76,23 @@ impl<'tx, S> HashedCursorFactory for OpProofsHashedAccountCursorFactory<'tx, S>
where
S: OpProofsStore + 'tx,
{
type AccountCursor = OpProofsHashedAccountCursor<S::AccountHashedCursor<'tx>>;
type StorageCursor = OpProofsHashedStorageCursor<S::StorageCursor<'tx>>;
type AccountCursor<'a>
= OpProofsHashedAccountCursor<S::AccountHashedCursor<'a>>
where
Self: 'a;
type StorageCursor<'a>
= OpProofsHashedStorageCursor<S::StorageCursor<'a>>
where
Self: 'a;

fn hashed_account_cursor(&self) -> Result<Self::AccountCursor, DatabaseError> {
fn hashed_account_cursor(&self) -> Result<Self::AccountCursor<'_>, DatabaseError> {
Ok(OpProofsHashedAccountCursor::new(self.storage.account_hashed_cursor(self.block_number)?))
}

fn hashed_storage_cursor(
&self,
hashed_address: B256,
) -> Result<Self::StorageCursor, DatabaseError> {
) -> Result<Self::StorageCursor<'_>, DatabaseError> {
Ok(OpProofsHashedStorageCursor::new(
self.storage.storage_hashed_cursor(hashed_address, self.block_number)?,
))
Expand Down
17 changes: 8 additions & 9 deletions crates/optimism/trie/src/db/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,10 @@ impl MdbxProofsStorage {

let sorted_post_state = block_state_diff.post_state.into_sorted();

let sorted_accounts = sorted_post_state.accounts().accounts_sorted();
let sorted_storage = sorted_post_state
.account_storages()
.iter()
.sorted_by_key(|(hashed_address, _)| *hashed_address)
.map(|(k, v)| (*k, v.clone()))
.collect::<Vec<_>>();

let storage_trie_len = sorted_storage_nodes.len();
Expand All @@ -265,7 +264,7 @@ impl MdbxProofsStorage {
let hashed_account_keys = self.append_or_delete_dup_sorted(
tx,
block_number,
sorted_accounts.into_iter(),
sorted_post_state.accounts().iter().copied(),
soft_delete,
)?;

Expand Down Expand Up @@ -298,19 +297,19 @@ impl MdbxProofsStorage {
if storage.is_wiped() {
// Yet to have any update for the current block number - So just using up to
// previous block number
let mut ro = self.storage_hashed_cursor(*hashed_address, block_number - 1)?;
let keys = self.wipe_storage(tx, block_number, *hashed_address, || ro.next())?;
let mut ro = self.storage_hashed_cursor(hashed_address, block_number - 1)?;
let keys = self.wipe_storage(tx, block_number, hashed_address, || ro.next())?;
hashed_storage_keys.extend(keys);
// Skip any further processing for this hashed_address
continue;
}
let storage_items = storage.storage_slots_sorted().collect::<Vec<_>>();
let keys = self.append_or_delete_dup_sorted(
tx,
block_number,
storage_items
.into_iter()
.map(|(key, val)| (*hashed_address, key, Some(StorageValue(val)))),
storage
.storage_slots_ref()
.iter()
.map(|(key, val)| (hashed_address, *key, Some(StorageValue(*val)))),
soft_delete,
)?;
hashed_storage_keys.extend(keys);
Expand Down
8 changes: 4 additions & 4 deletions crates/optimism/trie/tests/live.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use reth_db_common::init::init_genesis;
use reth_ethereum_primitives::{Block, BlockBody, Receipt, TransactionSigned};
use reth_evm::{execute::Executor, ConfigureEvm};
use reth_evm_ethereum::EthEvmConfig;
use reth_node_api::{FullNodePrimitives, NodeTypesWithDB};
use reth_node_api::{NodePrimitives, NodeTypesWithDB};
use reth_optimism_trie::{
backfill::BackfillJob, in_memory::InMemoryProofsStorage, live::LiveTrieCollector,
OpProofsStorage,
Expand Down Expand Up @@ -145,7 +145,7 @@ fn execute_block<N>(
) -> eyre::Result<reth_evm::execute::BlockExecutionOutput<Receipt>>
where
N: ProviderNodeTypes<
Primitives: FullNodePrimitives<Block = Block, BlockBody = BlockBody, Receipt = Receipt>,
Primitives: NodePrimitives<Block = Block, BlockBody = BlockBody, Receipt = Receipt>,
> + NodeTypesWithDB,
{
let provider = provider_factory.provider()?;
Expand All @@ -172,7 +172,7 @@ fn commit_block_to_database<N>(
) -> eyre::Result<()>
where
N: ProviderNodeTypes<
Primitives: FullNodePrimitives<Block = Block, BlockBody = BlockBody, Receipt = Receipt>,
Primitives: NodePrimitives<Block = Block, BlockBody = BlockBody, Receipt = Receipt>,
> + NodeTypesWithDB,
{
let execution_outcome = ExecutionOutcome {
Expand Down Expand Up @@ -210,7 +210,7 @@ async fn run_test_scenario<N>(
) -> eyre::Result<()>
where
N: ProviderNodeTypes<
Primitives: FullNodePrimitives<Block = Block, BlockBody = BlockBody, Receipt = Receipt>,
Primitives: NodePrimitives<Block = Block, BlockBody = BlockBody, Receipt = Receipt>,
> + NodeTypesWithDB,
{
let genesis_hash = chain_spec.genesis_hash();
Expand Down
10 changes: 8 additions & 2 deletions crates/storage/db-api/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,18 @@ impl<T: Table> DbCursorRO<T> for CursorMock {
}

impl<T: DupSort> DbDupCursorRO<T> for CursorMock {
/// Moves to the next duplicate entry.
/// **Mock behavior**: Always returns `None`.
fn prev_dup(&mut self) -> PairResult<T> {
Ok(None)
}

fn next_dup(&mut self) -> PairResult<T> {
Ok(None)
}

fn last_dup(&mut self) -> ValueOnlyResult<T> {
Ok(None)
}

/// Moves to the next entry with a different key.
/// **Mock behavior**: Always returns `None`.
fn next_no_dup(&mut self) -> PairResult<T> {
Expand Down
4 changes: 2 additions & 2 deletions crates/trie/common/src/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,9 @@ pub struct TrieUpdatesSortedRef<'a> {
pub struct TrieUpdatesSorted {
/// Sorted collection of updated state nodes with corresponding paths. None indicates that a
/// node was removed.
account_nodes: Vec<(Nibbles, Option<BranchNodeCompact>)>,
pub account_nodes: Vec<(Nibbles, Option<BranchNodeCompact>)>,
/// Storage tries stored by hashed address of the account the trie belongs to.
storage_tries: B256Map<StorageTrieUpdatesSorted>,
pub storage_tries: B256Map<StorageTrieUpdatesSorted>,
}

impl TrieUpdatesSorted {
Expand Down
Loading