go-ethereum/core/state
Daniel Liu bfbb024dc4
core/vm/program: evm bytecode-building utility #30725 (#1801)
In many cases, there is a need to create somewhat nontrivial bytecode. A
recent example is the verkle statetests, where we want a `CREATE2`- op
to create a contract, which can then be invoked, and when invoked does a
selfdestruct-to-self.

It is overkill to go full solidity, but it is also a bit tricky do
assemble this by concatenating bytes. This PR takes an approach that
has been used in in goevmlab for several years.

Using this utility, the case can be expressed as:
```golang
	// Some runtime code
	runtime := program.New().Ops(vm.ADDRESS, vm.SELFDESTRUCT).Bytecode()
	// A constructor returning the runtime code
	initcode := program.New().ReturnData(runtime).Bytecode()
	// A factory invoking the constructor
	outer := program.New().Create2AndCall(initcode, nil).Bytecode()
```

We have a lot of places in the codebase where we concatenate bytes, cast
from `vm.OpCode` . By taking tihs approach instead, thos places can be made a
bit more maintainable/robust.

Co-authored-by: Martin HS <martin@swende.se>
2025-12-08 13:01:55 +05:30
..
access_list.go core/state: reduce one alloc #33024 (#1784) 2025-11-24 11:00:15 +05:30
database.go core/vm/program: evm bytecode-building utility #30725 (#1801) 2025-12-08 13:01:55 +05:30
dump.go core/state: do not ignore null addr while iterative dump #27320 (#1223) 2025-08-29 05:25:15 +08:00
iterator.go cmd, core, eth, trie: track deleted nodes #22225 #25757 (#1120) 2025-11-12 13:32:22 +05:30
iterator_test.go core, trie: port changes from pbss #26637 (#1127) 2025-12-07 15:38:38 +05:30
journal.go core/state: get rid of field pointer in journal #30361 (#1761) 2025-11-15 16:48:52 +05:30
metrics.go cmd, core, eth, trie: track deleted nodes #22225 #25757 (#1120) 2025-11-12 13:32:22 +05:30
state_object.go core/state: get rid of field pointer in journal #30361 (#1761) 2025-11-15 16:48:52 +05:30
state_object_test.go all: using testing.B.Loop (#1554) 2025-09-24 07:59:48 +08:00
state_reader.go new EVM Upgrade 2021-09-21 16:53:46 +05:30
state_test.go eth/tracers: live chain tracing with hooks #29189 (#1352) 2025-09-09 17:30:56 +08:00
statedb.go core, trie: clean up trie interface #26388 (#1125) 2025-11-18 11:19:27 +05:30
statedb_test.go all: use WaigGroup.Go() to simplify code (#1699) 2025-11-29 17:17:08 +05:30
statedb_utils.go all: rework statedb utils (#1785) 2025-11-18 11:26:28 +05:30
sync.go core, trie: prepare for path-based trie storage #26603 (#1126) 2025-11-18 11:20:00 +05:30
sync_test.go core, trie: prepare for path-based trie storage #26603 (#1126) 2025-11-18 11:20:00 +05:30
transient_storage.go all: implement EIP-1153 transient storage (#26003) 2024-11-15 19:39:18 +08:00
trc21_reader.go all: rework trc21 (#1777) 2025-11-18 11:24:56 +05:30