foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Forge Script could not estimate Gas

Open MiguelBits opened this issue 3 years ago • 3 comments

So I am forking olympus, and using forge scripts to deploy it.
It says transaction could not estimate gas, when deploying too many events. I comment them out and it works.
How can I not get this error? Would rather not change the olympus codebase.
It also uses my Ethereum to deploy all contracts, my when it reaches the fail point it does not revert

MiguelBits avatar Sep 08 '22 19:09 MiguelBits

pragma solidity ^0.7.5;

import "forge-std/Script.sol";
import "../src/BondDepositor.sol";
import "../src/OlympusAuthority.sol";
import "../src/interfaces/IOlympusAuthority.sol";
import "../src/interfaces/IgOHM.sol";
import "../src/interfaces/IERC20.sol";
import "../src/Staking.sol";
import "../src/interfaces/IStaking.sol";
import "../src/Treasury.sol";
import "../src/interfaces/ITreasury.sol";
import "../src/governance/gOHM.sol";
import "../src/sOlympusERC20.sol";
import "../src/OlympusERC20.sol";

//forge script script/DeployContract.s.sol:DeployBondScript --rpc-url $ARBITRUM_RINKEBY_RPC_URL  --private-key $PRIVATE_KEY --broadcast -vvvv

contract DeployBondScript is Script {

    OlympusBondDepositoryV2 bondDepositor;
    OlympusAuthority authority;
    OlympusStaking staking;
    OlympusTreasury treasury;
    gOHM gohm;
    sOlympus sohm;
    OlympusERC20Token ohm;

    //authority arguments
    address governer = address(1);
    address guardian = address(2);
    address policy = address(3);
    address vault = address(4);

    //staking arguments
    uint256 epochLength = 0;
    uint256 firstEpochNumber = 0;
    uint256 firstEpochTime = 0;

    //treasury arguments
    uint256 timelock = 0;

    function setUp() public {}

    function run() public {
        vm.startBroadcast();

        //Deploy ohm
        ohm = new OlympusERC20Token(governer);

        //Deploy sOhm
        sohm = new sOlympus();

        //Deploy gOhm
        gohm = new gOHM(governer, address(sohm));

        //Deploy Staking TODO: init arguments
        staking = new OlympusStaking(address(ohm), address(sohm), address(gohm), epochLength, firstEpochNumber, firstEpochTime, address(authority));

        // Deploy the Authority
        authority = new OlympusAuthority(msg.sender, msg.sender, msg.sender, msg.sender);

        //Deploy Treasury
        treasury = new OlympusTreasury(address(ohm), timelock, address(authority));

        // Deploy the bond contract
        bondDepositor = new OlympusBondDepositoryV2(IOlympusAuthority(address(authority)), IERC20(address(ohm)), IgOHM(address(gohm)), IStaking(address(staking)), ITreasury(address(treasury)));

        console2.log("ohm address: ", address(ohm));
        console2.log("sohm address: ", address(sohm));
        console2.log("gohm address: ", address(gohm));
        console2.log("staking address: ", address(staking));
        console2.log("authority address: ", address(authority));
        console2.log("treasury address: ", address(treasury));
        console2.log("bondDepositor address: ", address(bondDepositor));

        vm.stopBroadcast();
    }
}

MiguelBits avatar Sep 08 '22 19:09 MiguelBits

Please don't open issues unrelated to the book in the book repository

onbjerg avatar Sep 09 '22 12:09 onbjerg

could please elaborate a bit more on the issue you're facing from reading this it's not perfectly clear to me I'm afraid

So I am forking olympus, and using forge scripts to deploy it.

on arbitrum?

It says transaction could not estimate gas, when deploying too many events. I comment them out and it works.

what's the error? what command?

It also uses my Ethereum to deploy all contracts, my when it reaches the fail point it does not revert

what's the fail point? it succeeds but there should be an error?

mattsse avatar Sep 09 '22 12:09 mattsse

Going to close this as stale.

@MiguelBits if you can answer @mattsse's questions and provide a repo we can clone/run to reproduce that would be great, and we can reopen

mds1 avatar Apr 11 '23 22:04 mds1