|
11 | 11 | import
|
12 | 12 | std/[json, strutils, times, tables, os, sets],
|
13 | 13 | eth/[rlp, trie, eip1559],
|
14 |
| - stint, chronicles, stew/results, |
| 14 | + stint, chronicles, stew/[results, byteutils], |
15 | 15 | "."/[config, types, helpers],
|
16 | 16 | ../common/state_clearing,
|
17 | 17 | ../../nimbus/[vm_types, vm_state, transaction],
|
18 | 18 | ../../nimbus/common/common,
|
19 | 19 | ../../nimbus/db/accounts_cache,
|
20 |
| - ../../nimbus/utils/utils, |
| 20 | + ../../nimbus/evm/validate, |
| 21 | + ../../nimbus/utils/[utils, eof], |
21 | 22 | ../../nimbus/core/pow/difficulty,
|
22 | 23 | ../../nimbus/core/dao,
|
23 | 24 | ../../nimbus/core/executor/[process_transaction, executor_helpers]
|
24 | 25 |
|
25 |
| -import stew/byteutils |
26 | 26 | const
|
27 | 27 | wrapExceptionEnabled* {.booldefine.} = true
|
28 | 28 | stdinSelector = "stdin"
|
@@ -372,6 +372,21 @@ proc transitionAction*(ctx: var TransContext, conf: T8NConf) =
|
372 | 372 | else:
|
373 | 373 | raise newError(ErrorConfig, "EIP-1559 config but missing 'currentBaseFee' in env section")
|
374 | 374 |
|
| 375 | + # Sanity check pre-allocated EOF code to not panic in state transition. |
| 376 | + if com.forkGTE(HardFork.Cancun): |
| 377 | + for address, acc in ctx.alloc: |
| 378 | + if not hasEOFByte(acc.code): |
| 379 | + continue |
| 380 | + |
| 381 | + var c: Container |
| 382 | + var res = c.decode(acc.code) |
| 383 | + if res.isOk: |
| 384 | + res = c.validateCode() |
| 385 | + |
| 386 | + if res.isErr: |
| 387 | + raise newError(ErrorConfig, "code at $1 considered invalid: $2" % |
| 388 | + [address.toHex, res.error.toString]) |
| 389 | + |
375 | 390 | if com.forkGTE(MergeFork):
|
376 | 391 | if ctx.env.currentRandom.isNone:
|
377 | 392 | raise newError(ErrorConfig, "post-merge requires currentRandom to be defined in env")
|
|
0 commit comments