Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,13 @@ slither .
To simulate deployment on sepolia, run

```sh
forge script script/Deploy.s.sol:Deploy \
--rpc-url sepolia
forge script script/DeployProtocolAdapter.s.sol:DeployProtocolAdapter --rpc-url sepolia
```

Append the

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

Expand Down
14 changes: 1 addition & 13 deletions contracts/.env-example
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
## RPC Providers

API_KEY_INFURA=<API_KEY_INFURA_KEY>
API_KEY_ALCHEMY=<API_KEY_ALCHEMY>

## Block Explorers

## Block Explorers (see https://docs.etherscan.io/etherscan-v2)
API_KEY_ETHERSCAN=<API_KEY_ETHERSCAN>
API_KEY_POLYGONSCAN=<API_KEY_POLYGONSCAN>
API_KEY_ARBISCAN=<API_KEY_ARBISCAN>
API_KEY_BASESCAN=<API_KEY_BASESCAN>

API_KEY_OPTIMISTIC_ETHERSCAN=<API_KEY_OPTIMISTIC_ETHERSCAN>
API_KEY_SNOWTRACE=<API_KEY_SNOWTRACE>
API_KEY_BSCSCAN=<API_KEY_BSCSCAN>
API_KEY_GNOSISSCAN=<API_KEY_GNOSISSCAN>

## Deploying Wallet

MNEMONIC="test test test test test test test test test test test junk"
36 changes: 9 additions & 27 deletions contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,36 +51,18 @@ fuzz = { runs = 10_000 }
verbosity = 4

[etherscan]
arbitrum = { key = "${API_KEY_ARBISCAN}" }
avalanche = { key = "${API_KEY_SNOWTRACE}" }
base = { key = "${API_KEY_BASESCAN}" }
bnb_smart_chain = { key = "${API_KEY_BSCSCAN}" }
gnosis_chain = { key = "${API_KEY_GNOSISSCAN}" }
goerli = { key = "${API_KEY_ETHERSCAN}" }
mainnet = { key = "${API_KEY_ETHERSCAN}" }
optimism = { key = "${API_KEY_OPTIMISTIC_ETHERSCAN}" }
polygon = { key = "${API_KEY_POLYGONSCAN}" }
sepolia = { key = "${API_KEY_ETHERSCAN}" }
arbitrum = { key = "${API_KEY_ETHERSCAN}" }
arbitrum-sepolia = { key = "${API_KEY_ETHERSCAN}" }
base = { key = "${API_KEY_ETHERSCAN}" }
base-sepolia = { key = "${API_KEY_ETHERSCAN}" }

[rpc_endpoints]
#arbitrum = "https://arbitrum-mainnet.infura.io/v3/${API_KEY_INFURA}"
#avalanche = "https://avalanche-mainnet.infura.io/v3/${API_KEY_INFURA}"
#base = "https://mainnet.base.org"
#bnb_smart_chain = "https://bsc-dataseed.binance.org"
#gnosis_chain = "https://rpc.gnosischain.com"
#localhost = "http://localhost:8545"
#mainnet = "https://mainnet.infura.io/v3/${API_KEY_INFURA}"
#optimism = "https://optimism-mainnet.infura.io/v3/${API_KEY_INFURA}"
#polygon = "https://polygon-mainnet.infura.io/v3/${API_KEY_INFURA}"
#sepolia = "https://sepolia.infura.io/v3/${API_KEY_INFURA}"

arbitrum = "https://arb-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
avalanche = "https://avax-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
base = "https://mainnet.base.org"
bnb_smart_chain = "https://bsc-dataseed.binance.org"
gnosis_chain = "https://rpc.gnosischain.com"
localhost = "http://localhost:8545"
mainnet = "https://eth-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
optimism = "https://opt-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
polygon = "https://polygon-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
sepolia = "https://eth-sepolia.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
arbitrum = "https://arb-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
arbitrum-sepolia = "https://arb-sepolia.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
base = "https://base-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
base-sepolia = "https://base-sepolia.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
localhost = "http://localhost:8545"
23 changes: 14 additions & 9 deletions contracts/script/DeployProtocolAdapter.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,26 @@ import {Script} from "forge-std/Script.sol";
import {ProtocolAdapter} from "../src/ProtocolAdapter.sol";

contract DeployProtocolAdapter is Script {
function run() public returns (address protocolAdapter) {
string memory path = "script/constructor-args.txt";

RiscZeroVerifierRouter trustedSepoliaVerifierRouter = RiscZeroVerifierRouter(vm.parseAddress(vm.readLine(path)));
mapping(uint256 chainId => string network) internal _networks;
mapping(string network => RiscZeroVerifierRouter router) internal _routers;

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

uint8 actionTagTreeDepth = uint8(vm.parseUint(vm.readLine(path)));
_routers["sepolia"] = RiscZeroVerifierRouter(0x925d8331ddc0a1F0d96E68CF073DFE1d92b69187);
_routers["arbitrum-sepolia"] = RiscZeroVerifierRouter(0x0b144E07A0826182B6b59788c34b32Bfa86Fb711);
_routers["base-sepolia"] = RiscZeroVerifierRouter(0x0b144E07A0826182B6b59788c34b32Bfa86Fb711);
}

function run() public returns (address protocolAdapter) {
vm.startBroadcast();
protocolAdapter = address(
new ProtocolAdapter{salt: sha256("ProtocolAdapterDraft")}({
riscZeroVerifierRouter: trustedSepoliaVerifierRouter,
commitmentTreeDepth: commitmentTreeDepth,
actionTagTreeDepth: actionTagTreeDepth
riscZeroVerifierRouter: _routers[_networks[block.chainid]],
commitmentTreeDepth: 32,
actionTagTreeDepth: 4
})
);
vm.stopBroadcast();
Expand Down
6 changes: 6 additions & 0 deletions contracts/src/ProtocolAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ contract ProtocolAdapter is IProtocolAdapter, ReentrancyGuardTransient, Commitme

uint256 internal _txCount;

error ZeroNotAllowed();

error ForwarderCallOutputMismatch(bytes expected, bytes actual);

error ResourceLifecycleMismatch(bool expected);
Expand All @@ -62,6 +64,10 @@ contract ProtocolAdapter is IProtocolAdapter, ReentrancyGuardTransient, Commitme
_TRUSTED_RISC_ZERO_VERIFIER_ROUTER = riscZeroVerifierRouter;
_ACTION_TAG_TREE_DEPTH = actionTagTreeDepth;

if (address(riscZeroVerifierRouter) == address(0)) {
revert ZeroNotAllowed();
}

// Sanity check that the verifier has not been stopped already.
if (isEmergencyStopped()) {
revert RiscZeroVerifierStopped();
Expand Down
Loading