go-ethereum/core/vm
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
..
privacy core: fix unused warnings (#1811) 2025-12-07 15:39:31 +05:30
program core/vm/program: evm bytecode-building utility #30725 (#1801) 2025-12-08 13:01:55 +05:30
runtime core/vm/program: evm bytecode-building utility #30725 (#1801) 2025-12-08 13:01:55 +05:30
testdata core/vm, protocol_params: implement eip-2565 modexp repricing (#21607) 2024-10-17 10:36:53 +08:00
analysis.go core/vm: clarify comment (#27045) 2025-02-05 18:16:17 +08:00
analysis_test.go core/vm: use clear from go v1.21 #29307 (#1246) 2025-08-04 11:54:49 +08:00
common.go all: get rid of custom MaxUint64 and MaxUint64 (#30636) 2024-12-28 09:06:31 +08:00
contract.go eth/tracers: live chain tracing with hooks #29189 (#1352) 2025-09-09 17:30:56 +08:00
contracts.go internal/ethapi: eth_simulateV1 #27720 (#1606) 2025-11-08 16:09:18 +05:30
contracts_fuzz_test.go eth/tracers: live chain tracing with hooks #29189 (#1352) 2025-09-09 17:30:56 +08:00
contracts_test.go all: using testing.B.Loop (#1554) 2025-09-24 07:59:48 +08:00
doc.go core/vm: remove JIT VM codes (#16362) 2018-03-26 13:48:04 +03:00
eips.go core/vm: fold EVMInterpreter into EVM #32352 (#1838) 2025-12-04 10:31:40 +05:30
errors.go core/vm: better error-info for vm errors #29354 (#1464) 2025-09-13 10:20:34 +08:00
evm.go core/vm: fold EVMInterpreter into EVM #32352 (#1838) 2025-12-04 10:31:40 +05:30
gas.go core/vm: use uint256 in EVM implementation (#20787) 2024-03-01 14:13:23 +08:00
gas_table.go core/vm: better error-info for vm errors #29354 (#1464) 2025-09-13 10:20:34 +08:00
gas_table_test.go params: define prague block #26481 #26880 (#1836) 2025-12-07 15:36:02 +05:30
instructions.go core/vm: fold EVMInterpreter into EVM #32352 (#1838) 2025-12-04 10:31:40 +05:30
instructions_test.go core/vm: fold EVMInterpreter into EVM #32352 (#1838) 2025-12-04 10:31:40 +05:30
interface.go core/vm: reject contract creation if the storage is non-empty #28912 (#1569) 2025-09-24 07:57:02 +08:00
interpreter.go core/vm: fold EVMInterpreter into EVM #32352 (#1838) 2025-12-04 10:31:40 +05:30
jump_table.go core/vm: fold EVMInterpreter into EVM #32352 (#1838) 2025-12-04 10:31:40 +05:30
jump_table_export.go params: define prague block #26481 #26880 (#1836) 2025-12-07 15:36:02 +05:30
jump_table_test.go core: fix typos (#1237) 2025-07-26 17:42:50 +08:00
memory.go core/vm, go.mod: update uint256 to v1.3.2 and use faster method #30868 (#1241) 2025-07-17 17:56:53 +08:00
memory_table.go core/vm: implement EIP-5656, mcopy instruction (#26181) 2025-02-06 16:54:19 +08:00
memory_test.go core/vm: implement EIP-5656, mcopy instruction (#26181) 2025-02-06 16:54:19 +08:00
opcodes.go core/vm: BLOBHASH opcode 0x49 (#27356) 2025-02-11 18:31:30 +08:00
operations_acl.go eth/tracers: live chain tracing with hooks #29189 (#1352) 2025-09-09 17:30:56 +08:00
stack.go core/vm: less allocations for various call variants (#21222) 2024-09-22 18:42:11 +08:00
stack_table.go new EVM Upgrade 2021-09-21 16:53:46 +05:30
XDCx_price.go new EVM Upgrade 2021-09-21 16:53:46 +05:30