-
Notifications
You must be signed in to change notification settings - Fork 603
all: sync with go-ethereum v1.17.2 (upstream merge 4/6) #2328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Open
Changes from 86 commits
Commits
Show all changes
87 commits
Select commit
Hold shift + click to select a range
db7d3a4
version: begin v1.17.2 release cycle
fjl 856e4d5
go.mod: bump go.opentelemetry.io/otel/sdk from 1.39.0 to 1.40.0 (#33946)
jrhea 773f71b
miner: enable trie prefetcher in block builder (#33945)
jrhea 4f75049
miner: avoid unnecessary work after payload resolution (#33943)
jrhea fe3a74e
core/vm: use amsterdam jump table in lookup (#33947)
BZO95 6d99759
cmd, core, eth, tests: prevent state flushing in RPC (#33931)
rjl493456442 814edc5
core/vm: Switch to branchless normalization and extend EXCHANGE (#33869)
jrhea dd202d4
core, ethdb, triedb: add batch close (#33708)
rjl493456442 6d0dd08
core: implement eip-7778: block gas accounting without refunds (#33593)
MariusVanDerWijden 28dad94
cmd/geth: set default cache to 4096 (#33836)
jrhea 402c71f
internal/telemetry: fix undersized span queue causing dropped spans (…
jrhea fc8c104
internal/ethapi: add MaxUsedGas field to eth_simulateV1 response (#32…
Rhovian ce64ab4
internal/ethapi: fix gas cap for eth_simulateV1 (#33952)
s1na 344ce84
eth/fetcher: fix flaky test by improving event unsubscription (#33950)
healthykim a0fb810
trie/bintrie: fix overflow management in slot key computation (#33951)
gballet 3f18715
trie/bintrie: cache hashes of clean nodes so as not to rehash the who…
gballet ecee64e
core: fix TestProcessVerkle flaky test (#33971)
gballet 0d043d0
signer/core: prevent nil pointer panics in keystore operations (#33829)
marukai67 e15d4cc
core/types: reduce alloc in hot code path (#33523)
cuiweixie 00540f9
go.mod: update go-eth-kzg (#33963)
MariusVanDerWijden b08aac1
eth/catalyst: allow getPayloadV2 for pre-shanghai payloads (#33932)
Muzry b8a3fa7
cmd/utils, eth/ethconfig: change default cache settings (#33975)
rjl493456442 91cec92
core, miner, tests: introduce codedb and simplify cachingDB (#33816)
rjl493456442 aa417b0
core/tracing: fix nonce revert edge case (#33978)
s1na 27c4ca9
eth: resolve finalized from disk if it's not recently announced (#33150)
rjl493456442 f6068e3
eth/tracers: fix accessList StorageKeys return null (#33976)
georgehao 32f05d6
core: end telemetry span for ApplyTransactionWithEVM if error is retu…
jwasinger 88f8549
cmd/geth: correct misleading flag description in removedb command (#3…
aso20455 3c20e08
cmd/geth: add Prague pruning points (#33657)
s1na 59512b1
cmd/fetchpayload: add payload-building utility (#33919)
gballet 7d13acd
core/rawdb, triedb/pathdb: enable trienode history alongside existing…
rjl493456442 de0a452
eth/filters: fix race in pending tx and new heads subscriptions (#33990)
Copilot 95b9a2e
core: Implement eip-7954 increase Maximum Contract Size (#33832)
0xjvn 1c9ddee
trie/bintrie: use a sync.Pool when hashing binary tree nodes (#33989)
gballet eaa9418
core/rawdb: enforce exact key length for num->hash and td in db inspe…
legm0310 dba741f
console: fix autocomplete digit range to include 0 (#34003)
adblesss 189f9d0
eth/filters: check history pruning cutoff in GetFilterLogs (#33823)
vickkkkkyy ede376a
internal/ethapi: encode slotNumber as hex in RPCMarshalHeader (#34005)
jwasinger 24025c2
build: fix signify flag name in doWindowsInstaller (#34006)
vickkkkkyy 77e7e5a
go.mod, go.sum: update karalabe/hid to fix broken FreeBSD ports build…
gballet a7d09cc
core: fix code database initialization in stateless mode (#34011)
rjl493456442 98b13f3
miner: add OpenTelemetry spans for block building path (#33773)
jrhea 4b915af
core/state: avoid Bytes() allocation in flatReader hash computations …
CPerezz 519a450
core/state: skip redundant trie Commit for Verkle in stateObject.comm…
CPerezz fc1b0c0
internal/ethapi: warn on reaching global gas cap for eth_simulateV1 (…
s1na 9b2ce12
triedb/pathdb: enhance history index initer (#33640)
rjl493456442 ab35715
cmd/evm: don't strip prefixes on requests over t8n (#33997)
fselmo b6115e9
core: fix txLookupLock mutex leak on error returns in reorg() (#34039)
6138a11
trie/bintrie: parallelize InternalNode.Hash at shallow tree depths (#…
CPerezz 6ae3f9f
core/history: refactor pruning configuration (#34036)
s1na b35645b
build: fix missing '!' in shebang of generated oss-fuzz scripts (#34044)
haoyu-haoyu 3341d8a
eth/filters: rangeLogs should error on invalid block range (#33763)
vickkkkkyy 4faadf1
rlp: add AppendList method to RawList (#34048)
healthykim a3083ff
cmd: add support for enumerating a single storage trie (#34051)
rjl493456442 fd85963
core/vm: rework gas measurement for call variants (#33648)
jwasinger 35b9109
rlp: add Size method to EncoderBuffer (#34052)
fjl 59ce2cb
p2p: track in-progress inbound node IDs (#33198)
0xjvn 77779d1
core/state: bypass per-account updateTrie in IntermediateRoot for bin…
CPerezz 305cd7b
trie/bintrie: fix NodeIterator Empty node handling and expose tree ac…
gballet e23b0cb
core/rawdb: fix key length check for num -- hash in db inspect (#34074)
adblesss a61e5cc
core, internal/ethapi: fix incorrect max-initcode RPC error mapping (…
gzliudan b87340a
core, core/vm: implement EIP-7708 (#33645)
zsfelfoldi 745b0a8
cmd/utils: guard SampleRatio flag with IsSet check (#34062)
vickkkkkyy e951bcb
cmd/devp2p: fix discv5 PingMultiIP test session key mismatch (#34031)
cskiraly 8f9061f
cmd/utils: optimize history import with batched insertion (#33894)
Savid 5d0e18f
core/tracing: fix NonceChangeAuthorization comment (#34085)
aso20455 8a3a309
core/txpool/legacypool: remove redundant nil check in Get (#34092)
adblesss 1b3b028
miner: fix txFitsSize comment (#34100)
gzliudan acdd139
miner: set slot number when building test payload (#34094)
jwasinger c3467dd
core, miner, trie: relocate witness stats (#34106)
rjl493456442 a249685
p2p/discover: resolve DNS hostnames for bootstrap nodes (#34101)
cgdusek bd3c843
build, cmd/keeper: add "womir" target (#34079)
gballet d1369b6
core/txpool/legacypool: use types.Sender instead of signer.Sender (#3…
gzliudan e585ad3
core/rawdb: fix freezer dir.Sync() failure on Windows (#34115)
cgdusek ceabc39
internal/ethapi: limit number of calls to eth_simulateV1 (#34616)
s1na 95705e8
internal/ethapi: limit number of getProofs keys (#34617)
s1na be4dc0c
version: release go-ethereum v1.17.2 stable (#34618)
rjl493456442 09c7848
merge geth 00540f946 (v1.17.4 sync, batch 1/4 of v1.17.2)
pratikspatil024 0a83ed5
merge geth 77e7e5ad1 (v1.17.4 sync, batch 2/4 of v1.17.2)
pratikspatil024 1abb57b
merge geth e23b0cbc2 (v1.17.4 sync, batch 3/4 of v1.17.2)
pratikspatil024 682b4c3
merge geth be4dc0c4b (v1.17.4 sync, batch 4/4 of v1.17.2)
pratikspatil024 2bc495f
docs: v1.17.2 go-ethereum sync milestone chores (ledger, fork-registe…
pratikspatil024 d06fab0
Merge ppatil-upstream-v1.17.1 into ppatil-upstream-v1.17.2 (develop d…
pratikspatil024 35717ba
Merge ppatil-upstream-v1.17.1 into ppatil-upstream-v1.17.2
pratikspatil024 b055473
Merge ppatil-upstream-v1.17.1 into ppatil-upstream-v1.17.2
pratikspatil024 184ef43
Merge branch 'ppatil-upstream-v1.17.1' into ppatil-upstream-v1.17.2 (…
pratikspatil024 415c6b6
Merge branch 'ppatil-upstream-v1.17.1' into ppatil-upstream-v1.17.2 (…
pratikspatil024 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,177 @@ | ||
| // Copyright 2026 The go-ethereum Authors | ||
| // This file is part of go-ethereum. | ||
| // | ||
| // go-ethereum is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
| // | ||
| // go-ethereum is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU General Public License | ||
| // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| // fetchpayload queries an Ethereum node over RPC, fetches a block and its | ||
| // execution witness, and writes the combined Payload (ChainID + Block + | ||
| // Witness) to disk in the format consumed by cmd/keeper. | ||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "flag" | ||
| "fmt" | ||
| "math/big" | ||
| "os" | ||
| "path/filepath" | ||
| "strings" | ||
| "time" | ||
|
|
||
| "github.com/ethereum/go-ethereum/common/hexutil" | ||
| "github.com/ethereum/go-ethereum/core/stateless" | ||
| "github.com/ethereum/go-ethereum/core/types" | ||
| "github.com/ethereum/go-ethereum/ethclient" | ||
| "github.com/ethereum/go-ethereum/rlp" | ||
| "github.com/ethereum/go-ethereum/rpc" | ||
| ) | ||
|
|
||
| // Payload is duplicated from cmd/keeper/main.go (package main, not importable). | ||
| type Payload struct { | ||
| ChainID uint64 | ||
| Block *types.Block | ||
| Witness *stateless.Witness | ||
| } | ||
|
|
||
| func main() { | ||
| var ( | ||
| rpcURL = flag.String("rpc", "http://localhost:8545", "RPC endpoint URL") | ||
| blockArg = flag.String("block", "latest", `Block number: decimal, 0x-hex, or "latest"`) | ||
| format = flag.String("format", "rlp", "Comma-separated output formats: rlp, hex, json") | ||
| outDir = flag.String("out", "", "Output directory (default: current directory)") | ||
| ) | ||
| flag.Parse() | ||
|
|
||
| ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) | ||
| defer cancel() | ||
|
|
||
| // Parse block number (nil means "latest" in ethclient). | ||
| blockNum, err := parseBlockNumber(*blockArg) | ||
| if err != nil { | ||
| fatal("invalid block number %q: %v", *blockArg, err) | ||
| } | ||
|
|
||
| // Connect to the node. | ||
| client, err := ethclient.DialContext(ctx, *rpcURL) | ||
| if err != nil { | ||
| fatal("failed to connect to %s: %v", *rpcURL, err) | ||
| } | ||
| defer client.Close() | ||
|
|
||
| chainID, err := client.ChainID(ctx) | ||
| if err != nil { | ||
| fatal("failed to get chain ID: %v", err) | ||
| } | ||
|
|
||
| // Fetch the block first so we have a concrete number for the witness call, | ||
| // avoiding a race where "latest" advances between the two RPCs. | ||
| block, err := client.BlockByNumber(ctx, blockNum) | ||
| if err != nil { | ||
| fatal("failed to fetch block: %v", err) | ||
| } | ||
| fmt.Printf("Fetched block %d (%#x)\n", block.NumberU64(), block.Hash()) | ||
|
|
||
| // Fetch the execution witness via the debug namespace. | ||
| var extWitness stateless.ExtWitness | ||
| err = client.Client().CallContext(ctx, &extWitness, "debug_executionWitness", rpc.BlockNumber(block.NumberU64())) | ||
| if err != nil { | ||
| fatal("failed to fetch execution witness: %v", err) | ||
| } | ||
|
|
||
| witness := new(stateless.Witness) | ||
| err = witness.FromExtWitness(&extWitness) | ||
| if err != nil { | ||
| fatal("failed to convert witness: %v", err) | ||
| } | ||
|
|
||
| payload := Payload{ | ||
| ChainID: chainID.Uint64(), | ||
| Block: block, | ||
| Witness: witness, | ||
| } | ||
|
|
||
| // Encode payload as RLP (shared by "rlp" and "hex" formats). | ||
| rlpBytes, err := rlp.EncodeToBytes(payload) | ||
| if err != nil { | ||
| fatal("failed to RLP-encode payload: %v", err) | ||
| } | ||
|
|
||
| // Write one output file per requested format. | ||
| blockHex := fmt.Sprintf("%x", block.NumberU64()) | ||
| for f := range strings.SplitSeq(*format, ",") { | ||
| f = strings.TrimSpace(f) | ||
| outPath := filepath.Join(*outDir, fmt.Sprintf("%s_payload.%s", blockHex, f)) | ||
|
|
||
| var data []byte | ||
| switch f { | ||
| case "rlp": | ||
| data = rlpBytes | ||
| case "hex": | ||
| data = []byte(hexutil.Encode(rlpBytes)) | ||
| case "json": | ||
| data, err = marshalJSONPayload(chainID, block, &extWitness) | ||
| if err != nil { | ||
| fatal("failed to JSON-encode payload: %v", err) | ||
| } | ||
| default: | ||
| fatal("unknown format %q (valid: rlp, hex, json)", f) | ||
| } | ||
|
|
||
| if err := os.WriteFile(outPath, data, 0644); err != nil { | ||
| fatal("failed to write %s: %v", outPath, err) | ||
| } | ||
| fmt.Printf("Wrote %s (%d bytes)\n", outPath, len(data)) | ||
| } | ||
| } | ||
|
|
||
| // parseBlockNumber converts a CLI string to *big.Int. | ||
| // Returns nil for "latest" (ethclient convention for the head block). | ||
| func parseBlockNumber(s string) (*big.Int, error) { | ||
| if strings.EqualFold(s, "latest") { | ||
| return nil, nil | ||
| } | ||
| n := new(big.Int) | ||
| if strings.HasPrefix(s, "0x") || strings.HasPrefix(s, "0X") { | ||
| if _, ok := n.SetString(s[2:], 16); !ok { | ||
| return nil, fmt.Errorf("invalid hex number") | ||
| } | ||
| return n, nil | ||
| } | ||
| if _, ok := n.SetString(s, 10); !ok { | ||
| return nil, fmt.Errorf("invalid decimal number") | ||
| } | ||
| return n, nil | ||
| } | ||
|
|
||
| // jsonPayload is a JSON-friendly representation of Payload. It uses ExtWitness | ||
| // instead of the internal Witness (which has no JSON marshaling). | ||
| type jsonPayload struct { | ||
| ChainID uint64 `json:"chainId"` | ||
| Block *types.Block `json:"block"` | ||
| Witness *stateless.ExtWitness `json:"witness"` | ||
| } | ||
|
|
||
| func marshalJSONPayload(chainID *big.Int, block *types.Block, ext *stateless.ExtWitness) ([]byte, error) { | ||
| return json.MarshalIndent(jsonPayload{ | ||
| ChainID: chainID.Uint64(), | ||
| Block: block, | ||
| Witness: ext, | ||
| }, "", " ") | ||
| } | ||
|
|
||
| func fatal(format string, args ...any) { | ||
| fmt.Fprintf(os.Stderr, format+"\n", args...) | ||
| os.Exit(1) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impact: The tool advertises writing a payload "in the format consumed by cmd/keeper", but rlp.EncodeToBytes(payload) dispatches to Witness.EncodeRLP, which emits the 3-field BorWitness form (context, headers, state) and never writes w.Codes. cmd/keeper decodes that same Payload with rlp.DecodeBytes; DecodeRLP's BorWitness branch sets w.Codes to an empty map, then hands the witness to core.ExecuteStateless. If stateless execution needs contract bytecode from Codes, keeper fails (exit 10) or produces a wrong root; the failure appears at consumption time, far from this tool. The json output is unaffected because it serializes ExtWitness with Codes populated, so the three formats produced by the same invocation carry different data.
A debugging/fixture tool that silently produces content-incomplete payload files wastes triage time: the rlp and hex artifacts differ from the json artifact for the same block, and the loss is only observable when keeper executes them. Either the tool should serialize an encoding that preserves codes, or the omission should be documented so users know rlp/hex payloads are not self-contained.
Evidence:
Changed code:
core/stateless/encoding.go↗ (Payload embeds *stateless.Witness, so rlp.EncodeToBytes dispatches to this custom encoder, which serializes only w.State and never w.Codes.):core/stateless/encoding.go↗ (Confirms the round trip is lossy: a consumer re-decoding the .rlp/.hex file gets Codes == empty map, not the codes returned by debug_executionWitness.):cmd/keeper/main.go↗ (The named consumer decodes this exact RLP Payload and feeds the (Codes-empty) witness straight into ExecuteStateless.):cmd/fetchpayload/main.go↗ (The json format serializes ExtWitness (which has a Codes field populated from the RPC response), so the three advertised formats are not equivalent in content.):Suggested fix: Confirm whether core.ExecuteStateless requires Witness.Codes for this Bor witness format. If it does, serialize a codes-preserving encoding for the rlp/hex outputs (e.g. encode the ExtWitness form, which DecodeRLP already accepts via its 5-field fallback) so the file round-trips. If codes are genuinely redundant because State already contains them, reconcile the contradictory BorWitness/EncodeRLP doc comments and note in the fetchpayload package doc that rlp/hex payloads omit the separate Codes list.
Suggested test: Round-trip test in cmd/fetchpayload: build a Payload whose Witness has a non-empty Codes set, run rlp.EncodeToBytes then rlp.DecodeBytes into a fresh Payload, and assert on Codes — either that it survives (after the fix) or, if the loss is intentional, assert it is empty and document the invariant so the asymmetry with the json output is pinned by a test.