Skip to content

Commit d827b59

Browse files
committed
Merge remote-tracking branch 'origin/feature/improve-deploy-script-rebase'
2 parents 6d303ca + ef4b02b commit d827b59

File tree

5 files changed

+32
-52
lines changed

5 files changed

+32
-52
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,13 @@ slither .
119119
To simulate deployment on sepolia, run
120120

121121
```sh
122-
forge script script/Deploy.s.sol:Deploy \
123-
--rpc-url sepolia
122+
forge script script/DeployProtocolAdapter.s.sol:DeployProtocolAdapter --rpc-url sepolia
124123
```
125124

126125
Append the
127126

128127
- `--broadcast` flag to deploy on sepolia
129-
- `--verify` flag for subsequent contract verification on Etherscan
128+
- `--verify --slow` flags for subsequent contract verification on Etherscan (`--slow` adds 15 seconds of waiting time between verification attempts)
130129
- `--account <ACCOUNT_NAME>` flag to use a previously imported keystore (see
131130
`cast wallet --help` for more info)
132131

contracts/.env-example

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
11
## RPC Providers
2-
3-
API_KEY_INFURA=<API_KEY_INFURA_KEY>
42
API_KEY_ALCHEMY=<API_KEY_ALCHEMY>
53

6-
## Block Explorers
7-
4+
## Block Explorers (see https://docs.etherscan.io/etherscan-v2)
85
API_KEY_ETHERSCAN=<API_KEY_ETHERSCAN>
9-
API_KEY_POLYGONSCAN=<API_KEY_POLYGONSCAN>
10-
API_KEY_ARBISCAN=<API_KEY_ARBISCAN>
11-
API_KEY_BASESCAN=<API_KEY_BASESCAN>
12-
13-
API_KEY_OPTIMISTIC_ETHERSCAN=<API_KEY_OPTIMISTIC_ETHERSCAN>
14-
API_KEY_SNOWTRACE=<API_KEY_SNOWTRACE>
15-
API_KEY_BSCSCAN=<API_KEY_BSCSCAN>
16-
API_KEY_GNOSISSCAN=<API_KEY_GNOSISSCAN>
176

187
## Deploying Wallet
19-
208
MNEMONIC="test test test test test test test test test test test junk"

contracts/foundry.toml

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,36 +51,18 @@ fuzz = { runs = 10_000 }
5151
verbosity = 4
5252

5353
[etherscan]
54-
arbitrum = { key = "${API_KEY_ARBISCAN}" }
55-
avalanche = { key = "${API_KEY_SNOWTRACE}" }
56-
base = { key = "${API_KEY_BASESCAN}" }
57-
bnb_smart_chain = { key = "${API_KEY_BSCSCAN}" }
58-
gnosis_chain = { key = "${API_KEY_GNOSISSCAN}" }
59-
goerli = { key = "${API_KEY_ETHERSCAN}" }
6054
mainnet = { key = "${API_KEY_ETHERSCAN}" }
61-
optimism = { key = "${API_KEY_OPTIMISTIC_ETHERSCAN}" }
62-
polygon = { key = "${API_KEY_POLYGONSCAN}" }
6355
sepolia = { key = "${API_KEY_ETHERSCAN}" }
56+
arbitrum = { key = "${API_KEY_ETHERSCAN}" }
57+
arbitrum-sepolia = { key = "${API_KEY_ETHERSCAN}" }
58+
base = { key = "${API_KEY_ETHERSCAN}" }
59+
base-sepolia = { key = "${API_KEY_ETHERSCAN}" }
6460

6561
[rpc_endpoints]
66-
#arbitrum = "https://arbitrum-mainnet.infura.io/v3/${API_KEY_INFURA}"
67-
#avalanche = "https://avalanche-mainnet.infura.io/v3/${API_KEY_INFURA}"
68-
#base = "https://mainnet.base.org"
69-
#bnb_smart_chain = "https://bsc-dataseed.binance.org"
70-
#gnosis_chain = "https://rpc.gnosischain.com"
71-
#localhost = "http://localhost:8545"
72-
#mainnet = "https://mainnet.infura.io/v3/${API_KEY_INFURA}"
73-
#optimism = "https://optimism-mainnet.infura.io/v3/${API_KEY_INFURA}"
74-
#polygon = "https://polygon-mainnet.infura.io/v3/${API_KEY_INFURA}"
75-
#sepolia = "https://sepolia.infura.io/v3/${API_KEY_INFURA}"
76-
77-
arbitrum = "https://arb-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
78-
avalanche = "https://avax-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
79-
base = "https://mainnet.base.org"
80-
bnb_smart_chain = "https://bsc-dataseed.binance.org"
81-
gnosis_chain = "https://rpc.gnosischain.com"
82-
localhost = "http://localhost:8545"
8362
mainnet = "https://eth-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
84-
optimism = "https://opt-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
85-
polygon = "https://polygon-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
8663
sepolia = "https://eth-sepolia.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
64+
arbitrum = "https://arb-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
65+
arbitrum-sepolia = "https://arb-sepolia.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
66+
base = "https://base-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
67+
base-sepolia = "https://base-sepolia.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
68+
localhost = "http://localhost:8545"

contracts/script/DeployProtocolAdapter.s.sol

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,26 @@ import {Script} from "forge-std/Script.sol";
88
import {ProtocolAdapter} from "../src/ProtocolAdapter.sol";
99

1010
contract DeployProtocolAdapter is Script {
11-
function run() public returns (address protocolAdapter) {
12-
string memory path = "script/constructor-args.txt";
13-
14-
RiscZeroVerifierRouter trustedSepoliaVerifierRouter = RiscZeroVerifierRouter(vm.parseAddress(vm.readLine(path)));
11+
mapping(uint256 chainId => string network) internal _networks;
12+
mapping(string network => RiscZeroVerifierRouter router) internal _routers;
1513

16-
uint8 commitmentTreeDepth = uint8(vm.parseUint(vm.readLine(path)));
14+
constructor() {
15+
_networks[11155111] = "sepolia";
16+
_networks[421614] = "arbitrum-sepolia";
17+
_networks[84532] = "base-sepolia";
1718

18-
uint8 actionTagTreeDepth = uint8(vm.parseUint(vm.readLine(path)));
19+
_routers["sepolia"] = RiscZeroVerifierRouter(0x925d8331ddc0a1F0d96E68CF073DFE1d92b69187);
20+
_routers["arbitrum-sepolia"] = RiscZeroVerifierRouter(0x0b144E07A0826182B6b59788c34b32Bfa86Fb711);
21+
_routers["base-sepolia"] = RiscZeroVerifierRouter(0x0b144E07A0826182B6b59788c34b32Bfa86Fb711);
22+
}
1923

24+
function run() public returns (address protocolAdapter) {
2025
vm.startBroadcast();
2126
protocolAdapter = address(
2227
new ProtocolAdapter{salt: sha256("ProtocolAdapterDraft")}({
23-
riscZeroVerifierRouter: trustedSepoliaVerifierRouter,
24-
commitmentTreeDepth: commitmentTreeDepth,
25-
actionTagTreeDepth: actionTagTreeDepth
28+
riscZeroVerifierRouter: _routers[_networks[block.chainid]],
29+
commitmentTreeDepth: 32,
30+
actionTagTreeDepth: 4
2631
})
2732
);
2833
vm.stopBroadcast();

contracts/src/ProtocolAdapter.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ contract ProtocolAdapter is IProtocolAdapter, ReentrancyGuardTransient, Commitme
4040

4141
uint256 internal _txCount;
4242

43+
error ZeroNotAllowed();
44+
4345
error ForwarderCallOutputMismatch(bytes expected, bytes actual);
4446
error ResourceCountMismatch(uint256 expected, uint256 actual);
4547
error RootMismatch(bytes32 expected, bytes32 actual);
@@ -60,6 +62,10 @@ contract ProtocolAdapter is IProtocolAdapter, ReentrancyGuardTransient, Commitme
6062
_TRUSTED_RISC_ZERO_VERIFIER_ROUTER = riscZeroVerifierRouter;
6163
_ACTION_TAG_TREE_DEPTH = actionTagTreeDepth;
6264

65+
if (address(riscZeroVerifierRouter) == address(0)) {
66+
revert ZeroNotAllowed();
67+
}
68+
6369
// Sanity check that the verifier has not been stopped already.
6470
if (isEmergencyStopped()) {
6571
revert RiscZeroVerifierStopped();

0 commit comments

Comments
 (0)