Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: forge sends RPC requests for non-existent methods regardless of EVM Version specified #416

Closed
sambacha opened this issue Jan 11, 2022 · 5 comments · Fixed by #412
Closed
Labels
T-bug Type: bug

Comments

@sambacha
Copy link
Contributor

Bug: forge sends request for eth_feeHistory on non-london+ EVM Versions

When running forge create and specifying an EVM Version lower than berlin forge will attempt to request eth_feeHistory

Output

compiling...
success.
Error:
   0: (code: -32700, message: The method eth_feeHistory does not exist/is not available, data: None)

It should handle none, as I did not specify numberOfRequestedBlocks.

Desired Behavior

by default it should use a value of 1 for blockCount and newestBlock - or simply do not send this request on any EVM version (or limit it just to post london EVM Versions)

eth_feeHistory response (example)

{
  "1": {
    "response": {
      "baseFeePerGas": [
        "139569467980",
        "123568107321",
        "139010354553",
        "141881786034",
        "159611134013",
        "157601697097"
      ],
      "gasUsedRatio": [
        0.041407990167479085,
        0.9998780855982294,
        0.5826249667732252,
        0.9998343281249537,
        0.4496416706275115
      ],
      "oldestBlock": "0xd557fd",
      "reward": [
        [
          "1500000000",
          "1500000000",
          "1500000000"
        ],
        [
          "1500000000",
          "1500000000",
          "1500000000"
        ],
        [
          "1258880691",
          "1410000000",
          "1500000000"
        ],
        [
          "1500000000",
          "1500000000",
          "1500000000"
        ],
        [
          "1409999999",
          "1500000000",
          "1500000000"
        ]
      ]
    }
  }
}

Debug/RUSTC Log output

Raw Log Output ```sh Location: /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/result.rs:1914

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⋮ 10 frames hidden ⋮
11: <core::result::Result<T,F> as core::ops::try_trait::FromResidual<core::result::Resultcore::convert::Infallible,E>>::from_residual::h20d1fb275751fe54
at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/result.rs:1914
12: forge::cmd::create::CreateArgs::deploy::{{closure}}::h93c90620ed9e5073
at /Users/sbacha/foundry-docker/foundry/cli/src/cmd/create.rs:
13: <core::future::from_generator::GenFuture as core::future::future::Future>::poll::ha84a55ea845c6e7f
at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/future/mod.rs:80
14: tokio::park::thread::CachedParkThread::block_on::{{closure}}::haf8ca52c607682ca
at /Users/sbacha/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/park/thread.rs:263
15: tokio::coop::with_budget::{{closure}}::ha97f2f476892933f
at /Users/sbacha/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/coop.rs:102
16: std::thread::local::LocalKey::try_with::h0f67afacad12cbc9
at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/thread/local.rs:399
17: std::thread::local::LocalKey::with::he5fd0962d8fef72e
at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/thread/local.rs:375
18: tokio::coop::with_budget::h78a464ccd1aefed4
at /Users/sbacha/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/coop.rs:95
19: tokio::coop::budget::h78b34f00bbe5f4a7
at /Users/sbacha/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/coop.rs:72
20: tokio::park::thread::CachedParkThread::block_on::hd1d7fa6b9d8cfb73
at /Users/sbacha/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/park/thread.rs:263
21: tokio::runtime::enter::Enter::block_on::hd88631fb2265fbe6
at /Users/sbacha/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/enter.rs:151
22: tokio::runtime::thread_pool::ThreadPool::block_on::h982920b3c061fb06
at /Users/sbacha/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/thread_pool/mod.rs:77
23: tokio::runtime::Runtime::block_on::h7ad6a6e06036d78c
at /Users/sbacha/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/mod.rs:463
24: <forge::cmd::create::CreateArgs as forge::cmd::Cmd>::run::h12c3c7d54b26cdc8
at /Users/sbacha/foundry-docker/foundry/cli/src/cmd/create.rs:60
25: forge::main::ha36bb5ae4dda7416
at /Users/sbacha/foundry-docker/foundry/cli/src/forge.rs:34
26: core::ops::function::FnOnce::call_once::h35391823e5f9df29
at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:227
⋮ 2 frames hidden ⋮

</detail>
@gakonst
Copy link
Member

gakonst commented Jan 11, 2022

Good catch, this happens due to fee estimation here. The "real" fix is to check if the chain has enabled EIP1559, and if not, call .legacy() on the deployer. The fix from #412 should address this.

@sambacha
Copy link
Contributor Author

Good catch, this happens due to fee estimation here. The "real" fix is to check if the chain has enabled EIP1559, and if not, call .legacy() on the deployer. The fix from #412 should address this.

why not just use a constant for maxFeePerGas - this is how both ethersjs and web3js are currently configured (2.5gwei)

            maxPriorityFeePerGas = BigNumber.from("2500000000");
            maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas);

for some reason I was thinking that pragma would change this behavior - thanks

@gakonst
Copy link
Member

gakonst commented Jan 11, 2022

Because having a constant max fee per gas is not really correct :D We re-use the algorithm that MyCrypto uses, using the historical values: https://github.com/gakonst/ethers-rs/blob/e24117a1e1d6301d80101c7cc83c93ac4a8b1258/ethers-core/src/utils/mod.rs#L300-L318, which tends to give better estimates in my experience vs hardcoded.

@sambacha
Copy link
Contributor Author

Because having a constant max fee per gas is not really correct :D We re-use the algorithm that MyCrypto uses, using the historical values: gakonst/ethers-rs@e24117a/ethers-core/src/utils/mod.rs#L300-L318, which tends to give better estimates in my experience vs hardcoded.

fyi this fails when using ganache (v7) - ganache does not have this RPC method implemented :(

@gakonst
Copy link
Member

gakonst commented Jan 11, 2022

Yeah Ganache is still not fully London compatible, nothing we can do about that lol :D The method is in the JSON-RPC spec, tracked here for Ganache trufflesuite/ganache#1470

I added a --legacy flag you can use from the CLI, which will force usage of legacy transactions so you can still use it with Ganache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants