consensus-shipyard / ipc

🌳 Spawn multi-level trees of customized, scalable, EVM-compatible networks with IPC. L2++ powered by FVM, Wasm, libp2p, IPFS/IPLD, and CometBFT.
https://ipc.space
Apache License 2.0
44 stars 39 forks source link

Handling Filecoin Network Nonce Error with Custom Middleware #1195

Closed karlem closed 2 weeks ago

karlem commented 2 weeks ago

Issue:

When interacting with the Filecoin Calibration network using ipc-cli, transactions often fail with the error: message: minimum expected nonce is 63, got 62. This typically occurs when sending two consecutive transactions.

Cause:

The error is caused by Filecoin changing the behavior of the eth_getTransactionCount endpoint. To get the correct latest nonce, the "pending" block parameter must now be specified: Relevant Lotus PR.

Solution:

ethers-rs currently does not provide a built-in way to set the "pending" parameter for nonce fetching. The recommended workaround is to implement a custom middleware that explicitly sets the "pending" parameter when fetching the nonce.