alloy-rs / alloy

Transports, Middleware, and Networks for the Alloy project
https://alloy.rs
Apache License 2.0
664 stars 239 forks source link

[Bug] "duplicate field `status`" when deploying contract #1545

Closed mickvandijke closed 1 month ago

mickvandijke commented 1 month ago

Component

contract, transports

What version of Alloy are you on?

0.5.2

Operating System

macOS (Apple Silicon)

Describe the bug

When updating Alloy from 0.4.2 to 0.5.2, we were hit by an error when deploying a contract locally on Anvil:

Could not deploy contract: PendingTransactionError(TransportError(DeserError { err: Error("duplicate field `status`", line: 1, column: 1714), text: "{\"type\":\"0x2\",\"status\":\"0x1\",\"cumulativeGasUsed\":\"0x1dba69\",\"logs\":[{\"address\":\"0x5fbdb2315678afecb367f032d93f642f64180aa3\",\"topics\":[\"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef\",\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266\"],\"data\":\"0x000000000000000000000000000000000000000000108b2a2c28029094000000\",\"blockHash\":\"0xd8305cc83be13fa0ddcc7b5339220e416c006d23ed36a6c4b69dee879078bb83\",\"blockNumber\":\"0x1\",\"blockTimestamp\":\"0x67175347\",\"transactionHash\":\"0x432d3f80bc5bed03a9b7ff33795a496cffd6bf5ae2ca867ad984e070799a7cb7\",\"transactionIndex\":\"0x0\",\"logIndex\":\"0x0\",\"removed\":false}],\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000040020000000000000100000800000000000000000000000010000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000042000000200000000000000000000000002000000000000000000020000000000000000000000000000000000000000000000000000000000000000000\",\"transactionHash\":\"0x432d3f80bc5bed03a9b7ff33795a496cffd6bf5ae2ca867ad984e070799a7cb7\",\"transactionIndex\":\"0x0\",\"blockHash\":\"0xd8305cc83be13fa0ddcc7b5339220e416c006d23ed36a6c4b69dee879078bb83\",\"blockNumber\":\"0x1\",\"gasUsed\":\"0x1dba69\",\"effectiveGasPrice\":\"0x3b9aca01\",\"blobGasPrice\":\"0x1\",\"from\":\"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266\",\"to\":null,\"contractAddress\":\"0x5fbdb2315678afecb367f032d93f642f64180aa3\",\"root\":\"0xc676a81e3e84f07f816d8ec8b2c76e9710437d92c42f00e611682772207c10b3\"}" }))

Prior to updating, this wasn't an issue.

Import:

alloy = { version = "0.5.2", default-features = false, features = ["std", "reqwest-rustls-tls", "provider-anvil-node", "sol-types", "json", "signers", "contract", "signer-local", "network"] }

Relevant code:

sol!(
    #[allow(clippy::too_many_arguments)]
    #[allow(missing_docs)]
    #[sol(rpc)]
    NetworkTokenContract,
    "artifacts/AutonomiNetworkToken.json"
);

...

pub struct NetworkToken<T: Transport + Clone, P: Provider<T, N>, N: Network> {
    pub contract: NetworkTokenContractInstance<T, P, N>,
}

impl<T, P, N> NetworkToken<T, P, N>
where
    T: Transport + Clone,
    P: Provider<T, N>,
    N: Network,
{
    ...

    /// Deploys the AutonomiNetworkToken smart contract to the network of the provider.
    /// ONLY DO THIS IF YOU KNOW WHAT YOU ARE DOING!
    pub async fn deploy(provider: P) -> Self {
        let contract = NetworkTokenContract::deploy(provider)
            .await
            .expect("Could not deploy contract");
        NetworkToken { contract }
    }
}

https://github.com/maidsafe/safe_network/blob/main/evmlib/src/contract/network_token.rs

mattsse commented 1 month ago

which anvil version are you using? can you try with latest?

mickvandijke commented 1 month ago

which anvil version are you using? can you try with latest?

Hey @mattsse , thanks for the quick response! I'm using Anvil version 0.2.0, which seems to be the latest.

mattsse commented 1 month ago

what's the --version?

mickvandijke commented 1 month ago

anvil 0.2.0 (2044fae 2024-10-22T00:21:22.595388000Z)

mickvandijke commented 1 month ago

Ah sorry @mattsse , updating Anvil indeed fixed it! I thought I was already on latest with 0.2.0, but apparently, that version also has subversions.

For anyone else running into this problem, run foundryup again.