ledgerwatch / erigon-lib

Dependencies of Erigon project, rewritten from scratch and licensed under Apache 2.0
Apache License 2.0
59 stars 85 forks source link

Devnet configurations reject transactions when BaseFee is below 7 #1112

Open jyellick opened 10 months ago

jyellick commented 10 months ago

I've run into an issue where on a dev network, when the block baseFee is adequately low (say, 1 Wei), that the txpool begins rejecting transactions claiming they have an insufficient fee when their fee is in fact adequate. I traced it down to the following bit of code:

https://github.com/ledgerwatch/erigon-lib/blob/2d6e293a15e8d930c827a11d3e78e1e21bcb3885/txpool/pool.go#L178-L180

Unfortunately, there's no comment, but it looks to me like this function is probably supposed to implement some heuristic based on the pending block base fee to compute a 'protocol base fee' (maybe say, some fraction of the pending base fee?), but instead returns a constant 7.

Doing a git blame shows @AskAlexSharov as the author in 29bf077da4600e4e5599b0dea2daaac872c7a9f8 and that the protocolBaseFee used to be an atomic that got set and retrieved. But, I wasn't able to glean much from the PR https://github.com/ledgerwatch/erigon-lib/pull/48 it came in with.

So, can anyone explain to me why this function returns a constant 7? Is there some other behavior it should be doing that's documented? Would a patch which returns something equivalent to min(7, baseFee) be accepted as a fix for these devnet transactions being rejected when the basefee is adequately small?

I first raised this on Discord, but @AskAlexSharov suggested I create this in an issue https://discord.com/channels/687972960811745322/687972960811745326/1149164360644706355

I think you are right and it’s something mainnet-specific hardcode. Let’s do next way: create github issue from this comment - i will ask somebody in team to take a look. Likely we need “add support of non-mainnet chains to txpool”.

AskAlexSharov commented 10 months ago

adding link to pool docs: https://github.com/ledgerwatch/erigon/wiki/Transaction-Pool-Design