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

Add mainnet deployment #119

Merged
merged 17 commits into from
Jun 26, 2024
Merged

Add mainnet deployment #119

merged 17 commits into from
Jun 26, 2024

Conversation

capossele
Copy link
Contributor

Closes #112

@capossele capossele requested a review from nategraf June 17, 2024 15:15
@capossele capossele self-assigned this Jun 18, 2024
@@ -114,15 +116,16 @@ You can deploy your contracts on a testnet such as `Sepolia` and run an end-to-e
3. Deploy your contract by running:

```bash
forge script script/Deploy.s.sol --rpc-url https://eth-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY:?} --broadcast
forge script script/Deploy.s.sol --rpc-url https://eth-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY:?} --broadcast --sig "run(string memory configFile)" -- "script/configs/sepolia/deploy_sepolia_config.json"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, this syntax with --sig is kind of hard to understand. Using an environment variable seems like it would be easier to understand.

forge script script/MainnetDeploy.s.sol --rpc-url https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY:?} --broadcast --sig "run(string memory configFile)" -- "script/configs/mainnet/deploy_mainnet_config.json"
```

This command uses the RISC Zero managed RiscZeroVerifierRouter contract (see https://etherscan.io/address/0x8EaB2D97Dfce405A1692a21b3ff3A172d593D319#code.output) and should output something similar to:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's link to our docs where the router is explained, rather than linking to Etherscan. If they don't already know what the router is, then this won't help them much. Same comment applied to Sepolia above.

https://dev.risczero.com/api/blockchain-integration/contracts/verifier#verifier-router

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added that reference directly to the config.toml; lemme know if you think adding it also to the guide makes more sense

export BONSAI_API_KEY="YOUR_API_KEY" # see form linked in the previous section
export BONSAI_API_URL="BONSAI_API_URL" # provided with your api key
export ALCHEMY_API_KEY="YOUR_ALCHEMY_API_KEY" # the API_KEY provided with an alchemy account
export ETH_WALLET_PRIVATE_KEY="YOUR_WALLET_PRIVATE_KEY" # the private hex-encoded key of your Sepolia testnet wallet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a typo here in that this should refer to their Mainnet wallet.

Suggested change
export ETH_WALLET_PRIVATE_KEY="YOUR_WALLET_PRIVATE_KEY" # the private hex-encoded key of your Sepolia testnet wallet
export ETH_WALLET_PRIVATE_KEY="YOUR_WALLET_PRIVATE_KEY" # the private hex-encoded key of your Mainnet wallet

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also raises a bigger issue, in that we don't out-of-the-box support any kind of secure wallet as we would expect them to use on mainnet. To an extent, this is alright since we can't support ever wallet type and we expect our developers to have some idea of how to integrate Forge with their chosen platform. But we should certainly do a bit more work to support this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally agree. Do you think we should address that on this PR as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some implementation for this in #122

@@ -44,4 +48,26 @@ contract EvenNumberDeploy is Script {

vm.stopBroadcast();
}

function run(string memory deployConfigPath) external {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's confusing that these two function have the same name. Additionally, taking an argument here causes use to use the weird syntax with --sig for the CLI. It would make more sense to me to have these be one function with an if in the middle that decides whether to deploy a new verifier or use an existing one.

address verifier_address = stdJson.readAddress(config_data, ".risc_zero_verifier_address");

IRiscZeroVerifier verifier = IRiscZeroVerifier(verifier_address);
console2.log("Using RiscZeroVerifierRouter contract deployed at", address(verifier));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This log should reference IRiscZeroVerifier since this could actually be implemented by a number of different contracts, depending on the address they use. (Make sure to update the logs copied into the deployment guide)

Suggested change
console2.log("Using RiscZeroVerifierRouter contract deployed at", address(verifier));
console2.log("Using IRiscZeroVerifier contract deployed at", address(verifier));

@@ -0,0 +1,3 @@
{
"risc_zero_verifier_address": "0x8EaB2D97Dfce405A1692a21b3ff3A172d593D319"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems odd to me to use snake_case in a JSON file. I usually see camelCase or kebab-case. I'd lean towards using camelCase here because Solidity uses it.

Suggested change
"risc_zero_verifier_address": "0x8EaB2D97Dfce405A1692a21b3ff3A172d593D319"
"riscZeroVerifierAddress": "0x8EaB2D97Dfce405A1692a21b3ff3A172d593D319"

@capossele capossele requested a review from nategraf June 25, 2024 11:27
@nategraf nategraf mentioned this pull request Jun 25, 2024
* refactor to make defaults based on the chainId and support deployment with ledger

* add note about the lack of support for hardware wallets

* run forge fmt
Copy link
Contributor

@nategraf nategraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've confirmed that the publisher step also works. Here is the contract I've deployed and set an even number on:
https://etherscan.io/address/0x0060518ffad3c2bcee309d308b9f68ec16ba7f85#readContract

@capossele capossele marked this pull request as ready for review June 26, 2024 09:10
@capossele capossele merged commit 0eefc99 into main Jun 26, 2024
3 checks passed
@capossele capossele deleted the capossele/mainnet-deployment branch June 26, 2024 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add mainnet deployment documetation for the Foundry template
2 participants