MCPcopy Create free account
hub / github.com/base/base / commit_block_to_database

Function commit_block_to_database

crates/execution/trie/tests/live.rs:180–213  ·  view source on GitHub ↗

Commits a block and its execution output to the database

(
    block: &RecoveredBlock<Block>,
    execution_output: &reth_evm::execute::BlockExecutionOutput<Receipt>,
    provider_factory: &ProviderFactory<N>,
)

Source from the content-addressed store, hash-verified

178
179/// Commits a block and its execution output to the database
180fn commit_block_to_database<N>(
181 block: &RecoveredBlock<Block>,
182 execution_output: &reth_evm::execute::BlockExecutionOutput<Receipt>,
183 provider_factory: &ProviderFactory<N>,
184) -> eyre::Result<()>
185where
186 N: ProviderNodeTypes<
187 Primitives: NodePrimitives<Block = Block, BlockBody = BlockBody, Receipt = Receipt>,
188 > + NodeTypesWithDB,
189{
190 let execution_outcome = ExecutionOutcome {
191 bundle: execution_output.state.clone(),
192 receipts: vec![execution_output.receipts.clone()],
193 first_block: block.number(),
194 requests: vec![execution_output.requests.clone()],
195 };
196
197 // Calculate hashed state from execution result
198 let state_provider = provider_factory.provider()?;
199 let hashed_state = HashedPostStateProvider::hashed_post_state(
200 &LatestStateProviderRef::new(&state_provider),
201 &execution_output.state,
202 );
203
204 let provider_rw = provider_factory.provider_rw()?;
205 provider_rw.append_blocks_with_state(
206 vec![block.clone()],
207 &execution_outcome,
208 hashed_state.into_sorted(),
209 )?;
210 provider_rw.commit()?;
211
212 Ok(())
213}
214
215/// Runs a test scenario with the given configuration
216fn run_test_scenario<N>(

Callers 1

run_test_scenarioFunction · 0.85

Calls 4

cloneMethod · 0.45
numberMethod · 0.45
providerMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected