Skip to content
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

eth, miner: fix enforcing the minimum miner tip #28933

Merged
merged 3 commits into from
Feb 6, 2024

Conversation

karalabe
Copy link
Member

@karalabe karalabe commented Feb 5, 2024

Geth originally enforced transaction gas prices and tips in the transaction pool. This seemed like an elegant way to avoid having to check the same thing in two different places. By default the pool (and hence miner) admitted 1 wei tip transactions, and when mining was started, that was increased to whatever the user set, or 1gwei by default.

Unfortunately, the merge kind of broke this mechanism. Since post-merge mining is not requested to be "turned on" in Geth, rather blocks are sometimes produced on demand via the beacon client, the mechanism that flipped the pool from non-mining-node mode to mining-node mode never got triggered. The effect is that all validating Geth nodes accept 1 wei tip transactions into the pool currently, and because the miner doens't do a follow-up enforcement, those will get included in a block blindly...

Now, in practice, the transactions are still sorted in highest-tip order, so the effect isn't really relevant on mainnet, or anywhere really where the pool has enough proper transactions to fill up a block. The issue is mostly relevant in testnets, private nets, or Geth forks where the network might not be completely saturated. In those cases, even though Geth supports a --miner.gasprice flag, that gets elegantly ignored (tho you could still use txpool.gasprice to have the desired side effect).

The fix for this issue is not so obvious. Restoring the previous mechanism of the pool enforcing the tip is problematic, since there's no startup marker in Geth that would signal that the machine will be mining, so start enforcing stricter limits. Sure, we could require users to pass in --mine, but it seems like an arbitrary useless thing to need. We could also start enforcing gas tips the first time a block is requested from us, but it feels wrong to all of a sudden do a big txpool filtering exactly when we need to build a block and can't afford to waste time.

The solution proposed in this PR is to go back to a less simple way, that of having a second filtering step within a miner that can enforce tips independent of the pool. Cost wise this doesn't add anything to the current "faulty" behavior. What this would mean is that by default even block producing nodes accept and propagate txs down to 1 wei tip (as long as it fits into the 4/6K limit); but anything below the needed limit would get filtered out in the miner itself now.

Side note: if the user calls miner.setGasPrice API method, that will enforce the price on both the miner and the txpool. Whilst we could drop the enforcement from the pool, I felt that we should aim to keep as much behavior as we can unchanged.

@rjl493456442
Copy link
Member

Some tests are failing because of the additional restriction, please fix them.

@karalabe
Copy link
Member Author

karalabe commented Feb 6, 2024

@rjl493456442 Fixed + added a mechanism to the simulated backend to specifically set the minimum gas tip needed by the miner.

We'll have a small breakage here unfortunately. Previously the simulated backend used a gas tip of 0; and the buggy conversion due to this PR's root issue also kept supporting that 0 tip. However, with the miner fixed in the live node, the new simulated backend which wraps a live node will start rejecting 0 tips.

Currently it is not possible to make the miner accept 0 tip in a live node and I didn't want to add a hack to the simulated backend to make it possible there. Since ideally we want the sim to follow live as close as possible, I think we'll need to live with potentially breaking a few eggs here and there.

That said, abigen for example retrieves the prices and tips from the node implicitly, so it should not break in the default cases, only for use cases where the user very explicitly specified 0 gas tips (or below 1 gwei). Still, even the 1 gwei one can be fixed with the new option introduced. So really only the exact 0 price is problematic.

PTAL

Copy link
Member

@MariusVanDerWijden MariusVanDerWijden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@karalabe karalabe merged commit 16ce7bf into ethereum:master Feb 6, 2024
2 of 3 checks passed
@ghost
Copy link

ghost commented Feb 7, 2024

@karalabe @MariusVanDerWijden Think I was the first to find the issue but you ignored me back then.... #28487

lukanus pushed a commit to blocknative/go-ethereum that referenced this pull request Feb 19, 2024
* params: begin v.1.13.12 release cycle

* internal/flags: fix typo (ethereum#28876)

* core/types: fix and test handling of faulty nil-returning signer (ethereum#28879)

This adds an error if the signer returns a nil value for one of the signature value fields.

* README.md: fix travis badge (ethereum#28889)

The hyperlink in the README file that directs to the Travis CI build was broken.
This commit updates the link to point to the corrent build page.

* eth/catalyst: allow payload attributes v1 in fcu v2 (ethereum#28882)

At some point, `ForkchoiceUpdatedV2` stopped working for `PayloadAttributesV1` while `paris` was active. This was causing a few failures in hive. This PR fixes that, and also adds a gate in `ForkchoiceUpdatedV1` to disallow `PayloadAttributesV3`.

* docs/postmortems: fix outdated link (ethereum#28893)

* core: reset tx lookup cache if necessary (ethereum#28865)

This pull request resets the txlookup cache if chain reorg happens, 
preventing them from remaining reachable. It addresses failures in
the hive tests.

* build: fix problem with windows line-endings in CI download (ethereum#28900)

fixes ethereum#28890

* eth/downloader: fix skeleton cleanup (ethereum#28581)

* eth/downloader: fix skeleton cleanup

* eth/downloader: short circuit if nothing to delete

* eth/downloader: polish the logic in cleanup

* eth/downloader: address comments

* deps: update memsize (ethereum#28916)

* core/txpool/blobpool: post-crash cleanup and addition/removal metrics (ethereum#28914)

* core/txpool/blobpool: clean up resurrected junk after a crash

* core/txpool/blobpool: track transaction insertions and rejections

* core/txpool/blobpool: linnnnnnnt

* core/txpool: don't inject lazy resolved transactions into the container (ethereum#28917)

* core/txpool: don't inject lazy resolved transactions into the container

* core/txpool: minor typo fixes

* core/types: fix typo (ethereum#28922)

* p2p: fix accidental termination of portMappingLoop (ethereum#28911)

* internal/flags: fix --miner.gasprice default listing (ethereum#28932)

* all: fix typos in comments (ethereum#28881)

* Makefile: add help target to display available targets (ethereum#28845)


Co-authored-by: Martin HS <[email protected]>
Co-authored-by: Felix Lange <[email protected]>

* core: cache transaction indexing tail in memory (ethereum#28908)

* eth, miner: fix enforcing the minimum miner tip (ethereum#28933)

* eth, miner: fix enforcing the minimum miner tip

* ethclient/simulated: fix failing test due the min tip change

* accounts/abi/bind: fix simulater gas tip issue

* core/state, core/vm: minor uint256 related perf improvements (ethereum#28944)

* cmd,internal/era: implement `export-history` subcommand (ethereum#26621)

* all: implement era format, add history importer/export

* internal/era/e2store: refactor e2store to provide ReadAt interface

* internal/era/e2store: export HeaderSize

* internal/era: refactor era to use ReadAt interface

* internal/era: elevate anonymous func to named

* cmd/utils: don't store entire era file in-memory during import / export

* internal/era: better abstraction between era and e2store

* cmd/era: properly close era files

* cmd/era: don't let defers stack

* cmd/geth: add description for import-history

* cmd/utils: better bytes buffer

* internal/era: error if accumulator has more records than max allowed

* internal/era: better doc comment

* internal/era/e2store: rm superfluous reader, rm superfluous testcases, add fuzzer

* internal/era: avoid some repetition

* internal/era: simplify clauses

* internal/era: unexport things

* internal/era,cmd/utils,cmd/era: change to iterator interface for reading era entries

* cmd/utils: better defer handling in history test

* internal/era,cmd: add number method to era iterator to get the current block number

* internal/era/e2store: avoid double allocation during write

* internal/era,cmd/utils: fix lint issues

* internal/era: add ReaderAt func so entry value can be read lazily

Co-authored-by: lightclient <[email protected]>
Co-authored-by: Martin Holst Swende <[email protected]>

* internal/era: improve iterator interface

* internal/era: fix rlp decode of header and correctly read total difficulty

* cmd/era: fix rebase errors

* cmd/era: clearer comments

* cmd,internal: fix comment typos

---------

Co-authored-by: Martin Holst Swende <[email protected]>

* core,params: add holesky to default genesis function (ethereum#28903)

* node, rpc: add configurable HTTP request limit (ethereum#28948)

Adds a configurable HTTP request limit, and bumps the engine default

* all: fix docstring names (ethereum#28923)

* fix wrong comment

* reviewers input

* Update log/handler_glog.go

---------

Co-authored-by: Martin HS <[email protected]>

* ethclient/simulated: fix typo (ethereum#28952)

(ethclient/simulated):fix typo

* eth/gasprice: fix percentile validation in eth_feeHistory (ethereum#28954)

* cmd/devp2p, eth: drop support for eth/67 (ethereum#28956)

* params, core/forkid: add mainnet timestamp for Cancun (ethereum#28958)

* params: add cancun timestamp for mainnet

* core/forkid: add test for mainnet cancun forkid

* core/forkid: update todo tests for cancun

* internal/ethapi: add support for blobs in eth_fillTransaction (ethereum#28839)

This change adds support for blob-transaction in certain API-endpoints, e.g. eth_fillTransaction. A follow-up PR will add support for signing such transactions.

* internal/era: update block index format to be based on record offset (ethereum#28959)

As mentioned in ethereum#26621, the block index format for era1 is not in line with the regular era block index. This change modifies the index so all relative offsets are based against the beginning of the block index record.

* params: go-ethereum v1.13.12 stable

---------

Co-authored-by: Martin Holst Swende <[email protected]>
Co-authored-by: alex <[email protected]>
Co-authored-by: protolambda <[email protected]>
Co-authored-by: KeienWang <[email protected]>
Co-authored-by: lightclient <[email protected]>
Co-authored-by: rjl493456442 <[email protected]>
Co-authored-by: Péter Szilágyi <[email protected]>
Co-authored-by: zoereco <[email protected]>
Co-authored-by: Chris Ziogas <[email protected]>
Co-authored-by: Dimitris Apostolou <[email protected]>
Co-authored-by: Halimao <[email protected]>
Co-authored-by: Felix Lange <[email protected]>
Co-authored-by: lmittmann <[email protected]>
Co-authored-by: Sina Mahmoodi <[email protected]>
Co-authored-by: Austin Roberts <[email protected]>
Hiteon88 pushed a commit to Hiteon88/go-ethereum that referenced this pull request Apr 12, 2024
* eth, miner: fix enforcing the minimum miner tip

* ethclient/simulated: fix failing test due the min tip change

* accounts/abi/bind: fix simulater gas tip issue
maoueh pushed a commit to streamingfast/go-ethereum that referenced this pull request Apr 30, 2024
…ereum#1209)

* eth, miner: fix enforcing the minimum miner tip

* ethclient/simulated: fix failing test due the min tip change

* accounts/abi/bind: fix simulater gas tip issue

Co-authored-by: Péter Szilágyi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants