Skip to content

Commit

Permalink
read env, go through full flow e2e again
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstam committed Jun 26, 2024
1 parent 1148b71 commit c2e2cfb
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 14 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,17 @@ To deploy the contracts, ensure your [.env](./contracts/.env.example) file is co
Then you can use the `forge script` command and specify the specific contract you want to deploy. For example, to deploy the SP1 Verifier Gateway you can run:

```bash
FOUNDRY_PROFILE=deploy forge script SP1VerifierGatewayScript --private-key $PRIVATE_KEY --verify --verifier etherscan --multi --broadcast
FOUNDRY_PROFILE=deploy forge script ./script/deploy/SP1VerifierGateway.s.sol:SP1VerifierGatewayScript --private-key $PRIVATE_KEY --verify --verifier etherscan --multi --broadcast
```

To deploy a specific SP1 Verifier version and add it to the gateway, run:

```bash
FOUNDRY_PROFILE=deploy forge script ./script/deploy/v1.0.8-testnet/SP1Verifier.s.sol:SP1VerifierScript --private-key $PRIVATE_KEY --verify --verifier etherscan --multi --broadcast
```

Change `v1.0.8-testnet` to the desired version to add.

To re-verify already existing deployments, remove the `--broadcast` flag.

## For Developers: Integrate SP1 Contracts
Expand Down
7 changes: 3 additions & 4 deletions contracts/deployments/11155111.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"CREATE2_SALT": "0x0000000000000000000000000000000000000000000000000000000000000002",
"OWNER": "0xDEd0000E32f8F40414d3ab3a830f735a3553E18e",
"SP1_VERIFIER_GATEWAY": "0x810995869591a7a98f319c9802f452dabcea9937",
"V1_0_8_TESTNET_SP1_VERIFIER": "0x4588e29cbc2d715B7f8107140B9AA1Fd97Ba1083"
"SP1_VERIFIER_GATEWAY": "0x3B6041173B80E77f038f3F2C0f9744f04837185e",
"V1_0_7_TESTNET_SP1_VERIFIER": "0x331b350dDA287d0A65ce43103984CD44cb4Da9f0",
"V1_0_8_TESTNET_SP1_VERIFIER": "0xfE2bb0Ad7F2c44Bd1289234Af08aD6FDEC0d54a2"
}
7 changes: 3 additions & 4 deletions contracts/deployments/421614.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"CREATE2_SALT": "0x0000000000000000000000000000000000000000000000000000000000000002",
"OWNER": "0xDEd0000E32f8F40414d3ab3a830f735a3553E18e",
"SP1_VERIFIER_GATEWAY": "0x810995869591a7a98f319c9802f452dabcea9937",
"V1_0_8_TESTNET_SP1_VERIFIER": "0x4588e29cbc2d715B7f8107140B9AA1Fd97Ba1083"
"SP1_VERIFIER_GATEWAY": "0x3B6041173B80E77f038f3F2C0f9744f04837185e",
"V1_0_7_TESTNET_SP1_VERIFIER": "0x331b350dDA287d0A65ce43103984CD44cb4Da9f0",
"V1_0_8_TESTNET_SP1_VERIFIER": "0xfE2bb0Ad7F2c44Bd1289234Af08aD6FDEC0d54a2"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {console} from "forge-std/console.sol";
import {BaseScript} from "../utils/Base.s.sol";
import {SP1VerifierGateway} from "../../src/SP1VerifierGateway.sol";

Expand Down
1 change: 0 additions & 1 deletion contracts/script/deploy/v1.0.7-testnet/SP1Verifier.s.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {console} from "forge-std/console.sol";
import {BaseScript} from "../../utils/Base.s.sol";
import {SP1Verifier} from "../../../src/v1.0.7-testnet/SP1Verifier.sol";
import {SP1VerifierGateway} from "../../../src/SP1VerifierGateway.sol";
Expand Down
1 change: 0 additions & 1 deletion contracts/script/deploy/v1.0.8-testnet/SP1Verifier.s.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {console} from "forge-std/console.sol";
import {BaseScript} from "../../utils/Base.s.sol";
import {SP1Verifier} from "../../../src/v1.0.8-testnet/SP1Verifier.sol";
import {SP1VerifierGateway} from "../../../src/SP1VerifierGateway.sol";
Expand Down
20 changes: 18 additions & 2 deletions contracts/script/utils/Base.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,29 @@ abstract contract BaseScript is Script {
}
}

/// @notice Reads an address from the deployments file for the current chain.
/// @notice Tries to read an address from the env.
function envAddress(string memory key) internal view returns (address) {
return vm.envOr(key, address(0));
}

/// @notice Tries to read a bytes32 from the env.
function envBytes32(string memory key) internal view returns (bytes32) {
return vm.envOr(key, bytes32(0));
}

/// @notice Tries to read an address from the env first, then from the deployments file for the current chain.
function readAddress(string memory key) internal view returns (address) {
if (envAddress(key) != address(0)) {
return envAddress(key);
}
return deployments().readAddress(string.concat(".", key));
}

/// @notice Reads a bytes32 from the deployments file for the current chain.
/// @notice Tries to read a bytes32 from the env first, then from the deployments file for the current chain.
function readBytes32(string memory key) internal view returns (bytes32) {
if (envBytes32(key) != bytes32(0)) {
return envBytes32(key);
}
return deployments().readBytes32(string.concat(".", key));
}

Expand Down

0 comments on commit c2e2cfb

Please sign in to comment.