1
0
Fork 0
forked from forks/go-ethereum
Commit graph

15965 commits

Author SHA1 Message Date
Felix Lange
fd4049dc1e
core/rawdb: improve database stats output (#31463)
Instead of reporting all filtermaps stuff in one line, I'm breaking it
down into the three separate kinds of entries here.

```
+-----------------------+-----------------------------+------------+------------+
|       DATABASE        |          CATEGORY           |    SIZE    |   ITEMS    |
+-----------------------+-----------------------------+------------+------------+
| Key-Value store       | Log index filter-map rows   | 59.21 GiB  |  616077345 |
| Key-Value store       | Log index last-block-of-map | 12.35 MiB  |     269755 |
| Key-Value store       | Log index block-lv          | 421.70 MiB |   22109169 |
```

Also added some other changes to make it easier to debug:

- restored bloombits into the inspect output, so we notice if it doesn't
get deleted for some reason
- tracking of unaccounted key examples
2025-03-24 10:07:38 +01:00
jwasinger
b0b2b76509
internal/ethapi: return code 3 from call/estimateGas even if a revert reason was not returned (#31456) 2025-03-23 17:38:26 +01:00
rjl493456442
624a5d8b23
eth/filter: downgrade log level (#31450) 2025-03-21 14:08:51 +01:00
Sina M
8fe09df54f
cmd/geth: add prune history command (#31384)
This adds a new subcommand 'geth prune-history' that removes the pre-merge history
on supported networks. Geth is not fully ready to work in this mode, please do not run
this command on your production node.

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2025-03-21 13:12:56 +01:00
Sina M
1886922264
core: respect history cutoff in txindexer (#31393)
In #31384 we unindex TXes prior to the merge block. However when the
node starts up it will try to re-index those back if the config is to index the
whole chain. This change makes the indexer aware of the history cutoff block,
avoiding reindexing in that segment.

---------

Co-authored-by: Gary Rong <garyrong0905@gmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-03-21 11:29:51 +01:00
Felföldi Zsolt
07cca7ab9f
core/bloombits: remove old bloombits logic and chain indexer (#31081)
This PR is #3 of a 3-part series that implements the new log index
intended to replace core/bloombits.
Based on https://github.com/ethereum/go-ethereum/pull/31079 and
https://github.com/ethereum/go-ethereum/pull/31080
Replaces https://github.com/ethereum/go-ethereum/pull/30370

This part removes the old bloombits package and the chain indexer that
was only used by bloombits. Deletes the old bloombits database.

FilterMaps data structure explanation:
https://gist.github.com/zsfelfoldi/a60795f9da7ae6422f28c7a34e02a07e

Log index generator code overview:
https://gist.github.com/zsfelfoldi/97105dff0b1a4f5ed557924a24b9b9e7

Search pattern matcher code overview:
https://gist.github.com/zsfelfoldi/5981735641c956afb18065e84f8aff34

Note that the possibility of a tree hashing scheme and remote proof
protocol are mentioned in the documents above but they are not exactly
specified yet. These specs are WIP and will be finalized after the local
log indexer/filter code is finalized and merged.

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2025-03-21 10:47:58 +01:00
rjl493456442
7fed9584b5
core/txpool/legacypool: reject gapped tx from delegated account (#31430)
This pull request improves the protection mechanism in the txpool for 
senders with delegation. A sender with either delegation or pending 
delegation is now limited to a maximum of one in-flight executable 
transaction, while gapped transactions will be rejected.

Reason:
If nonce-gapped transaction from delegated/pending-delegated senders
can be acceptable, then it's no-longer possible to send another
"executable" transaction with correct nonce due to the policy of at most
one inflight tx. The gapped transaction will be stuck in the txpool, with no
meaningful way to unlock the sender.

---------

Co-authored-by: lightclient <lightclient@protonmail.com>
2025-03-20 22:05:15 +01:00
Felix Lange
9eb610f0a9
p2p/discover: repeat WHOAREYOU challenge when handshake in progress (#31356)
This fixes the handshake in a scenario where the remote end sends two unknown
packets in a row. When this happens, we would previously respond to both with
a WHOAREYOU challenge, but keep only the latest sent challenge. Transmission is
assumed to be unreliable, so any client that sends two request packets simultaneously
has to be prepared to follow up on whichever request leads to a handshake. With
this fix, we force them to do the handshake that we can actually complete.

Fixes #30581
2025-03-20 17:11:40 +01:00
Felföldi Zsolt
9fc2bbe1ce
core/filtermaps: allow log search while head indexing (#31429)
This PR changes the matcher syncing conditions so that it is possible to
run a search while head indexing is in progress. Previously it was a
requirement to have the head indexed in order to perform matcher sync
before and after a search. This was unnecessarily strict as the purpose
was just to avoid syncing the valid range with the temporary shortened
indexed range applied while updating existing head maps. Now the sync
condition explicitly checks whether the indexer has a temporary indexed
range with some head maps being partially updated.
It also fixes a deadlock that happened when matcher synchronization was
attempted in the event handler called from the `writeFinishedMaps`
periodical callback.
2025-03-20 14:13:58 +01:00
rjl493456442
0a8f41e2cb
eth/tracers: fix test (#31445)
This pull request fixes a broken unit test

```
=== CONT  TestTracingWithOverrides
    api_test.go:1012: result: {"gas":21167,"failed":false,"returnValue":"0x0000000000000000000000000000000000000000000000000000000000000002","structLogs":[{"pc":0,"op":"PUSH1","gas":24978860,"gasCost":3,"depth":1,"stack":[]},{"pc":2,"op":"CALLDATALOAD","gas":24978857,"gasCost":3,"depth":1,"stack":["0x0"]},{"pc":3,"op":"PUSH1","gas":24978854,"gasCost":3,"depth":1,"stack":["0x1"]},{"pc":5,"op":"ADD","gas":24978851,"gasCost":3,"depth":1,"stack":["0x1","0x1"]},{"pc":6,"op":"PUSH1","gas":24978848,"gasCost":3,"depth":1,"stack":["0x2"]},{"pc":8,"op":"MSTORE","gas":24978845,"gasCost":6,"depth":1,"stack":["0x2","0x0"]},{"pc":9,"op":"PUSH1","gas":24978839,"gasCost":3,"depth":1,"stack":[]},{"pc":11,"op":"PUSH1","gas":24978836,"gasCost":3,"depth":1,"stack":["0x20"]},{"pc":13,"op":"RETURN","gas":24978833,"gasCost":0,"depth":1,"stack":["0x20","0x0"]}]}
    api_test.go:1013: test 10, result mismatch, have
        {21167 false 0x0000000000000000000000000000000000000000000000000000000000000002}
        , want
        {21167 false 0000000000000000000000000000000000000000000000000000000000000002}
    api_test.go:1012: result: {"gas":25664,"failed":false,"returnValue":"0x000000000000000000000000c6e93f4c1920eaeaa1e699f76a7a8c18e3056074","structLogs":[]}
    api_test.go:1013: test 11, result mismatch, have
        {25664 false 0x000000000000000000000000c6e93f4c1920eaeaa1e699f76a7a8c18e3056074}
        , want
        {25664 false 000000000000000000000000c6e93f4c1920eaeaa1e699f76a7a8c18e3056074}

```
2025-03-20 13:33:13 +01:00
Sina M
43883c6456
eth/tracers: hex-encode returnValue (#31216)
This is a **breaking change** to the opcode tracer. The top-level
`returnValue` field of a trace will be now hex-encoded. If the return
data is empty, this field will contain "0x".

Fixes #31196
2025-03-20 10:20:51 +01:00
Felföldi Zsolt
03cc2942c2
cmd/workload: fixed filter test request error handling (#31424)
This PR fixes the broken request error handling of the workload filter
tests. Until now `validateHistoryPruneErr` was invoked with `fq.Err` as
an input which was always nil and a timeout or http error was reported
as a result content mismatch.
Also, in case of `errPrunedHistory` it is wrong to return here without
setting an error because then it will look like a valid empty result and
the check will later fail. So instead `errPrunedHistory` is always
returned now (without printing an error message) and the callers of
`run` should handle this special case (typically ignore silently).
2025-03-20 09:23:10 +01:00
maskpp
8e3cd41b04
cmd/utils: force hash scheme for archive mode (#31439) 2025-03-20 13:14:13 +08:00
Felix Lange
80b8d7a13c
core/types: cleanup tx signer logic (#31434)
This removes the signer type-train in favor of defining a single object
that can handle all tx types. Supported types are enabled via a map.
Notably, the new signer also supports disabling legacy transactions.
2025-03-19 16:05:44 +01:00
Marius van der Wijden
b47e4d5b38
core/types: reduce allocs in transaction signing (#31258)
This PR roughly halves the number of allocations needed to compute the
sigHash for a transaction.

This sigHash is used whenever we recover a signature of a transaction,
so quite often. During a recent benchmark full syncing on Holesky,
roughly 2.8% of all allocations were happening here because the fields
from the transaction would be copied multiple times.

```
66168733  153175654 (flat, cum)  2.80% of Total
         .          .    368:func (s londonSigner) Hash(tx *Transaction) common.Hash {
         .          .    369:	if tx.Type() != DynamicFeeTxType {
         .          .    370:		return s.eip2930Signer.Hash(tx)
         .          .    371:	}
         .   19169966    372:	return prefixedRlpHash(
         .          .    373:		tx.Type(),
  26442187   26442187    374:		[]interface{}{
         .          .    375:			s.chainId,
   6848616    6848616    376:			tx.Nonce(),
         .   19694077    377:			tx.GasTipCap(),
         .   18956774    378:			tx.GasFeeCap(),
   6357089    6357089    379:			tx.Gas(),
         .   12321050    380:			tx.To(),
         .   16865054    381:			tx.Value(),
  13435187   13435187    382:			tx.Data(),
  13085654   13085654    383:			tx.AccessList(),
         .          .    384:		})
         .          .    385:}
```

This PR reduces the allocations and speeds up the computation of the
sigHash by ~22%, which is quite significantly given that this operation
involves a call to Keccak
```
// BenchmarkHash-8   	  440082	      2639 ns/op	     384 B/op	      13 allocs/op
// BenchmarkHash-8   	  493566	      2033 ns/op	     240 B/op	       6 allocs/op
```

```
Hash-8   2.691µ ± 8%   2.097µ ± 9%  -22.07% (p=0.000 n=10)
```

It also kinda cleans up stuff in my opinion, since the transaction
should itself know best how to compute the sighash




![Screenshot_2025-02-25_13-52-41](https://github.com/user-attachments/assets/e2b268aa-e137-417d-926b-f3619daef748)

---------

Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2025-03-19 14:21:40 +08:00
minh-bq
930836ed66
core/txpool, eth: add GetRLP to transaction pool (#31307)
Currently, when answering GetPooledTransaction request, txpool.Get() is
used. When the requested hash is blob transaction, blobpool.Get() is
called. This function loads the RLP-encoded transaction from limbo then
decodes and returns. Later, in answerGetPooledTransactions, we need to
RLP encode again. This decode then encode is wasteful. This commit adds
GetRLP to transaction pool interface so that answerGetPooledTransactions
can use the RLP-encoded from limbo directly.

---------

Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2025-03-19 14:20:50 +08:00
Lee Bousfield
c4f0450710
ethclient: Add EstimateGasAtBlock[Hash] to estimate against a specific block (#27508)
The main use case I see of this is that it allows users to estimate gas
against the same state that they query for their nonce, and the same
state they base the data of their transaction against. This helps ensure
that gas estimation won't fail and the transaction won't revert on-chain
because of a mismatch between the state used for gas estimation and the
state used to generate the inputs to gas estimation or the transaction's
nonce when submitted to the mempool.

This PR also updates the EstimateGas comment based on the new geth
`eth_estimateGas` default of using latest state as of v1.12.0:
https://github.com/ethereum/go-ethereum/pull/24363

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2025-03-18 15:41:34 +01:00
Delweng
dba58830e9
cmd: set name to chaindata for all the opened db (#31352)
When I'm running `geth import --metrics`, the metrics is different to
normal `geth --metrics`, so the grafana dashboard needs to be updated,
eg: `eth_db_chaindata_disk_read` vs `disk_read`.

So I think we should always set the name to `eth/db/chaindata` for more
convenient.

---------

Signed-off-by: jsvisa <delweng@gmail.com>
2025-03-18 21:32:29 +08:00
Felföldi Zsolt
fe640f8f57
core/filtermaps: fixed indexer checkpoint initialization (#31419)
This PR fixes a bug in the `lastMapBoundaryBefore` logic that resulted
in incorrect checkpoint initialization (started rendering from the
previous epoch boundary which caused the `needTailEpoch` check to fail).
Apparently the bug was present before but went unnoticed because
`needTailEpoch` behaved differently.
Fixes https://github.com/ethereum/go-ethereum/issues/31413
2025-03-18 13:46:23 +01:00
Sina M
e5f4b274b3
internal/ethapi: fix logs bloom in eth_simulateV1 (#31411)
Geth was returning empty logsBloom for the simulated block.
2025-03-18 12:40:38 +01:00
Marius van der Wijden
668118bfe1
params: add hoodi testnet definition (#31406)
Adds support for the new hoodi testnet. Hoodi is meant for stakers to test
their setup. For more info please refer to https://hoodi.ethpandaops.io/.
2025-03-18 12:07:49 +01:00
Shahar Rosenberg
40ad6bedf6
eth/tracers: fix precompile move feat for debug_traceCall (#31348)
`debug_traceCall` was ignoring the override `movePrecompileToAddress`. Now it is
at feature-parity with eth_call.
2025-03-18 12:05:12 +01:00
Felföldi Zsolt
d85f796356
eth/filters: implement log filter using new log index (#31080)
This PR is #2 of a 3-part series that implements the new log index
intended to replace core/bloombits.
Based on https://github.com/ethereum/go-ethereum/pull/31079
Replaces https://github.com/ethereum/go-ethereum/pull/30370

This part replaces the old bloombits based log search logic in
`eth/filters` to use the new `core/filtermaps` logic.

FilterMaps data structure explanation:
https://gist.github.com/zsfelfoldi/a60795f9da7ae6422f28c7a34e02a07e

Log index generator code overview:
https://gist.github.com/zsfelfoldi/97105dff0b1a4f5ed557924a24b9b9e7

Search pattern matcher code overview:
https://gist.github.com/zsfelfoldi/5981735641c956afb18065e84f8aff34

Note that the possibility of a tree hashing scheme and remote proof
protocol are mentioned in the documents above but they are not exactly
specified yet. These specs are WIP and will be finalized after the local
log indexer/filter code is finalized and merged.

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2025-03-17 18:59:04 +01:00
Marius van der Wijden
0f06e35115
core/rawdb: allow for truncation in the freezer (#31362)
Here we add the notion of prunable tables for the `TruncateTail` operation
in the freezer. TruncateTail for the chain freezer now only truncates the body and
receipts tables, leaving headers and hashes as-is.

This change also requires changing the validation/repair at startup to allow for
tables with different tail. For the header and hash tables, we now require them to start
at number zero.

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2025-03-17 16:01:37 +01:00
jwasinger
64bd21393e
cmd/abigen, accounts/abi/bind: implement abigen version 2 (#31379)
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.

## Generating Bindings

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.

## What is Generated in the Bindings

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.

## Using the Generated Bindings

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: Sina Mahmoodi <itz.s1na@gmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-03-17 15:56:55 +01:00
Shude Li
1cdf4d6da7
eth/catalyst: set FeeRecipient in dev mode (#31316)
this adds 2 features to improve `geth --dev` experience.

1. we don't need to use `dev_SetFeeRecipient` to set initial coinbase
address. it was a pain.
2. we don't need to unlock keystore if we don't use it. we had it
because of clique.
2025-03-17 09:32:44 +01:00
dependabot[bot]
74c6b69384
go.mod: bump golang.org/x/net from 0.34.0 to 0.36.0 (#31369)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.34.0 to
0.36.0.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="85d1d54551"><code>85d1d54</code></a>
go.mod: update golang.org/x dependencies</li>
<li><a
href="cde1dda944"><code>cde1dda</code></a>
proxy, http/httpproxy: do not mismatch IPv6 zone ids against hosts</li>
<li><a
href="fe7f0391aa"><code>fe7f039</code></a>
publicsuffix: spruce up code gen and speed up PublicSuffix</li>
<li><a
href="459513d1f8"><code>459513d</code></a>
internal/http3: move more common stream processing to genericConn</li>
<li><a
href="aad0180cad"><code>aad0180</code></a>
http2: fix flakiness from t.Log when GOOS=js</li>
<li><a
href="b73e5746f6"><code>b73e574</code></a>
http2: don't log expected errors from writing invalid trailers</li>
<li><a
href="5f45c776a9"><code>5f45c77</code></a>
internal/http3: make read-data tests usable for server handlers</li>
<li><a
href="43c2540165"><code>43c2540</code></a>
http2, internal/httpcommon: reject userinfo in :authority</li>
<li><a
href="1d78a08500"><code>1d78a08</code></a>
http2, internal/httpcommon: factor out server header logic for
h2/h3</li>
<li><a
href="0d7dc54a59"><code>0d7dc54</code></a>
quic: add Conn.ConnectionState</li>
<li>Additional commits viewable in <a
href="https://github.com/golang/net/compare/v0.34.0...v0.36.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=golang.org/x/net&package-manager=go_modules&previous-version=0.34.0&new-version=0.36.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/ethereum/go-ethereum/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-17 09:22:12 +01:00
rjl493456442
881ee4062f
eth/catalyst: fix flaky test (#31403)
This pull request enhances the unit test, avoiding unnecessary failure
in CI.

```
--- FAIL: TestSimulatedBeaconSendWithdrawals (12.08s)
    simulated_beacon_test.go:139: timed out without including all withdrawals/txs
FAIL
```
2025-03-17 14:13:12 +08:00
Mike Weyandt
d25c3c32b2
metrics: spin up meter ticker routine when enabling metric system (#31400)
Addresses https://github.com/ethereum/go-ethereum/issues/31244
2025-03-17 09:48:08 +08:00
Vladimir Támara Patiño
7d99f7df00
cmd/utils: fix geth test issue on OpenBSD (#31357) 2025-03-15 18:35:10 +01:00
Sina M
e3853e910a
tests: update ethereum/tests to v17.0 (#31381)
Get the re-filled tests (plus removal of outdated EIP-2537 tests)
2025-03-14 18:53:05 +01:00
danceratopz
475e87cbc1
cmd/evm: fix statetest with multi-fork statetest fixtures (#31374)
Fixes `evm statetest` for state test fixtures with multiple fork entries
in their `post` field (e.g.,
[chainId.json](81862e4848/GeneralStateTests/stChainId/chainId.json (L39))).

When these re-activated flags aren't exposed, `statetest` only executes
the fixture for a single fork entry instead of all of the forks as
expected.

This only affects ethereum/tests state test fixtures, not
ethereum/execution-spec-tests (EEST) state tests. EEST writes a separate
fixture/test case (i.e. a separate top-level dict entry in the .json)
for each fork configuration as apposed to combining multiple forks in
one fixture test case: New EEST state tests targeting Prague behavior
are not affected.
2025-03-14 17:56:24 +01:00
Stephen Buttolph
51177ed8c5
log: fix SetDefault for custom loggers (#31368)
Currently, even though it takes in a `Logger` interface,
`log.SetDefualt` enforces that the concrete type of the provided logger
is `*logger` because:
1. in `init` `root.Store` is called with a `*logger`
2. `atomic.Value` panics if the concrete type provided in `Store` is not
consistent across calls.
([ref](https://pkg.go.dev/sync/atomic#Value.Store))

> All calls to Store for a given Value must use values of the same
concrete type.

This PR changes to use `sync.RWMutex` and adds a test that panics on
`master`.
2025-03-14 16:56:53 +01:00
Marius van der Wijden
e5758c606a
accounts/abi: improve unpack performance (#31387)
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: Exca-DK <dawidk.info@gmail.com>
2025-03-14 15:27:38 +01:00
Felföldi Zsolt
f9f1172d59
core/filtermaps: FilterMaps log index generator and search logic (#31079)
This PR is #1 of a 3-part series that implements the new log index
intended to replace core/bloombits.
Replaces https://github.com/ethereum/go-ethereum/pull/30370

This part implements the new data structure, the log index generator and
the search logic. This PR has most of the complexity but it does not
affect any existing code yet so maybe it is easier to review separately.

FilterMaps data structure explanation:
https://gist.github.com/zsfelfoldi/a60795f9da7ae6422f28c7a34e02a07e

Log index generator code overview:
https://gist.github.com/zsfelfoldi/97105dff0b1a4f5ed557924a24b9b9e7

Search pattern matcher code overview:
https://gist.github.com/zsfelfoldi/5981735641c956afb18065e84f8aff34

Note that the possibility of a tree hashing scheme and remote proof
protocol are mentioned in the documents above but they are not exactly
specified yet. These specs are WIP and will be finalized after the local
log indexer/filter code is finalized and merged.

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2025-03-13 19:04:16 +01:00
Sina M
78be413ca9
eth/ethconfig: fix history prune blocks (#31383) 2025-03-13 18:54:20 +01:00
jwasinger
444a6d007a
cmd/workload: implement checks for history-pruned node (#31355)
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-03-13 15:21:47 +01:00
Chen Kai
5117f77af9
p2p/discover: expose discv5 functions for portal JSON-RPC interface (#31117)
Fixes #31093

Here we add some API functions on the UDPv5 object for the purpose of implementing
the Portal Network JSON-RPC API in the shisui client.

---------

Signed-off-by: Chen Kai <281165273grape@gmail.com>
2025-03-13 15:16:01 +01:00
Felföldi Zsolt
f3e4866073
core: update blockProcFeed in insertChain (#31065)
This PR moves the updating of the `blockProcFeed` event feed from
`InsertChain` to `insertChain` in order to ensure that the feed
subscribers are notified whenever block processing happens.
Note that this event is not subscribed to anywhere in our codebase at
the moment, earlier it was used by the LES server to avoid slowing down
block processing. Now I want to do the same with the log indexer, the
problem is that back then every block insertion was done by
`InsertChain`, now the regular payload insertion is done by
`InsertBlockWithoutSetHead`. Both of these (and also `SetCanonical` if
needed) calls `insertChain` so I moved the feed update there.
2025-03-13 12:35:10 +01:00
Pierre R
18faa251b3 Update core/txpool/txpool.go
Co-authored-by: jwasinger <j-wasinger@hotmail.com>
2025-03-13 20:15:41 +09:00
Felix Lange
1ca2da81e6
eth/ethconfig: add HistoryMode (#31365)
Here I am adding a config option and geth flag (`--history.chain`) for
configuring history pruning. There are two options available:

- `--history.chain all` is the default and will keep all history like
before.
- `--history.chain postmerge` will configure the history cutoff point to
the merge block.

The option doesn't actually do anything right now, but we need it as a
precursor for other history pruning changes.
2025-03-13 11:43:00 +01:00
Marius van der Wijden
5606cbc710
crypto/secp256k1: update libsecp256k1 (#31242)
Updates the libsecp256k1 dependency to commit:
c0d9480fbbf8eccbd4be23ed27f6f2af6f3b211e

PR:
```
BenchmarkSign-24    	   57756	     21214 ns/op	     164 B/op	       3 allocs/op
BenchmarkRecover-24    	   37156	     33044 ns/op	      80 B/op	       1 allocs/op
BenchmarkEcrecoverSignature-24    	   36889	     32935 ns/op	      80 B/op	       1 allocs/op
BenchmarkVerifySignature-24    	   41163	     29207 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecompressPubkey-24    	  318624	      4062 ns/op	     304 B/op	       6 allocs/op
```

Master:
```
BenchmarkSign-24    	   34509	     35330 ns/op	     164 B/op	       3 allocs/op
BenchmarkRecover-24    	   25418	     47725 ns/op	      80 B/op	       1 allocs/op
BenchmarkEcrecoverSignature-24    	   25735	     47591 ns/op	      80 B/op	       1 allocs/op
BenchmarkVerifySignature-24    	   29108	     41097 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecompressPubkey-24    	  294747	      4143 ns/op	     304 B/op	       6 allocs/op
```

Performance seems to be improved significantly:
```
Sign-24      34.86µ ± 3%   21.66µ ± 2%  -37.86% (p=0.000 n=10)
Recover-24   46.14µ ± 3%   33.24µ ± 2%  -27.95% (p=0.000 n=10)
```
2025-03-12 12:21:50 +01:00
Delweng
915d9d9de5
cmd: ctrl-c to halt the whole import process (#31360)
When I press Ctrl-C during the import of multiple files, the import
process will still attempt to import the subsequent files. However, in
normal circumstances, users would expect the import to stop immediately
upon pressing Ctrl-C.

And because the current file was not finished importing, subsequent
import tasks often fail due to an `unknown ancestor` error.

---------

Signed-off-by: jsvisa <delweng@gmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-03-12 12:20:40 +01:00
buddho
eb879a76cf
go.mod: update crypto to remove dependency warning (#31334) 2025-03-11 22:30:45 +01:00
Delweng
ca530362ca
ethdb: no need to check the metric nilness (#31353)
The metric always has a value, no need to check for the nil. 

Seems this code was first introduced here
054412e335/metrics/meter.go (L45-L48)

As the `nilMeter` was removed, so this check seems is useless.

Signed-off-by: jsvisa <delweng@gmail.com>
2025-03-11 22:30:02 +01:00
Felix Lange
e442c4d50c
beacon/types, beacon/blsync: update for electra (#31243)
This updates the blsync base types for the Electra fork. I've been
testing, and it doesn't seem to make blsync fully work on Electra. But
I'd still like to get this in to make some progress.

---------

Co-authored-by: Zsolt Felfoldi <zsfelfoldi@gmail.com>
2025-03-11 17:17:47 +01:00
Marius van der Wijden
71f9f1e684
core: prefund pectra precompiles in developer genesis (#31342)
Prefund the precompile addresses for the new precompiles in the
developer genesis block.
2025-03-11 16:15:07 +01:00
Austin Larson
49ef375033
core/txpool: demote error log to warn (#31332)
This error log in `legacypool.go` isn't necessary, since even though the
behavior is unexpected, it is handled correctly. A discussion on issue
#22301 concluded that this should instead be a warning log.
2025-03-11 16:00:50 +01:00
lightclient
4cdd7c8631
cmd,eth,les: replace Cancun override flag with Prague (#31341)
It's that time of the cycle, should have this ready to go for mainnet
Prague release.
2025-03-10 07:10:16 -06:00
Delweng
9aba6895b9
core/rawdb,state: add preimage miss metric (#31295)
1. The metric of preimage/hits are always the same as preimage/total, prefer to replace
   the hits with miss instead.
2. For the state/read/accounts metric, follow the same naming of others,
  change into singuar.
2025-03-07 11:23:19 +01:00