Commits a block and its execution output to the database
(
block: &RecoveredBlock<Block>,
execution_output: &reth_evm::execute::BlockExecutionOutput<Receipt>,
provider_factory: &ProviderFactory<N>,
)
| 178 | |
| 179 | /// Commits a block and its execution output to the database |
| 180 | fn 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<()> |
| 185 | where |
| 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 |
| 216 | fn run_test_scenario<N>( |
no test coverage detected