@@ -146,31 +146,32 @@ void clear_empty_accounts(State& state)
146
146
}
147
147
} // namespace
148
148
149
- void system_calls (State& state, const BlockInfo& block, evmc_revision rev, evmc::VM& vm)
149
+ void system_call (State& state, const BlockInfo& block, evmc_revision rev, evmc::VM& vm)
150
150
{
151
151
static constexpr auto SystemAddress = 0xfffffffffffffffffffffffffffffffffffffffe_address;
152
152
static constexpr auto BeaconRootsAddress = 0xbEac00dDB15f3B6d645C48263dC93862413A222D_address;
153
153
154
154
if (rev >= EVMC_CANCUN)
155
155
{
156
- evmc_message msg{};
157
- msg.kind = EVMC_CALL;
158
- msg.sender = SystemAddress;
159
- msg.recipient = BeaconRootsAddress;
160
- msg.code_address = BeaconRootsAddress;
161
- msg.gas = 30'000'000 ;
162
- msg.input_data = block.parent_beacon_block_root .bytes ;
163
- msg.input_size = sizeof (block.parent_beacon_block_root );
164
- msg.depth = 1 ; // Prevent nonce bump.
165
- Host host{rev, vm, state, block, {}};
166
- [[maybe_unused]] const auto result = host.call (msg);
167
- assert (result.status_code == EVMC_SUCCESS);
168
-
169
- // Set accounts and their storage access status to cold in the end of transition process
170
- for (auto & acc : state.get_accounts ())
156
+ if (const auto acc = state.find (BeaconRootsAddress); acc != nullptr )
171
157
{
172
- acc.second .access_status = EVMC_ACCESS_COLD;
173
- for (auto & [_, val] : acc.second .storage )
158
+ const evmc_message msg{
159
+ .kind = EVMC_CALL,
160
+ .gas = 30'000'000 ,
161
+ .recipient = BeaconRootsAddress,
162
+ .sender = SystemAddress,
163
+ .input_data = block.parent_beacon_block_root .bytes ,
164
+ .input_size = sizeof (block.parent_beacon_block_root ),
165
+ };
166
+
167
+ Host host{rev, vm, state, block, {}};
168
+ const auto & code = acc->code ;
169
+ [[maybe_unused]] const auto res = vm.execute (host, rev, msg, code.data (), code.size ());
170
+ assert (res.status_code == EVMC_SUCCESS);
171
+ assert (acc->access_status == EVMC_ACCESS_COLD);
172
+
173
+ // Reset storage status.
174
+ for (auto & [_, val] : acc->storage )
174
175
{
175
176
val.access_status = EVMC_ACCESS_COLD;
176
177
val.original = val.current ;
0 commit comments