File tree 2 files changed +25
-2
lines changed
2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -173,6 +173,7 @@ class ExecutionState
173
173
private:
174
174
evmc_tx_context m_tx = {};
175
175
std::optional<std::unordered_map<evmc::bytes32, bytes_view>> m_initcodes;
176
+ std::unordered_map<evmc::bytes32, bool > m_initcodes_validity;
176
177
177
178
public:
178
179
// / Pointer to code analysis.
@@ -216,6 +217,7 @@ class ExecutionState
216
217
deploy_container = {};
217
218
m_tx = {};
218
219
m_initcodes.reset ();
220
+ m_initcodes_validity.clear ();
219
221
call_stack = {};
220
222
}
221
223
@@ -247,5 +249,16 @@ class ExecutionState
247
249
const auto it = m_initcodes->find (hash);
248
250
return it != m_initcodes->end () ? it->second : bytes_view{};
249
251
}
252
+
253
+ [[nodiscard]] std::optional<bool > get_initcode_validity (const evmc_bytes32& hash) noexcept
254
+ {
255
+ const auto it = m_initcodes_validity.find (hash);
256
+ return (it != m_initcodes_validity.end () ? std::optional{it->second } : std::nullopt);
257
+ }
258
+
259
+ void set_initcode_validity (const evmc_bytes32& hash, bool is_valid)
260
+ {
261
+ m_initcodes_validity[hash] = is_valid;
262
+ }
250
263
};
251
264
} // namespace evmone
Original file line number Diff line number Diff line change @@ -435,8 +435,18 @@ Result create_eof_impl(
435
435
436
436
if constexpr (Op == OP_TXCREATE)
437
437
{
438
- const auto error_subcont = validate_eof (state.rev , ContainerKind::initcode, initcontainer);
439
- if (error_subcont != EOFValidationError::success)
438
+ const auto validity = state.get_initcode_validity (initcode_hash);
439
+ bool is_valid = false ;
440
+ if (validity.has_value ())
441
+ is_valid = *validity;
442
+ else
443
+ {
444
+ const auto error_subcont =
445
+ validate_eof (state.rev , ContainerKind::initcode, initcontainer);
446
+ is_valid = (error_subcont == EOFValidationError::success);
447
+ state.set_initcode_validity (initcode_hash, is_valid);
448
+ }
449
+ if (!is_valid)
440
450
return {EVMC_SUCCESS, gas_left}; // "Light" failure.
441
451
}
442
452
You can’t perform that action at this time.
0 commit comments