Commit graph

16238 commits

Author SHA1 Message Date
rjl493456442
bf8f63dcd2
trie, core/state: introduce trie Prefetch for optimizing preload (#32134)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
This pull introduces a `Prefetch` operation in the trie to prefetch trie
nodes in parallel. It is used by the `triePrefetcher` to accelerate state 
loading and improve overall chain processing performance.
2025-08-20 21:45:27 +08:00
rjl493456442
9ce40d19a8
internal/ethapi, miner: fix GetBlockReceipts for pending (#32461)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
2025-08-19 19:20:21 -06:00
maskpp
7d4852b9eb
eth/catalyst: return methods by reflect (#32300)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
Return the exposed methods in `ConsensusAPI` by reflection.
2025-08-19 06:54:19 -06:00
Klimov Sergei
62ac0e05b6
p2p: update MaxPeers comment (#32414) 2025-08-19 20:14:11 +08:00
gohan
1c74f23761
graphql: add query depth limit to prevent DoS attacks (#32344)
## Summary

This PR addresses a DoS vulnerability in the GraphQL service by
implementing a maximum query depth limit. While #26026 introduced
timeout handling, it didn't fully mitigate the attack vector where
deeply nested queries can still consume excessive CPU and memory
resources before the timeout is reached.

## Changes
- Added `maxQueryDepth` constant (set to 20) to limit the maximum
nesting depth of GraphQL queries
- Applied the depth limit using `graphql.MaxDepth()` option when parsing
the schema
- Added test case `TestGraphQLMaxDepth` to verify that queries exceeding
the depth limit are properly rejected

## Security Impact

Without query depth limits, malicious actors could craft deeply nested
queries that:
  - Consume excessive CPU cycles during query parsing and execution
  - Allocate large amounts of memory for nested result structures
- Potentially cause service degradation or outages even with timeout
protection

This fix complements the existing timeout mechanism by preventing
resource-intensive queries from being executed in the first place.

## Testing

Added `TestGraphQLMaxDepth` which verifies that queries with nesting
depth > 20 are rejected with a `MaxDepthExceeded` error.

## References
  - Original issue: #26026
- Related security best practices:
https://www.howtographql.com/advanced/4-security/

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2025-08-19 19:47:47 +08:00
Fibonacci747
dffa1f5104
ethclient/gethclient: use common.Hash to debug_traceTransaction (#32404) 2025-08-19 19:37:36 +08:00
Guillaume Ballet
d99143d7f5
CODEOWNERS: add gballet as the owner of trie package (#32466) 2025-08-19 19:21:16 +08:00
Yiming Zang
d93f820358
rpc: add SetWebsocketReadLimit in Server (#32279)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
Exposing the public method to setReadLimits for Websocket RPC to
prevent OOM.

Current, Geth Server is using a default 32MB max read limit (message
size) for websocket, which is prune to being attacked for OOM. Any one
can easily launch a client to send a bunch of concurrent large request
to cause the node to crash for OOM. One example of such script that can
easily crash a Geth node running websocket server is like this:

ec830979ac/poc.go

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2025-08-19 14:32:59 +08:00
cui
42bf4844d8
core/rawdb: enhance database key construction (#32431) 2025-08-19 14:19:01 +08:00
phrwlk
7cc01375ef
eth/syncer: stop ticker to prevent resource leak (#32443)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
2025-08-19 09:47:48 +08:00
kevaundray
5b2fc67eee
core/rawdb: add non-unix alternative for tablewriter (#32455)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
Continuation of https://github.com/ethereum/go-ethereum/issues/32022

tablewriter assumes unix or windows, which may not be the case for
embedded targets.

For v0.0.5 of tablewriter, it is noted in table.go: "The protocols were
written in pure Go and works on windows and unix systems"

---------

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2025-08-18 20:42:22 +08:00
kevaundray
85077be58e
metrics: add tinygo build flag for CPU time (#32454)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
2025-08-18 14:15:48 +08:00
jwasinger
a9a19c4202
core/vm: fix EIP-7823 modexp input length check (#32363)
Some checks failed
/ Linux Build (push) Has been cancelled
/ Linux Build (arm) (push) Has been cancelled
/ Windows Build (push) Has been cancelled
/ Docker Image (push) Has been cancelled
The order of the checks was wrong which would have allowed a call to
modexp with `baseLen == 0 && modLen == 0` post fusaka.

Also handles an edge case where base/mod/exp length >= 2**64

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2025-08-15 15:58:00 +02:00
Felix Lange
1693a48f8c
rlp: remove workaround for Value.Bytes (#32433)
As of Go 1.19, it is permitted to call Bytes() on a reflect.Value
representing an adressable byte array. So we can remove our workaround,
undoing #22924.

https://go.dev/doc/go1.19#reflectpkgreflect

> The method [Value.Bytes](https://go.dev/pkg/reflect/#Value.Bytes) now
accepts addressable arrays in addition to slices.
2025-08-15 14:08:27 +02:00
Felix Lange
1d29e3ec0e
consensus/misc/eip4844: use blob parameters of current header (#32424)
This changes the implementation to resolve the blob parameters according
to the current header timestamp. This matters for EIP-7918, where we
would previously resolve the UpdateFraction according to the parent
header fork, leading to a confusing situation at the fork transition
block.

---------

Co-authored-by: MariusVanDerWijden <m.vanderwijden@live.de>
2025-08-15 14:07:27 +02:00
cui
88922d2bf5
crypto/bn256: refactor to use bitutil.TestBytes (#32435)
Some checks are pending
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
2025-08-15 15:12:22 +08:00
cui
ccf684f1ba
core/vm: refactor to use bitutil.TestBytes (#32434) 2025-08-15 15:10:44 +08:00
Guillaume Ballet
a002a6c03f
cmd/evm: use PathScheme in blockrunner (#32444)
This is a preparatory change for Verkle/binary trees, since they don't
support the hash-based database scheme. This has no impact on the MPT.
2025-08-15 14:58:24 +08:00
Guillaume Ballet
ea3a71792d
trie, core/state: add the transition tree (verkle transition part 2) (#32366)
This add some of the changes that were missing from #31634. It
introduces the `TransitionTrie`, which is a façade pattern between the
current MPT trie and the overlay tree.

---------

Signed-off-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2025-08-15 14:34:32 +08:00
cui
2dbb580f51
build: remove unused functions (#32393)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
2025-08-14 14:47:43 +02:00
cui
e798e26c69
crypto/secp256k1: use ReadBits from common/math (#32430) 2025-08-14 14:32:45 +02:00
levisyin
25cce4dfe4
build: upgrade -dlgo version to Go 1.25.0 (#32412) 2025-08-14 13:24:47 +02:00
Felix Lange
b00b6fe234
.github: upgrade workflows to Go 1.25 (#32425) 2025-08-14 13:07:20 +02:00
cui
2b38daa48c
p2p: refactor to use time.Now().UnixMilli() in golang std lib (#32402) 2025-08-14 16:28:57 +08:00
Marius van der Wijden
3ff99ae52c
eth/syncer: fix typo (#32427)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
avaibale -> available
2025-08-13 09:12:08 -06:00
Nebojsa Urosevic
51342136fa
eth/tracers: Adds codeHash to prestateTracer's response (#32391)
**Problem:** Including full account code in prestateTracer response
significantly increases response payload size.

**Solution:** Add codeHash field to the response. This will allow
client-side bytecode caching and is a non-breaking change.

**Note:** codeHash for EoAs is excluded to save space.

---------

Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2025-08-13 13:51:38 +02:00
cui
f054befc55
rlp: optimize intsize (#32421)
goos: darwin
goarch: arm64
pkg: github.com/ethereum/go-ethereum/rlp
cpu: Apple M4
        │   old.txt   │               new.txt               │
        │   sec/op    │   sec/op     vs base                │
Intsize   2.175n ± 5%   1.050n ± 4%  -51.76% (p=0.000 n=10)
2025-08-13 12:00:54 +02:00
cui
a4d3fb9805
node: remove unused err var (#32398)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
2025-08-13 15:08:23 +08:00
Klimov Sergei
75fc56f27d
eth: abort requiredBlocks check if peer handler terminated (#32413) 2025-08-13 15:02:50 +08:00
youzichuan
56edd21453
cmd: fix inconsistent function name in comment (#32411)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
fix inconsistent function name in comment

Signed-off-by: youzichuan <youzichuan6@outlook.com>
2025-08-12 11:37:09 -06:00
cui
43b2aac33c
trie: refactor to use slices.Concat (#32401)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
2025-08-12 21:47:18 +08:00
Rizky Ikwan
2e9c9b5e98
consensus: fix ambiguous invalid gas limit error (#32405)
## Description

Correct symmetric tolerance in gas limit validation:
Replace ambiguous "+-=" with standard "+/-" in the error message.
Logic rejects when |header − parent| ≥ limit, so allowed range is |Δ| ≤
limit − 1.

No logic or functionality has been modified.
2025-08-12 06:11:18 -06:00
rjl493456442
cbbf686ecc
trie, core: rework tracer and track origin value of dirty nodes (#32306)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
These changes made in the PR should be highlighted here

The trie tracer is split into two distinct structs: opTracer and prevalueTracer. 
The former is specific to MPT, while the latter is generic and applicable to all
trie implementations.

The original values of dirty nodes are tracked in a NodeSet. This serves
as the foundation for both full archive node implementations and the state live
tracer.
2025-08-11 21:55:38 +08:00
Forostovec
55a471efaf
eth/downloader: skip nil peer in GetHeader (#32369)
The GetHeader function was incorrectly returning an error when
encountering nil peers in the peers list, which contradicted the comment 
"keep retrying if none are yet available". 

Changed the logic to skip nil peers with 'continue' instead of returning
an error, allowing the function to properly iterate through all
available peers and attempt to retrieve the target header from each valid peer.

This ensures the function behaves as intended - trying all available
peers before giving up, rather than failing on the first nil peer encountered.
2025-08-11 21:34:59 +08:00
cui
92106a6b17
accounts/abi, accounts/keystore: use reflect.TypeFor (#32323)
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-08-11 14:24:55 +02:00
sashass1315
2485d096f3
downloader: fix comment (#32382)
The previous comment stated that every 3rd block has a tx and every 5th
has an uncle.
The implementation actually adds one transaction to every second block
and does not add uncles.
Updated the comment to reflect the real behavior to avoid confusion when
reading tests.
2025-08-11 12:48:38 +02:00
cui
6238effeff
miner: remove todo comment (#32389)
see
https://github.com/ethereum/go-ethereum/pull/32372#discussion_r2265885182
2025-08-11 12:05:06 +02:00
cui
40072af04a
core/vm: make types consistent in makeDup (#32378) 2025-08-11 15:00:11 +08:00
MozirDmitriy
18b4ee5972
ethdb/leveldb: check iterator error in Database.DeleteRange (#32384)
Add missing it.Error() check after iteration in Database.DeleteRange to
avoid silently ignoring iterator errors before writing the batch.

Aligns behavior with batch.DeleteRange, which already validates iterator
errors. No other functional changes; existing tests pass (TestLevelDB).
2025-08-11 14:32:27 +08:00
kashitaka
8ba1c791bf
ethclient: fix flaky pending tx test (#32380)
Fixes: https://github.com/ethereum/go-ethereum/issues/32252
2025-08-11 14:29:07 +08:00
Ömer Faruk Irmak
c3ef6c77c2
core/vm: fold EVMInterpreter into EVM (#32352)
Some checks failed
/ Linux Build (push) Has been cancelled
/ Linux Build (arm) (push) Has been cancelled
/ Windows Build (push) Has been cancelled
/ Docker Image (push) Has been cancelled
The separation serves no purpose atm, and the circular dependency that
EVM and EVMInterpreter had was begging for them to be merged.
2025-08-08 00:01:41 +02:00
cui
888b71b3cf
metrics: use atomic.Pointer in runtimeHistogram (#32361)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-08-07 20:03:30 +02:00
radik878
f86870f5da
eth/downloader: fix incomplete code comment (#32354) 2025-08-07 16:31:02 +02:00
cui
4e7bc2bdc8
rlp: use reflect.TypeFor (#32317)
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-08-07 15:58:27 +02:00
cui
bd6797eafa
signer/core/apitypes: simplify reflect []byte creation (#32315)
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-08-07 15:56:25 +02:00
cui
e979438a55
p2p/enode: use atomic.Pointer in LocalNode (#32360) 2025-08-07 15:03:18 +02:00
cui
f9f85d0227
core: use reflect.TypeFor (#32320)
https://github.com/golang/go/issues/60088
2025-08-07 14:53:36 +02:00
cui
2e3971aed1
beacon/merkle: use reflect.TypeFor (#32322) 2025-08-07 14:36:20 +02:00
cui
ec97ac7085
common, common/hexutil: use reflect.TypeFor (#32321) 2025-08-07 14:30:03 +02:00
cui
dfde155541
crypto/kzg4844: use reflect.TypeFor (#32319) 2025-08-07 14:22:11 +02:00