Commit graph

13456 commits

Author SHA1 Message Date
Daniel Liu
4f738d2191
eth/tracers: clean-up tracer collection #24320 (#1274) 2025-09-08 17:47:33 +08:00
Daniel Liu
0c293e5c34
eth/tracers: native prestate tracer #24268 (#1273) 2025-09-08 17:45:28 +08:00
Daniel Liu
060642e619
eth/tracers/js: add support for REVERT/SELFDESTRUCT in evmdis_tracer #24016 (#1271)
* eth/tracers: Add support for REVERT in evmdis_tracer

* evm/tracers: Fix evmdis_tracer to use SELFDESTRUCT instead of SUICIDE

* eth/tracers: Regenerate tracer library

Co-authored-by: Alex Beregszaszi <alex@rtfs.hu>
2025-09-08 17:28:59 +08:00
Daniel Liu
5d64f3b32f
eth/tracers: avoid using blockCtx concurrently #24286 (#1272) 2025-09-08 17:28:18 +08:00
Daniel Liu
95d06d0f15
eth/tracers: capture fault states in logger #23970 (#1270) 2025-09-08 17:27:13 +08:00
Daniel Liu
58184f0212
ethstats: fix full node interface post 1559 #23159 (#1451) 2025-09-08 15:41:16 +08:00
Daniel Liu
84e19a7b7f
ethstats: set readlimit on ethstats server connection #26207 (#1450)
This prevents DoS when connected to a malicious ethstats server.

Co-authored-by: Martin Holst Swende <martin@swende.se>
2025-09-08 15:40:41 +08:00
Daniel Liu
1bd4eaab88
ethstats: fix function comments #25726 (#1449) 2025-09-08 15:40:07 +08:00
Daniel Liu
bf6011fc06
ethstats: fix typo in comment #22952 (#1447)
Trivial but helpful to understanding.

Co-authored-by: Mike Burr <mburr@nightmare.com>
2025-09-08 15:39:30 +08:00
Daniel Liu
c1e02cb232
ethstats: fix URL parser for '@' or ':' in node name/password #21640 (#1446)
Fixes the case (example below) where the value passed
to --ethstats flag would be parsed wrongly because the
node name and/or password value contained the special
characters '@' or ':'

    --ethstats "ETC Labs Metrics @meowsbits":mypass@ws://mordor.dash.fault.dev:3000

Co-authored-by: meowsbits <b5c6@protonmail.com>
2025-09-08 15:38:54 +08:00
Daniel Liu
24a1f37892
ethstats: avoid creating subscriptions on background goroutine #22587 (#1445) 2025-09-08 15:38:18 +08:00
Daniel Liu
3d59a3930f
ethstats: use timer instead of time.Sleep #20924 #21404 (#1442)
* ethstats: use timer instead of time.Sleep #20924

* ethstats: avoid concurrent write on websocket, fixes #21403 #21404
2025-09-08 15:37:36 +08:00
Daniel Liu
343cd1021a
accounts/abi: precompile regex #32301 (#1427)
Co-authored-by: cui <cuiweixie@gmail.com>
2025-09-08 15:36:33 +08:00
Daniel Liu
4fd1e0b04d
accounts/abi/abigen: fix a flaky bind test case NewSingleStructArgument #31501 (#1418)
Co-authored-by: Delweng <delweng@gmail.com>
2025-09-08 15:34:39 +08:00
Daniel Liu
8e8a04d9ce
accounts/abi: include access-list in gas estimation #31394 (#1417)
Simple bugfix to include the access-list in the gas-estimation step of
the ABI bindings code.

Co-authored-by: protolambda <proto@protolambda.com>
2025-09-08 15:33:31 +08:00
wit765
81f84b79ce
ethclient/gethclient: remove unused function GetProof (#1448)
Co-authored-by: Wit Liu <wit765765346@gmail>
2025-09-08 14:39:41 +08:00
Daniel Liu
0a1bcdcbff
ethstats: avoid blocking chan when received invalid stats request #21073 (#1441)
* ethstats: avoid blocking chan when received invalid stats request

* ethstats: minor code polishes

Co-authored-by: Hao Duan <duanhao0814@gmail.com>
Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2025-09-06 17:18:22 +08:00
Daniel Liu
65c7f4418f
ethstats: stop report ticker in each loop cycle #21071 (#1440)
Co-authored-by: Hao Duan <duanhao0814@gmail.com>
2025-09-06 17:17:40 +08:00
Daniel Liu
3032fb1fca
ethstats: fix comment typo #17102 (#1439) 2025-09-06 17:17:03 +08:00
Daniel Liu
04f6f697c9
ethstats: fix golint warning #16837 (#1438) 2025-09-06 17:16:29 +08:00
Daniel Liu
f852b21b44
ethstats: add missing Ticker.Stop call #20867 (#1437) 2025-09-06 17:15:52 +08:00
Daniel Liu
c7f17cb300
crypto/bn256: refactor to use bitutil.TestBytes #32435 (#1436)
Co-authored-by: cui <cuiweixie@gmail.com>
2025-09-06 17:15:07 +08:00
Daniel Liu
57612d9826
crypto/secp256k1: use ReadBits from common/math #32430 (#1435)
Co-authored-by: cui <cuiweixie@gmail.com>
2025-09-06 17:14:33 +08:00
Daniel Liu
d2859ecb9c
common, common/hexutil: use reflect.TypeFor #32321 (#1434)
Co-authored-by: cui <cuiweixie@gmail.com>
2025-09-06 17:13:56 +08:00
Daniel Liu
1b09e585ab
common/hexutil: replace customized bit sizer with bit.Uintsize #32304 (#1433) 2025-09-06 17:13:17 +08:00
Daniel Liu
06b2524fb2
all: use fmt.Appendf instead of fmt.Sprintf where possible #31301 (#1432) 2025-09-06 17:12:19 +08:00
Daniel Liu
a85b4ee518
accounts/abi: fix panic when check event with log has empty or nil topics #32503 (#1431)
When the log has empty or nil topics, the generated bindings code will
panic when accessing `log.Topics[0]`, add a check to avoid it.

Co-authored-by: nthumann <nthumanna@gmail.com>
2025-09-06 17:04:33 +08:00
Daniel Liu
b0996a2829
accounts/usbwallet: correct version comparison logic #32417 (#1430)
This PR fixes a bug in the Ledger hardware wallet version validation
logic for EIP-155 transaction signing. The original condition
incorrectly allowed older versions that don't support EIP-155 such as
0.9.9 and 0.1.5 to proceed.

Co-authored-by: Rizky Ikwan <rizzikwann@gmail.com>
2025-09-06 17:03:55 +08:00
Daniel Liu
8c4863a567
accounts/scwallet: fixes nil pointer dereference in scwallet #32186 (#1429)
Fixes #32181

Signed-off-by: kapil <kapilsareen584@gmail.com>
Co-authored-by: Kapil Sareen <kapilsareen584@gmail.com>
2025-09-06 17:03:04 +08:00
Daniel Liu
9b189e1ea3
accounts/abi, accounts/keystore: use reflect.TypeFor #32323 (#1428)
Co-authored-by: cui <cuiweixie@gmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-09-06 17:01:22 +08:00
Daniel Liu
61fcd420b3
accounts/keystore: update links to documenation #32194 (#1425) 2025-09-03 15:50:18 +08:00
Daniel Liu
aec5f28dab
accounts: fix data race when closing manager #31982 (#1423)
Fixes a data race on the `wallets` slice when closing account Manager.

At the moment, there is a data race between a go-routine calling the
Manager's `Close` function and the background go-routine handling most
operations on the `Manager`. The `Manager`'s `wallets` field is accessed
without proper synchronization.

By moving the closing of wallets from the `Close()` function into the
background thread, this issue can be resolved.

Co-authored-by: Herbert <herbert.jordan.jun@gmail.com>
2025-09-03 15:49:24 +08:00
Daniel Liu
b6f28effa9
accounts/abi: error when packing negative values in unsigned types #31790 (#1422)
This is an alternative approach to
https://github.com/ethereum/go-ethereum/pull/31607 , that doesn't break
backwards-compatibility with abigen.

Note that this does change the behavior of `Argument.Pack`: previously,
packing negative values for a `uint` parameter would cause them to be
represented in signed binary representation via two's complement. Now,
it will fail explicitly in this case.

However, I don't see a reason to support this functionality. The ABI
already explicitly supports signed integers. There's no reason that a
smart contract author would choose to store signed values in a `uint`
afaict.

---------

Co-authored-by: jwasinger <j-wasinger@hotmail.com>
Co-authored-by: MariusVanDerWijden <m.vanderwijden@live.de>
2025-09-03 15:48:44 +08:00
Daniel Liu
4e3bd78545
accounts/usbwallet: full 32bit chainId support for Trezor #17439 (#1419)
This fix allows Trezor to support full 32bit chainId in geth, with the
next version of firmware.

For `chainId > 2147483630` case, Trezor returns signature bit only.
- Trezor returns only signature parity for `chainId > 2147483630` case.
- for `chainId == 2147483630` case, Trezor returns `MAX_UINT32` or `0`,
but it doesn't matter.
  (`2147483630 * 2 + 35` = `4294967295`(`MAX_UINT32`))

chainId | returned signature_v | compatible issue
---------|------------------------|--------------------
0 < chainId <= 255 | chainId * 2 + 35 + v | no issue (firmware `1.6.2`
for Trezor one)
255 < chainId <= 2147483630 | chainId * 2 + 35 + v | ***fixed.***
*firmware `1.6.3`*
chainId > 2147483630 | v | *firmware `1.6.3`*

Please see also: full 32bit chainId support for Trezor
- Trezor one: https://github.com/trezor/trezor-mcu/pull/399 ***merged***
- Trezor model T: https://github.com/trezor/trezor-core/pull/311
***merged***

---------

Signed-off-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
Co-authored-by: HackyMiner <hackyminer@gmail.com>
Co-authored-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
2025-09-03 15:48:01 +08:00
Daniel Liu
05a9e91898
cmd/abigen, accounts/abi/bind: implement abigen version 2 #31379 (#1416)
This PR implements a new version of the abigen utility (v2) which exists
along with the pre-existing v1 version.

Abigen is a utility command provided by go-ethereum that, given a
solidity contract ABI definition, will generate Go code to transact/call
the contract methods, converting the method parameters/results and
structures defined in the contract into corresponding Go types. This is
useful for preventing the need to write custom boilerplate code for
contract interactions.

Methods in the generated bindings perform encoding between Go types and
Solidity ABI-encoded packed bytecode, as well as some action (e.g.
`eth_call` or creating and submitting a transaction). This limits the
flexibility of how the generated bindings can be used, and prevents
easily adding new functionality, as it will make the generated bindings
larger for each feature added.

Abigen v2 was conceived of by the observation that the only
functionality that generated Go bindings ought to perform is conversion
between Go types and ABI-encoded packed data. Go-ethereum already
provides various APIs which in conjunction with conversion methods
generated in v2 bindings can cover all functionality currently provided
by v1, and facilitate all other previously-desired use-cases.

To generate contract bindings using abigen v2, invoke the `abigen`
command with the `--v2` flag. The functionality of all other flags is
preserved between the v2 and v1 versions.

The execution of `abigen --v2` generates Go code containing methods
which convert between Go types and corresponding ABI-encoded data
expected by the contract. For each input-accepting contract method and
the constructor, a "packing" method is generated in the binding which
converts from Go types to the corresponding packed solidity expected by
the contract. If a method returns output, an "unpacking" method is
generated to convert this output from ABI-encoded data to the
corresponding Go types.

For contracts which emit events, an unpacking method is defined for each
event to unpack the corresponding raw log to the Go type that it
represents.

Likewise, where custom errors are defined by contracts, an unpack method
is generated to unpack raw error data into a Go type.

For a smooth user-experience, abigen v2 comes with a number of utility
functions to be used in conjunction with the generated bindings for
performing common contract interaction use-cases. These include:

* filtering for historical logs of a given topic
* watching the chain for emission of logs with a given topic
* contract deployment methods
* Call/Transact methods

https://geth.ethereum.org will be updated to include a new tutorial page
for abigen v2 with full code examples. The page currently exists in a
PR: https://github.com/ethereum/go-ethereum/pull/31390 .

There are also extensive examples of interactions with contract bindings
in [test
cases](cc855c7ede/accounts/abi/bind/v2/lib_test.go)
provided with this PR.

---------

Co-authored-by: jwasinger <j-wasinger@hotmail.com>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-09-03 15:47:12 +08:00
Daniel Liu
ca8d39b862
accounts/abi: improve unpack performance #31387 (#1415)
Slightly improves performance of abi.Unpack

```
Before
BenchmarkUnpack/0-14   5965714       210.9 ns/op     280 B/op       5 allocs/op
BenchmarkUnpack/1-14   2148283       569.7 ns/op     688 B/op      16 allocs/op

After:
BenchmarkUnpack/0-14  	 7693365	       151.2 ns/op	     136 B/op	       4 allocs/op
BenchmarkUnpack/1-14  	 2261294	       508.9 ns/op	     544 B/op	      15 allocs/op
```

replaces https://github.com/ethereum/go-ethereum/pull/31292 since I was
unable to push to your branch @Exca-DK

---------

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Co-authored-by: Exca-DK <dawidk.info@gmail.com>
2025-09-03 15:46:23 +08:00
Daniel Liu
47d17e1b97
accounts/usbwallet: fix ledger access for latest firmware and add Ledger Flex #31004 (#1414)
The latest firmware for Ledger Nano S Plus now returns `0x5000` for it's
product ID, which doesn't match any of the product IDs enumerated in
`hub.go`.

This PR removes the assumption about the interfaces exposed, and simply
checks the upper byte for a match.

Also adds support for the `0x0007` / `0x7000` product ID (Ledger Flex).

Co-authored-by: Michael de Hoog <michael.dehoog@coinbase.com>
2025-09-03 15:45:34 +08:00
Daniel Liu
2def2b955b
accounts: fix typo (#1413) 2025-09-03 15:44:49 +08:00
Daniel Liu
ce26c34c7b
rpc: refactor read limit test #32494 (#1412)
closes #32240 #32232

The main cause for the time out is the slow json encoding of large data.
In #32240 they tried to resolve the issue by reducing the size of the
test. However as Felix pointed out, the test is still kind of confusing.

I've refactored the test so it is more understandable and have reduced
the amount of data needed to be json encoded. I think it is still
important to ensure that the default read limit is not active, so I have
retained one large (~32 MB) test case, but it's at least smaller than
the existing ~64 MB test case.

Co-authored-by: lightclient <14004106+lightclient@users.noreply.github.com>
2025-09-03 15:44:04 +08:00
Daniel Liu
a6762110b5
rpc: add SetWebsocketReadLimit in Server #32279 (#1411)
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: Yiming Zang <50607998+yzang2019@users.noreply.github.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-09-03 15:43:14 +08:00
Daniel Liu
33b40aef2c
rpc: use reflect.TypeFor #32316 (#1410)
Co-authored-by: cui <cuiweixie@gmail.com>
2025-09-03 15:42:31 +08:00
Daniel Liu
2d36f159c7
all: update dead wiki links #32215 (#1409)
---

**Description:**
- Replaced outdated GitHub wiki links with current, official
documentation URLs.
- Removed links that redirect or are no longer relevant.
- Ensured all references point to up-to-date and reliable sources.

---

Co-authored-by: Maxim Evtush <154841002+maximevtush@users.noreply.github.com>
2025-09-03 15:41:48 +08:00
Daniel Liu
e711a77747
internal: remove eth_{compile,getWork,submitWork} from console #31856 (#1408) 2025-09-03 15:41:09 +08:00
Daniel Liu
eb770486f2
internal: remove unused shh and swarm modules from console #32073 (#1407)
Similar to https://github.com/ethereum/go-ethereum/pull/31856, remove
the not availabe shh, swarm modules in the console.

---------

Co-authored-by: Zhou <DanialZhouMAX@gmail.com>
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2025-09-03 15:40:28 +08:00
Daniel Liu
5081beee0e
rpc: add method name length limit #31711 (#1406)
This change adds a limit for RPC method names to prevent potential abuse
where large method names could lead to large response sizes.

The limit is enforced in:
- handleCall for regular RPC method calls
- handleSubscribe for subscription method calls

Added tests in websocket_test.go to verify the length limit
functionality for both regular method calls and subscriptions.

---------

Co-authored-by: Matus Kysel <MatusKysel@users.noreply.github.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-09-03 15:39:40 +08:00
Daniel Liu
cfd81dd8c4
rlp: refactor to use maths.ReadBits #32432 (#1405)
Co-authored-by: cui <cuiweixie@gmail.com>
2025-09-03 15:38:55 +08:00
Daniel Liu
152609e7d0
rlp: remove workaround for Value.Bytes #32433 (#1404)
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.

Co-authored-by: Felix Lange <fjl@twurst.com>
2025-09-03 15:37:59 +08:00
Daniel Liu
ed1570c2d1
rlp: optimize intsize #32421 (#1403)
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)

Co-authored-by: cui <cuiweixie@gmail.com>
2025-09-03 15:37:14 +08:00
Daniel Liu
e2edc41b50
all: mv loggers to eth/tracers #23892 (#1269) 2025-09-03 15:35:28 +08:00
Daniel Liu
aca2149f12
core, eth, trie: use TryGetAccount to read what TryUpdateAccount has written #25458 (#1106)
* core: use TryGetAccount to read where TryUpdateAccount has been used to write

* Gary's review feedback

* implement Gary's suggestion

* fix bug + rename NewSecure into NewStateTrie

* trie: add backwards-compatibility aliases for SecureTrie

* Update database.go

* make the linter happy

Co-authored-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2025-09-03 15:34:11 +08:00