Skip to content

Commit

Permalink
Hyperclient Improvements (#331)
Browse files Browse the repository at this point in the history
Co-authored-by: David Salami <[email protected]>
  • Loading branch information
seunlanlege and Wizdave97 authored Oct 30, 2024
1 parent d2322e8 commit 23971dc
Show file tree
Hide file tree
Showing 45 changed files with 917 additions and 710 deletions.
26 changes: 20 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions evm/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ optimizer = true
#via-ir = true

[rpc_endpoints]
sepolia = "${SEPOLIA_RPC_URL}"
ethereum-sepolia = "${SEPOLIA_RPC_URL}"
optimism-sepolia = "${OPTIMISM_SEPOLIA_RPC_URL}"
arbitrum-sepolia = "${ARBITRUM_SEPOLIA_RPC_URL}"
base-sepolia = "${BASE_SEPOLIA_RPC_URL}"
polygon-mumbai = "${POLYGON_MUMBAI_RPC_URL}"
bsc-testnet = "${BSC_TESTNET_RPC_URL}"
chiado = "${CHIADO_RPC_URL}"
gnosis-chiado = "${CHIADO_RPC_URL}"

[etherscan]
# testnet
sepolia = { key = "${ETHEREUM_ETHERSCAN_API_KEY}", chain = 11155111, url = "https://api-sepolia.etherscan.io/api" }
ethereum-sepolia = { key = "${ETHEREUM_ETHERSCAN_API_KEY}", chain = 11155111, url = "https://api-sepolia.etherscan.io/api" }
optimism-sepolia = { key = "${OPTIMISM_ETHERSCAN_API_KEY}", chain = 11155420, url = "https://api-sepolia-optimistic.etherscan.io/api" }
arbitrum-sepolia = { key = "${ARBITRUM_ETHERSCAN_API_KEY}", chain = 421614, url = "https://api-sepolia.arbiscan.io/api" }
base-sepolia = { key = "${BASE_ETHERSCAN_API_KEY}", chain = 84532, url = "https://api-sepolia.basescan.org/api" }
polygon-mumbai = { key = "${POLYGON_ETHERSCAN_API_KEY}", chain = 80001, url = "https://api-testnet.polygonscan.com/api" }
bsc-testnet = { key = "${BSC_ETHERSCAN_API_KEY}", chain = 97, url = "https://api-testnet.bscscan.com/api" }
chiado = { key = "${GNOSIS_BLOCKSCOUT_API_KEY}", chain = 10200, url = "https://gnosis-chiado.blockscout.com/api" }
gnosis-chiado = { key = "${GNOSIS_BLOCKSCOUT_API_KEY}", chain = 10200, url = "https://gnosis-chiado.blockscout.com/api" }

# mainnet
2 changes: 1 addition & 1 deletion evm/lib/sp1-contracts
Submodule sp1-contracts updated 45 files
+3 −1 .gitmodules
+408 −668 Cargo.lock
+1 −1 Cargo.toml
+4 −4 README.md
+21 −7 UPDATE_CONTRACTS.md
+4 −1 contracts/.env.example
+3 −1 contracts/deployments/1.json
+3 −1 contracts/deployments/10.json
+8 −1 contracts/deployments/11155111.json
+7 −1 contracts/deployments/11155420.json
+7 −1 contracts/deployments/17000.json
+3 −1 contracts/deployments/42161.json
+7 −1 contracts/deployments/421614.json
+7 −1 contracts/deployments/534351.json
+3 −1 contracts/deployments/534352.json
+3 −1 contracts/deployments/8453.json
+7 −1 contracts/deployments/84532.json
+38 −0 contracts/script/deploy/v3.0.0-rc1/SP1VerifierGroth16.s.sol
+38 −0 contracts/script/deploy/v3.0.0-rc1/SP1VerifierPlonk.s.sol
+38 −0 contracts/script/deploy/v3.0.0-rc3/SP1VerifierGroth16.s.sol
+38 −0 contracts/script/deploy/v3.0.0-rc3/SP1VerifierPlonk.s.sol
+38 −0 contracts/script/deploy/v3.0.0-rc4/SP1VerifierGroth16.s.sol
+38 −0 contracts/script/deploy/v3.0.0-rc4/SP1VerifierPlonk.s.sol
+38 −0 contracts/script/deploy/v3.0.0/SP1VerifierGroth16.s.sol
+38 −0 contracts/script/deploy/v3.0.0/SP1VerifierPlonk.s.sol
+578 −0 contracts/src/v3.0.0-rc1/Groth16Verifier.sol
+1,375 −0 contracts/src/v3.0.0-rc1/PlonkVerifier.sol
+57 −0 contracts/src/v3.0.0-rc1/SP1VerifierGroth16.sol
+59 −0 contracts/src/v3.0.0-rc1/SP1VerifierPlonk.sol
+578 −0 contracts/src/v3.0.0-rc3/Groth16Verifier.sol
+1,379 −0 contracts/src/v3.0.0-rc3/PlonkVerifier.sol
+57 −0 contracts/src/v3.0.0-rc3/SP1VerifierGroth16.sol
+59 −0 contracts/src/v3.0.0-rc3/SP1VerifierPlonk.sol
+578 −0 contracts/src/v3.0.0-rc4/Groth16Verifier.sol
+1,379 −0 contracts/src/v3.0.0-rc4/PlonkVerifier.sol
+57 −0 contracts/src/v3.0.0-rc4/SP1VerifierGroth16.sol
+59 −0 contracts/src/v3.0.0-rc4/SP1VerifierPlonk.sol
+578 −0 contracts/src/v3.0.0/Groth16Verifier.sol
+1,379 −0 contracts/src/v3.0.0/PlonkVerifier.sol
+57 −0 contracts/src/v3.0.0/SP1VerifierGroth16.sol
+59 −0 contracts/src/v3.0.0/SP1VerifierPlonk.sol
+1 −1 contracts/test/SP1VerifierGateway.t.sol
+4 −4 contracts/test/SP1VerifierGroth16.t.sol
+4 −4 contracts/test/SP1VerifierPlonk.t.sol
+83 −20 src/bin/artifacts.rs
12 changes: 6 additions & 6 deletions evm/script/BaseScript.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import "forge-std/Script.sol";
abstract contract BaseScript is Script {
bytes32 public salt = keccak256(bytes(vm.envString("VERSION")));

address payable internal SEPOLIA_HOST = payable(vm.envAddress("SEPOLIA_HOST"));
address payable internal ARB_SEPOLIA_HOST = payable(vm.envAddress("ARB_SEPOLIA_HOST"));
address payable internal OP_SEPOLIA_HOST = payable(vm.envAddress("OP_SEPOLIA_HOST"));
address payable internal BASE_SEPOLIA_HOST = payable(vm.envAddress("BASE_SEPOLIA_HOST"));
address payable internal BSC_TESTNET_HOST = payable(vm.envAddress("BSC_TESTNET_HOST"));
address payable internal CHIADO_HOST = payable(vm.envAddress("CHIADO_HOST"));
address payable internal ETHEREUM_HOST = payable(vm.envAddress("ETHEREUM_HOST"));
address payable internal ARBITRUM_HOST = payable(vm.envAddress("ARBITRUM_HOST"));
address payable internal OPTIMISM_HOST = payable(vm.envAddress("OPTIMISM_HOST"));
address payable internal BASE_HOST = payable(vm.envAddress("BASE_HOST"));
address payable internal BNB_HOST = payable(vm.envAddress("BNB_HOST"));
address payable internal GNOSIS_HOST = payable(vm.envAddress("GNOSIS_HOST"));
address payable internal FEE_TOKEN = payable(vm.envAddress("FEE_TOKEN"));

bytes32 internal privateKey = vm.envBytes32("PRIVATE_KEY");
Expand Down
42 changes: 23 additions & 19 deletions evm/script/DeployGateway.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
pragma solidity ^0.8.17;

import "forge-std/Script.sol";
import "stringutils/strings.sol";

import {ERC6160Ext20} from "@polytope-labs/erc6160/tokens/ERC6160Ext20.sol";
import {IERC6160Ext20} from "@polytope-labs/erc6160/interfaces/IERC6160Ext20.sol";
import {TokenGateway, Asset, TokenGatewayParamsExt, TokenGatewayParams, AssetMetadata} from "../src/modules/TokenGateway.sol";
Expand All @@ -11,37 +13,39 @@ import {BaseScript} from "./BaseScript.sol";
import {IIsmpHost} from "@polytope-labs/ismp-solidity/IIsmpHost.sol";

contract DeployScript is BaseScript {
using strings for *;

bytes32 public constant MINTER_ROLE = keccak256("MINTER ROLE");
bytes32 public constant BURNER_ROLE = keccak256("BURNER ROLE");

function run() external {
function run() external {
// todo:
address callDispatcher = address(1);

if (equal(host, "sepolia") || equal(host, "ethereum")) {
if (host.toSlice().startsWith("ethereum".toSlice())) {
vm.startBroadcast(uint256(privateKey));
deployInscription(SEPOLIA_HOST, admin);
deployGateway(SEPOLIA_HOST, admin, callDispatcher);
} else if (equal(host, "arbitrum-sepolia")) {
deployInscription(ETHEREUM_HOST, admin);
deployGateway(ETHEREUM_HOST, admin, callDispatcher);
} else if (host.toSlice().startsWith("arbitrum".toSlice())) {
vm.startBroadcast(uint256(privateKey));
deployInscription(ARB_SEPOLIA_HOST, admin);
deployGateway(ARB_SEPOLIA_HOST, admin, callDispatcher);
} else if (equal(host, "optimism-sepolia")) {
deployInscription(ARBITRUM_HOST, admin);
deployGateway(ARBITRUM_HOST, admin, callDispatcher);
} else if (host.toSlice().startsWith("optimism".toSlice())) {
vm.startBroadcast(uint256(privateKey));
deployInscription(OP_SEPOLIA_HOST, admin);
deployGateway(OP_SEPOLIA_HOST, admin, callDispatcher);
} else if (equal(host, "base-sepolia")) {
deployInscription(OPTIMISM_HOST, admin);
deployGateway(OPTIMISM_HOST, admin, callDispatcher);
} else if (host.toSlice().startsWith("base".toSlice())) {
vm.startBroadcast(uint256(privateKey));
deployInscription(BASE_SEPOLIA_HOST, admin);
deployGateway(BASE_SEPOLIA_HOST, admin, callDispatcher);
} else if (equal(host, "bsc-testnet")) {
deployInscription(BASE_HOST, admin);
deployGateway(BASE_HOST, admin, callDispatcher);
} else if (host.toSlice().startsWith("bsc".toSlice())) {
vm.startBroadcast(uint256(privateKey));
deployInscription(BSC_TESTNET_HOST, admin);
deployGateway(BSC_TESTNET_HOST, admin, callDispatcher);
} else if (equal(host, "chiado")) {
deployInscription(BNB_HOST, admin);
deployGateway(BNB_HOST, admin, callDispatcher);
} else if (host.toSlice().startsWith("gnosis".toSlice())) {
vm.startBroadcast(uint256(privateKey));
deployInscription(CHIADO_HOST, admin);
deployGateway(CHIADO_HOST, admin, callDispatcher);
deployInscription(GNOSIS_HOST, admin);
deployGateway(GNOSIS_HOST, admin, callDispatcher);
}
}

Expand Down
28 changes: 14 additions & 14 deletions evm/script/DeployHostUpdates.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,36 @@ contract DeployScript is BaseScript {
// HandlerV1 handler = new HandlerV1();
BeefyV1 consensusClient = new BeefyV1{salt: salt}();

if (equal(host, "sepolia") || host.toSlice().startsWith("eth".toSlice())) {
HostParams memory params = EvmHost(SEPOLIA_HOST).hostParams();
if (host.toSlice().startsWith("ethereum".toSlice())) {
HostParams memory params = EvmHost(ETHEREUM_HOST).hostParams();
params.consensusClient = address(consensusClient);
// params.handler = address(handler);
EvmHost(SEPOLIA_HOST).updateHostParams(params);
EvmHost(ETHEREUM_HOST).updateHostParams(params);
} else if (host.toSlice().startsWith("arbitrum".toSlice())) {
HostParams memory params = EvmHost(ARB_SEPOLIA_HOST).hostParams();
HostParams memory params = EvmHost(ARBITRUM_HOST).hostParams();
params.consensusClient = address(consensusClient);
// params.handler = address(handler);
EvmHost(ARB_SEPOLIA_HOST).updateHostParams(params);
EvmHost(ARBITRUM_HOST).updateHostParams(params);
} else if (host.toSlice().startsWith("optimism".toSlice())) {
HostParams memory params = EvmHost(OP_SEPOLIA_HOST).hostParams();
HostParams memory params = EvmHost(OPTIMISM_HOST).hostParams();
params.consensusClient = address(consensusClient);
// params.handler = address(handler);
EvmHost(OP_SEPOLIA_HOST).updateHostParams(params);
EvmHost(OPTIMISM_HOST).updateHostParams(params);
} else if (host.toSlice().startsWith("base".toSlice())) {
HostParams memory params = EvmHost(BASE_SEPOLIA_HOST).hostParams();
HostParams memory params = EvmHost(BASE_HOST).hostParams();
params.consensusClient = address(consensusClient);
// params.handler = address(handler);
EvmHost(BASE_SEPOLIA_HOST).updateHostParams(params);
EvmHost(BASE_HOST).updateHostParams(params);
} else if (host.toSlice().startsWith("bsc".toSlice())) {
HostParams memory params = EvmHost(BSC_TESTNET_HOST).hostParams();
HostParams memory params = EvmHost(BNB_HOST).hostParams();
params.consensusClient = address(consensusClient);
// params.handler = address(handler);
EvmHost(BSC_TESTNET_HOST).updateHostParams(params);
} else if (host.toSlice().startsWith("chiado".toSlice())) {
HostParams memory params = EvmHost(CHIADO_HOST).hostParams();
EvmHost(BNB_HOST).updateHostParams(params);
} else if (host.toSlice().startsWith("gnosis".toSlice())) {
HostParams memory params = EvmHost(GNOSIS_HOST).hostParams();
params.consensusClient = address(consensusClient);
// params.handler = address(handler);
EvmHost(CHIADO_HOST).updateHostParams(params);
EvmHost(GNOSIS_HOST).updateHostParams(params);
} else {
revert("Unknown Host");
}
Expand Down
33 changes: 33 additions & 0 deletions evm/script/DeployInscriptions.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;

import "forge-std/Script.sol";
import "stringutils/strings.sol";

import {CrossChainInscription} from "../src/modules/Inscriptions.sol";
import {BaseScript} from "./BaseScript.sol";

contract DeployScript is BaseScript {
using strings for *;

function run() external {
vm.startBroadcast(uint256(privateKey));
CrossChainInscription module = new CrossChainInscription{salt: salt}(admin);

if (host.toSlice().startsWith("ethereum".toSlice())) {
module.setHost(ETHEREUM_HOST);
} else if (host.toSlice().startsWith("arbitrum".toSlice())) {
module.setHost(ARBITRUM_HOST);
} else if (host.toSlice().startsWith("optimism".toSlice())) {
module.setHost(OPTIMISM_HOST);
} else if (host.toSlice().startsWith("base".toSlice())) {
module.setHost(BASE_HOST);
} else if (host.toSlice().startsWith("bsc".toSlice())) {
module.setHost(BNB_HOST);
} else if (host.toSlice().startsWith("gnosis".toSlice())) {
module.setHost(GNOSIS_HOST);
}

vm.stopBroadcast();
}
}
6 changes: 3 additions & 3 deletions evm/script/DeployIsmp.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {PingModule} from "../examples/PingModule.sol";
import {BscHost} from "../src/hosts/Bsc.sol";
import {PolygonHost} from "../src/hosts/Polygon.sol";

// import {SP1Verifier} from "@sp1-contracts/v2.0.0/SP1VerifierPlonk.sol";
// import {SP1Verifier} from "@sp1-contracts/v3.0.0/SP1VerifierGroth16.sol";
// import {SP1Beefy} from "../src/consensus/SP1Beefy.sol";
import {BeefyV1} from "../src/consensus/BeefyV1.sol";
import {StateMachine} from "@polytope-labs/ismp-solidity/StateMachine.sol";
Expand Down Expand Up @@ -95,7 +95,7 @@ contract DeployScript is BaseScript {
}

function initHost(HostParams memory params) public returns (address) {
if (equal(host, "sepolia") || host.toSlice().startsWith("eth".toSlice())) {
if (host.toSlice().startsWith("ethereum".toSlice())) {
EthereumHost h = new EthereumHost{salt: salt}(params);
return address(h);
} else if (host.toSlice().startsWith("arbitrum".toSlice())) {
Expand All @@ -113,7 +113,7 @@ contract DeployScript is BaseScript {
} else if (host.toSlice().startsWith("polygon".toSlice())) {
PolygonHost h = new PolygonHost{salt: salt}(params);
return address(h);
} else if (host.toSlice().startsWith("chiado".toSlice())) {
} else if (host.toSlice().startsWith("gnosis".toSlice())) {
GnosisHost h = new GnosisHost{salt: salt}(params);
return address(h);
}
Expand Down
24 changes: 14 additions & 10 deletions evm/script/DeployPing.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,33 @@
pragma solidity ^0.8.17;

import "forge-std/Script.sol";
import "stringutils/strings.sol";

import {ERC6160Ext20} from "@polytope-labs/erc6160/tokens/ERC6160Ext20.sol";

import {PingModule} from "../examples/PingModule.sol";
import {BaseScript} from "./BaseScript.sol";

contract DeployScript is BaseScript {
using strings for *;

function run() external {
address admin = vm.envAddress("ADMIN");
address tokenFaucet = vm.envAddress("TOKEN_FAUCET");

vm.startBroadcast(uint256(privateKey));
PingModule ping = new PingModule{salt: salt}(admin);

if (equal(host, "sepolia") || equal(host, "ethereum")) {
ping.setIsmpHost(SEPOLIA_HOST, tokenFaucet);
} else if (equal(host, "arbitrum-sepolia")) {
ping.setIsmpHost(ARB_SEPOLIA_HOST, tokenFaucet);
} else if (equal(host, "optimism-sepolia")) {
ping.setIsmpHost(OP_SEPOLIA_HOST, tokenFaucet);
} else if (equal(host, "base-sepolia")) {
ping.setIsmpHost(BASE_SEPOLIA_HOST, tokenFaucet);
} else if (equal(host, "bsc-testnet")) {
ping.setIsmpHost(BSC_TESTNET_HOST, tokenFaucet);
if (host.toSlice().startsWith("ethereum".toSlice())) {
ping.setIsmpHost(ETHEREUM_HOST, tokenFaucet);
} else if (host.toSlice().startsWith("arbitrum".toSlice())) {
ping.setIsmpHost(ARBITRUM_HOST, tokenFaucet);
} else if (host.toSlice().startsWith("optimism".toSlice())) {
ping.setIsmpHost(OPTIMISM_HOST, tokenFaucet);
} else if (host.toSlice().startsWith("base".toSlice())) {
ping.setIsmpHost(BASE_HOST, tokenFaucet);
} else if (host.toSlice().startsWith("bsc".toSlice())) {
ping.setIsmpHost(BNB_HOST, tokenFaucet);
}
vm.stopBroadcast();
}
Expand Down
2 changes: 1 addition & 1 deletion evm/script/batchDeploy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

declare -a arr=("sepolia" "arbitrum-sepolia" "optimism-sepolia" "base-sepolia" "bsc-testnet" "chiado")
declare -a arr=("ethereum-sepolia" "arbitrum-sepolia" "optimism-sepolia" "base-sepolia" "bsc-testnet" "gnosis-chiado")

for i in "${arr[@]}"
do
Expand Down
2 changes: 1 addition & 1 deletion evm/script/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ echo "Deploying to $1, environment: $3 "
# load prod .env
source "$(pwd)/.env.$3"
# remove existing sources
rm -rf out/ cache/
rm -rf out/ cache/ broadcast/
# deploy
HOST=$1 forge script "script/Deploy$2.s.sol:DeployScript" --rpc-url "$1" -vvvv --sender="$ADMIN" --broadcast
# verify
Expand Down
2 changes: 0 additions & 2 deletions evm/src/consensus/Header.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ library HeaderImpl {

error TimestampNotFound();
error ChildTrieRootNotFound();
error MmrRootHashNotFound();

// Extracts the `StateCommitment` from the provided header.
function stateCommitment(Header calldata self) public pure returns (StateCommitment memory) {
Expand All @@ -76,7 +75,6 @@ library HeaderImpl {
// sanity check
if (timestamp == 0) revert TimestampNotFound();
if (childTrieRoot == bytes32(0)) revert ChildTrieRootNotFound();
if (mmrRoot == bytes32(0)) revert MmrRootHashNotFound();

return StateCommitment({timestamp: timestamp, overlayRoot: mmrRoot, stateRoot: childTrieRoot});
}
Expand Down
2 changes: 1 addition & 1 deletion evm/src/consensus/SP1Beefy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ contract SP1Beefy is IConsensusClient, ERC165 {
using HeaderImpl for Header;

// SP1 verification key
bytes32 public verificationKey = bytes32(0x00b3830a7bcbd368596446801391435c29bb5319827319de0acb83fb7490ef49);
bytes32 public verificationKey = bytes32(0x0071ba110ada2601c43635dabd6abea7180d3132fd75df662cac13505ade1f5d);

// Sp1 verifier contract
ISP1Verifier internal _verifier;
Expand Down
Loading

0 comments on commit 23971dc

Please sign in to comment.