Could not instantiate forked environment with fork url
Closed this issue · 3 comments
Component
Forge
Have you ensured that all of these are up to date?
- Foundry
- Foundryup
What version of Foundry are you on?
forge 0.2.0 (7bef9ca 2024-06-26T00:18:22.002685333Z)
What command(s) is the bug in?
forge script
Operating System
Linux
Describe the bug
After trying to deploy a pretty simple mock ERC-20 token to the Polygon Amoy testnet, I got this error, which the CLI asked me to report as a bug:
forge script script/MockToken.s.sol --rpc-url https://rpc-amoy.polygon.technology/ --broadcast -vvvv
[⠊] Compiling...
No files changed, compilation skipped
2024-11-21T15:25:27.218837Z ERROR foundry_evm_core::fork::init: It looks like you're trying to fork from an older block with a non-archive node which is not supported. Please try to change your RPC url to an archive node if the issue persists.
The application panicked (crashed).
Message: Unable to create fork:
Could not instantiate forked environment with fork url: https://rpc-amoy.polygon.technology/
Location: crates/evm/core/src/backend/mod.rs:454
This is a bug. Consider reporting it at https://github.com/foundry-rs/foundry
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1: __libc_start_main<unknown>
at <unknown source file>:<unknown line>
Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
[1] 15730 IOT instruction (core dumped) forge script script/MockToken.s.sol --rpc-url --broadcast -vvvv
The script doesn't do much:
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import {Script} from "forge-std/Script.sol";
import {MockToken} from "../src/MockToken.sol";
contract MockTokenScript is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);
new MockToken("Mock ERC20 Token", "MCK");
vm.stopBroadcast();
}
}
And the contract is as dumb as possible:
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MockToken is ERC20 {
constructor(
string memory _name,
string memory _symbol
) ERC20(_name, _symbol) {}
function mint(address to, uint256 amount) public virtual {
_mint(to, amount);
}
function burn(address form, uint amount) public virtual {
_burn(form, amount);
}
}
Note: foundryup --version
returns an empty string, I was not able to find out its version.
@heitor-lassarote pls add forge --version
output, looks like an older version as sources doesn't match crates/evm/core/src/backend/mod.rs:454
Also there's a good hint what happens: 2024-11-21T15:25:27.218837Z ERROR foundry_evm_core::fork::init: It looks like you're trying to fork from an older block with a non-archive node which is not supported. Please try to change your RPC url to an archive node if the issue persists.
nm, I see forge version now, that's quite old, you should run foundryup
and retest