foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Use pending for fetching nonces in scripts

Open LogvinovLeon opened this issue 1 month ago • 1 comments

Component

Forge

Have you ensured that all of these are up to date?

  • [ ] Foundry
  • [x] Foundryup

What version of Foundry are you on?

forge Version: 1.5.0-dev

What version of Foundryup are you on?

leo@sov-dev-box:~/sdk/foundry$

What command(s) is the bug in?

forge script

Operating System

Linux

Describe the bug

When running foundry scripts - I'm sometimes encountering nonce issues. This happens because when the script fetches the nonce for account - it uses "latest" instead of "pending" so if there is a pending tx - we will submit the tx with a colliding nonce.

The fix is a 1-line fix here: https://github.com/foundry-rs/foundry/blob/master/crates/script/src/broadcast.rs#L58

Please let me know if you agree and I'll submit the PR.

LogvinovLeon avatar Nov 28 '25 14:11 LogvinovLeon

thank you, I think this makes sense though wonder if you could share a repro / the chain you experience this? CC @mattsse @klkvr could you pls chime in?

grandizzy avatar Nov 28 '25 15:11 grandizzy