alloy icon indicating copy to clipboard operation
alloy copied to clipboard

[Bug] nonce too low error despite `NonceFiller` added

Open ts0yu opened this issue 6 months ago • 1 comments

Component

transports

What version of Alloy are you on?

alloy v0.2.1

Operating System

Linux

Describe the bug

I am using an anvil instance and alloy bindings to deploy a contract and make calls.

I instantiate the anvil instance and provider as such

    let anvil = Anvil::new().try_spawn().unwrap();
    let signer: PrivateKeySigner = anvil.keys()[0].clone().into();
    let wallet = EthereumWallet::from(signer);
    let rpc_url = anvil.endpoint().parse().unwrap();

    let client = ProviderBuilder::new()
        .with_recommended_fillers()
        .wallet(wallet)
        .on_http(rpc_url);

The provider has a NonceFiller as with_recommended_fillers should include that.

The bindings are called as below

 let pool_manager = PoolManager::deploy(client.clone(), Uint::from(5000))
        .await
        .unwrap();

    let currency0 = ArenaToken::deploy(
        client.clone(),
        "ARENA0".to_string(),
        "ARENA0".to_string(),
        18,
    )
    .await
    .unwrap();

    let currency1 = ArenaToken::deploy(
        client.clone(),
        "ARENA1".to_string(),
        "ARENA1".to_string(),
        18,
    )
    .await
    .unwrap();

    currency0
        .mint(Uint::from(2).pow(Uint::from(255)))
        .send()
        .await
        .unwrap()
        .watch()
        .await
        .unwrap();

However, this results in an error of nonce too low.

If i manually set the nonce on the CallBuilder struct to a manually calculated value, there is no error which suggests that the NonceFiller filler could be problematic in this context.

thread 'main' panicked at src/main.rs:60:10:
called `Result::unwrap()` on an `Err` value: TransportError(ErrorResp(ErrorPayload { code: -32003, message: "nonce too low", data: None }))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

full code w bindings can be found here:

https://github.com/arena-rs/lp-alloy-test

ts0yu avatar Aug 05 '24 18:08 ts0yu