go-ethereum/core
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
..
asm all: pre-allocate memory for slices and maps, close XFN-148 (#1714) 2025-11-14 20:13:36 +05:30
bloombits all: use WaigGroup.Go() to simplify code (#1699) 2025-11-29 17:17:08 +05:30
rawdb core/rawdb: refactor func WriteChainConfig (#1805) 2025-12-08 13:00:25 +05:30
state core/vm/program: evm bytecode-building utility #30725 (#1801) 2025-12-08 13:01:55 +05:30
tracing eth/tracers: various fixes #30540 (#1491) 2025-09-17 09:04:38 +08:00
txpool core, eth: for types with accurate size calcs, return uint64 #26046 (#1791) 2025-12-07 15:52:03 +05:30
types core/types: implement encode/decode for TxData interface #27841 (#1795) 2025-12-07 15:52:27 +05:30
vm core/vm/program: evm bytecode-building utility #30725 (#1801) 2025-12-08 13:01:55 +05:30
.gitignore Renamed chain => core 2014-12-04 10:28:02 +01:00
bench_test.go all: using testing.B.Loop (#1554) 2025-09-24 07:59:48 +08:00
block_validator.go all: remove mongodb support in XDCx (#1679) 2025-11-15 16:50:02 +05:30
block_validator_test.go core: remove outdated tests #27662 (#1496) 2025-09-17 08:16:07 +08:00
blockchain.go core/types: implement encode/decode for TxData interface #27841 (#1795) 2025-12-07 15:52:27 +05:30
blockchain_insert.go all: simplify timestamps to uint64 #19372 (#1318) 2025-08-08 10:33:37 +08:00
blockchain_reader.go core, eth, trie: abstract node scheme #25532 (#1123) 2025-11-17 11:25:08 +05:30
blockchain_test.go all: fix whitespace (#1572) 2025-09-24 07:58:40 +08:00
blocks.go new EVM Upgrade 2021-09-21 16:53:46 +05:30
chain_indexer.go core: refactor read and write section head (#1809) 2025-12-08 12:59:23 +05:30
chain_indexer_test.go light: CHT and bloom trie indexers working in light mode (#16534) 2025-03-06 15:30:48 +08:00
chain_makers.go all: rework trc21 (#1777) 2025-11-18 11:24:56 +05:30
chain_makers_test.go all: fix goimports (#1560) 2025-09-24 07:51:10 +08:00
dao_test.go core, trie: port changes from pbss #26637 (#1127) 2025-12-07 15:38:38 +05:30
error.go all: improve EstimateGas API (#20830) 2024-12-21 14:35:44 +08:00
events.go eth/filters: remove use of event.TypeMux for pending logs (#20312) 2024-08-03 10:03:22 +08:00
evm.go core, docs: add solidity document, close XFN-68 (#1670) 2025-11-14 16:25:42 +05:30
gaspool.go miner: avoid unnecessary work (#15883) 2018-01-15 12:57:06 +02:00
gen_genesis.go all: format golang files (#1548) 2025-09-21 19:41:54 +08:00
genesis.go core :use batch to write chain config (#1760) 2025-11-14 19:59:10 +05:30
genesis_alloc_devnet.go all: format golang files (#1548) 2025-09-21 19:41:54 +08:00
genesis_alloc_mainnet.go core: tidy up genesis alloc 2025-02-19 14:15:09 +08:00
genesis_alloc_testnet.go core: tidy up genesis alloc 2025-02-19 14:15:09 +08:00
genesis_test.go core, light, params: clean genesis hash 2025-03-05 14:30:39 +08:00
headerchain.go all: simplify timestamps to uint64 #19372 (#1318) 2025-08-08 10:33:37 +08:00
mkalloc.go core: use slices package for sorting #27489 #27909 (#1701) 2025-12-07 15:43:24 +05:30
sender_cacher.go all: refactor txpool into it's own package in prep for 4844 (#26038) 2024-11-01 11:36:53 +08:00
state_prefetcher.go core/types: remove message #25977 (#1322) 2025-09-09 11:23:47 +08:00
state_processor.go all: use WaigGroup.Go() to simplify code (#1699) 2025-11-29 17:17:08 +05:30
state_processor_test.go all: refactor so NewBlock, WithBody take types.Body #29482 (#1605) 2025-10-08 13:12:35 +08:00
state_transition.go internal/ethapi: eth_simulateV1 #27720 (#1606) 2025-11-08 16:09:18 +05:30
token_validator.go all: rework trc21 (#1777) 2025-11-18 11:24:56 +05:30
types.go core: use atomic type #27011 2025-04-28 16:57:56 +08:00