paradigmxyz / reth

Modular, contributor-friendly and blazing-fast implementation of the Ethereum protocol, in Rust
https://reth.rs/
Apache License 2.0
3.82k stars 1.07k forks source link

inconsistent JSON RPC API responses: eth_getTransactionCount(address, 'pending') returns used nonce #10881

Open perekopskiy opened 1 week ago

perekopskiy commented 1 week ago

Describe the bug

When running reth in dev mode with a small block-time (e.g. 300ms) JSON RPC API returns inconsistent results. After transaction with nonce X is included in the block (node returns receipt for it with blockNumber set) node may still return nonce X as a response for eth_getTransactionCount(address, 'pending').

Steps to reproduce

Here is repo with a small script that reproduces the issue. It sends transactions in loop from a single address. The script fails after some time with "nonce has already been used" error. It's better to run it on a resource-constrained machine and/or make all the CPUs busy so it reproduces faster.

Node logs

No response

Platform(s)

Linux (x86), Linux (ARM), Mac (Apple Silicon)

What version/commit are you on?

reth Version: 1.0.6 Commit SHA: c228fe15808c3acbf18dc3af1a03ef5cbdcda07a Build Timestamp: 2024-08-29T18:34:24.773465330Z Build Features: asm_keccak,jemalloc Build Profile: maxperf

What database version are you on?

Error: Datadir does not exist: "/root/.local/share/reth/mainnet"

Which chain / network are you on?

dev

What type of node are you running?

Archive (default)

What prune config do you use, if any?

No response

If you've built Reth from source, provide the full command you used

No response

Code of Conduct

mattsse commented 1 week ago

I see, we should swap the logic for pending and do the pool lookup after the disk lookup to rule this out

https://github.com/paradigmxyz/reth/blob/74c733d22dc6fc27cd9fa38ba6f7db7db648ce2e/crates/rpc/rpc-eth-api/src/helpers/state.rs#L272-L282

because the pool update can happen later

perekopskiy commented 23 hours ago

@mattsse it reproduces for me with 1.0.7

mattsse commented 22 hours ago

do you mean this is still happening?

perekopskiy commented 22 hours ago

yes