mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(execution): state change size based commits (#2494)
This commit is contained in:
@ -23,7 +23,10 @@ use reth_staged_sync::{
|
||||
};
|
||||
use reth_stages::{
|
||||
prelude::*,
|
||||
stages::{ExecutionStage, HeaderSyncMode, SenderRecoveryStage, TotalDifficultyStage},
|
||||
stages::{
|
||||
ExecutionStage, ExecutionStageThresholds, HeaderSyncMode, SenderRecoveryStage,
|
||||
TotalDifficultyStage,
|
||||
},
|
||||
};
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
use tokio::sync::watch;
|
||||
@ -171,7 +174,14 @@ impl ImportCommand {
|
||||
.set(SenderRecoveryStage {
|
||||
commit_threshold: config.stages.sender_recovery.commit_threshold,
|
||||
})
|
||||
.set(ExecutionStage::new(factory, config.stages.execution.commit_threshold)),
|
||||
.set(ExecutionStage::new(
|
||||
factory,
|
||||
ExecutionStageThresholds {
|
||||
max_blocks: config.stages.execution.max_blocks,
|
||||
max_changes: config.stages.execution.max_changes,
|
||||
max_changesets: config.stages.execution.max_changesets,
|
||||
},
|
||||
)),
|
||||
)
|
||||
.build(db);
|
||||
|
||||
|
||||
@ -4,7 +4,10 @@ use reth_db::{database::Database, table::TableImporter, tables};
|
||||
use reth_primitives::{BlockNumber, MAINNET};
|
||||
use reth_provider::Transaction;
|
||||
use reth_stages::{
|
||||
stages::{AccountHashingStage, ExecutionStage, MerkleStage, StorageHashingStage},
|
||||
stages::{
|
||||
AccountHashingStage, ExecutionStage, ExecutionStageThresholds, MerkleStage,
|
||||
StorageHashingStage,
|
||||
},
|
||||
Stage, StageId, UnwindInput,
|
||||
};
|
||||
use std::{ops::DerefMut, path::PathBuf, sync::Arc};
|
||||
@ -58,8 +61,14 @@ async fn unwind_and_copy<DB: Database>(
|
||||
MerkleStage::default_unwind().unwind(&mut unwind_tx, unwind).await?;
|
||||
|
||||
// Bring Plainstate to TO (hashing stage execution requires it)
|
||||
let mut exec_stage =
|
||||
ExecutionStage::new(reth_revm::Factory::new(Arc::new(MAINNET.clone())), u64::MAX);
|
||||
let mut exec_stage = ExecutionStage::new(
|
||||
reth_revm::Factory::new(Arc::new(MAINNET.clone())),
|
||||
ExecutionStageThresholds {
|
||||
max_blocks: Some(u64::MAX),
|
||||
max_changes: None,
|
||||
max_changesets: None,
|
||||
},
|
||||
);
|
||||
|
||||
exec_stage
|
||||
.unwind(
|
||||
|
||||
@ -7,8 +7,9 @@ use reth_provider::Transaction;
|
||||
use reth_staged_sync::utils::{chainspec::genesis_value_parser, init::init_db};
|
||||
use reth_stages::{
|
||||
stages::{
|
||||
AccountHashingStage, ExecutionStage, MerkleStage, StorageHashingStage, ACCOUNT_HASHING,
|
||||
EXECUTION, MERKLE_EXECUTION, SENDER_RECOVERY, STORAGE_HASHING,
|
||||
AccountHashingStage, ExecutionStage, ExecutionStageThresholds, MerkleStage,
|
||||
StorageHashingStage, ACCOUNT_HASHING, EXECUTION, MERKLE_EXECUTION, SENDER_RECOVERY,
|
||||
STORAGE_HASHING,
|
||||
},
|
||||
ExecInput, Stage,
|
||||
};
|
||||
@ -82,7 +83,14 @@ impl Command {
|
||||
MERKLE_EXECUTION.get_progress(tx.deref())?.unwrap_or_default());
|
||||
|
||||
let factory = reth_revm::Factory::new(self.chain.clone());
|
||||
let mut execution_stage = ExecutionStage::new(factory, 1);
|
||||
let mut execution_stage = ExecutionStage::new(
|
||||
factory,
|
||||
ExecutionStageThresholds {
|
||||
max_blocks: Some(1),
|
||||
max_changes: None,
|
||||
max_changesets: None,
|
||||
},
|
||||
);
|
||||
|
||||
let mut account_hashing_stage = AccountHashingStage::default();
|
||||
let mut storage_hashing_stage = StorageHashingStage::default();
|
||||
|
||||
@ -54,7 +54,10 @@ use reth_staged_sync::{
|
||||
};
|
||||
use reth_stages::{
|
||||
prelude::*,
|
||||
stages::{ExecutionStage, HeaderSyncMode, SenderRecoveryStage, TotalDifficultyStage, FINISH},
|
||||
stages::{
|
||||
ExecutionStage, ExecutionStageThresholds, HeaderSyncMode, SenderRecoveryStage,
|
||||
TotalDifficultyStage, FINISH,
|
||||
},
|
||||
};
|
||||
use reth_tasks::TaskExecutor;
|
||||
use reth_transaction_pool::{EthTransactionValidator, TransactionPool};
|
||||
@ -689,7 +692,14 @@ impl Command {
|
||||
.set(SenderRecoveryStage {
|
||||
commit_threshold: stage_conf.sender_recovery.commit_threshold,
|
||||
})
|
||||
.set(ExecutionStage::new(factory, stage_conf.execution.commit_threshold))
|
||||
.set(ExecutionStage::new(
|
||||
factory,
|
||||
ExecutionStageThresholds {
|
||||
max_blocks: stage_conf.execution.max_blocks,
|
||||
max_changes: stage_conf.execution.max_changes,
|
||||
max_changesets: stage_conf.execution.max_changesets,
|
||||
},
|
||||
))
|
||||
.disable_if(MERKLE_UNWIND, || self.auto_mine)
|
||||
.disable_if(MERKLE_EXECUTION, || self.auto_mine),
|
||||
)
|
||||
|
||||
@ -16,7 +16,10 @@ use reth_staged_sync::{
|
||||
Config,
|
||||
};
|
||||
use reth_stages::{
|
||||
stages::{BodyStage, ExecutionStage, MerkleStage, SenderRecoveryStage, TransactionLookupStage},
|
||||
stages::{
|
||||
BodyStage, ExecutionStage, ExecutionStageThresholds, MerkleStage, SenderRecoveryStage,
|
||||
TransactionLookupStage,
|
||||
},
|
||||
ExecInput, Stage, StageId, UnwindInput,
|
||||
};
|
||||
use std::{net::SocketAddr, path::PathBuf, sync::Arc};
|
||||
@ -181,7 +184,14 @@ impl Command {
|
||||
}
|
||||
StageEnum::Execution => {
|
||||
let factory = reth_revm::Factory::new(self.chain.clone());
|
||||
let mut stage = ExecutionStage::new(factory, num_blocks);
|
||||
let mut stage = ExecutionStage::new(
|
||||
factory,
|
||||
ExecutionStageThresholds {
|
||||
max_blocks: Some(num_blocks),
|
||||
max_changes: None,
|
||||
max_changesets: None,
|
||||
},
|
||||
);
|
||||
if !self.skip_unwind {
|
||||
stage.unwind(&mut tx, unwind).await?;
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ pub async fn run_test(path: PathBuf) -> eyre::Result<TestOutcome> {
|
||||
// Initialize the execution stage
|
||||
// Hardcode the chain_id to Ethereum 1.
|
||||
let factory = reth_revm::Factory::new(Arc::new(chain_spec));
|
||||
let mut stage = ExecutionStage::new(factory, 1_000);
|
||||
let mut stage = ExecutionStage::new_with_factory(factory);
|
||||
|
||||
// Call execution stage
|
||||
let input = ExecInput {
|
||||
|
||||
Reference in New Issue
Block a user