Skip to content

Commit befa36d

Browse files
committed
move block hash buffer set outside of process_ethereum_block
1 parent 5845ccc commit befa36d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

cmd/monad/runloop_ethereum.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ void log_tps(
7979

8080
// Process a single historical Ethereum block
8181
template <Traits traits>
82-
Result<void> process_ethereum_block(
83-
Chain const &chain, Db &db, vm::VM &vm,
84-
BlockHashBufferFinalized &block_hash_buffer,
82+
Result<BlockHeader> process_ethereum_block(
83+
Chain const &chain, Db &db, vm::VM &vm, BlockHashBuffer &block_hash_buffer,
8584
fiber::PriorityPool &priority_pool, Block &block, bytes32_t const &block_id,
8685
bytes32_t const &parent_block_id, bool const enable_tracing)
8786
{
@@ -164,17 +163,14 @@ Result<void> process_ethereum_block(
164163
std::chrono::steady_clock::now() - commit_begin);
165164

166165
// Post-commit validation of header, with Merkle root fields filled in
167-
auto const output_header = db.read_eth_header();
166+
BlockHeader const output_header = db.read_eth_header();
168167
BOOST_OUTCOME_TRY(
169168
chain.validate_output_header(block.header, output_header));
170169

171170
// Commit prologue: database finalization, computation of the Ethereum
172171
// block hash to append to the circular hash buffer
173172
db.finalize(block.header.number, block_id);
174173
db.update_verified_block(block.header.number);
175-
auto const eth_block_hash =
176-
to_bytes(keccak256(rlp::encode_block_header(output_header)));
177-
block_hash_buffer.set(block.header.number, eth_block_hash);
178174

179175
// Emit the block metrics log line
180176
[[maybe_unused]] auto const block_time =
@@ -209,7 +205,7 @@ Result<void> process_ethereum_block(
209205
vm.print_and_reset_block_counts(),
210206
vm.print_compiler_stats());
211207

212-
return outcome_e::success();
208+
return output_header;
213209
}
214210

215211
MONAD_ANONYMOUS_NAMESPACE_END
@@ -245,7 +241,7 @@ Result<std::pair<uint64_t, uint64_t>> runloop_ethereum(
245241
evmc_revision const rev =
246242
chain.get_revision(block.header.number, block.header.timestamp);
247243

248-
BOOST_OUTCOME_TRY([&] {
244+
BOOST_OUTCOME_TRY(BlockHeader const output_header, [&] {
249245
SWITCH_EVM_TRAITS(
250246
process_ethereum_block,
251247
chain,
@@ -260,6 +256,10 @@ Result<std::pair<uint64_t, uint64_t>> runloop_ethereum(
260256
MONAD_ABORT_PRINTF("unhandled rev switch case: %d", rev);
261257
}());
262258

259+
bytes32_t const eth_block_hash =
260+
to_bytes(keccak256(rlp::encode_block_header(output_header)));
261+
block_hash_buffer.set(block.header.number, eth_block_hash);
262+
263263
ntxs += block.transactions.size();
264264
batch_num_txs += block.transactions.size();
265265
total_gas += block.header.gas_used;

0 commit comments

Comments
 (0)