Cyfrin / foundry-devops

426 stars 53 forks source link

"No contract deployed" error, no known non-standard file location #2

Closed curi0n-s closed 1 year ago

curi0n-s commented 1 year ago

Hi, I'd like to sort out a "no contract deployed" error while deploying to the Arbitrum testnet. Here were the steps I took:

  1. forge init
  2. install foundry-devops
  3. deploy "ConfigManager" contract from src/ConfigManager.sol with script ConfigManager.s.sol (below)
  4. confirm that broadcast/ConfigManager.s.sol/421613/run-latest.json exists
  5. attempt to run GetConfigManager.s.sol which uses foundry-devops to retrieve the latest deployment
  6. get "No contract deployed" error
  7. check paths/try relative/absolute paths - nothing seems to be misplaced, still getting error
  8. scratch head for a while, time to ask the expert. glad to provide any other info

Thanks in advance for any advice!

-curion

ConfigManager.s.sol:

  pragma solidity ^0.8.15;

  import {ConfigManager} from "src/ConfigManager.sol";
  import "lib/forge-std/src/Script.sol";

  contract ConfigDeployScript is Script {

      ConfigManager public config;

      function run() public {
          vm.startBroadcast(vm.envUint("PRIVATE_KEY"));

          config = new ConfigManager();

          vm.stopBroadcast();
      }
  }

GetConfigManager.s.sol:

  pragma solidity ^0.8.15;

  import {DevOpsTools} from "lib/foundry-devops/src/DevOpsTools.sol";
  import {ConfigManager} from "src/ConfigManager.sol";
  import "lib/forge-std/src/Script.sol";

  contract GetConfigScript is Script {

      ConfigManager public config;
      uint256 public CHAIN_ID = 421613;

      function run() public {
          vm.startBroadcast(vm.envUint("PRIVATE_KEY"));

          address configAddress = DevOpsTools.get_most_recent_deployment("ConfigManager", CHAIN_ID);
          config = ConfigManager(configAddress); 

          vm.stopBroadcast();
      }

  }

Traces:

  [777837] → new DevOpsTools@0x4B56260B13555A87725dF82Fe524E0e7afB74409
    └─ ← 3885 bytes of code

  [362678] → new GetConfigScript@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519
    └─ ← 1477 bytes of code

  [76886] GetConfigScript::run()
    ├─ [0] VM::envUint(PRIVATE_KEY) [staticcall]
    │   └─ ← <env var value>
    ├─ [0] VM::startBroadcast(<pk>)
    │   └─ ← ()
    ├─ [46254] DevOpsTools::e374cdf1(00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000066eed000000000000000000000000000000000000000000000000000000000000000d436f6e6669674d616e6167657200000000000000000000000000000000000000) [delegatecall]
    │   ├─ [0] VM::ffi([pwd])
    │   │   └─ ← 0x2f686f6d652f637572696f6e2f63727970746f5f6465762f7a4b6172726f742f6b6172726f742d617262
    │   ├─ [0] VM::toString(421613) [staticcall]
    │   │   └─ ← 0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000063432313631330000000000000000000000000000000000000000000000000000
    │   ├─ [0] VM::ffi([bash, /home/curion/crypto_dev/projectname/projectname-arb/lib/foundry-devops/src/get_recent_deployment.sh, ConfigManager, 421613, /home/curion/crypto_dev/projectname/projectname-arb//broadcast])
    │   │   └─ ← 0x0000000000000000000000000000000000000000
    │   ├─ [0] console::log(Return Data:) [staticcall]
    │   │   └─ ← ()
    │   ├─ [0] console::log(0x0000000000000000000000000000000000000000) [staticcall]
    │   │   └─ ← ()
    │   └─ ← 0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000144e6f20636f6e7472616374206465706c6f796564000000000000000000000000
    └─ ← "No contract deployed"
PatrickAlphaC commented 1 year ago

Hmm... odd. Thanks for reporting.

Can you run this script and see what it gives you?

bash /home/curion/crypto_dev/projectname/projectname-arb/lib/foundry-devops/src/get_recent_deployment.sh ConfigManager 421613 /home/curion/crypto_dev/projectname/projectname-arb//broadcast

You can see in the logs that's the script it's running to find your recent deploys. If you look in the folder /home/curion/crypto_dev/projectname/projectname-arb//broadcast you should see it saved under latest-run or something. The script looks for the CREATE opcode.

curi0n-s commented 1 year ago

Ahh ok, I ran this, this gave me a "jq: command not found" error, so I ran (ubuntu) sudo apt-get install jq and that fixed things. I can now grab the latest address. Thanks for your help / maybe that will come in handy for someone else!