44
55#include " ../state/mpt_hash.hpp"
66#include " ../state/rlp.hpp"
7- #include " ../state/state.hpp"
8- #include " ../state/system_contracts.hpp"
97#include " ../test/statetest/statetest.hpp"
108#include " blockchaintest.hpp"
119#include < gtest/gtest.h>
@@ -30,11 +28,11 @@ struct TransitionResult
3028
3129namespace
3230{
33- TransitionResult apply_block (state::State & state, evmc::VM & vm, const state::BlockInfo& block,
31+ TransitionResult apply_block (TestState & state, evmc::VM & vm, const state::BlockInfo& block,
3432 const std::vector<state::Transaction>& txs, evmc_revision rev,
3533 std::optional<int64_t > block_reward)
3634{
37- state:: system_call (state, block, rev, vm);
35+ system_call (state, block, rev, vm);
3836
3937 std::vector<state::Log> txs_logs;
4038 int64_t block_gas_left = block.gas_limit ;
@@ -50,7 +48,7 @@ TransitionResult apply_block(state::State& state, evmc::VM& vm, const state::Blo
5048 const auto & tx = txs[i];
5149
5250 const auto computed_tx_hash = keccak256 (rlp::encode (tx));
53- auto res = state ::transition (state, block, tx, rev, vm, block_gas_left, blob_gas_left);
51+ auto res = test ::transition (state, block, tx, rev, vm, block_gas_left, blob_gas_left);
5452
5553 if (holds_alternative<std::error_code>(res))
5654 {
@@ -67,15 +65,15 @@ TransitionResult apply_block(state::State& state, evmc::VM& vm, const state::Blo
6765 cumulative_gas_used += receipt.gas_used ;
6866 receipt.cumulative_gas_used = cumulative_gas_used;
6967 if (rev < EVMC_BYZANTIUM )
70- receipt.post_state = state::mpt_hash (TestState{ state} );
68+ receipt.post_state = state::mpt_hash (state);
7169
7270 block_gas_left -= receipt.gas_used ;
7371 blob_gas_left -= tx.blob_gas_used ();
7472 receipts.emplace_back (std::move (receipt));
7573 }
7674 }
7775
78- state ::finalize (state, rev, block.coinbase , block_reward, block.ommers , block.withdrawals );
76+ test ::finalize (state, rev, block.coinbase , block_reward, block.ommers , block.withdrawals );
7977
8078 const auto bloom = compute_bloom_filter (receipts);
8179 return {std::move (receipts), std::move (rejected_txs), cumulative_gas_used, bloom};
@@ -137,7 +135,7 @@ void run_blockchain_tests(std::span<const BlockchainTest> tests, evmc::VM& vm)
137135 bytes32{});
138136 EXPECT_EQ (c.genesis_block_header .logs_bloom , bytes_view{state::BloomFilter{}});
139137
140- auto state = c.pre_state . to_intra_state () ;
138+ auto state = c.pre_state ;
141139
142140 std::unordered_map<int64_t , hash256> known_block_hashes{
143141 {c.genesis_block_header .block_number , c.genesis_block_header .hash }};
@@ -158,8 +156,7 @@ void run_blockchain_tests(std::span<const BlockchainTest> tests, evmc::VM& vm)
158156 SCOPED_TRACE (std::string{evmc::to_string (rev)} + ' /' + std::to_string (case_index) +
159157 ' /' + c.name + ' /' + std::to_string (test_block.block_info .number ));
160158
161- EXPECT_EQ (
162- state::mpt_hash (TestState{state}), test_block.expected_block_header .state_root );
159+ EXPECT_EQ (state::mpt_hash (state), test_block.expected_block_header .state_root );
163160
164161 if (rev >= EVMC_SHANGHAI )
165162 {
@@ -178,14 +175,13 @@ void run_blockchain_tests(std::span<const BlockchainTest> tests, evmc::VM& vm)
178175 // TODO: Add difficulty calculation verification.
179176 }
180177
181- const TestState post {state};
182178 const auto expected_post_hash =
183179 std::holds_alternative<TestState>(c.expectation .post_state ) ?
184180 state::mpt_hash (std::get<TestState>(c.expectation .post_state )) :
185181 std::get<hash256>(c.expectation .post_state );
186- EXPECT_TRUE (state::mpt_hash (post ) == expected_post_hash)
182+ EXPECT_TRUE (state::mpt_hash (state ) == expected_post_hash)
187183 << " Result state:\n "
188- << print_state (post )
184+ << print_state (state )
189185 << (std::holds_alternative<TestState>(c.expectation .post_state ) ?
190186 " \n\n Expected state:\n " +
191187 print_state (std::get<TestState>(c.expectation .post_state )) :
0 commit comments