From a4720648110fd3773c61b76c1942f8f556d04e7c Mon Sep 17 00:00:00 2001 From: Seun Lanlege Date: Wed, 22 Jan 2025 21:19:49 +0400 Subject: [PATCH] Bump `SP1Beefy` (#370) --- docs/pages/developers/network/relayer.mdx | 47 ++++++++------ evm/lib/sp1-contracts | 2 +- evm/script/DeployHostUpdates.s.sol | 76 +++++++++++------------ evm/src/consensus/SP1Beefy.sol | 6 +- evm/test/SP1BeefyTest.sol | 8 +-- 5 files changed, 75 insertions(+), 64 deletions(-) diff --git a/docs/pages/developers/network/relayer.mdx b/docs/pages/developers/network/relayer.mdx index c2ddee0df..86bd997fc 100644 --- a/docs/pages/developers/network/relayer.mdx +++ b/docs/pages/developers/network/relayer.mdx @@ -175,15 +175,23 @@ max_rpc_payload_size = 150000000 # misuse can cause the rpc to be overloaded with queries # initial_height = 1000 -# (Optional) Frequency in seconds to poll the chain +# (Optional) Frequency in seconds to poll the chain # for new state machine update events # poll_interval = 10 +# (Optional) Hyperbridge's consensus state id +# Only add this if relaying to a solochain. +# Relaying between solochains and parachains with the +# same relayer instance is not supported. +# For Paseo Testnet: PAS0 +# For Polkadot Mainnet: DOT0 +# consensus_state_id = "PAS0" + # Relayer config, required [relayer] -# Define your profitability configuration. +# Define your profitability configuration. # 0 -> 0% i.e relay all requests, even unprofitable ones. -# 1 -> 1%. ie fees provided for requests must be +# 1 -> 1%. ie fees provided for requests must be # profitable by at least 1%. etc. minimum_profit_percentage = 0 @@ -195,23 +203,25 @@ withdrawal_frequency = 86400 # defaults to $100 minimum_withdrawal_amount = 100 -# If not empty, tesseract will only deliver requests +# If not empty, tesseract will only deliver requests # to the specified state-machines delivery_endpoints = [ "EVM-11155111", "EVM-421614", "EVM-11155420", "EVM-84532", - "EVM-97" + "EVM-97", + "SUBSTRATE-myid", + "POLKADOT-2100" ] -# (Optional) +# (Optional) # If not empty, will filter requests to be delivered # by originating module identifier (eg contract address/pallet ids) # module_filter = [] -# (Optional) -# How frequently to retry unprofitable or +# (Optional) +# How frequently to retry unprofitable or # failed messages in seconds. # If this is value not supplied retries will not be enabled. # unprofitable_retry_frequency = 600 @@ -256,9 +266,9 @@ consensus_state_id = "ETH0" # Etherscan api key for querying the # state machine's native token price. -# Do note that ethereum and all +# Do note that ethereum and all # its L2's use ETH as the native token -# So they can all share the same key +# So they can all share the same key # # Bsc on the other hand uses the BNB token # and would need its own API key from bscscan @@ -268,7 +278,7 @@ etherscan_api_key = "" ismp_host = "" # (Optional) -# Maximum block range that should be used to query eth_getLogs +# Maximum block range that should be used to query eth_getLogs # in a single rpc call. if this parameter is not supplied, # the range will not be split into smaller chunks # and will be queried at once. This might be needed @@ -278,7 +288,7 @@ ismp_host = "" # hex-encoded private key for the relayer account on this chain signer = "" -# (Optional) +# (Optional) # Maximum number of concurrent requests to be used for tx tracing. # If not supplied will trace entire tx batches at once. # This increases tracing speeds by tracing txs concurrently @@ -287,20 +297,20 @@ signer = "" # If using an rpc provider, ensure that they support a # large number of `debug_traceCall` requests/sec. # -# Note: if you use the same provider for all your endpoints +# Note: if you use the same provider for all your endpoints # then a very high request/sec threshold is required (> 1000 / sec) # # eg 5 transactions would be traced concurrently on this client # tracing_batch_size = 5 -# (Optional) +# (Optional) # Percentage buffer to add to gas prices # to increase likelihood of the transactions # going through e.g 1%, 2% # gas_price_buffer = 1 # (Optional) -# The execution client implementation, +# The execution client implementation, # only Geth or Erigon are fully supported # The possible values: "Geth" | "Erigon" # If this field is not set, the default is "Geth" @@ -312,7 +322,7 @@ signer = "" # misuse can cause the rpc to be overloaded with queries # initial_height = 1000 -# (Optional) Frequency in seconds to poll the chain +# (Optional) Frequency in seconds to poll the chain # for new state machine update events # poll_interval = 10 @@ -333,6 +343,7 @@ hashing = "Blake2" rpc_ws = "ws://127.0.0.1:9944" # example endpoint # The consensus state identifier for this chain on hyperbridge. +# "PARA" for parachains consensus_state_id = "PARA" # (Optional) @@ -344,13 +355,13 @@ consensus_state_id = "PARA" # Unneeded if the chain uses unsigned extrinsics for pallet-ismp # signer = "" -# (Optional) Frequency in seconds to poll the chain +# (Optional) Frequency in seconds to poll the chain # for new state machine update events # poll_interval = 10 # (Optional) initial height # This sets the height at which to start querying messages, -# This exists for testing and development, +# This exists for testing and development, # misuse can cause the rpc to be overloaded with queries # initial_height = 1000 ``` diff --git a/evm/lib/sp1-contracts b/evm/lib/sp1-contracts index 1c4acaeab..0885c34b5 160000 --- a/evm/lib/sp1-contracts +++ b/evm/lib/sp1-contracts @@ -1 +1 @@ -Subproject commit 1c4acaeab86789995ae5c6baced66f81e4a57f4d +Subproject commit 0885c34b525708ed5f7e87a3d7b20c42564b4c00 diff --git a/evm/script/DeployHostUpdates.s.sol b/evm/script/DeployHostUpdates.s.sol index 450c31a53..722019d0a 100644 --- a/evm/script/DeployHostUpdates.s.sol +++ b/evm/script/DeployHostUpdates.s.sol @@ -11,7 +11,7 @@ import {BaseScript} from "./BaseScript.sol"; import "../src/modules/HandlerV1.sol"; import {SP1Beefy} from "../src/consensus/SP1Beefy.sol"; -import {SP1Verifier} from "@sp1-contracts/v2.0.0/SP1VerifierPlonk.sol"; +import {SP1Verifier} from "@sp1-contracts/v4.0.0-rc.3/SP1VerifierGroth16.sol"; import {SP1Beefy} from "../src/consensus/SP1Beefy.sol"; contract DeployScript is BaseScript { @@ -20,44 +20,44 @@ contract DeployScript is BaseScript { function run() external { vm.startBroadcast(uint256(privateKey)); - // SP1Verifier verifier = new SP1Verifier(); - // SP1Beefy consensusClient = new SP1Beefy(verifier); + SP1Verifier verifier = new SP1Verifier(); + SP1Beefy consensusClient = new SP1Beefy(verifier); // HandlerV1 handler = new HandlerV1(); - BeefyV1 consensusClient = new BeefyV1{salt: salt}(); - - if (host.toSlice().startsWith("ethereum".toSlice())) { - HostParams memory params = EvmHost(ETHEREUM_HOST).hostParams(); - params.consensusClient = address(consensusClient); - // params.handler = address(handler); - EvmHost(ETHEREUM_HOST).updateHostParams(params); - } else if (host.toSlice().startsWith("arbitrum".toSlice())) { - HostParams memory params = EvmHost(ARBITRUM_HOST).hostParams(); - params.consensusClient = address(consensusClient); - // params.handler = address(handler); - EvmHost(ARBITRUM_HOST).updateHostParams(params); - } else if (host.toSlice().startsWith("optimism".toSlice())) { - HostParams memory params = EvmHost(OPTIMISM_HOST).hostParams(); - params.consensusClient = address(consensusClient); - // params.handler = address(handler); - EvmHost(OPTIMISM_HOST).updateHostParams(params); - } else if (host.toSlice().startsWith("base".toSlice())) { - HostParams memory params = EvmHost(BASE_HOST).hostParams(); - params.consensusClient = address(consensusClient); - // params.handler = address(handler); - EvmHost(BASE_HOST).updateHostParams(params); - } else if (host.toSlice().startsWith("bsc".toSlice())) { - HostParams memory params = EvmHost(BNB_HOST).hostParams(); - params.consensusClient = address(consensusClient); - // params.handler = address(handler); - 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(GNOSIS_HOST).updateHostParams(params); - } else { - revert("Unknown Host"); - } + // BeefyV1 consensusClient = new BeefyV1{salt: salt}(); + + // if (host.toSlice().startsWith("ethereum".toSlice())) { + // HostParams memory params = EvmHost(ETHEREUM_HOST).hostParams(); + // params.consensusClient = address(consensusClient); + // // params.handler = address(handler); + // EvmHost(ETHEREUM_HOST).updateHostParams(params); + // } else if (host.toSlice().startsWith("arbitrum".toSlice())) { + // HostParams memory params = EvmHost(ARBITRUM_HOST).hostParams(); + // params.consensusClient = address(consensusClient); + // // params.handler = address(handler); + // EvmHost(ARBITRUM_HOST).updateHostParams(params); + // } else if (host.toSlice().startsWith("optimism".toSlice())) { + // HostParams memory params = EvmHost(OPTIMISM_HOST).hostParams(); + // params.consensusClient = address(consensusClient); + // // params.handler = address(handler); + // EvmHost(OPTIMISM_HOST).updateHostParams(params); + // } else if (host.toSlice().startsWith("base".toSlice())) { + // HostParams memory params = EvmHost(BASE_HOST).hostParams(); + // params.consensusClient = address(consensusClient); + // // params.handler = address(handler); + // EvmHost(BASE_HOST).updateHostParams(params); + // } else if (host.toSlice().startsWith("bsc".toSlice())) { + // HostParams memory params = EvmHost(BNB_HOST).hostParams(); + // params.consensusClient = address(consensusClient); + // // params.handler = address(handler); + // 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(GNOSIS_HOST).updateHostParams(params); + // } else { + // revert("Unknown Host"); + // } } } diff --git a/evm/src/consensus/SP1Beefy.sol b/evm/src/consensus/SP1Beefy.sol index 34eda57dc..0005c5a10 100644 --- a/evm/src/consensus/SP1Beefy.sol +++ b/evm/src/consensus/SP1Beefy.sol @@ -32,7 +32,7 @@ contract SP1Beefy is IConsensusClient, ERC165 { using HeaderImpl for Header; // SP1 verification key - bytes32 public verificationKey = bytes32(0x0071ba110ada2601c43635dabd6abea7180d3132fd75df662cac13505ade1f5d); + bytes32 public verificationKey = bytes32(0x004609733a0366baf52880d2a058a858c8c83479d4b1fca39c1a14666375419f); // Sp1 verifier contract ISP1Verifier internal _verifier; @@ -58,8 +58,8 @@ contract SP1Beefy is IConsensusClient, ERC165 { } /* - * @dev Given some opaque consensus proof, produce the new consensus state and newly finalized intermediate states. - */ + * @dev Given some opaque consensus proof, produce the new consensus state and newly finalized intermediate states. + */ function verifyConsensus( bytes calldata encodedState, bytes calldata encodedProof diff --git a/evm/test/SP1BeefyTest.sol b/evm/test/SP1BeefyTest.sol index 23b8002e9..b0367e1b7 100644 --- a/evm/test/SP1BeefyTest.sol +++ b/evm/test/SP1BeefyTest.sol @@ -15,7 +15,7 @@ pragma solidity 0.8.20; import "forge-std/Test.sol"; -import {SP1Verifier} from "@sp1-contracts/v3.0.0/SP1VerifierGroth16.sol"; +import {SP1Verifier} from "@sp1-contracts/v4.0.0-rc.3/SP1VerifierGroth16.sol"; import {ISP1Verifier} from "@sp1-contracts/ISP1Verifier.sol"; import "../src/consensus/SP1Beefy.sol"; @@ -52,12 +52,12 @@ contract SP1BeefyTest is Test { function testPolkadotVerifier() public view { bytes - memory proof = hex"090690900a331610accb89fe31c04e9d4e0af42b9a99c946330fa6955af1254eb86aa8d3156ad94ef914c0f0901e9226264c7ebbd95145ec8e4a49dca2d348300d1fff3f19cd79389cd6fa52de5d8b0dfe2d60e5d53f7c706c0568c46dfc19c7bb232a951b01fc65f1360369a2ac0c50bbb41163127840d1dedc2e3f6ee98338bd59c7b81e8ea4f720ca1a2b9f7207e27ccb833c4965503a47e4fa62ea5e419555bfdd6421af119e05ad9e13adc643de98945d29f6a6b8d2a470a218e4a2abc9092b693618e7ecf7e780dbe7580bccfe2d5be334035c7ac5361d435cbc760c7896290f7b2b109a2dbe6c47e8401ab119a2da052fb3c0933f3e1669a59437bd8bc8dc157b"; + memory proof = hex"11b6a09d0602783a739ff23a34879d0f31c9742293407605ad35b2ab9f2112445436251c2929a1f895ee9c0a7185734a57da30feaa42de756ef44ac2383ad0146f525ed41ea56e5485fe3d329cec126256c2c19918560e93fea6e69d6c1287aba55359e020f8368e1be185cabcaf87407e6e700be708bb4f0e3d800fea43e7e06f95d8a7141f29d97bbdec0ead4c051dc1a8ff931bf470e7f48bf8edba580d1a1e7f93bf2c7fc4b3124ccbbcaa0cb0243a3be77001d71fc4eb020bfce79d88ce520a9cf611b8032714b5f7429e0bd89c76474f67e0b8f02c0a1cc9fd3cbc8fdf6039a89904236d309f7153c388b5c66d5e5bdc484f4272b71aa246b121bbac05fd50bbe5"; bytes - memory publicInputs = hex"0000000000000000000000000000000000000000000000000000000000000020a2f65237d65bf11eaf9883b0c994bc18a95ab47b43b572d7aff843b432973c9b000000000000000000000000000000000000000000000000000000000000019068ac81e3764c16d937384d2efebff4111285fda59d98dde537b309aeb0832d9100000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001e7cfa25980d95567aa5b02809fb9e3485b1c54296b3ff471a70d12ef5314edd1"; + memory publicInputs = hex"00000000000000000000000000000000000000000000000000000000000000209b5eebd2ca5ae7248ba20456bd8866e6a233ea23c4079303c5b19971f05c40c900000000000000000000000000000000000000000000000000000000000001f38055badaa1bf16bbbb8cd6fe066815bb9e1f23ae46d9641cb88d88aeff1b9569000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000016482008a0af7995d30781c057b8decb26eac6bcebf646283fe386a919b833822"; - bytes32 verificationKey = bytes32(0x0071ba110ada2601c43635dabd6abea7180d3132fd75df662cac13505ade1f5d); + bytes32 verificationKey = bytes32(0x004609733a0366baf52880d2a058a858c8c83479d4b1fca39c1a14666375419f); ISP1Verifier(address(sp1)).verifyProof(verificationKey, publicInputs, proof);