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

Deployment crashes #361

Open
2 tasks done
PatrickAlphaC opened this issue May 3, 2024 · 3 comments
Open
2 tasks done

Deployment crashes #361

PatrickAlphaC opened this issue May 3, 2024 · 3 comments
Labels

Comments

@PatrickAlphaC
Copy link
Collaborator

PatrickAlphaC commented May 3, 2024

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.0.2 (5ae06f9 2024-04-30T00:24:57.466082000Z)

What command(s) is the bug in?

forge script

Operating System

macOS (Intell)

Describe the bug

Zksync Testnet Issues

If you create a default project with forge init and try to deploy with a deploy script like such:

forge script script/Counter.s.sol --zksync --rpc-url zksync-sepolia --account yellow --sender $DEFAULT_SENDER --broadcast --verify -vvvv

After running the following script (and entering password for decrypting the yellow key), the program crashes with:


Script ran successfully.
Enter keystore password:

## Setting up 1 EVM.
==========================
Simulated On-chain Traces:

  [0] 0x0000000000000000000000000000000000000000::fallback()
    └─ ← <empty revert data>


Transactions saved to: xxx

Sensitive values saved to: xxx

Error: 
Failed to get EIP-1559 fees

This can be fixed by adding --legacy to the script (making them type0 transactions). You'll then have to update foundry.toml with the following:

[etherscan]
zksync-sepolia = { key = "${ETHERSCAN_API_KEY}", url = "https://explorer.sepolia.era.zksync.dev/contract_verification", chain = 300 }

Otherwise it'll fail with:

Chain 300

Estimated gas price: 0.264893396 gwei

Estimated total gas used for script: 469939

Estimated amount required: 0.000124483737622844 ETH

==========================

Transactions saved to:xxx

Sensitive values saved to: xxx

Error: 
Etherscan API key wasn't found for chain id 300. On-chain execution aborted

And then it will just freeze, and get stuck here forever:


###
Finding wallets for all the necessary addresses...
##
Sending transactions [0 - 0].
⠁ [00:00:00] [#################################################################################################################################] 1/1 txes (0.0s)
Transactions saved to: xxx/run-latest.json

Sensitive values saved to:xxx/run-latest.json

##
Waiting for receipts.
⠁ [00:00:00] [-----------------------------------------------------------------------------------------------------------------------------] 0/1 receipts (0.0s)

Requested action items

  1. Add docs for adding the sample config to the toml
  2. Figure out how to get past the EIP-1559 error
  3. Figure out how to get past the deployment freezing

ZkSync Mainne Issues

However, everything works "pretty good" for zksync mainnet, except, my contracts are not being verified. I get this in foundry:


ONCHAIN EXECUTION COMPLETE & SUCCESSFUL.
Total Paid: 0.000005884325 ETH (235373 gas * avg 0.025 gwei)

We haven't found any matching bytecode for the following contracts: [0xd3f8d13e3e1d0c978a242ea71b177e5d04586f4b].

This may occur when resuming a verification, but the underlying source code or compiler version has changed.
##
Start verification for (0) contracts
All (0) contracts were verified!

Transactions saved to: xxx

Sensitive values saved to:  xxx
@dutterbutter
Copy link
Collaborator

@PatrickAlphaC thanks for flagging. Will triage this accordingly.

@dutterbutter
Copy link
Collaborator

dutterbutter commented May 17, 2024

@PatrickAlphaC hmmm i cannot reproduce exactly....

Again --verify is not supported just yet so that needs to be removed from the cmd. Nonetheless the following command works fine for me:

forge script script/Counter.s.sol --zksync --rpc-url https://sepolia.era.zksync.dev --account yellow --sender $DEFAULT_SENDER --broadcast -vvvv

Steps taken to reproduce:

  1. Update to latest forge by re-executing the ./install-foundry-zksync script
  2. Run: forge init
  3. Setup ENV vars (DEFAULT_SENDER)
  4. Setup wallet import - alias to "yellow" with password
  5. Run: forge script script/Counter.s.sol --zksync --rpc-url https://sepolia.era.zksync.dev --account yellow --sender $DEFAULT_SENDER --broadcast -vvvv
  6. Output successful

Can you share the script you are executing? When I run forge init this is the script template provided:

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Script, console} from "forge-std/Script.sol";

contract CounterScript is Script {
    function setUp() public {}

    function run() public {
        vm.broadcast();
    }
}

I just want to confirm we are testing the same thing!

@ciaranightingale
Copy link

Hey @dutterbutter here are the exact steps to reproduce:

  • Setup a simple Foundry project (forge init to create a new project, run forge install, add testing vars to .env file & run source .env)
  • Add the following to the script/Counter.s.sol file to deploy the Counter contract:
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Script, console} from "forge-std/Script.sol";
+import {Counter} from "../src/Counter.sol";

contract CounterScript is Script {
    function setUp() public {}

    function run() public {
-        vm.broadcast();
+        vm.startBroadcast();
+        Counter counter = new Counter();
 +       vm.stopBroadcast();
    }
}
  • run the following command to deploy the contract:
forge script script/Counter.s.sol --rpc-url $ZKSYNC_SEPOLIA_RPC_URL --private-key $TEST_PRIVATE_KEY  --broadcast --zksync -vvvv

You will see the following error in the terminal output:

Error: 
Failed to get EIP-1559 fees

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

No branches or pull requests

3 participants