├── .dockerignore ├── .github └── workflows │ ├── ci.yml │ ├── docker-telemetry.yml │ ├── docs.yml │ ├── hyperbridge-docker.yml │ ├── hyperclient.yml │ ├── release.yml │ └── tesseract-docker.yml ├── .gitignore ├── .gitmodules ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── audits └── SRL-Hyperbridge-ISMP-baseline_assurance-report.pdf ├── docs ├── README.md ├── components │ └── Algorithm.tsx ├── fixTrailingSlash.js ├── footer.tsx ├── package-lock.json ├── package.json ├── pages │ ├── developers │ │ ├── evm │ │ │ ├── contracts │ │ │ │ ├── mainnet.mdx │ │ │ │ └── testnet.mdx │ │ │ ├── delivery.mdx │ │ │ ├── dispatching.mdx │ │ │ ├── fees.mdx │ │ │ ├── filler.mdx │ │ │ ├── getting-started.mdx │ │ │ └── receiving.mdx │ │ ├── explore │ │ │ ├── fishermen.mdx │ │ │ ├── index.mdx │ │ │ ├── modules │ │ │ │ ├── host-executive.mdx │ │ │ │ ├── ismp.mdx │ │ │ │ └── relayer.mdx │ │ │ ├── nexus.mdx │ │ │ └── relayers.mdx │ │ ├── index.mdx │ │ ├── network │ │ │ ├── node.mdx │ │ │ ├── relayer.mdx │ │ │ └── relayer │ │ │ │ └── errors.mdx │ │ └── polkadot │ │ │ ├── dispatching.mdx │ │ │ ├── fees.mdx │ │ │ ├── getting-started.mdx │ │ │ ├── ismp-parachain-inherent.mdx │ │ │ ├── ismp-parachain-runtime-api.mdx │ │ │ ├── pallet-ismp-rpc.mdx │ │ │ ├── pallet-ismp-runtime-api.mdx │ │ │ ├── pallet-ismp.mdx │ │ │ ├── parachains.mdx │ │ │ ├── receiving.mdx │ │ │ ├── solochains.mdx │ │ │ └── token-gateway.mdx │ ├── index.mdx │ └── protocol │ │ ├── consensus │ │ ├── beefy.mdx │ │ ├── casper-ffg.mdx │ │ ├── grandpa.mdx │ │ ├── parlia.mdx │ │ └── sync-committee.mdx │ │ ├── cryptography │ │ ├── apk-proofs.mdx │ │ ├── digital-signatures.mdx │ │ ├── hash-functions.mdx │ │ ├── merkle-trees │ │ │ ├── binary.mdx │ │ │ ├── mountain-range.mdx │ │ │ └── patricia-trie.mdx │ │ ├── polynomial-commitments.mdx │ │ └── verkle-tries.mdx │ │ ├── index.mdx │ │ ├── interoperability │ │ ├── consensus-proofs.mdx │ │ └── state-machine-proofs.mdx │ │ ├── ismp │ │ ├── consensus.mdx │ │ ├── dispatcher.mdx │ │ ├── host.mdx │ │ ├── index.mdx │ │ ├── proxies.mdx │ │ ├── relayers.mdx │ │ ├── requests.mdx │ │ ├── responses.mdx │ │ ├── router.mdx │ │ ├── state-machine.mdx │ │ └── timeouts.mdx │ │ └── state-machine │ │ ├── arbitrum-orbit.mdx │ │ ├── fault-dispute-games.mdx │ │ ├── l2-oracle.mdx │ │ └── parachain.mdx ├── public │ ├── Screenshot_2023-05-09_at_3.12.19_PM.png │ ├── add_parachain.png │ ├── add_state_machine.png │ ├── committments.svg │ ├── consensus.svg │ ├── consensus │ │ ├── 51_(1).svg │ │ ├── Screenshot_2023-03-20_at_9.31.23_AM.png │ │ ├── Untitled_Diagram_(4).svg │ │ ├── Untitled_Diagram_(5).svg │ │ └── Untitled_eclipse_(1).svg │ ├── coprocessor.gif │ ├── coprocessor.png │ ├── coprocessor.svg │ ├── cores.webp │ ├── favicon.ico │ ├── favicon.svg │ ├── fonts │ │ ├── BerkeleyMono-Bold.woff2 │ │ ├── BerkeleyMono-Italic.woff2 │ │ ├── BerkeleyMono-Regular.woff2 │ │ ├── BerkeleyMonoVariable-Regular.woff2 │ │ ├── GeneralSans-Variable.ttf │ │ ├── JetBrainsMono-Regular.ttf │ │ ├── Novatica-Bold.woff2 │ │ ├── Novatica-Light.woff2 │ │ ├── Novatica-Medium.woff2 │ │ ├── Novatica.woff2 │ │ └── Scoreboard.ttf │ ├── full-node.jpeg │ ├── get_request.drawio.png │ ├── grnp_init.png │ ├── incoming.request.svg │ ├── ismp_request.drawio.png │ ├── logo.svg │ ├── logo_black.svg │ ├── logo_white.svg │ ├── merkle │ │ ├── Untitled_Diagram.drawio_(1).svg │ │ ├── Untitled_Diagram.drawio_(3).svg │ │ ├── merkle_proof.svg │ │ ├── single1.svg │ │ └── single2.svg │ ├── mmr-01.svg │ ├── mmr-02.svg │ ├── og.png │ ├── patricia │ │ ├── NibbledBranch.svg │ │ ├── ParallelSTF.svg │ │ ├── Screenshot_2023-02-26_at_9.16.56_AM.png │ │ ├── Untitled_Diagram_(2).svg │ │ ├── branch.svg │ │ ├── consensus.svg │ │ ├── extension.svg │ │ ├── merkle.webp │ │ ├── stf.svg │ │ └── trie_world.png │ ├── poly-curve.png │ ├── receipts.svg │ ├── relayers.png │ ├── request.commitment.svg │ ├── state-machine.svg │ ├── state │ │ ├── NibbledBranch.svg │ │ ├── ParallelSTF.svg │ │ ├── Screenshot_2023-02-26_at_9.16.56_AM.png │ │ ├── Untitled_Diagram_(2).svg │ │ ├── branch.svg │ │ ├── consensus.svg │ │ ├── extension.svg │ │ ├── header.png │ │ ├── merkle.webp │ │ ├── stf.svg │ │ └── trie_world.png │ ├── stf.svg │ ├── sudoku.png │ └── verkle │ │ ├── IMG_0033.jpg │ │ ├── IMG_0041.jpg │ │ └── ezgif.com-gif-maker.gif ├── styles.css ├── tsconfig.json ├── vocs.config.tsx └── yarn.lock ├── evm ├── .prettierrc ├── abi │ ├── Cargo.toml │ ├── build.rs │ └── src │ │ ├── conversions.rs │ │ ├── generated │ │ ├── beefy.rs │ │ ├── erc20.rs │ │ ├── evm_host.rs │ │ ├── handler.rs │ │ ├── host_manager.rs │ │ ├── mod.rs │ │ ├── ping_module.rs │ │ ├── shared_types.rs │ │ └── sp1_beefy.rs │ │ └── lib.rs ├── examples │ └── PingModule.sol ├── foundry.toml ├── integration-tests │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ ├── tests.rs │ │ └── tests │ │ ├── beefy_v1.rs │ │ ├── get_response.rs │ │ ├── get_timeout.rs │ │ ├── host_manager.rs │ │ ├── post_request.rs │ │ ├── post_response.rs │ │ ├── post_timeout.rs │ │ └── utils.rs ├── package.json ├── pnpm-lock.yaml ├── remappings.txt ├── script │ ├── BaseScript.sol │ ├── DeployGateway.s.sol │ ├── DeployHostUpdates.s.sol │ ├── DeployInscriptions.s.sol │ ├── DeployIntentGateway.s.sol │ ├── DeployIsmp.s.sol │ ├── DeployMnt.s.sol │ ├── DeployPing.s.sol │ ├── README.md │ ├── batchDeploy.sh │ └── deploy.sh ├── src │ ├── consensus │ │ ├── BeefyV1.sol │ │ ├── Codec.sol │ │ ├── Header.sol │ │ ├── SP1Beefy.sol │ │ └── Types.sol │ ├── hosts │ │ ├── Arbitrum.sol │ │ ├── Base.sol │ │ ├── Bsc.sol │ │ ├── Ethereum.sol │ │ ├── EvmHost.sol │ │ ├── Gnosis.sol │ │ ├── Optimism.sol │ │ ├── Polygon.sol │ │ └── Soneium.sol │ ├── interfaces │ │ ├── ICallDispatcher.sol │ │ └── IWETH.sol │ └── modules │ │ ├── CallDispatcher.sol │ │ ├── GnosisUniswapV2Interface.sol │ │ ├── HandlerV1.sol │ │ ├── HostManager.sol │ │ ├── Inscriptions.sol │ │ ├── IntentGateway.sol │ │ ├── Registrar.sol │ │ ├── TokenFaucet.sol │ │ ├── TokenGateway.sol │ │ └── UniV3UniswapV2Wrapper.sol ├── test │ ├── BaseTest.sol │ ├── Beefy.sol │ ├── EvmHostForkTest.sol │ ├── EvmHostTest.sol │ ├── FeeToken.sol │ ├── GetRequest.sol │ ├── HostManagerTest.sol │ ├── IntentGatewayTest.sol │ ├── MainnetForkBaseTest.sol │ ├── MockUSDC.sol │ ├── PostRequest.sol │ ├── PostResponse.sol │ ├── RegistrarTest.sol │ ├── SP1BeefyTest.sol │ ├── TestConsensusClient.sol │ ├── TestHost.sol │ ├── TokenGatewayForkTest.sol │ ├── TokenGatewayTest.sol │ ├── UniV3UniswapV2WrapperTest.sol │ └── mocks │ │ ├── ERC20Token.sol │ │ └── MiniStakingContract.sol └── yarn.lock ├── modules ├── consensus │ ├── beefy │ │ ├── primitives │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── lib.rs │ │ └── prover │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ ├── lib.rs │ │ │ ├── relay.rs │ │ │ └── util.rs │ ├── bsc │ │ ├── prover │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ ├── lib.rs │ │ │ │ └── test.rs │ │ └── verifier │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ ├── lib.rs │ │ │ └── primitives.rs │ ├── geth-primitives │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ ├── grandpa │ │ ├── primitives │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ ├── justification.rs │ │ │ │ └── lib.rs │ │ ├── prover │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── lib.rs │ │ └── verifier │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ ├── lib.rs │ │ │ └── tests.rs │ ├── polygon-pos │ │ ├── prover │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ ├── lib.rs │ │ │ │ └── test.rs │ │ └── verifier │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ ├── lib.rs │ │ │ └── primitives.rs │ └── sync-committee │ │ ├── README.md │ │ ├── primitives │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── consensus_types.rs │ │ │ ├── constants.rs │ │ │ ├── deneb.rs │ │ │ ├── domains.rs │ │ │ ├── electra.rs │ │ │ ├── error.rs │ │ │ ├── lib.rs │ │ │ ├── ssz │ │ │ ├── byte_list.rs │ │ │ ├── byte_vector.rs │ │ │ └── mod.rs │ │ │ ├── types.rs │ │ │ └── util.rs │ │ ├── prover │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── lib.rs │ │ │ ├── middleware.rs │ │ │ ├── responses │ │ │ ├── beacon_block_header_response.rs │ │ │ ├── beacon_block_response.rs │ │ │ ├── beacon_state_response.rs │ │ │ ├── finality_checkpoint_response.rs │ │ │ ├── mod.rs │ │ │ ├── sync_committee_response.rs │ │ │ └── validator_response.rs │ │ │ ├── routes.rs │ │ │ └── test.rs │ │ └── verifier │ │ ├── Cargo.toml │ │ └── src │ │ ├── crypto.rs │ │ ├── error.rs │ │ └── lib.rs ├── hyperclient │ ├── Cargo.toml │ ├── README.md │ ├── build.sh │ ├── hyperclient.d.ts │ ├── package.json │ ├── src │ │ ├── any_client.rs │ │ ├── interfaces.rs │ │ ├── internals.rs │ │ ├── internals │ │ │ ├── get_request.rs │ │ │ ├── post_request.rs │ │ │ └── post_response.rs │ │ ├── lib.rs │ │ ├── providers │ │ │ ├── evm.rs │ │ │ ├── interface.rs │ │ │ ├── mod.rs │ │ │ └── substrate.rs │ │ ├── testing.rs │ │ ├── tests.rs │ │ └── types.rs │ └── tests │ │ └── streams.rs ├── ismp │ ├── clients │ │ ├── arbitrum │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ ├── lib.rs │ │ │ │ └── tests.rs │ │ ├── bsc │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ ├── lib.rs │ │ │ │ └── pallet.rs │ │ ├── casper-ffg │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── lib.rs │ │ ├── grandpa │ │ │ ├── Cargo.toml │ │ │ ├── README.md │ │ │ └── src │ │ │ │ ├── benchmarking.rs │ │ │ │ ├── consensus.rs │ │ │ │ ├── lib.rs │ │ │ │ ├── messages.rs │ │ │ │ └── weights.rs │ │ ├── optimism │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── lib.rs │ │ ├── parachain │ │ │ ├── client │ │ │ │ ├── Cargo.toml │ │ │ │ ├── README.md │ │ │ │ └── src │ │ │ │ │ ├── benchmarking.rs │ │ │ │ │ ├── consensus.rs │ │ │ │ │ ├── lib.rs │ │ │ │ │ ├── migration.rs │ │ │ │ │ └── weights.rs │ │ │ ├── inherent │ │ │ │ ├── Cargo.toml │ │ │ │ ├── README.md │ │ │ │ └── src │ │ │ │ │ └── lib.rs │ │ │ └── runtime-api │ │ │ │ ├── Cargo.toml │ │ │ │ ├── README.md │ │ │ │ └── src │ │ │ │ └── lib.rs │ │ ├── polygon-pos │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ ├── lib.rs │ │ │ │ ├── pallet.rs │ │ │ │ └── test.rs │ │ └── sync-committee │ │ │ ├── Cargo.toml │ │ │ ├── README.md │ │ │ └── src │ │ │ ├── beacon_client.rs │ │ │ ├── lib.rs │ │ │ ├── pallet.rs │ │ │ └── types.rs │ ├── core │ │ ├── Cargo.toml │ │ ├── README.md │ │ └── src │ │ │ ├── consensus.rs │ │ │ ├── dispatcher.rs │ │ │ ├── error.rs │ │ │ ├── events.rs │ │ │ ├── handlers.rs │ │ │ ├── handlers │ │ │ ├── consensus.rs │ │ │ ├── request.rs │ │ │ ├── response.rs │ │ │ └── timeout.rs │ │ │ ├── host.rs │ │ │ ├── lib.rs │ │ │ ├── messaging.rs │ │ │ ├── module.rs │ │ │ └── router.rs │ ├── state-machines │ │ ├── evm │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ ├── lib.rs │ │ │ │ ├── presets.rs │ │ │ │ ├── types.rs │ │ │ │ └── utils.rs │ │ ├── hyperbridge │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── lib.rs │ │ └── substrate │ │ │ ├── Cargo.toml │ │ │ ├── README.md │ │ │ └── src │ │ │ └── lib.rs │ └── testsuite │ │ ├── Cargo.toml │ │ └── src │ │ ├── lib.rs │ │ ├── mocks.rs │ │ └── tests.rs ├── pallets │ ├── bridge-drop │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ ├── call-decompressor │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── README.md │ │ │ └── lib.rs │ ├── demo │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ ├── fishermen │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ ├── host-executive │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── lib.rs │ │ │ └── params.rs │ ├── hyperbridge │ │ ├── Cargo.toml │ │ ├── README.md │ │ └── src │ │ │ ├── child_trie.rs │ │ │ └── lib.rs │ ├── ismp │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── rpc │ │ │ ├── Cargo.toml │ │ │ ├── README.md │ │ │ └── src │ │ │ │ └── lib.rs │ │ ├── runtime-api │ │ │ ├── Cargo.toml │ │ │ ├── README.md │ │ │ └── src │ │ │ │ └── lib.rs │ │ └── src │ │ │ ├── child_trie.rs │ │ │ ├── dispatcher.rs │ │ │ ├── errors.rs │ │ │ ├── events.rs │ │ │ ├── fee_handler.rs │ │ │ ├── host.rs │ │ │ ├── impls.rs │ │ │ ├── lib.rs │ │ │ ├── offchain.rs │ │ │ ├── utils.rs │ │ │ └── weights.rs │ ├── mmr │ │ ├── Cargo.toml │ │ ├── gadget │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ ├── aux_schema.rs │ │ │ │ ├── lib.rs │ │ │ │ └── offchain_mmr.rs │ │ ├── primitives │ │ │ ├── Cargo.toml │ │ │ ├── README.md │ │ │ └── src │ │ │ │ └── lib.rs │ │ ├── rpc │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── lib.rs │ │ ├── runtime-api │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── lib.rs │ │ └── src │ │ │ ├── lib.rs │ │ │ └── mmr │ │ │ ├── mmr.rs │ │ │ ├── mod.rs │ │ │ └── storage.rs │ ├── relayer-incentives │ │ ├── Cargo.toml │ │ ├── README.md │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── relayer │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── lib.rs │ │ │ └── withdrawal.rs │ ├── state-coprocessor │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── testsuite │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── lib.rs │ │ │ ├── relay_chain.rs │ │ │ ├── runtime.rs │ │ │ ├── tests │ │ │ ├── child_trie_proof_check.rs │ │ │ ├── mod.rs │ │ │ ├── pallet_bridge_airdrop.rs │ │ │ ├── pallet_call_decompressor.rs │ │ │ ├── pallet_fishermen.rs │ │ │ ├── pallet_hyperbridge.rs │ │ │ ├── pallet_ismp.rs │ │ │ ├── pallet_ismp_host_executive.rs │ │ │ ├── pallet_ismp_relayer.rs │ │ │ ├── pallet_relayer_incentives.rs │ │ │ ├── pallet_token_gateway.rs │ │ │ ├── pallet_xcm_gateway.rs │ │ │ └── xcm_integration_test.rs │ │ │ └── xcm.rs │ ├── token-gateway-inspector │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ ├── token-gateway │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── primitives │ │ │ ├── Cargo.toml │ │ │ ├── README.md │ │ │ └── src │ │ │ │ └── lib.rs │ │ └── src │ │ │ ├── benchmarking.rs │ │ │ ├── impls.rs │ │ │ ├── lib.rs │ │ │ ├── types.rs │ │ │ └── weights.rs │ ├── token-governor │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ ├── lib.rs │ │ │ └── types.rs │ └── xcm-gateway │ │ ├── Cargo.toml │ │ └── src │ │ ├── lib.rs │ │ └── xcm_utilities.rs ├── trees │ └── ethereum │ │ ├── Cargo.toml │ │ ├── README.md │ │ └── src │ │ ├── lib.rs │ │ ├── node_codec.rs │ │ ├── storage_proof.rs │ │ └── tests.rs └── utils │ ├── serde │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── lib.rs │ └── subxt │ ├── Cargo.toml │ └── src │ ├── client.rs │ └── lib.rs ├── parachain ├── chainspec │ ├── gargantua.paseo.json │ ├── gargantua.plain.json │ ├── messier.json │ ├── nexus.json │ └── paseo.raw.json ├── node │ ├── Cargo.toml │ ├── build.rs │ └── src │ │ ├── chain_spec.rs │ │ ├── cli.rs │ │ ├── command.rs │ │ ├── main.rs │ │ ├── rpc.rs │ │ ├── runtime_api.rs │ │ ├── service.rs │ │ └── simnode.rs ├── runtimes │ ├── gargantua │ │ ├── Cargo.toml │ │ ├── build.rs │ │ └── src │ │ │ ├── genesis_config.rs │ │ │ ├── ismp.rs │ │ │ ├── lib.rs │ │ │ ├── weights │ │ │ ├── block_weights.rs │ │ │ ├── cumulus_pallet_parachain_system.rs │ │ │ ├── cumulus_pallet_xcmp_queue.rs │ │ │ ├── extrinsic_weights.rs │ │ │ ├── frame_system.rs │ │ │ ├── ismp_grandpa.rs │ │ │ ├── ismp_parachain.rs │ │ │ ├── mod.rs │ │ │ ├── pallet_asset_rate.rs │ │ │ ├── pallet_assets.rs │ │ │ ├── pallet_balances.rs │ │ │ ├── pallet_collective.rs │ │ │ ├── pallet_message_queue.rs │ │ │ ├── pallet_session.rs │ │ │ ├── pallet_sudo.rs │ │ │ ├── pallet_timestamp.rs │ │ │ ├── pallet_treasury.rs │ │ │ ├── pallet_utility.rs │ │ │ ├── paritydb_weights.rs │ │ │ └── rocksdb_weights.rs │ │ │ └── xcm.rs │ ├── messier │ │ ├── Cargo.toml │ │ ├── build.rs │ │ └── src │ │ │ ├── ismp.rs │ │ │ ├── lib.rs │ │ │ ├── weights │ │ │ ├── block_weights.rs │ │ │ ├── cumulus_pallet_xcmp_queue.rs │ │ │ ├── extrinsic_weights.rs │ │ │ ├── frame_system.rs │ │ │ ├── mod.rs │ │ │ ├── pallet_assets.rs │ │ │ ├── pallet_balances.rs │ │ │ ├── pallet_message_queue.rs │ │ │ ├── pallet_sudo.rs │ │ │ ├── pallet_timestamp.rs │ │ │ ├── paritydb_weights.rs │ │ │ └── rocksdb_weights.rs │ │ │ └── xcm.rs │ └── nexus │ │ ├── Cargo.toml │ │ ├── build.rs │ │ └── src │ │ ├── genesis_config.rs │ │ ├── ismp.rs │ │ ├── lib.rs │ │ ├── weights │ │ ├── block_weights.rs │ │ ├── cumulus_pallet_parachain_system.rs │ │ ├── cumulus_pallet_xcmp_queue.rs │ │ ├── extrinsic_weights.rs │ │ ├── frame_system.rs │ │ ├── ismp_grandpa.rs │ │ ├── ismp_parachain.rs │ │ ├── mod.rs │ │ ├── pallet_asset_rate.rs │ │ ├── pallet_assets.rs │ │ ├── pallet_balances.rs │ │ ├── pallet_collator_selection.rs │ │ ├── pallet_collective.rs │ │ ├── pallet_message_queue.rs │ │ ├── pallet_multisig.rs │ │ ├── pallet_proxy.rs │ │ ├── pallet_session.rs │ │ ├── pallet_sudo.rs │ │ ├── pallet_timestamp.rs │ │ ├── pallet_treasury.rs │ │ ├── pallet_utility.rs │ │ ├── paritydb_weights.rs │ │ └── rocksdb_weights.rs │ │ └── xcm.rs └── simtests │ ├── Cargo.toml │ └── src │ ├── hyperbridge_client.rs │ ├── lib.rs │ ├── pallet_ismp.rs │ └── pallet_mmr.rs ├── rust-toolchain.toml ├── rustfmt.toml ├── scripts ├── benchmarking.sh ├── build_release_runtime.sh ├── docker │ ├── hyperbridge.Dockerfile │ ├── telemetry.Dockerfile │ └── tesseract.Dockerfile ├── generate_subxt_types.sh ├── parachain-launch │ ├── dev-2000-2000.json │ ├── docker-compose.yml │ ├── local_config.yml │ ├── package.json │ ├── parachain-2000.Dockerfile │ ├── relaychain.Dockerfile │ ├── rococo-local.json │ └── yarn.lock ├── release-crates.sh ├── template.hbs ├── wait_for_tcp_port_opening.sh └── zombienet │ └── local-testnet.toml └── tesseract ├── README.md ├── assets └── relayer.webp ├── config ├── Cargo.toml └── src │ └── lib.rs ├── evm ├── Cargo.toml ├── abis │ ├── ArbGasInfo.json │ ├── ERC20.json │ └── OVM_gasPriceOracle.json ├── build.rs ├── op-registry │ └── chainList.json └── src │ ├── abi.rs │ ├── abi │ ├── arb_gas_info.rs │ ├── erc_20.rs │ └── ovm_gas_price_oracle.rs │ ├── byzantine.rs │ ├── gas_oracle.rs │ ├── lib.rs │ ├── provider.rs │ ├── test.rs │ └── tx.rs ├── fees ├── Cargo.toml ├── prisma-cli │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── prisma │ ├── migrations │ │ ├── 20240227154307_ │ │ │ └── migration.sql │ │ ├── 20240315095442_pending_withdrawals │ │ │ └── migration.sql │ │ ├── 20240327084356_unproitable_retries │ │ │ └── migration.sql │ │ └── migration_lock.toml │ └── schema.prisma └── src │ ├── db.rs │ ├── lib.rs │ ├── mock.rs │ └── tests.rs ├── fisherman ├── Cargo.toml └── src │ └── lib.rs ├── integration-test ├── Cargo.toml └── src │ └── lib.rs ├── messaging ├── Cargo.toml └── src │ ├── events.rs │ ├── get_requests.rs │ ├── lib.rs │ └── retries.rs ├── primitives ├── Cargo.toml └── src │ ├── config.rs │ ├── lib.rs │ ├── mocks.rs │ └── queue.rs ├── relayer ├── Cargo.toml └── src │ ├── cli.rs │ ├── config.rs │ ├── fees.rs │ ├── lib.rs │ ├── logging.rs │ └── main.rs ├── substrate ├── Cargo.toml └── src │ ├── byzantine.rs │ ├── calls.rs │ ├── config.rs │ ├── extrinsic.rs │ ├── host.rs │ ├── lib.rs │ ├── provider.rs │ └── testing.rs ├── telemetry ├── Cargo.toml └── src │ ├── lib.rs │ └── main.rs └── test-config.toml /.dockerignore: -------------------------------------------------------------------------------- 1 | # Exclude the executable files to be copied into the image 2 | target 3 | !target/release/tesseract 4 | !target/release/telemetry-server 5 | !target/release/hyperbridge 6 | 7 | .github 8 | .cargo 9 | 10 | # Compiler files 11 | cache/ 12 | out/ 13 | 14 | # Ignores development broadcast logs 15 | !/broadcast 16 | /broadcast/*/31337/ 17 | /broadcast/**/dry-run/ 18 | 19 | # Docs 20 | docs/ 21 | 22 | # Dotenv file 23 | .env 24 | -------------------------------------------------------------------------------- /.github/workflows/docker-telemetry.yml: -------------------------------------------------------------------------------- 1 | name: Telemetry Server Docker Publish 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | concurrency: 7 | group: ${{ github.ref }} 8 | cancel-in-progress: true 9 | 10 | jobs: 11 | build_and_publish: 12 | runs-on: release-runner 13 | steps: 14 | - name: Checkout sources 15 | uses: actions/checkout@v3 16 | with: 17 | token: ${{ secrets.GH_TOKEN }} 18 | submodules: recursive 19 | 20 | - uses: webfactory/ssh-agent@v0.5.4 21 | with: 22 | ssh-private-key: "${{ secrets.SSH_KEY }}" 23 | 24 | - name: Install toolchain 25 | uses: dtolnay/rust-toolchain@nightly 26 | with: 27 | toolchain: nightly 28 | 29 | - name: Build 30 | run: | 31 | sudo apt-get install -y clang netcat wget curl libssl-dev llvm libudev-dev make protobuf-compiler pkg-config 32 | cargo +nightly build --release -p telemetry-server 33 | 34 | - name: Install Cargo get 35 | run: cargo install cargo-get 36 | 37 | - name: Login to Docker Hub 38 | uses: docker/login-action@v3 39 | with: 40 | username: ${{ secrets.DOCKER_USERNAME }} 41 | password: ${{ secrets.DOCKER_ACCESS_TOKEN }} 42 | 43 | - name: Build the Docker image 44 | run: docker build -t polytopelabs/telemetry-server:v$(cargo get package.version --entry ./telemetry) -t polytopelabs/telemetry-server:latest -f ./scripts/docker/telemetry.Dockerfile . 45 | 46 | - name: Docker Push 47 | run: | 48 | docker push polytopelabs/telemetry-server:v$(cargo get package.version --entry ./telemetry) 49 | docker push polytopelabs/telemetry-server:latest 50 | -------------------------------------------------------------------------------- /.github/workflows/hyperclient.yml: -------------------------------------------------------------------------------- 1 | name: Publish hyperclient to npmjs 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | concurrency: 7 | group: hyperclient-publish-${{ github.ref }} 8 | cancel-in-progress: true 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | # Setup .npmrc file to publish to npm 16 | - uses: actions/setup-node@v4 17 | with: 18 | node-version: "20.x" 19 | registry-url: "https://registry.npmjs.org" 20 | scope: "@polytope-labs" 21 | 22 | - name: Install wasm-pack 23 | run: | 24 | curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh 25 | rustup target add wasm32-unknown-unknown 26 | 27 | - name: Build and Publish 28 | working-directory: modules/hyperclient 29 | env: 30 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 31 | run: | 32 | yarn build 33 | npm publish --access public 34 | -------------------------------------------------------------------------------- /.github/workflows/tesseract-docker.yml: -------------------------------------------------------------------------------- 1 | name: Tesseract Docker Publish 2 | 3 | on: 4 | push: 5 | tags: 6 | - "tesseract-v[0-9]+.[0-9]+.[0-9]+" 7 | 8 | concurrency: 9 | group: release-${{ github.ref }} 10 | cancel-in-progress: true 11 | 12 | env: 13 | TELEMETRY_SECRET_KEY: ${{ secrets.TELEMETRY_SECRET_KEY }} 14 | 15 | jobs: 16 | build_and_publish: 17 | runs-on: release-runner 18 | steps: 19 | - name: Checkout sources 20 | uses: actions/checkout@v3 21 | with: 22 | token: ${{ secrets.GH_TOKEN }} 23 | submodules: recursive 24 | 25 | - uses: webfactory/ssh-agent@v0.5.4 26 | with: 27 | ssh-private-key: "${{ secrets.SSH_KEY }}" 28 | 29 | - name: Install toolchain 30 | uses: dtolnay/rust-toolchain@nightly 31 | with: 32 | toolchain: stable 33 | 34 | - name: Build 35 | run: | 36 | sudo apt-get install -y clang netcat wget curl libssl-dev llvm libudev-dev make protobuf-compiler pkg-config 37 | cargo build --release -p tesseract 38 | 39 | - name: Install Cargo get 40 | run: cargo install cargo-get 41 | 42 | - name: Login to Docker Hub 43 | uses: docker/login-action@v3 44 | with: 45 | username: ${{ secrets.DOCKER_USERNAME }} 46 | password: ${{ secrets.DOCKER_ACCESS_TOKEN }} 47 | 48 | - name: Build the Docker image 49 | run: docker build -t polytopelabs/tesseract:v$(cargo get package.version --entry ./tesseract/relayer) -t polytopelabs/tesseract:latest -f ./scripts/docker/tesseract.Dockerfile . 50 | 51 | - name: Docker Push 52 | run: | 53 | docker push polytopelabs/tesseract:v$(cargo get package.version --entry ./tesseract/relayer) 54 | docker push polytopelabs/tesseract:latest 55 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | .idea/ 3 | dist/ 4 | 5 | *.log 6 | **/node_modules/* 7 | **/polkadot-launch/rococo*.json 8 | .cargo/ 9 | .DS_Store 10 | **/zombienet/zombienet 11 | /pallet-ismp/evm/solidity/out 12 | /pallet-ismp/evm/solidity/cache 13 | .env* 14 | .vscode 15 | 16 | evm/out/ 17 | evm/cache/ 18 | evm/broadcast/ 19 | evm/integration-tests/target/ 20 | 21 | .uuid* 22 | 23 | modules/hyperclient/pkg 24 | 25 | evm/subgraph/build 26 | evm/subgraph/generated 27 | ## logs 28 | *.log 29 | 30 | 31 | # Generated by Cargo 32 | # will have compiled files and executables 33 | **/target/ 34 | # These are backup files generated by rustfmt 35 | **/*.rs.bk 36 | 37 | .DS_Store 38 | 39 | # The cache for docker container dependency 40 | .cargo 41 | 42 | # The cache for chain data in container 43 | .local 44 | 45 | # direnv cache 46 | .direnv 47 | 48 | .idea 49 | .fleet 50 | 51 | # ignore user vscode sttings 52 | .vscode/* 53 | .env 54 | .uuid 55 | 56 | **/proofs/* 57 | /fees/prisma/dev.db 58 | /fees/prisma/dev.db-journal 59 | / 60 | **/*.db 61 | package-lock.json 62 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "evm/lib/forge-std"] 2 | path = evm/lib/forge-std 3 | url = https://github.com/foundry-rs/forge-std 4 | [submodule "evm/lib/solidity-stringutils"] 5 | path = evm/lib/solidity-stringutils 6 | url = https://github.com/Arachnid/solidity-stringutils 7 | [submodule "evm/lib/sp1-contracts"] 8 | path = evm/lib/sp1-contracts 9 | url = https://github.com/succinctlabs/sp1-contracts 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Hyperbridge Coprocessor](./docs/public/coprocessor.gif) 2 | 3 | # Hyperbridge 4 | 5 | > Hyperbridge is a hyper-scalable coprocessor for verifiable, cross-chain interoperability. 6 | 7 | 8 | ## Join the network 9 | 10 | Hyperbridge is the first fully permissionless and decentralized cross-chain protocol powered by interoperability proofs. 11 | It allows **anyone** to run a relayer which transmits messages across chains without any staking or whitelisting. [Learn more about relayers.](https://docs.hyperbridge.network/developers/explore/relayers) 12 | 13 | - [Run a relayer](https://docs.hyperbridge.network/developers/network/relayer) 14 | - [Run a node](https://docs.hyperbridge.network/developers/network/node) 15 | 16 | 17 | ## Developers 18 | 19 | Onchain application developers can leverage Hyperbridge for mission-critical cross-chain applications which do not have the luxury of centralized or trusted security models. 20 | 21 | - [Evm Developers](https://docs.hyperbridge.network/developers/evm/getting-started) 22 | - [Polkadot-sdk Developers](https://docs.hyperbridge.network/developers/polkadot/getting-started) 23 | 24 | ## Projects using Hyperbridge 25 | 26 | The growing list of teams that are choosing Hyperbridge for verifiable interoperability. 27 | 28 | - [RegionX](https://github.com/RegionX-Labs/RegionX) 29 | - [zkVerify](https://github.com/HorizenLabs/zkVerify) 30 | - [Bifrost](https://github.com/bifrost-io/bifrost) 31 | - [Cere Network](https://github.com/Cerebellum-Network/blockchain-node) 32 | - [Argon Protocol](https://github.com/argonprotocol/mainchain) 33 | 34 | Please feel free to add your project to this list via a pull request! 35 | -------------------------------------------------------------------------------- /audits/SRL-Hyperbridge-ISMP-baseline_assurance-report.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/audits/SRL-Hyperbridge-ISMP-baseline_assurance-report.pdf -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | This is a [Vocs](https://vocs.dev) project bootstrapped with the Vocs CLI. 2 | -------------------------------------------------------------------------------- /docs/fixTrailingSlash.js: -------------------------------------------------------------------------------- 1 | import path from "path"; 2 | import fs from "fs-extra"; 3 | import { glob } from "glob"; 4 | 5 | // /myPath/index.html => /myPath.html 6 | (async function FixTrailingSlash(outDir = "./dist") { 7 | const pattern = path.join(outDir, "/**/index.html"); 8 | const filePaths = (await glob(pattern)).filter((filePath) => { 9 | return filePath !== path.join(outDir, "/index.html"); 10 | }); 11 | 12 | await Promise.all( 13 | filePaths.map(async (filePath) => { 14 | if ((await fs.stat(filePath)).isDirectory()) { 15 | return; 16 | } 17 | const filePathCopy = `${path.dirname(filePath)}.html`; 18 | if (await fs.pathExists(filePathCopy)) { 19 | } else { 20 | await fs.copyFile(filePath, filePathCopy); 21 | await fs.rm(filePath); 22 | } 23 | }), 24 | ); 25 | })(); 26 | -------------------------------------------------------------------------------- /docs/footer.tsx: -------------------------------------------------------------------------------- 1 | export default function Footer() { 2 | return ( 3 |
4 |
Copyright © {new Date().getFullYear()} Polytope Labs.
5 |
6 | ) 7 | } 8 | -------------------------------------------------------------------------------- /docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hyperbridge-protocol-specification", 3 | "version": "0.0.0", 4 | "type": "module", 5 | "scripts": { 6 | "dev": "while true; do vocs dev --host && break; done", 7 | "build": "vocs build && node ./fixTrailingSlash.js", 8 | "preview": "vocs preview" 9 | }, 10 | "dependencies": { 11 | "@types/react": "latest", 12 | "fs-extra": "^11.2.0", 13 | "glob": "^10.4.1", 14 | "i": "^0.3.7", 15 | "prettier": "^3.2.2", 16 | "react": "latest", 17 | "react-dom": "latest", 18 | "rehype-katex": "^7.0.0", 19 | "rehype-stringify": "^10.0.0", 20 | "remark-math": "^6.0.0", 21 | "remark-parse": "^11.0.0", 22 | "remark-rehype": "^11.1.0", 23 | "sitemap-ts": "^1.7.3", 24 | "typescript": "latest", 25 | "vocs": "latest" 26 | }, 27 | "devDependencies": { 28 | "vite-plugin-radar": "^0.9.2" 29 | }, 30 | "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" 31 | } 32 | -------------------------------------------------------------------------------- /docs/pages/developers/explore/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: Hyperbridge Overview 3 | description: Hyperbridge brings together advanced cryptographic and mechanistic protocols to facilitate secure cross-chain interoperability. 4 | --- 5 | 6 | # Overview 7 | 8 | Hyperbridge brings together advanced cryptographic and mechanistic protocols to facilitate secure cross-chain interoperability. 9 | 10 | The protocol is facilitated by: 11 | 12 | - A permissionless set of relayers that transmit cross-chain messages authenticated by cryptographic proofs. 13 | - Fishermen who challenge malicous consensus updates by vetoing misrepresentative state comitments. 14 | - Hyperbridge Nexus, a blockchain that serves as a crypto-economic coprocessor for aggregating interoperability proofs. 15 | -------------------------------------------------------------------------------- /docs/pages/developers/explore/modules/host-executive.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: Pallet Host Executive 3 | description: The Hyperbridge protocol encompasses more than just the Hyperbridge Nexus blockchain, it also includes contracts or modules on its connected chains. These modules, which are governed by the Hyperbridge protocol, are responsible for collecting relayer and protocol revenue for cross-chain operations. 4 | --- 5 | 6 | # Pallet Host Executive 7 | 8 | The Hyperbridge protocol encompasses more than just the Hyperbridge nexus blockchain, it also includes contracts or modules on its connected chains. These modules, which are governed by the Hyperbridge protocol, are responsible for collecting relayer and protocol revenue for cross-chain operations. They are managed from Hyperbridge through the `HostManager` interface. This interface allows the Hyperbridge protocol to dispatch cross-chain governance actions which may either withdraw any accrued protocol or relayer revenue or modify its fee structure or other protocol parameters. 9 | 10 | The `HostExecutive` module on Hyperbridge is the module responsible for managing the `HostManager` across all connected chains. It tracks any relevant protocol parameters for each chain and allows the Hyperbridge governance to dispatch any protocol parameter changes to the connected chains. It is named after the corporate structure of a multi-~chain~national company, where the "Executive" is responsible for managing the "Regional Manager". 11 | 12 | 13 | ## Implementation 14 | 15 | - [pallet-ismp-host-executive](https://github.com/polytope-labs/hyperbridge/blob/main/modules/ismp/pallets/host-executive/src/lib.rs) 16 | -------------------------------------------------------------------------------- /docs/pages/developers/polkadot/ismp-parachain-runtime-api.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: ISMP Parachain Runtime API 3 | description: This is required by the `ismp-parachain-inherent`. It is used to access the whitelist of sibling parachains to produce consensus proofs for. 4 | --- 5 | 6 | # ISMP Parachain Runtime API 7 | 8 | This is required by the `ismp-parachain-inherent`. It is used to access the whitelist of sibling parachains to produce consensus proofs for. 9 | 10 | To use this, Include the `ismp-parachain-runtime-api` implementation in your `impl_runtime_apis` section. 11 | 12 | ```rust showLineNumbers [runtime.rs] 13 | use ismp_parachain_runtime_api::IsmpParachainApi; 14 | 15 | impl_runtime_apis! { 16 | impl IsmpParachainApi for Runtime { 17 | fn para_ids() -> Vec { 18 | ismp_parachain::Pallet::::para_ids() 19 | } 20 | 21 | fn current_relay_chain_state() -> RelayChainState { 22 | ismp_parachain::Pallet::::current_relay_chain_state() 23 | } 24 | } 25 | } 26 | ``` 27 | 28 | ## Implementation 29 | 30 | - [ismp-parachain-runtime-api](https://github.com/polytope-labs/hyperbridge/blob/main/modules/ismp/clients/parachain/runtime-api/src/lib.rs) -------------------------------------------------------------------------------- /docs/pages/protocol/consensus/grandpa.mdx: -------------------------------------------------------------------------------- 1 | # GRANDPA 2 | -------------------------------------------------------------------------------- /docs/public/Screenshot_2023-05-09_at_3.12.19_PM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/Screenshot_2023-05-09_at_3.12.19_PM.png -------------------------------------------------------------------------------- /docs/public/add_parachain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/add_parachain.png -------------------------------------------------------------------------------- /docs/public/add_state_machine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/add_state_machine.png -------------------------------------------------------------------------------- /docs/public/consensus/Screenshot_2023-03-20_at_9.31.23_AM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/consensus/Screenshot_2023-03-20_at_9.31.23_AM.png -------------------------------------------------------------------------------- /docs/public/coprocessor.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/coprocessor.gif -------------------------------------------------------------------------------- /docs/public/coprocessor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/coprocessor.png -------------------------------------------------------------------------------- /docs/public/cores.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/cores.webp -------------------------------------------------------------------------------- /docs/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/favicon.ico -------------------------------------------------------------------------------- /docs/public/fonts/BerkeleyMono-Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/fonts/BerkeleyMono-Bold.woff2 -------------------------------------------------------------------------------- /docs/public/fonts/BerkeleyMono-Italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/fonts/BerkeleyMono-Italic.woff2 -------------------------------------------------------------------------------- /docs/public/fonts/BerkeleyMono-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/fonts/BerkeleyMono-Regular.woff2 -------------------------------------------------------------------------------- /docs/public/fonts/BerkeleyMonoVariable-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/fonts/BerkeleyMonoVariable-Regular.woff2 -------------------------------------------------------------------------------- /docs/public/fonts/GeneralSans-Variable.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/fonts/GeneralSans-Variable.ttf -------------------------------------------------------------------------------- /docs/public/fonts/JetBrainsMono-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/fonts/JetBrainsMono-Regular.ttf -------------------------------------------------------------------------------- /docs/public/fonts/Novatica-Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/fonts/Novatica-Bold.woff2 -------------------------------------------------------------------------------- /docs/public/fonts/Novatica-Light.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/fonts/Novatica-Light.woff2 -------------------------------------------------------------------------------- /docs/public/fonts/Novatica-Medium.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/fonts/Novatica-Medium.woff2 -------------------------------------------------------------------------------- /docs/public/fonts/Novatica.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/fonts/Novatica.woff2 -------------------------------------------------------------------------------- /docs/public/fonts/Scoreboard.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/fonts/Scoreboard.ttf -------------------------------------------------------------------------------- /docs/public/full-node.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/full-node.jpeg -------------------------------------------------------------------------------- /docs/public/get_request.drawio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/get_request.drawio.png -------------------------------------------------------------------------------- /docs/public/grnp_init.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/grnp_init.png -------------------------------------------------------------------------------- /docs/public/ismp_request.drawio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/ismp_request.drawio.png -------------------------------------------------------------------------------- /docs/public/og.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/og.png -------------------------------------------------------------------------------- /docs/public/patricia/Screenshot_2023-02-26_at_9.16.56_AM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/patricia/Screenshot_2023-02-26_at_9.16.56_AM.png -------------------------------------------------------------------------------- /docs/public/patricia/merkle.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/patricia/merkle.webp -------------------------------------------------------------------------------- /docs/public/patricia/trie_world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/patricia/trie_world.png -------------------------------------------------------------------------------- /docs/public/poly-curve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/poly-curve.png -------------------------------------------------------------------------------- /docs/public/relayers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/relayers.png -------------------------------------------------------------------------------- /docs/public/state/Screenshot_2023-02-26_at_9.16.56_AM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/state/Screenshot_2023-02-26_at_9.16.56_AM.png -------------------------------------------------------------------------------- /docs/public/state/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/state/header.png -------------------------------------------------------------------------------- /docs/public/state/merkle.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/state/merkle.webp -------------------------------------------------------------------------------- /docs/public/state/trie_world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/state/trie_world.png -------------------------------------------------------------------------------- /docs/public/sudoku.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/sudoku.png -------------------------------------------------------------------------------- /docs/public/verkle/IMG_0033.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/verkle/IMG_0033.jpg -------------------------------------------------------------------------------- /docs/public/verkle/IMG_0041.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/verkle/IMG_0041.jpg -------------------------------------------------------------------------------- /docs/public/verkle/ezgif.com-gif-maker.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/docs/public/verkle/ezgif.com-gif-maker.gif -------------------------------------------------------------------------------- /docs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | "jsx": "react-jsx", 16 | 17 | /* Linting */ 18 | "strict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true 22 | }, 23 | "include": ["**/*.ts", "**/*.tsx"] 24 | } 25 | -------------------------------------------------------------------------------- /evm/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120, 3 | "tabWidth": 4, 4 | "useTabs": false 5 | } 6 | -------------------------------------------------------------------------------- /evm/abi/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ismp-solidity-abi" 3 | version = "0.1.1" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | description = "Generated rust types for the ISMP solidity ABI" 7 | publish = false 8 | 9 | 10 | [build-dependencies] 11 | anyhow.workspace = true 12 | ethers-contract-abigen = { workspace = true } 13 | forge-testsuite = { workspace = true } 14 | 15 | [dependencies] 16 | primitive-types = { workspace = true } 17 | anyhow = { workspace = true, default-features = true } 18 | 19 | ethers = { workspace = true } 20 | ismp = { workspace = true } 21 | 22 | mmr-primitives = { workspace = true, default-features = true, optional = true } 23 | merkle-mountain-range = { workspace = true, default-features = true, optional = true } 24 | beefy-verifier-primitives = { workspace = true, default-features = true, optional = true } 25 | 26 | [dependencies.polkadot-sdk] 27 | workspace = true 28 | optional = true 29 | features = ["sp-consensus-beefy"] 30 | 31 | [features] 32 | default = ["beefy", "std"] 33 | std = ["primitive-types/std", "anyhow/std", "ethers/default", "ismp/std"] 34 | build-abi = [] 35 | beefy = [ 36 | "merkle-mountain-range", 37 | "polkadot-sdk", 38 | "beefy-verifier-primitives", 39 | "mmr-primitives", 40 | ] 41 | -------------------------------------------------------------------------------- /evm/abi/build.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | 3 | fn main() -> anyhow::Result<()> { 4 | let base_dir = env::current_dir()?.parent().unwrap().display().to_string(); 5 | 6 | #[cfg(feature = "build-abi")] 7 | { 8 | use ethers_contract_abigen::MultiAbigen; 9 | use forge_testsuite::Runner; 10 | use std::path::PathBuf; 11 | // first compile the project. 12 | 13 | let _ = Runner::new(PathBuf::from(&base_dir)); 14 | 15 | let sources = vec![ 16 | ("EvmHost", format!("{base_dir}/out/EvmHost.sol/EvmHost.json")), 17 | ("Handler", format!("{base_dir}/out/HandlerV1.sol/HandlerV1.json")), 18 | ("Beefy", format!("{base_dir}/out/BeefyV1.sol/BeefyV1.json")), 19 | ("SP1Beefy", format!("{base_dir}/out/SP1Beefy.sol/SP1Beefy.json")), 20 | ("PingModule", format!("{base_dir}/out/PingModule.sol/PingModule.json")), 21 | ("HostManager", format!("{base_dir}/out/HostManager.sol/HostManager.json")), 22 | ("ERC20", format!("{base_dir}/out/ERC20.sol/ERC20.json")), 23 | ]; 24 | 25 | MultiAbigen::new(sources) 26 | .unwrap() 27 | .build() 28 | .unwrap() 29 | .write_to_module(format!("{base_dir}/abi/src/generated"), false) 30 | .unwrap(); 31 | } 32 | 33 | println!("cargo:rerun-if-changed={base_dir}/out"); 34 | 35 | Ok(()) 36 | } 37 | -------------------------------------------------------------------------------- /evm/abi/src/generated/mod.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::all)] 2 | //! This module contains abigen! generated bindings for solidity contracts. 3 | //! This is autogenerated code. 4 | //! Do not manually edit these files. 5 | //! These files may be overwritten by the codegen system at any time. 6 | pub mod beefy; 7 | pub mod erc20; 8 | pub mod evm_host; 9 | pub mod handler; 10 | pub mod host_manager; 11 | pub mod ping_module; 12 | pub mod shared_types; 13 | pub mod sp1_beefy; 14 | -------------------------------------------------------------------------------- /evm/abi/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Polytope Labs. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | //! Generated types for the ismp-solidity ABI 17 | 18 | mod conversions; 19 | mod generated; 20 | 21 | pub use conversions::*; 22 | pub use generated::*; 23 | -------------------------------------------------------------------------------- /evm/integration-tests/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused_parens)] 2 | 3 | // #[cfg(test)] 4 | // mod tests; 5 | 6 | pub use ethers::{abi::Token, types::U256, utils::keccak256}; 7 | use merkle_mountain_range::{util::MemMMR, Error, Merge}; 8 | use pallet_ismp::offchain::Leaf; 9 | use pallet_mmr_tree::mmr::Hasher; 10 | use polkadot_sdk::*; 11 | use primitive_types::H256; 12 | use sp_runtime::traits; 13 | 14 | #[derive(Clone, Default)] 15 | pub struct Keccak256; 16 | 17 | pub type DataOrHash = mmr_primitives::DataOrHash; 18 | 19 | impl rs_merkle::Hasher for Keccak256 { 20 | type Hash = [u8; 32]; 21 | 22 | fn hash(data: &[u8]) -> [u8; 32] { 23 | keccak256(data) 24 | } 25 | } 26 | 27 | impl ismp::messaging::Keccak256 for Keccak256 { 28 | fn keccak256(bytes: &[u8]) -> H256 29 | where 30 | Self: Sized, 31 | { 32 | keccak256(bytes).into() 33 | } 34 | } 35 | 36 | struct MergeKeccak; 37 | 38 | impl Merge for MergeKeccak { 39 | type Item = NumberHash; 40 | fn merge(lhs: &Self::Item, rhs: &Self::Item) -> Result { 41 | let mut concat = vec![]; 42 | concat.extend(&lhs.0); 43 | concat.extend(&rhs.0); 44 | let hash = keccak256(&concat); 45 | Ok(NumberHash(hash.to_vec().into())) 46 | } 47 | } 48 | 49 | #[derive(Eq, PartialEq, Clone, Debug, Default)] 50 | struct NumberHash(pub Vec); 51 | 52 | impl From for NumberHash { 53 | fn from(num: u32) -> Self { 54 | let hash = keccak256(&num.to_le_bytes()); 55 | NumberHash(hash.to_vec()) 56 | } 57 | } 58 | 59 | pub type Mmr = MemMMR>; 60 | -------------------------------------------------------------------------------- /evm/integration-tests/src/tests.rs: -------------------------------------------------------------------------------- 1 | mod beefy_v1; 2 | mod get_response; 3 | mod get_timeout; 4 | mod host_manager; 5 | mod post_request; 6 | mod post_response; 7 | mod post_timeout; 8 | mod utils; 9 | -------------------------------------------------------------------------------- /evm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "evm", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "directories": { 6 | "example": "examples", 7 | "lib": "lib", 8 | "test": "test" 9 | }, 10 | "scripts": { 11 | "test": "echo \"Error: no test specified\" && exit 1" 12 | }, 13 | "author": "", 14 | "license": "ISC", 15 | "description": "", 16 | "dependencies": { 17 | "@polytope-labs/erc6160": "^0.3.1", 18 | "@polytope-labs/ismp-solidity": "^0.7.3", 19 | "@polytope-labs/ismp-solidity-v1": "npm:@polytope-labs/ismp-solidity@^1.1.0", 20 | "@polytope-labs/solidity-merkle-trees": "^0.3.4", 21 | "@uniswap/v2-periphery": "^1.1.0-beta.0", 22 | "@uniswap/v3-core": "^1.0.1", 23 | "@uniswap/v3-periphery": "^1.4.4", 24 | "openzeppelin-solidity": "4.8.1", 25 | "prettier": "^3.3.3", 26 | "prettier-plugin-solidity": "^1.3.1" 27 | }, 28 | "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" 29 | } 30 | -------------------------------------------------------------------------------- /evm/remappings.txt: -------------------------------------------------------------------------------- 1 | @polytope-labs/ismp-solidity/=node_modules/@polytope-labs/ismp-solidity/interfaces/ 2 | @polytope-labs/ismp-solidity-v1/=node_modules/@polytope-labs/ismp-solidity-v1/interfaces/ 3 | @openzeppelin/=node_modules/openzeppelin-solidity 4 | @polytope-labs/solidity-merkle-trees/=node_modules/@polytope-labs/solidity-merkle-trees/ 5 | @polytope-labs/erc6160/=node_modules/@polytope-labs/erc6160/src/ 6 | @uniswap/v2-periphery/=node_modules/@uniswap/v2-periphery 7 | @uniswap/v3-periphery/=node_modules/@uniswap/v3-periphery 8 | @uniswap/v3-core/=node_modules/@uniswap/v3-core 9 | stringutils/=lib/solidity-stringutils/src/ 10 | @sp1-contracts/=lib/sp1-contracts/contracts/src/ -------------------------------------------------------------------------------- /evm/script/BaseScript.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.17; 3 | 4 | import "forge-std/Script.sol"; 5 | 6 | abstract contract BaseScript is Script { 7 | bytes32 public salt = keccak256(bytes(vm.envString("VERSION"))); 8 | 9 | address payable internal ETHEREUM_HOST = payable(vm.envAddress("ETHEREUM_HOST")); 10 | address payable internal ARBITRUM_HOST = payable(vm.envAddress("ARBITRUM_HOST")); 11 | address payable internal OPTIMISM_HOST = payable(vm.envAddress("OPTIMISM_HOST")); 12 | address payable internal BASE_HOST = payable(vm.envAddress("BASE_HOST")); 13 | address payable internal BNB_HOST = payable(vm.envAddress("BNB_HOST")); 14 | address payable internal GNOSIS_HOST = payable(vm.envAddress("GNOSIS_HOST")); 15 | address payable internal SONEIUM_HOST = payable(vm.envAddress("SONEIUM_HOST")); 16 | 17 | bytes32 internal privateKey = vm.envBytes32("PRIVATE_KEY"); 18 | string internal host = vm.envString("HOST"); 19 | address internal admin = vm.envAddress("ADMIN"); 20 | 21 | /** 22 | * @dev Returns true if the two strings are equal. 23 | */ 24 | function equal(string memory a, string memory b) internal pure returns (bool) { 25 | return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /evm/script/DeployInscriptions.s.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.20; 3 | 4 | import "forge-std/Script.sol"; 5 | import "stringutils/strings.sol"; 6 | 7 | import {CrossChainInscription} from "../src/modules/Inscriptions.sol"; 8 | import {BaseScript} from "./BaseScript.sol"; 9 | 10 | contract DeployScript is BaseScript { 11 | using strings for *; 12 | 13 | function run() external { 14 | vm.startBroadcast(uint256(privateKey)); 15 | CrossChainInscription module = new CrossChainInscription{salt: salt}(admin); 16 | 17 | if (host.toSlice().startsWith("ethereum".toSlice())) { 18 | module.setHost(ETHEREUM_HOST); 19 | } else if (host.toSlice().startsWith("arbitrum".toSlice())) { 20 | module.setHost(ARBITRUM_HOST); 21 | } else if (host.toSlice().startsWith("optimism".toSlice())) { 22 | module.setHost(OPTIMISM_HOST); 23 | } else if (host.toSlice().startsWith("base".toSlice())) { 24 | module.setHost(BASE_HOST); 25 | } else if (host.toSlice().startsWith("bsc".toSlice())) { 26 | module.setHost(BNB_HOST); 27 | } else if (host.toSlice().startsWith("gnosis".toSlice())) { 28 | module.setHost(GNOSIS_HOST); 29 | } 30 | 31 | vm.stopBroadcast(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /evm/script/DeployIntentGateway.s.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.17; 3 | 4 | import "forge-std/Script.sol"; 5 | import "stringutils/strings.sol"; 6 | 7 | import {IntentGateway, Params} from "../src/modules/IntentGateway.sol"; 8 | import {BaseScript} from "./BaseScript.sol"; 9 | 10 | contract DeployIntentGatewayScript is BaseScript { 11 | using strings for *; 12 | 13 | function run() external { 14 | address admin = vm.envAddress("ADMIN"); 15 | address dispatcher = vm.envAddress("DISPATCHER"); 16 | 17 | vm.startBroadcast(uint256(privateKey)); 18 | 19 | IntentGateway gateway = new IntentGateway{salt: salt}(admin); 20 | 21 | Params memory params = Params({host: address(0), dispatcher: dispatcher}); 22 | 23 | // Set the host based on the current chain 24 | if (host.toSlice().startsWith("ethereum".toSlice())) { 25 | params.host = ETHEREUM_HOST; 26 | } else if (host.toSlice().startsWith("arbitrum".toSlice())) { 27 | params.host = ARBITRUM_HOST; 28 | } else if (host.toSlice().startsWith("optimism".toSlice())) { 29 | params.host = OPTIMISM_HOST; 30 | } else if (host.toSlice().startsWith("base".toSlice())) { 31 | params.host = BASE_HOST; 32 | } else if (host.toSlice().startsWith("bsc".toSlice())) { 33 | params.host = BNB_HOST; 34 | } else if (host.toSlice().startsWith("gnosis".toSlice())) { 35 | params.host = GNOSIS_HOST; 36 | } else if (host.toSlice().startsWith("soneium".toSlice())) { 37 | params.host = SONEIUM_HOST; 38 | } 39 | 40 | gateway.setParams(params); 41 | 42 | vm.stopBroadcast(); 43 | 44 | console.log("IntentGateway deployed at:", address(gateway)); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /evm/script/DeployMnt.s.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.17; 3 | 4 | import "forge-std/Script.sol"; 5 | import "stringutils/strings.sol"; 6 | 7 | import {ERC6160Ext20} from "@polytope-labs/erc6160/tokens/ERC6160Ext20.sol"; 8 | 9 | import {PingModule} from "../examples/PingModule.sol"; 10 | import {BaseScript} from "./BaseScript.sol"; 11 | 12 | // Mostly for verifying MNTs not deploying 13 | contract DeployScript is BaseScript { 14 | using strings for *; 15 | 16 | function run() external { 17 | address tokenGateway = vm.envAddress("TOKEN_GATEWAY"); 18 | string memory name = vm.envString("TOKEN_NAME"); 19 | string memory symbol = vm.envString("TOKEN_SYMBOL"); 20 | vm.startBroadcast(uint256(privateKey)); 21 | 22 | new ERC6160Ext20{salt: keccak256(bytes(symbol))}(tokenGateway, name, symbol); 23 | vm.stopBroadcast(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /evm/script/DeployPing.s.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.17; 3 | 4 | import "forge-std/Script.sol"; 5 | import "stringutils/strings.sol"; 6 | 7 | import {ERC6160Ext20} from "@polytope-labs/erc6160/tokens/ERC6160Ext20.sol"; 8 | 9 | import {PingModule} from "../examples/PingModule.sol"; 10 | import {BaseScript} from "./BaseScript.sol"; 11 | 12 | contract DeployScript is BaseScript { 13 | using strings for *; 14 | 15 | function run() external { 16 | address admin = vm.envAddress("ADMIN"); 17 | address tokenFaucet = vm.envAddress("TOKEN_FAUCET"); 18 | 19 | vm.startBroadcast(uint256(privateKey)); 20 | PingModule ping = new PingModule{salt: salt}(admin); 21 | 22 | if (host.toSlice().startsWith("ethereum".toSlice())) { 23 | ping.setIsmpHost(ETHEREUM_HOST, tokenFaucet); 24 | } else if (host.toSlice().startsWith("arbitrum".toSlice())) { 25 | ping.setIsmpHost(ARBITRUM_HOST, tokenFaucet); 26 | } else if (host.toSlice().startsWith("optimism".toSlice())) { 27 | ping.setIsmpHost(OPTIMISM_HOST, tokenFaucet); 28 | } else if (host.toSlice().startsWith("base".toSlice())) { 29 | ping.setIsmpHost(BASE_HOST, tokenFaucet); 30 | } else if (host.toSlice().startsWith("bsc".toSlice())) { 31 | ping.setIsmpHost(BNB_HOST, tokenFaucet); 32 | } 33 | vm.stopBroadcast(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /evm/script/README.md: -------------------------------------------------------------------------------- 1 | # How to deploy 2 | 3 | Ensure you have a local beacon chain testnet running, see [polytope-labs/eth-pos-devnet](https://github.com/polytope-labs/eth-pos-devnet). 4 | 5 | Fill out an `.env` file at the root of this repo with the given contents. 6 | 7 | ```dotenv 8 | export ADMIN=0x123463a4B065722E99115D6c222f267d9cABb524 9 | export PARA_ID=2000 10 | export GOERLI_RPC_URL=http://127.0.0.1:8545 11 | export PRIVATE_KEY=2e0834786285daccd064ca17f1654f67b4aef298acbb82cef9ec422fb4975622 12 | ``` 13 | 14 | The given private key is for the prefunded `0x123463a4B065722E99115D6c222f267d9cABb524` account in the devnet. 15 | 16 | Run the command below to deploy 17 | 18 | ```shell 19 | ./scripts/deploy.sh {local|goerli|optimism-goerli|arbitrum-goerli|base-goerli} 20 | ``` 21 | -------------------------------------------------------------------------------- /evm/script/batchDeploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | set -o xtrace 4 | 5 | declare -a testnet=("ethereum-sepolia" "arbitrum-sepolia" "optimism-sepolia" "base-sepolia" "bsc-testnet" "gnosis-chiado") 6 | declare -a mainnet=("ethereum" "arbitrum" "optimism" "base" "bsc" "gnosis") 7 | 8 | if [ "$2" == "mainnet" ]; then 9 | for i in "${mainnet[@]}"; do 10 | "$(pwd)/script/deploy.sh" "$i" $1 mainnet 11 | done 12 | else 13 | for i in "${testnet[@]}"; do 14 | "$(pwd)/script/deploy.sh" "$i" $1 testnet 15 | done 16 | fi 17 | -------------------------------------------------------------------------------- /evm/script/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "================Deploying to $1, environment: $3 ================" 4 | # load prod .env 5 | source "$(pwd)/.env.$3" 6 | # remove existing sources 7 | rm -rf out/ cache/ broadcast/ 8 | # deploy 9 | HOST=$1 forge script "script/Deploy$2.s.sol:DeployScript" --rpc-url "$1" -vvvvv --sender="$ADMIN" --broadcast 10 | # verify 11 | HOST=$1 forge script "script/Deploy$2.s.sol:DeployScript" --rpc-url "$1" --resume --verify -vvvvv --private-keys $PRIVATE_KEY 12 | -------------------------------------------------------------------------------- /evm/src/hosts/Arbitrum.sol: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | pragma solidity ^0.8.17; 16 | 17 | import {EvmHost, HostParams} from "./EvmHost.sol"; 18 | 19 | /** 20 | * @title The ArbitrumHost 21 | * @author Polytope Labs (hello@polytope.technology) 22 | * 23 | * @notice The IsmpHost and IsmpDispatcher implementation for the Arbitrum state machine. 24 | * Refer to the official ISMP specification. https://docs.hyperbridge.network/protocol/ismp 25 | */ 26 | contract ArbitrumHost is EvmHost { 27 | constructor(HostParams memory params) EvmHost(params) {} 28 | 29 | /// chainId for the arbitrum mainnet 30 | uint256 public constant CHAIN_ID = 42161; 31 | 32 | function chainId() public pure override returns (uint256) { 33 | return CHAIN_ID; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /evm/src/hosts/Base.sol: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | pragma solidity ^0.8.17; 16 | 17 | import {EvmHost, HostParams} from "./EvmHost.sol"; 18 | 19 | /** 20 | * @title The BaseHost 21 | * @author Polytope Labs (hello@polytope.technology) 22 | * 23 | * @notice The IsmpHost and IsmpDispatcher implementation for the Base state machine. 24 | * Refer to the official ISMP specification. https://docs.hyperbridge.network/protocol/ismp 25 | */ 26 | contract BaseHost is EvmHost { 27 | constructor(HostParams memory params) EvmHost(params) {} 28 | 29 | /// chainId for the base mainnet 30 | uint256 public constant CHAIN_ID = 8453; 31 | 32 | function chainId() public pure override returns (uint256) { 33 | return CHAIN_ID; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /evm/src/hosts/Bsc.sol: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | pragma solidity ^0.8.17; 16 | 17 | import {EvmHost, HostParams} from "./EvmHost.sol"; 18 | 19 | /** 20 | * @title The BscHost 21 | * @author Polytope Labs (hello@polytope.technology) 22 | * 23 | * @notice The IsmpHost and IsmpDispatcher implementation for the Binance state machine. 24 | * Refer to the official ISMP specification. https://docs.hyperbridge.network/protocol/ismp 25 | */ 26 | contract BscHost is EvmHost { 27 | constructor(HostParams memory params) EvmHost(params) {} 28 | 29 | /// chainId for the bsc mainnet 30 | uint256 public constant CHAIN_ID = 56; 31 | 32 | function chainId() public pure override returns (uint256) { 33 | return CHAIN_ID; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /evm/src/hosts/Ethereum.sol: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | pragma solidity ^0.8.17; 16 | 17 | import {EvmHost, HostParams} from "./EvmHost.sol"; 18 | 19 | /** 20 | * @title The EthereumHost 21 | * @author Polytope Labs (hello@polytope.technology) 22 | * 23 | * @notice The IsmpHost and IsmpDispatcher implementation for the Ethereum state machine. 24 | * Refer to the official ISMP specification. https://docs.hyperbridge.network/protocol/ismp 25 | */ 26 | contract EthereumHost is EvmHost { 27 | constructor(HostParams memory params) EvmHost(params) {} 28 | 29 | /// chainId for the ethereum mainnet 30 | uint256 public constant CHAIN_ID = 1; 31 | 32 | function chainId() public pure override returns (uint256) { 33 | return CHAIN_ID; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /evm/src/hosts/Gnosis.sol: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | pragma solidity ^0.8.17; 16 | 17 | import {EvmHost, HostParams} from "./EvmHost.sol"; 18 | 19 | /** 20 | * @title The GnosisHost 21 | * @author Polytope Labs (hello@polytope.technology) 22 | * 23 | * @notice The IsmpHost and IsmpDispatcher implementation for the Gnosis state machine. 24 | * Refer to the official ISMP specification. https://docs.hyperbridge.network/protocol/ismp 25 | */ 26 | contract GnosisHost is EvmHost { 27 | constructor(HostParams memory params) EvmHost(params) {} 28 | 29 | /// chainId for the Gnosis mainnet 30 | uint256 public constant CHAIN_ID = 100; 31 | 32 | function chainId() public pure override returns (uint256) { 33 | return CHAIN_ID; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /evm/src/hosts/Optimism.sol: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | pragma solidity ^0.8.17; 16 | 17 | import {EvmHost, HostParams} from "./EvmHost.sol"; 18 | 19 | /** 20 | * @title The OptimismHost 21 | * @author Polytope Labs (hello@polytope.technology) 22 | * 23 | * @notice The IsmpHost and IsmpDispatcher implementation for the Optimism state machine. 24 | * Refer to the official ISMP specification. https://docs.hyperbridge.network/protocol/ismp 25 | */ 26 | contract OptimismHost is EvmHost { 27 | constructor(HostParams memory params) EvmHost(params) {} 28 | 29 | /// chainId for the optimism mainnet 30 | uint256 public constant CHAIN_ID = 10; 31 | 32 | function chainId() public pure override returns (uint256) { 33 | return CHAIN_ID; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /evm/src/hosts/Polygon.sol: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | pragma solidity ^0.8.17; 16 | 17 | import {EvmHost, HostParams} from "./EvmHost.sol"; 18 | 19 | /** 20 | * @title The PolygonHost 21 | * @author Polytope Labs (hello@polytope.technology) 22 | * 23 | * @notice The IsmpHost and IsmpDispatcher implementation for the Polygon state machine. 24 | * Refer to the official ISMP specification. https://docs.hyperbridge.network/protocol/ismp 25 | */ 26 | contract PolygonHost is EvmHost { 27 | constructor(HostParams memory params) EvmHost(params) {} 28 | 29 | /// chainId for the polygon mainnet 30 | uint256 public constant CHAIN_ID = 137; 31 | 32 | function chainId() public pure override returns (uint256) { 33 | return CHAIN_ID; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /evm/src/hosts/Soneium.sol: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | pragma solidity ^0.8.17; 16 | 17 | import {EvmHost, HostParams} from "./EvmHost.sol"; 18 | 19 | /** 20 | * @title The SoneiumHost 21 | * @author Polytope Labs (hello@polytope.technology) 22 | * 23 | * @notice The IsmpHost and IsmpDispatcher implementation for the Soneium state machine. 24 | * Refer to the official ISMP specification. https://docs.hyperbridge.network/protocol/ismp 25 | */ 26 | contract SoneiumHost is EvmHost { 27 | constructor(HostParams memory params) EvmHost(params) {} 28 | 29 | /// chainId for the Soneium mainnet 30 | uint256 public constant CHAIN_ID = 1868; 31 | 32 | function chainId() public pure override returns (uint256) { 33 | return CHAIN_ID; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /evm/src/interfaces/ICallDispatcher.sol: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | pragma solidity ^0.8.17; 16 | 17 | /** 18 | * @title The ICallDispatcher 19 | * @author Polytope Labs (hello@polytope.technology) 20 | * 21 | * @notice This interface is used to dispatch untrusted call(s) 22 | */ 23 | interface ICallDispatcher { 24 | /* 25 | * @dev Dispatch the encoded call(s) 26 | */ 27 | function dispatch(bytes memory params) external; 28 | } 29 | -------------------------------------------------------------------------------- /evm/src/interfaces/IWETH.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | 6 | interface IWETH is IERC20 { 7 | function deposit() external payable; 8 | function withdraw(uint256) external; 9 | } -------------------------------------------------------------------------------- /evm/src/modules/TokenFaucet.sol: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | pragma solidity ^0.8.17; 16 | 17 | import {IERC6160Ext20} from "@polytope-labs/erc6160/interfaces/IERC6160Ext20.sol"; 18 | 19 | /** 20 | * @title The TokenFaucet. 21 | * @author Polytope Labs (hello@polytope.technology) 22 | * 23 | * @notice Allows access to a fixed amount of tokens to users on a daily basis 24 | */ 25 | contract TokenFaucet { 26 | mapping(address => uint256) private consumers; 27 | 28 | // @dev Will only drip tokens, once per day 29 | function drip(address token) public { 30 | uint256 lastDrip = consumers[msg.sender]; 31 | uint256 delay = block.timestamp - lastDrip; 32 | 33 | if (delay < 1 days) { 34 | revert("Can only request tokens once daily"); 35 | } 36 | 37 | consumers[msg.sender] = block.timestamp; 38 | IERC6160Ext20(token).mint(msg.sender, 1000 * 1e18); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /evm/test/FeeToken.sol: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | pragma solidity ^0.8.17; 16 | 17 | import {ERC6160Ext20} from "@polytope-labs/erc6160/tokens/ERC6160Ext20.sol"; 18 | 19 | contract FeeToken is ERC6160Ext20 { 20 | constructor( 21 | address _defaultOwner, 22 | string memory _name, 23 | string memory _symbol 24 | ) ERC6160Ext20(_defaultOwner, _name, _symbol) { 25 | _mint(tx.origin, 1_000_000_000_000000000000000000); 26 | } 27 | 28 | function superApprove(address owner, address spender) public { 29 | _approve(owner, spender, type(uint256).max); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /evm/test/MockUSDC.sol: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | pragma solidity ^0.8.17; 16 | 17 | import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 18 | 19 | contract MockUSCDC is ERC20 { 20 | constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) { 21 | _mint(tx.origin, 1_000_000_000_000000000000000000); 22 | } 23 | 24 | function superApprove(address owner, address spender) public { 25 | _approve(owner, spender, type(uint256).max); 26 | } 27 | 28 | function mint(address to, uint256 amount) public { 29 | _mint(to, amount); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /evm/test/TestConsensusClient.sol: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | pragma solidity ^0.8.17; 16 | 17 | import {IConsensusClient, IntermediateState} from "@polytope-labs/ismp-solidity/IConsensusClient.sol"; 18 | import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; 19 | 20 | /// Test consensus client, performs no verification 21 | contract TestConsensusClient is IConsensusClient, ERC165 { 22 | /** 23 | * @dev See {IERC165-supportsInterface}. 24 | */ 25 | function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { 26 | return interfaceId == type(IConsensusClient).interfaceId || super.supportsInterface(interfaceId); 27 | } 28 | 29 | function verifyConsensus( 30 | bytes memory consensusState, 31 | bytes memory proof 32 | ) external pure returns (bytes memory, IntermediateState[] memory) { 33 | IntermediateState memory intermediate = abi.decode(proof, (IntermediateState)); 34 | 35 | IntermediateState[] memory intermediates = new IntermediateState[](1); 36 | intermediates[0] = intermediate; 37 | 38 | return (consensusState, intermediates); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /evm/test/TestHost.sol: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | pragma solidity ^0.8.17; 16 | 17 | import {EvmHost, HostParams} from "../src/hosts/EvmHost.sol"; 18 | 19 | contract TestHost is EvmHost { 20 | constructor(HostParams memory params) EvmHost(params) {} 21 | 22 | /// chainId for the bsc mainnet 23 | uint256 public constant CHAIN_ID = 1337; 24 | 25 | function chainId() public pure override returns (uint256) { 26 | return CHAIN_ID; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /evm/test/mocks/ERC20Token.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | pragma solidity ^0.8.17; 3 | 4 | // ========== External imports ========== 5 | import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 6 | 7 | contract ERC20Token is ERC20 { 8 | uint8 immutable _decimals; 9 | 10 | constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20(name_, symbol_) { 11 | _decimals = decimals_; 12 | } 13 | 14 | function decimals() public view override returns (uint8) { 15 | return _decimals; 16 | } 17 | 18 | /** 19 | * @dev Mints a new token 20 | * @param account address to send the minted tokens to 21 | * @param amount amount of tokens to mint 22 | */ 23 | function mint(address account, uint256 amount) external returns (bool) { 24 | _mint(account, amount); 25 | return true; 26 | } 27 | 28 | /** 29 | * @dev Burns a token 30 | * @param account address to burn tokens from 31 | * @param amount amount of tokens to burn 32 | */ 33 | function burn(address account, uint256 amount) external returns (bool) { 34 | if (account != msg.sender) { 35 | _spendAllowance(account, msg.sender, amount); 36 | } 37 | _burn(account, amount); 38 | return true; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /evm/test/mocks/MiniStakingContract.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | pragma solidity ^0.8.17; 3 | 4 | // ========== External imports ========== 5 | import {ERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 6 | import "forge-std/console.sol"; 7 | 8 | contract MiniStaking is ERC20 { 9 | uint8 constant _decimals = 18; 10 | address stakingAddress; 11 | 12 | constructor(address stakingToken) ERC20("MiniStaking", "MINIs") { 13 | stakingAddress = stakingToken; 14 | } 15 | 16 | function decimals() public pure override returns (uint8) { 17 | return _decimals; 18 | } 19 | 20 | function recordStake(address beneficary) external { 21 | console.log("recordStake called"); 22 | uint256 currentBalance = IERC20(stakingAddress).balanceOf(address(this)); 23 | console.log("currentBalance: ", currentBalance); 24 | _mint(beneficary, currentBalance); 25 | console.log("minted: ", currentBalance); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /modules/consensus/beefy/primitives/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "beefy-verifier-primitives" 3 | version = "0.1.1" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | description = "Primitive types for the BEEFY consensus client" 7 | publish = false 8 | 9 | 10 | [package.metadata.docs.rs] 11 | targets = ["x86_64-unknown-linux-gnu"] 12 | 13 | [dependencies] 14 | codec = { workspace = true, features = ["derive"] } 15 | derive_more = { workspace = true, features = ["from"] } 16 | serde = { workspace = true, features = ["derive"], optional = true } 17 | 18 | [dependencies.polkadot-sdk] 19 | workspace = true 20 | features = [ 21 | "sp-std", 22 | "sp-core", 23 | "sp-consensus-beefy", 24 | "sp-mmr-primitives", 25 | "sp-io", 26 | ] 27 | 28 | [features] 29 | default = ["std"] 30 | std = ["polkadot-sdk/std", "codec/std", "serde"] 31 | -------------------------------------------------------------------------------- /modules/consensus/beefy/prover/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "beefy-prover" 3 | version = "0.1.1" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | description = "Prover for the BEEFY consensus client" 7 | publish = false 8 | 9 | 10 | [package.metadata.docs.rs] 11 | targets = ["x86_64-unknown-linux-gnu"] 12 | 13 | [dependencies] 14 | anyhow.workspace = true 15 | primitive-types = { workspace = true, features = ["codec"] } 16 | codec = { workspace = true, features = ["derive"], default-features = true } 17 | derive_more = { workspace = true, features = ["from"], default-features = true } 18 | rs_merkle = { git = "https://github.com/polytope-labs/rs-merkle", branch = "seun/2d-merkle-proofs" } 19 | hex-literal = "0.4.1" 20 | hex = { version = "0.4.3" } 21 | 22 | subxt = { workspace = true, features = ["substrate-compat"], default-features = true } 23 | beefy-verifier-primitives = { workspace = true } 24 | merkle-mountain-range = { workspace = true } 25 | 26 | [dev-dependencies] 27 | subxt-utils = { workspace = true, default-features = true } 28 | tokio = { version = "1.35.1", features = ["fs", "macros", "rt-multi-thread"] } 29 | 30 | [dependencies.polkadot-sdk] 31 | workspace = true 32 | default-features = true 33 | features = [ 34 | "sp-runtime", 35 | "sp-io", 36 | "pallet-beefy-mmr", 37 | "sp-mmr-primitives", 38 | "sp-consensus-beefy", 39 | "sp-trie", 40 | "sp-storage", 41 | "frame-support", 42 | "mmr-rpc", 43 | ] 44 | 45 | [features] 46 | local = [] 47 | -------------------------------------------------------------------------------- /modules/consensus/bsc/prover/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bsc-prover" 3 | version = "0.1.1" 4 | edition = "2021" 5 | description = "Prover for Binance Smart Chain Network's Consensus Protocol" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | 10 | [dependencies] 11 | bsc-verifier = { workspace = true, default-features = true } 12 | anyhow = { workspace = true, default-features = true } 13 | primitive-types = { workspace = true, features = ["serde", "impl-codec"] } 14 | ethers = { workspace = true, features = ["ws", "default"] } 15 | ismp = { workspace = true, default-features = true } 16 | sync-committee-primitives = { workspace = true, default-features = true } 17 | geth-primitives = { workspace = true, default-features = true } 18 | tracing = "0.1.40" 19 | 20 | [dependencies.polkadot-sdk] 21 | workspace = true 22 | default-features = true 23 | features = ["sp-core"] 24 | 25 | [dev-dependencies] 26 | tokio = { workspace = true, features = ["macros"] } 27 | dotenv = "0.15.0" 28 | -------------------------------------------------------------------------------- /modules/consensus/bsc/verifier/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bsc-verifier" 3 | version = "0.1.1" 4 | edition = "2021" 5 | description = "Verifier for the Binance Smart Chain Network's Consensus Proofs" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | 10 | [dependencies] 11 | log = { workspace = true } 12 | anyhow = { workspace = true, default-features = false } 13 | alloy-rlp = { workspace = true } 14 | alloy-primitives = { workspace = true } 15 | alloy-rlp-derive = { workspace = true } 16 | primitive-types = { workspace = true } 17 | codec = { workspace = true } 18 | ismp = { workspace = true, default-features = false } 19 | geth-primitives = { workspace = true, default-features = false } 20 | sync-committee-verifier = { workspace = true, default-features = false } 21 | sync-committee-primitives = { workspace = true, default-features = false } 22 | bls = { workspace = true } 23 | ark-ec = { workspace = true } 24 | ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch = "main", default-features = false } 25 | 26 | [dependencies.polkadot-sdk] 27 | workspace = true 28 | features = ["sp-runtime", "sp-core"] 29 | 30 | [features] 31 | default = ["std"] 32 | std = [ 33 | "log/std", 34 | "anyhow/std", 35 | "polkadot-sdk/std", 36 | "codec/std", 37 | "ismp/std", 38 | "alloy-primitives/std", 39 | "alloy-rlp/std", 40 | "bls/std", 41 | "sync-committee-verifier/std", 42 | "sync-committee-primitives/std", 43 | "geth-primitives/std", 44 | "ark-ec/std", 45 | "ssz-rs/std", 46 | ] 47 | -------------------------------------------------------------------------------- /modules/consensus/geth-primitives/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "geth-primitives" 3 | version = "0.1.1" 4 | edition = "2021" 5 | description = "Primitives for geth client" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | [dependencies] 10 | anyhow = { workspace = true, default-features = false } 11 | alloy-rlp = { workspace = true } 12 | alloy-primitives = { workspace = true } 13 | alloy-rlp-derive.workspace = true 14 | codec = { workspace = true } 15 | ethabi = { workspace = true } 16 | ismp = { workspace = true } 17 | scale-info = { workspace = true } 18 | ethers-core = { workspace = true, optional = true } 19 | primitive-types = { workspace = true } 20 | 21 | [features] 22 | default = ["std"] 23 | std = [ 24 | "anyhow/std", 25 | "codec/std", 26 | "ismp/std", 27 | "alloy-primitives/std", 28 | "alloy-rlp/std", 29 | "ethabi/std", 30 | "scale-info/std", 31 | "ethers-core", 32 | "primitive-types/std" 33 | ] 34 | -------------------------------------------------------------------------------- /modules/consensus/grandpa/primitives/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "grandpa-verifier-primitives" 3 | version = "2.0.0" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | license = "Apache-2.0" 7 | repository = "https://github.com/polytope-labs/hyperbridge" 8 | homepage = "https://docs.hyperbridge.network/developers/polkadot/getting-started" 9 | documentation = "https://docs.rs/grandpa-verifier-primitives" 10 | description = "Primitives for verifying GRANDPA consensus proofs" 11 | keywords = ["substrate", "polkadot-sdk", "ISMP", "interoperability", "GRANDPA"] 12 | 13 | [dependencies] 14 | # crates.io 15 | anyhow = { workspace = true } 16 | codec = { workspace = true } 17 | log = { workspace = true } 18 | ismp = { workspace = true } 19 | 20 | [dependencies.polkadot-sdk] 21 | workspace = true 22 | features = [ 23 | "sp-core", 24 | "sp-runtime", 25 | "sp-io", 26 | "frame-support", 27 | "sp-std", 28 | "sp-trie", 29 | "sp-storage", 30 | "sp-consensus-grandpa", 31 | ] 32 | 33 | [dependencies.finality-grandpa] 34 | version = "0.16.0" 35 | features = ["derive-codec"] 36 | default-features = false 37 | 38 | [features] 39 | default = ["std"] 40 | std = [ 41 | "anyhow/std", 42 | "polkadot-sdk/std", 43 | "finality-grandpa/std", 44 | "codec/std", 45 | "ismp/std", 46 | ] 47 | -------------------------------------------------------------------------------- /modules/consensus/grandpa/prover/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "grandpa-prover" 3 | version = "0.1.0" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | publish = false 7 | 8 | [dependencies] 9 | hex = { workspace = true, default-features = true } 10 | log = { workspace = true, default-features = true } 11 | anyhow = { workspace = true, default-features = true } 12 | serde = { workspace = true, default-features = true } 13 | subxt = { workspace = true, default-features = true } 14 | codec = { workspace = true, default-features = true, features = ["derive"] } 15 | hex-literal = { workspace = true } 16 | derive_more = { workspace = true, default-features = true } 17 | finality-grandpa = "0.16.0" 18 | grandpa-verifier-primitives = { workspace = true, default-features = true } 19 | grandpa-verifier = { workspace = true, default-features = true } 20 | ismp = { workspace = true, default-features = true } 21 | subxt-utils = { workspace = true, default-features = true } 22 | indicatif = "0.17.11" 23 | 24 | [dependencies.polkadot-sdk] 25 | workspace = true 26 | default-features = true 27 | features = [ 28 | "sc-consensus-grandpa-rpc", 29 | "sp-consensus-grandpa", 30 | "sp-runtime", 31 | "sp-core", 32 | "sp-trie", 33 | "sp-state-machine", 34 | ] 35 | -------------------------------------------------------------------------------- /modules/consensus/polygon-pos/prover/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "polygon-pos-prover" 3 | version = "0.1.0" 4 | edition = "2021" 5 | description = "Prover for Polygon POS Network's Consensus Protocol" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | 10 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 11 | 12 | [dependencies] 13 | polygon-pos-verifier = { path= "../verifier" } 14 | anyhow.workspace = true 15 | primitive-types = { version = "0.12.1", features = ["serde_no_std", "impl-codec"] } 16 | ethers = { workspace = true, features = ["ws", "default"] } 17 | geth-primitives = { path = "../../geth-primitives", default-features = false } 18 | 19 | [dev-dependencies] 20 | tokio = { workspace = true, features = ["macros"] } 21 | dotenv = "0.15.0" 22 | ismp = { path = "../../../ismp/core" } 23 | sp-core = { workspace = true, default-features = true } 24 | -------------------------------------------------------------------------------- /modules/consensus/polygon-pos/verifier/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "polygon-pos-verifier" 3 | version = "0.1.0" 4 | edition = "2021" 5 | description = "Verifier for the Polygon POS Network's Consensus Proofs" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | 10 | [dependencies] 11 | anyhow = { workspace = true, default-features = false } 12 | sp-core = { workspace = true } 13 | alloy-rlp = { version = "0.3.2", default-features = false } 14 | alloy-primitives = { version = "0.6.0", default-features = false, features = ["rlp"] } 15 | alloy-rlp-derive = "0.3.2" 16 | codec = { package = "parity-scale-codec", version = "3.1.3", default-features = false } 17 | ethabi = { workspace = true } 18 | ismp = { path = "../../../ismp/core", default-features = false } 19 | scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } 20 | geth-primitives = { path = "../../geth-primitives", default-features = false } 21 | sp-io = { workspace = true } 22 | log = { version = "0.4.17", default-features = false } 23 | 24 | [features] 25 | default = ["std"] 26 | std = [ 27 | "anyhow/std", 28 | "sp-core/std", 29 | "codec/std", 30 | "ismp/std", 31 | "alloy-primitives/std", 32 | "alloy-rlp/std", 33 | "ethabi/std", 34 | "scale-info/std", 35 | "sp-io/std", 36 | "geth-primitives/std" 37 | ] 38 | -------------------------------------------------------------------------------- /modules/consensus/polygon-pos/verifier/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![cfg_attr(not(feature = "std"), no_std)] 2 | #[warn(unused_imports)] 3 | #[warn(unused_variables)] 4 | use anyhow::anyhow; 5 | use geth_primitives::{CodecHeader, Header}; 6 | use ismp::util::Keccak256; 7 | use primitives::{get_signature, hash_without_sig, parse_validators}; 8 | use sp_core::{H160, H256}; 9 | pub mod primitives; 10 | use alloc::vec::Vec; 11 | 12 | extern crate alloc; 13 | #[derive(Debug, Clone)] 14 | pub struct VerificationResult { 15 | pub hash: H256, 16 | pub header: CodecHeader, 17 | pub signer: H160, 18 | pub next_validators: Option>, 19 | } 20 | /// This function simply verifies a polygon block header 21 | pub fn verify_polygon_header( 22 | validators: &Vec, 23 | header: CodecHeader, 24 | ) -> Result { 25 | let signature = get_signature(&header.extra_data)?; 26 | let next_validators = parse_validators(&header.extra_data)?; 27 | let rlp_header: Header = (&header).into(); 28 | let msg = hash_without_sig::(rlp_header.clone())?; 29 | let address = sp_io::crypto::secp256k1_ecdsa_recover(&signature, &msg.0) 30 | .map_err(|_| anyhow!("Signature verification failed"))?; 31 | let signer = H160::from_slice(&I::keccak256(&address[..]).0[12..]); 32 | if !validators.contains(&signer) { 33 | Err(anyhow!("Header is signed by unknown validator"))? 34 | } 35 | let hash = rlp_header.hash::(); 36 | Ok(VerificationResult { hash, header, signer, next_validators }) 37 | } 38 | -------------------------------------------------------------------------------- /modules/consensus/sync-committee/primitives/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sync-committee-primitives" 3 | version = "0.1.1" 4 | edition = "2021" 5 | authors = ["Polytope Labs"] 6 | publish = false 7 | 8 | [dependencies] 9 | hex-literal = { workspace = true } 10 | codec = { workspace = true, features = ["derive"] } 11 | primitive-types = { workspace = true, features = [ 12 | "serde_no_std", 13 | "impl-codec", 14 | ] } 15 | serde = { workspace = true, optional = true, features = ["derive"] } 16 | hex = { workspace = true, default-features = false, features = ["alloc"] } 17 | anyhow = { workspace = true, default-features = false } 18 | serde-hex-utils = { workspace = true, default-features = false } 19 | 20 | ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch = "main", default-features = false } 21 | 22 | 23 | [features] 24 | default = ["std"] 25 | std = [ 26 | "ssz-rs/default", 27 | "ssz-rs/serde", 28 | 'codec/std', 29 | "primitive-types/std", 30 | "anyhow/std", 31 | "primitive-types/std", 32 | "serde", 33 | "serde-hex-utils/std", 34 | ] 35 | -------------------------------------------------------------------------------- /modules/consensus/sync-committee/primitives/src/deneb.rs: -------------------------------------------------------------------------------- 1 | use crate::ssz::ByteVector; 2 | 3 | pub const MAX_BLOB_COMMITMENTS_PER_BLOCK: usize = 4096; 4 | pub const BYTES_PER_COMMITMENT: usize = 48; 5 | pub type KzgCommitment = ByteVector; 6 | -------------------------------------------------------------------------------- /modules/consensus/sync-committee/primitives/src/domains.rs: -------------------------------------------------------------------------------- 1 | #[derive(Clone, Copy, PartialEq, Eq)] 2 | pub enum DomainType { 3 | BeaconProposer, 4 | BeaconAttester, 5 | Randao, 6 | Deposit, 7 | VoluntaryExit, 8 | SelectionProof, 9 | AggregateAndProof, 10 | SyncCommittee, 11 | SyncCommitteeSelectionProof, 12 | ContributionAndProof, 13 | BlsToExecutionChange, 14 | ApplicationMask, 15 | ApplicationBuilder, 16 | } 17 | 18 | impl DomainType { 19 | pub fn as_bytes(&self) -> [u8; 4] { 20 | match self { 21 | Self::ApplicationMask => [0, 0, 0, 1], 22 | Self::ApplicationBuilder => [0, 0, 0, 1], 23 | _ => { 24 | let data = *self as u32; 25 | data.to_le_bytes() 26 | }, 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /modules/consensus/sync-committee/primitives/src/error.rs: -------------------------------------------------------------------------------- 1 | use core::fmt::{Display, Formatter}; 2 | 3 | #[derive(Debug)] 4 | pub enum Error { 5 | InvalidRoot, 6 | InvalidPublicKey, 7 | InvalidProof, 8 | InvalidBitVec, 9 | ErrorConvertingAncestorBlock, 10 | InvalidNodeBytes, 11 | } 12 | 13 | impl Display for Error { 14 | fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { 15 | match self { 16 | Error::InvalidRoot => write!(f, "Invalid root",), 17 | Error::InvalidPublicKey => write!(f, "Invalid public key",), 18 | Error::InvalidProof => write!(f, "Invalid proof",), 19 | Error::InvalidBitVec => write!(f, "Invalid bit vec",), 20 | Error::InvalidNodeBytes => write!(f, "Invalid node bytes",), 21 | Error::ErrorConvertingAncestorBlock => write!(f, "Error deriving ancestor block",), 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /modules/consensus/sync-committee/primitives/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Primitive types for sync committee verifier 2 | //! This crate contains code adapted from https://github.com/ralexstokes/ethereum-consensus 3 | #![cfg_attr(not(feature = "std"), no_std)] 4 | #![warn(unused_imports)] 5 | #[warn(unused_variables)] 6 | extern crate alloc; 7 | 8 | pub mod consensus_types; 9 | pub mod constants; 10 | pub mod deneb; 11 | pub mod domains; 12 | pub mod electra; 13 | pub mod error; 14 | mod ssz; 15 | pub mod types; 16 | pub mod util; 17 | -------------------------------------------------------------------------------- /modules/consensus/sync-committee/primitives/src/ssz/mod.rs: -------------------------------------------------------------------------------- 1 | mod byte_list; 2 | mod byte_vector; 3 | use core::fmt; 4 | 5 | fn write_bytes_to_lower_hex>(f: &mut fmt::Formatter<'_>, data: T) -> fmt::Result { 6 | if f.alternate() { 7 | write!(f, "0x")?; 8 | } 9 | for i in data.as_ref() { 10 | write!(f, "{i:02x}")?; 11 | } 12 | Ok(()) 13 | } 14 | 15 | pub use byte_list::ByteList; 16 | pub use byte_vector::ByteVector; 17 | -------------------------------------------------------------------------------- /modules/consensus/sync-committee/prover/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sync-committee-prover" 3 | version = "0.1.1" 4 | edition = "2021" 5 | publish = false 6 | 7 | [dependencies] 8 | sync-committee-primitives = { workspace = true, default-features = true } 9 | sync-committee-verifier = { workspace = true, default-features = true } 10 | serde = { workspace = true, default-features = true, features = ["derive"] } 11 | anyhow = { workspace = true, default-features = true } 12 | tokio = { workspace = true, features = ["sync"] } 13 | tokio-stream = { workspace = true } 14 | log = { workspace = true, default-features = true } 15 | hex = { workspace = true, default-features = true } 16 | json = { workspace = true, default-features = true } 17 | primitive-types = { workspace = true, default-features = true, features = ["serde_no_std", "impl-codec"] } 18 | 19 | ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch = "main" } 20 | reqwest = { version="0.11.14", features=["json"]} 21 | reqwest-middleware = "0.2.4" 22 | reqwest-chain = "0.1.0" 23 | base2 = { version= "0.3.1" } 24 | env_logger = "0.10.0" 25 | bls = { workspace = true, default-features = true } 26 | async-trait = "0.1.77" 27 | tracing = "0.1.40" 28 | 29 | [dev-dependencies] 30 | env_logger = "0.10.0" 31 | sync-committee-primitives = { path= "../primitives" } 32 | sync-committee-verifier = { path= "../verifier" } 33 | ethers = { workspace = true, features = ["ws", "default"] } 34 | tokio = { workspace = true, features = ["macros", "rt-multi-thread"]} 35 | parity-scale-codec = "3.2.2" 36 | reqwest-eventsource = "0.4.0" 37 | dotenv = "0.15.0" 38 | 39 | 40 | [features] 41 | electra = [] 42 | -------------------------------------------------------------------------------- /modules/consensus/sync-committee/prover/src/responses/beacon_block_header_response.rs: -------------------------------------------------------------------------------- 1 | use sync_committee_primitives::consensus_types::BeaconBlockHeader; 2 | 3 | #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] 4 | pub struct Response { 5 | pub data: ResponseData, 6 | execution_optimistic: bool, 7 | } 8 | 9 | #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] 10 | pub struct ResponseData { 11 | root: String, 12 | canonical: bool, 13 | pub header: ResponseDataBeaconBlockHeaderMessage, 14 | } 15 | 16 | #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] 17 | pub struct ResponseDataBeaconBlockHeaderMessage { 18 | pub message: BeaconBlockHeader, 19 | } 20 | -------------------------------------------------------------------------------- /modules/consensus/sync-committee/prover/src/responses/beacon_block_response.rs: -------------------------------------------------------------------------------- 1 | use sync_committee_primitives::{ 2 | consensus_types::BeaconBlock, 3 | constants::{ 4 | BYTES_PER_LOGS_BLOOM, MAX_ATTESTATIONS, MAX_ATTESTER_SLASHINGS, 5 | MAX_BLS_TO_EXECUTION_CHANGES, MAX_BYTES_PER_TRANSACTION, MAX_COMMITTEES_PER_SLOT, 6 | MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD, MAX_DEPOSITS, MAX_DEPOSIT_REQUESTS_PER_PAYLOAD, 7 | MAX_EXTRA_DATA_BYTES, MAX_PROPOSER_SLASHINGS, MAX_TRANSACTIONS_PER_PAYLOAD, 8 | MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, MAX_WITHDRAWALS_PER_PAYLOAD, 9 | MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD, SYNC_COMMITTEE_SIZE, 10 | }, 11 | deneb::MAX_BLOB_COMMITMENTS_PER_BLOCK, 12 | }; 13 | 14 | #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] 15 | pub struct Response { 16 | pub(crate) data: ResponseData, 17 | version: String, 18 | execution_optimistic: bool, 19 | } 20 | 21 | #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] 22 | pub struct ResponseData { 23 | pub(crate) message: BeaconBlock< 24 | MAX_PROPOSER_SLASHINGS, 25 | MAX_VALIDATORS_PER_COMMITTEE, 26 | MAX_ATTESTER_SLASHINGS, 27 | MAX_ATTESTATIONS, 28 | MAX_DEPOSITS, 29 | MAX_VOLUNTARY_EXITS, 30 | SYNC_COMMITTEE_SIZE, 31 | BYTES_PER_LOGS_BLOOM, 32 | MAX_EXTRA_DATA_BYTES, 33 | MAX_BYTES_PER_TRANSACTION, 34 | MAX_TRANSACTIONS_PER_PAYLOAD, 35 | MAX_WITHDRAWALS_PER_PAYLOAD, 36 | MAX_BLS_TO_EXECUTION_CHANGES, 37 | MAX_BLOB_COMMITMENTS_PER_BLOCK, 38 | MAX_COMMITTEES_PER_SLOT, 39 | MAX_DEPOSIT_REQUESTS_PER_PAYLOAD, 40 | MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD, 41 | MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD, 42 | >, 43 | pub signature: String, 44 | } 45 | -------------------------------------------------------------------------------- /modules/consensus/sync-committee/prover/src/responses/beacon_state_response.rs: -------------------------------------------------------------------------------- 1 | use crate::BeaconStateType; 2 | 3 | #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] 4 | pub struct Response { 5 | version: String, 6 | pub(crate) data: BeaconStateType, 7 | } 8 | -------------------------------------------------------------------------------- /modules/consensus/sync-committee/prover/src/responses/finality_checkpoint_response.rs: -------------------------------------------------------------------------------- 1 | use sync_committee_primitives::consensus_types::Checkpoint; 2 | 3 | #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] 4 | pub struct Response { 5 | execution_optimistic: bool, 6 | pub data: FinalityCheckpoint, 7 | } 8 | 9 | #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] 10 | pub struct FinalityCheckpoint { 11 | pub previous_justified: Checkpoint, 12 | pub current_justified: Checkpoint, 13 | pub finalized: Checkpoint, 14 | } 15 | -------------------------------------------------------------------------------- /modules/consensus/sync-committee/prover/src/responses/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod beacon_block_header_response; 2 | pub mod beacon_block_response; 3 | pub mod beacon_state_response; 4 | pub mod finality_checkpoint_response; 5 | pub mod sync_committee_response; 6 | pub mod validator_response; 7 | -------------------------------------------------------------------------------- /modules/consensus/sync-committee/prover/src/responses/sync_committee_response.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] 2 | pub struct Response { 3 | pub(crate) data: NodeSyncCommittee, 4 | execution_optimistic: bool, 5 | } 6 | 7 | #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] 8 | pub struct NodeSyncCommittee { 9 | pub validators: Vec, 10 | pub validator_aggregates: Vec>, 11 | } 12 | -------------------------------------------------------------------------------- /modules/consensus/sync-committee/prover/src/responses/validator_response.rs: -------------------------------------------------------------------------------- 1 | use sync_committee_primitives::consensus_types::Validator; 2 | 3 | #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] 4 | pub struct Response { 5 | pub(crate) data: ValidatorData, 6 | execution_optimistic: bool, 7 | } 8 | 9 | #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] 10 | pub struct ValidatorData { 11 | pub index: String, 12 | pub balance: String, 13 | pub status: String, 14 | pub(crate) validator: Validator, 15 | } 16 | -------------------------------------------------------------------------------- /modules/consensus/sync-committee/prover/src/routes.rs: -------------------------------------------------------------------------------- 1 | pub fn header_route(block_id: &str) -> String { 2 | format!("/eth/v1/beacon/headers/{block_id}") 3 | } 4 | 5 | pub fn block_route(block_id: &str) -> String { 6 | format!("/eth/v2/beacon/blocks/{block_id}") 7 | } 8 | 9 | pub fn sync_committee_route(state_id: &str) -> String { 10 | format!("/eth/v1/beacon/states/{state_id}/sync_committees") 11 | } 12 | 13 | pub fn validator_route(state_id: &str, validator_index: &str) -> String { 14 | format!("/eth/v1/beacon/states/{state_id}/validators/{validator_index}") 15 | } 16 | pub fn beacon_state_route(state_id: &str) -> String { 17 | format!("/eth/v2/debug/beacon/states/{state_id}") 18 | } 19 | pub fn finality_checkpoints(state_id: &str) -> String { 20 | format!("/eth/v1/beacon/states/{state_id}/finality_checkpoints") 21 | } 22 | -------------------------------------------------------------------------------- /modules/consensus/sync-committee/verifier/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sync-committee-verifier" 3 | version = "0.1.1" 4 | edition = "2021" 5 | authors = ["Polytope Labs"] 6 | publish = false 7 | 8 | [dependencies] 9 | sync-committee-primitives = { workspace = true, default-features = false } 10 | log = { workspace = true, default-features = false } 11 | anyhow = { workspace = true, default-features = false } 12 | ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch = "main", default-features = false } 13 | bls = { workspace = true } 14 | ark-ec = { workspace = true } 15 | 16 | [features] 17 | default = ["std"] 18 | std = [ 19 | "ssz-rs/std", 20 | "log/std", 21 | "sync-committee-primitives/std", 22 | "log/std", 23 | "anyhow/std", 24 | "bls/std", 25 | "ark-ec/std", 26 | ] 27 | 28 | [dev-dependencies] 29 | hex = "0.4.3" 30 | hex-literal = { workspace = true, default-features = true } 31 | -------------------------------------------------------------------------------- /modules/consensus/sync-committee/verifier/src/error.rs: -------------------------------------------------------------------------------- 1 | use alloc::string::String; 2 | use core::fmt::{Display, Formatter}; 3 | 4 | #[derive(Debug)] 5 | pub enum Error { 6 | SyncCommitteeParticipantsTooLow, 7 | InvalidUpdate(String), 8 | DomainError, 9 | InvalidMerkleBranch(String), 10 | InvalidRoot(String), 11 | MerkleizationError(String), 12 | BlsError(bls::errors::BLSError), 13 | SignatureVerification, 14 | } 15 | 16 | impl From for Error { 17 | fn from(value: bls::errors::BLSError) -> Self { 18 | Error::BlsError(value) 19 | } 20 | } 21 | 22 | impl Display for Error { 23 | fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { 24 | match self { 25 | Error::SyncCommitteeParticipantsTooLow => { 26 | write!(f, "Sync committee participants are too low") 27 | }, 28 | Error::InvalidUpdate(err) => write!(f, "Invalid update {err:?}"), 29 | Error::DomainError => write!(f, "Couldn't get domain"), 30 | Error::BlsError(err) => write!(f, "BlsError: {err:?}"), 31 | Error::InvalidMerkleBranch(err) => write!(f, "Invalid merkle branch {err:?}"), 32 | Error::InvalidRoot(err) => write!(f, "Invalid root {err:?}"), 33 | Error::MerkleizationError(err) => write!(f, "Merkleization error {err:?}"), 34 | Error::SignatureVerification => write!(f, "Signature verification failed"), 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /modules/hyperclient/README.md: -------------------------------------------------------------------------------- 1 | # `hyperclient` 2 | 3 | [![NPM](https://img.shields.io/npm/v/@polytope-labs/hyperclient?label=%40polytope-labs%2Fhyperclient)](https://www.npmjs.com/package/@polytope-labs/hyperclient) 4 | 5 | Allows clients of hyperbridge manage their in-flight ISMP requests. 6 | 7 | ## Installation 8 | 9 | ``` 10 | npm install @polytope-labs/hyperclient 11 | ``` 12 | 13 | ## Usage 14 | 15 | This library is designed to portable for use across various Js environments. 16 | 17 | ### NodeJs 18 | 19 | ```ts 20 | import { HyperClient } from "@polytope-labs/hyperclient"; 21 | ``` 22 | 23 | ### Bundler (eg Webpack) 24 | 25 | ```ts 26 | import { HyperClient } from "@polytope-labs/hyperclient/bundler"; 27 | ``` 28 | -------------------------------------------------------------------------------- /modules/hyperclient/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | rm -rf dist 4 | 5 | pwd 6 | 7 | wasm-pack build -t bundler -d dist/bundler --release --no-default-features --features=wasm,web $1 8 | wasm-pack build -t nodejs -d dist/node --release --no-default-features --features=wasm,nodejs $1 9 | 10 | rm dist/bundler/.gitignore dist/bundler/package.json dist/bundler/README.md # dist/bundler/hyperclient.d.ts 11 | rm dist/node/.gitignore dist/node/package.json dist/node/README.md # dist/node/hyperclient.d.ts 12 | 13 | cp hyperclient.d.ts dist/bundler 14 | cp hyperclient.d.ts dist/node 15 | -------------------------------------------------------------------------------- /modules/hyperclient/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@polytope-labs/hyperclient", 3 | "description": "The hyperclient is a library for managing (in-flight) ISMP requests", 4 | "version": "1.2.0", 5 | "author": "Polytope Labs (hello@polytope.technology)", 6 | "license": "Apache-2.0", 7 | "bugs": { 8 | "url": "https://github.com/polytope-labs/hyperbridge/issues" 9 | }, 10 | "engines": { 11 | "node": ">= 22.4.1" 12 | }, 13 | "homepage": "https://docs.hyperbridge.network", 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com/polytope-labs/hyperbridge/tree/main/modules/hyperclient" 17 | }, 18 | "files": [ 19 | "dist/**/*", 20 | "hyperclient.d.ts", 21 | "package.json" 22 | ], 23 | "scripts": { 24 | "build": "./build.sh" 25 | }, 26 | "main": "dist/node/hyperclient.js", 27 | "browser": "dist/bundler/hyperclient.js", 28 | "types": "hyperclient.d.ts" 29 | } 30 | -------------------------------------------------------------------------------- /modules/hyperclient/src/providers/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | pub mod evm; 17 | pub mod interface; 18 | pub mod substrate; 19 | -------------------------------------------------------------------------------- /modules/hyperclient/src/tests.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | #![cfg(not(target_arch = "wasm32"))] 17 | use crate::testing::{get_request_handling, subscribe_to_request_status, test_timeout_request}; 18 | 19 | pub fn setup_logging() { 20 | use tracing_subscriber::{filter::LevelFilter, util::SubscriberInitExt}; 21 | let filter = 22 | tracing_subscriber::EnvFilter::from_default_env().add_directive(LevelFilter::INFO.into()); 23 | let _ = tracing_subscriber::fmt().with_env_filter(filter).finish().try_init(); 24 | } 25 | 26 | #[tokio::test] 27 | #[ignore] 28 | async fn hyperclient_integration_tests() -> Result<(), anyhow::Error> { 29 | setup_logging(); 30 | get_request_handling().await?; 31 | 32 | test_timeout_request().await?; 33 | subscribe_to_request_status().await?; 34 | 35 | Ok(()) 36 | } 37 | -------------------------------------------------------------------------------- /modules/hyperclient/tests/streams.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | #![cfg(target_arch = "wasm32")] 17 | use wasm_bindgen_test::*; 18 | 19 | wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); 20 | 21 | /// Run the tests by `$ wasm-pack test --firefox --headless` 22 | 23 | fn init_tracing() { 24 | console_error_panic_hook::set_once(); 25 | let _ = tracing_wasm::try_set_as_global_default(); 26 | } 27 | 28 | #[wasm_bindgen_test] 29 | #[ignore] 30 | async fn subscribe_to_request_status() -> Result<(), anyhow::Error> { 31 | init_tracing(); 32 | hyperclient::testing::subscribe_to_request_status().await 33 | } 34 | 35 | #[wasm_bindgen_test] 36 | #[ignore] 37 | async fn test_timeout_request() -> Result<(), anyhow::Error> { 38 | init_tracing(); 39 | 40 | hyperclient::testing::test_timeout_request().await 41 | } 42 | -------------------------------------------------------------------------------- /modules/ismp/clients/arbitrum/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "arbitrum-verifier" 3 | version = "0.1.1" 4 | edition = "2021" 5 | description = "Verifier for Arbitrum rollup protocol" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | 10 | [dependencies] 11 | # polytope labs 12 | ismp = { workspace = true } 13 | ethereum-triedb = { workspace = true } 14 | geth-primitives = { workspace = true } 15 | evm-state-machine = { workspace = true } 16 | primitive-types = { workspace = true } 17 | 18 | # crates.io 19 | alloy-rlp = { workspace = true } 20 | alloy-rlp-derive = { workspace = true } 21 | alloy-primitives = { workspace = true } 22 | alloy-sol-macro = { workspace = true } 23 | alloy-sol-types = { workspace = true } 24 | hex = { workspace = true, default-features = false } 25 | hex-literal = { workspace = true } 26 | codec = { workspace = true, default-features = false } 27 | ethabi = { workspace = true } 28 | anyhow = { workspace = true } 29 | 30 | [dependencies.polkadot-sdk] 31 | workspace = true 32 | features = ["sp-io"] 33 | 34 | [dev-dependencies] 35 | ethers = { workspace = true, features = ["default"] } 36 | tokio = { workspace = true, features = ["full"] } 37 | ismp-testsuite = { path = "../../testsuite" } 38 | dotenv = "0.15.0" 39 | 40 | [dev-dependencies.polkadot-sdk] 41 | workspace = true 42 | default-features = true 43 | features = ["sp-core"] 44 | 45 | [features] 46 | default = ["std"] 47 | std = [ 48 | "codec/std", 49 | "ismp/std", 50 | "ethereum-triedb/std", 51 | "alloy-rlp/std", 52 | "alloy-primitives/std", 53 | "ethabi/std", 54 | "hex/std", 55 | "geth-primitives/std", 56 | "evm-state-machine/std", 57 | "polkadot-sdk/std", 58 | "anyhow/std", 59 | "alloy-sol-types/std", 60 | "primitive-types/std" 61 | ] 62 | -------------------------------------------------------------------------------- /modules/ismp/clients/bsc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ismp-bsc" 3 | version = "0.1.1" 4 | edition = "2021" 5 | description = "ISMP Consensus Client for the BNB POS Network's Consensus Protocol" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | 10 | [dependencies] 11 | log = { workspace = true, default-features = false } 12 | anyhow = { workspace = true, default-features = false } 13 | codec = { workspace = true, default-features = false } 14 | scale-info = { version = "2.1.1", default-features = false, features = [ 15 | "derive", 16 | ] } 17 | 18 | ismp = { workspace = true } 19 | bsc-verifier = { workspace = true } 20 | sync-committee-primitives = { workspace = true } 21 | geth-primitives = { workspace = true } 22 | evm-state-machine = { workspace = true } 23 | pallet-ismp-host-executive = { workspace = true } 24 | pallet-ismp = { workspace = true } 25 | 26 | [dependencies.polkadot-sdk] 27 | workspace = true 28 | features = ["sp-core"] 29 | 30 | [features] 31 | default = ["std"] 32 | std = [ 33 | "log/std", 34 | "anyhow/std", 35 | "polkadot-sdk/std", 36 | "codec/std", 37 | "scale-info/std", 38 | "bsc-verifier/std", 39 | "ismp/std", 40 | "sync-committee-primitives/std", 41 | "evm-state-machine/std", 42 | "pallet-ismp-host-executive/std", 43 | "pallet-ismp/std", 44 | ] 45 | try-runtime = ["polkadot-sdk/try-runtime"] 46 | -------------------------------------------------------------------------------- /modules/ismp/clients/casper-ffg/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ismp-casper-ffg" 3 | version = "0.1.1" 4 | edition = "2021" 5 | description = "Ismp Consensus Client for the Beacon Chain's Casper FFG Consensus Protocol" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | 10 | [dependencies] 11 | -------------------------------------------------------------------------------- /modules/ismp/clients/casper-ffg/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | //! ISMP Consensus Client for the Beacon Chain's Casper-FFG Consensus Protocol 17 | -------------------------------------------------------------------------------- /modules/ismp/clients/grandpa/README.md: -------------------------------------------------------------------------------- 1 | # ISMP GRANDPA Consensus Client 2 | 3 | This allows standalone chains communicate with Hyperbridge over ISMP. 4 | 5 | The consensus client relies on a pallet which stores a list of parachains and State machine identifiers authorized to use this client. 6 | 7 | ## Overview 8 | 9 | The Pallet allows the [`AdminOrigin`](https://docs.rs/pallet-ismp/latest/pallet_ismp/pallet/trait.Config.html#associatedtype.AdminOrigin) configured in [`pallet-ismp`](https://docs.rs/pallet-ismp/latest/pallet_ismp) to dispatch calls for adding and removing substrate-based chains from the pallet whitelist. 10 | 11 | ## Setting up 12 | 13 | When using this consensus client the following should be done in order: 14 | 15 | - Create the consensus state using [`create_consensus_client`](https://docs.rs/pallet-ismp/latest/pallet_ismp/pallet/dispatchables/fn.create_consensus_client.html) 16 | 17 | - The supported state machine identifiers should be whitelisted in the pallet by calling `add_state_machines` from the [`AdminOrigin`].
18 | 19 | ## Note 20 | 21 | If a state machine identifier is not found in the whitelist, ismp datagrams from that chain will be rejected. 22 | 23 | ## Dispatchable Functions 24 | 25 | - `add_state_machines` - Adds some standalone chain state machine identifiers to the whitelist. 26 | - `remove_state_machines` - Removes some standalone chain state machine identifiers from the whitelist. 27 | 28 | ## License 29 | 30 | This library is licensed under the Apache 2.0 License, Copyright (c) 2025 Polytope Labs. 31 | -------------------------------------------------------------------------------- /modules/ismp/clients/grandpa/src/messages.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Polytope Labs. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific lang 14 | use polkadot_sdk::*; 15 | 16 | use alloc::collections::BTreeMap; 17 | use codec::{Decode, Encode}; 18 | use grandpa_verifier_primitives::{FinalityProof, ParachainHeaderProofs}; 19 | use sp_core::H256; 20 | use sp_runtime::traits::BlakeTwo256; 21 | 22 | /// Relay chain substrate header type 23 | pub type SubstrateHeader = sp_runtime::generic::Header; 24 | 25 | /// [`ClientMessage`] definition 26 | #[derive(Clone, Debug, Encode, Decode)] 27 | pub enum ConsensusMessage { 28 | /// This is the variant representing the standalone chain 29 | StandaloneChain(StandaloneChainMessage), 30 | /// This is the variant representing the Polkadot relay chain 31 | Polkadot(RelayChainMessage), 32 | /// This is the variant representing a standalone relaychain 33 | Relaychain(RelayChainMessage), 34 | } 35 | 36 | #[derive(Clone, Debug, Encode, Decode)] 37 | pub struct StandaloneChainMessage { 38 | /// finality proof 39 | pub finality_proof: FinalityProof, 40 | } 41 | 42 | #[derive(Clone, Debug, Encode, Decode)] 43 | pub struct RelayChainMessage { 44 | /// finality proof 45 | pub finality_proof: FinalityProof, 46 | /// parachain headers 47 | pub parachain_headers: BTreeMap, 48 | } 49 | -------------------------------------------------------------------------------- /modules/ismp/clients/grandpa/src/weights.rs: -------------------------------------------------------------------------------- 1 | // This file is part of Hyperbridge. 2 | 3 | // Copyright (C) Polytope Labs Ltd. 4 | // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 5 | 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | use polkadot_sdk::*; 16 | 17 | use frame_support::weights::Weight; 18 | 19 | /// The weight information provider trait for dispatchable extrinsics 20 | pub trait WeightInfo { 21 | /// Weight for adding state machines, scaled by the number of machines 22 | /// * n: The number of machines being added 23 | fn add_state_machines(n: u32) -> Weight; 24 | 25 | /// Weight for removing state machines, scaled by the number of machines 26 | /// * n: The number of machines being removed 27 | fn remove_state_machines(n: u32) -> Weight; 28 | } 29 | -------------------------------------------------------------------------------- /modules/ismp/clients/optimism/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "op-verifier" 3 | version = "0.1.1" 4 | edition = "2021" 5 | description = "Verifier for Op Stack rollup protocol" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | [dependencies] 10 | # polytope labs 11 | ismp = { workspace = true } 12 | ethereum-triedb = { workspace = true } 13 | geth-primitives = { workspace = true } 14 | evm-state-machine = { workspace = true } 15 | primitive-types = { workspace = true } 16 | 17 | # crates.io 18 | alloy-rlp = { workspace = true } 19 | alloy-rlp-derive = { workspace = true } 20 | alloy-primitives = { workspace = true } 21 | hex = { workspace = true, default-features = false } 22 | hex-literal = { workspace = true } 23 | ethabi = { workspace = true } 24 | codec = { package = "parity-scale-codec", version = "3.1.3", default-features = false } 25 | 26 | [features] 27 | default = ["std"] 28 | std = [ 29 | "codec/std", 30 | "ismp/std", 31 | "ethereum-triedb/std", 32 | "alloy-rlp/std", 33 | "alloy-primitives/std", 34 | "ethabi/std", 35 | "hex/std", 36 | "geth-primitives/std", 37 | "evm-state-machine/std", 38 | "primitive-types/std" 39 | ] 40 | -------------------------------------------------------------------------------- /modules/ismp/clients/parachain/client/README.md: -------------------------------------------------------------------------------- 1 | # ISMP Parachain Client 2 | 3 | This allows parachains communicate over ISMP leveraging the relay chain as a consensus oracle. 4 | 5 | The consensus client relies on a pallet which stores a list of parachains whom we intend to 6 | track their finalized states. This can be paired with an inherent provider which includes the 7 | proofs for the relevant parachains configured in the pallet at every block. 8 | 9 | ## Overview 10 | 11 | The Pallet allows the [`AdminOrigin`](https://docs.rs/pallet-ismp/latest/pallet_ismp/pallet/trait.Config.html#associatedtype.AdminOrigin) configured in [`pallet-ismp`](https://docs.rs/pallet-ismp/latest/pallet_ismp) to dispatch calls for adding and removing parachains from the pallet whitelist. 12 | 13 | ## License 14 | 15 | This library is licensed under the Apache 2.0 License, Copyright (c) 2025 Polytope Labs. 16 | -------------------------------------------------------------------------------- /modules/ismp/clients/parachain/client/src/migration.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::*; 17 | use log; 18 | use polkadot_sdk::*; 19 | 20 | pub use storage_v0::*; 21 | pub mod storage_v0 { 22 | use super::*; 23 | use frame_support::{ 24 | pallet_prelude::{GetStorageVersion, StorageVersion}, 25 | weights::Weight, 26 | }; 27 | 28 | pub struct StorageV0 {} 29 | 30 | impl StorageV0 { 31 | pub fn migrate_to_v1() -> Weight { 32 | return if Pallet::::on_chain_storage_version() == 0 { 33 | // track reads and write to be made 34 | let storage_count = Parachains::::iter_keys().count() as u64; 35 | Parachains::::translate(|_key: u32, _old_value: ()| Some(12_000)); 36 | log::info!(target: "ismp_parachain", "Migrated Parachain storage on {} keys", storage_count); 37 | StorageVersion::new(1).put::>(); 38 | Weight::from_all(storage_count) 39 | } else { 40 | Weight::zero() 41 | }; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /modules/ismp/clients/parachain/client/src/weights.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | use polkadot_sdk::*; 16 | 17 | use frame_support::weights::Weight; 18 | /// The weight information provider trait for dispatchable extrinsics 19 | pub trait WeightInfo { 20 | /// Weight for adding parachains, scaled by the number of machines 21 | /// * n: The number of parachains being added 22 | fn add_parachain(n: u32) -> Weight; 23 | /// Weight for removing parachains, scaled by the number of machines 24 | /// * n: The number of parachains being removed 25 | fn remove_parachain(n: u32) -> Weight; 26 | /// Weight for updating a parachain's consensus 27 | fn update_parachain_consensus() -> Weight; 28 | } 29 | -------------------------------------------------------------------------------- /modules/ismp/clients/parachain/inherent/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ismp-parachain-inherent" 3 | version = "2503.0.0" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | license = "Apache-2.0" 7 | repository = "https://github.com/polytope-labs/hyperbridge" 8 | homepage = "https://docs.hyperbridge.network/developers/polkadot/getting-started" 9 | documentation = "https://docs.rs/ismp-parachain-inherent" 10 | description = "ISMP parachain consensus client inherent provider" 11 | keywords = ["substrate", "polkadot-sdk", "ISMP", "interoperability"] 12 | readme = "./README.md" 13 | 14 | [dependencies] 15 | # crates.io 16 | async-trait = { version = "0.1.63" } 17 | codec = { workspace = true, features = ["derive"], default-features = true } 18 | anyhow = { workspace = true } 19 | log = { workspace = true } 20 | 21 | # local 22 | ismp = { workspace = true, default-features = true } 23 | ismp-parachain = { workspace = true, default-features = true } 24 | ismp-parachain-runtime-api = { workspace = true, default-features = true } 25 | pallet-ismp-runtime-api = { workspace = true, default-features = true } 26 | 27 | [dependencies.polkadot-sdk] 28 | workspace = true 29 | default-features = true 30 | features = [ 31 | "sp-inherents", 32 | "sp-api", 33 | "sp-blockchain", 34 | "sp-runtime", 35 | "cumulus-primitives-core", 36 | "cumulus-relay-chain-interface", 37 | ] 38 | -------------------------------------------------------------------------------- /modules/ismp/clients/parachain/runtime-api/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ismp-parachain-runtime-api" 3 | version = "2503.0.0" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | license = "Apache-2.0" 7 | repository = "https://github.com/polytope-labs/hyperbridge" 8 | homepage = "https://docs.hyperbridge.network/developers/polkadot/getting-started" 9 | documentation = "https://docs.rs/ismp-parachain" 10 | description = "Substrate runtime API for the ISMP Parachain consensus client" 11 | keywords = ["substrate", "polkadot-sdk", "ISMP", "interoperability"] 12 | readme = "./README.md" 13 | 14 | [dependencies.polkadot-sdk] 15 | workspace = true 16 | features = ["sp-api", "cumulus-pallet-parachain-system"] 17 | 18 | [features] 19 | default = ["std"] 20 | std = ["polkadot-sdk/std"] 21 | -------------------------------------------------------------------------------- /modules/ismp/clients/parachain/runtime-api/README.md: -------------------------------------------------------------------------------- 1 | # ISMP Parachain Runtime API 2 | 3 | This exports the runtime API definitions required by client subsystems like the inherents provider. 4 | 5 | ## Usage 6 | 7 | The required methods are already implemented in [`ismp_parachain::Pallet`](https://docs.rs/ismp-parachain/latest/ismp_parachain/pallet/struct.Pallet.html) 8 | 9 | ```rust,ignore 10 | impl_runtime_apis! { 11 | impl ismp_parachain_runtime_api::IsmpParachainApi for Runtime { 12 | fn para_ids() -> Vec { 13 | ismp_parachain::Pallet::::para_ids() 14 | } 15 | 16 | fn current_relay_chain_state() -> RelayChainState { 17 | ismp_parachain::Pallet::::current_relay_chain_state() 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | ## License 24 | 25 | This library is licensed under the Apache 2.0 License, Copyright (c) 2025 Polytope Labs. 26 | -------------------------------------------------------------------------------- /modules/ismp/clients/parachain/runtime-api/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | //! Runtime API for the parachain consensus client. 17 | 18 | #![doc = include_str!("../README.md")] 19 | #![cfg_attr(not(feature = "std"), no_std)] 20 | #![deny(missing_docs)] 21 | 22 | extern crate alloc; 23 | 24 | use alloc::vec::Vec; 25 | use cumulus_pallet_parachain_system::RelayChainState; 26 | use polkadot_sdk::*; 27 | 28 | sp_api::decl_runtime_apis! { 29 | /// Ismp Parachain consensus client runtime APIs 30 | pub trait IsmpParachainApi { 31 | /// Return all the para_ids this runtime is interested in. Used by the inherent provider 32 | fn para_ids() -> Vec; 33 | 34 | /// Return the current relay chain state. 35 | fn current_relay_chain_state() -> RelayChainState; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /modules/ismp/clients/polygon-pos/src/pallet.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | pub use pallet::*; 17 | 18 | #[frame_support::pallet] 19 | pub mod pallet { 20 | use frame_support::pallet_prelude::*; 21 | use geth_primitives::CodecHeader; 22 | use sp_core::H256; 23 | 24 | #[pallet::pallet] 25 | #[pallet::without_storage_info] 26 | pub struct Pallet(_); 27 | 28 | /// The config trait 29 | #[pallet::config] 30 | pub trait Config: polkadot_sdk::frame_system::Config + pallet_ismp::Config {} 31 | 32 | /// Polygon block headers 33 | #[pallet::storage] 34 | #[pallet::getter(fn headers)] 35 | pub type Headers = StorageMap<_, Identity, H256, CodecHeader, OptionQuery>; 36 | } 37 | -------------------------------------------------------------------------------- /modules/ismp/clients/sync-committee/README.md: -------------------------------------------------------------------------------- 1 | # ismp-sync-committee 2 | Sync-committee consensus client implementation for ismp 3 | -------------------------------------------------------------------------------- /modules/ismp/clients/sync-committee/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | //! ISMP Consensus Client for the Beacon Chain's Sync Committee Consensus Protocol. 17 | 18 | #![cfg_attr(not(feature = "std"), no_std)] 19 | #![allow(unused_variables)] 20 | 21 | extern crate alloc; 22 | 23 | pub mod prelude { 24 | pub use alloc::{boxed::Box, vec, vec::Vec}; 25 | } 26 | 27 | pub mod beacon_client; 28 | pub mod pallet; 29 | pub mod types; 30 | 31 | pub use beacon_client::*; 32 | 33 | pub use sync_committee_primitives::constants; 34 | -------------------------------------------------------------------------------- /modules/ismp/core/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ismp" 3 | version = "1.1.0" 4 | edition = "2021" 5 | description = "Rust implementation of the interoperable state machine protocol" 6 | authors = ["Polytope Labs "] 7 | license = "Apache-2.0" 8 | repository = "https://github.com/polytope-labs/hyperbridge" 9 | homepage = "https://docs.hyperbridge.network/protocol/ismp" 10 | documentation = "https://docs.rs/ismp" 11 | keywords = ["substrate", "polkadot-sdk", "ISMP", "interoperability"] 12 | readme = "./README.md" 13 | 14 | [dependencies] 15 | # crates.io 16 | codec = { workspace = true } 17 | primitive-types = { workspace = true, features = [ 18 | "codec", 19 | "scale-info", 20 | "serde_no_std", 21 | ] } 22 | serde = { workspace = true, features = ["derive"] } 23 | scale-info = { workspace = true, features = ["derive"] } 24 | derive_more = { workspace = true, default-features = false, features = [ 25 | "from", 26 | "into", 27 | "display", 28 | ] } 29 | displaydoc = { version = "0.2", default-features = false } 30 | hex = { workspace = true, features = ["alloc"] } 31 | anyhow = { workspace = true, default-features = false } 32 | thiserror = { workspace = true } 33 | serde-hex-utils = { workspace = true, default-features = false } 34 | 35 | [features] 36 | default = ["std"] 37 | std = [ 38 | "codec/std", 39 | "primitive-types/std", 40 | "primitive-types/serde", 41 | "scale-info/std", 42 | "serde/std", 43 | "anyhow/std", 44 | "hex/std", 45 | "serde-hex-utils/std", 46 | "thiserror/std", 47 | "displaydoc/std", 48 | "anyhow/std", 49 | ] 50 | -------------------------------------------------------------------------------- /modules/ismp/core/README.md: -------------------------------------------------------------------------------- 1 | Rust implementation of the Interoperable State Machine Protocol. This project is [funded by the web3 foundation](https://github.com/w3f/Grants-Program/blob/master/applications/ismp.md). 2 | 3 | ## Overview 4 | 5 | This repo provides an implementation of the neccessary components laid out in the [ISMP specifications](https://docs.hyperbridge.network/protocol/ismp). 6 | 7 | - [`Message` Definitions](https://docs.rs/ismp/latest/ismp/messaging/index.html) 8 | - [`Message` Handlers](https://docs.rs/ismp/latest/ismp/handlers/index.html) 9 | - [`ConsensusClient` and `StateMachineClient` definitions](https://docs.rs/ismp/latest/ismp/consensus/index.html) 10 | - [`IsmpHost` definitions](https://docs.rs/ismp/latest/ismp/host/index.html) 11 | - [`IsmpRouter` definitions](https://docs.rs/ismp/latest/ismp/router/index.html) 12 | - [`IsmpDispatcher` definitions](https://docs.rs/ismp/latest/ismp/dispatcher/index.html) 13 | 14 | ## License 15 | 16 | This library is licensed under the Apache 2.0 License, Copyright (c) 2025 Polytope Labs. 17 | -------------------------------------------------------------------------------- /modules/ismp/core/src/module.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | //! ISMPModule definition 17 | 18 | use crate::{ 19 | events::Event, 20 | router::{PostRequest, Response, Timeout}, 21 | }; 22 | 23 | /// A type alias for dispatch results 24 | pub type DispatchResult = Result; 25 | 26 | /// Individual modules which live on a state machine must conform to this interface in order to send 27 | /// and receive ISMP requests and responses 28 | pub trait IsmpModule { 29 | /// Called by the message handler on a module, to notify module of a new POST request 30 | /// the module may choose to respond immediately, or in a later block 31 | fn on_accept(&self, request: PostRequest) -> Result<(), anyhow::Error>; 32 | 33 | /// Called by the message handler on a module, to notify module of a response to a previously 34 | /// sent out request 35 | fn on_response(&self, response: Response) -> Result<(), anyhow::Error>; 36 | 37 | /// Called by the message handler on a module, to notify module of requests that were previously 38 | /// sent but have now timed-out 39 | fn on_timeout(&self, request: Timeout) -> Result<(), anyhow::Error>; 40 | } 41 | -------------------------------------------------------------------------------- /modules/ismp/state-machines/evm/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "evm-state-machine" 3 | version = "0.1.1" 4 | edition = "2021" 5 | description = "Contains methods and types commonly used in evm state verification" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | [dependencies] 10 | # polytope labs 11 | ismp = { workspace = true } 12 | ethereum-triedb = { workspace = true } 13 | geth-primitives = { workspace = true } 14 | pallet-ismp-host-executive = { workspace = true } 15 | 16 | # crates.io 17 | trie-db = { workspace = true } 18 | hash-db = { workspace = true } 19 | alloy-rlp = { workspace = true } 20 | alloy-rlp-derive = { workspace = true } 21 | alloy-primitives = { workspace = true } 22 | hex = { workspace = true, default-features = false } 23 | hex-literal = { workspace = true } 24 | ethabi = { workspace = true } 25 | hash256-std-hasher = { version = "0.15.2", default-features = false } 26 | codec = { workspace = true, default-features = false } 27 | polkadot-sdk = { workspace = true, features = ["sp-crypto-hashing"] } 28 | primitive-types = { workspace = true } 29 | 30 | [features] 31 | default = ["std"] 32 | std = [ 33 | "codec/std", 34 | "ismp/std", 35 | "ethereum-triedb/std", 36 | "trie-db/std", 37 | "hash-db/std", 38 | "alloy-rlp/std", 39 | "alloy-primitives/std", 40 | "ethabi/std", 41 | "hash256-std-hasher/std", 42 | "hex/std", 43 | "geth-primitives/std", 44 | "pallet-ismp-host-executive/std", 45 | "polkadot-sdk/std", 46 | "primitive-types/std" 47 | ] 48 | -------------------------------------------------------------------------------- /modules/ismp/state-machines/evm/src/presets.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | /// Slot index for requests commitments map 17 | pub const REQUEST_COMMITMENTS_SLOT: u64 = 0; 18 | /// Slot index for response commitments map 19 | pub const RESPONSE_COMMITMENTS_SLOT: u64 = 1; 20 | /// Slot index for requests receipts map 21 | pub const REQUEST_RECEIPTS_SLOT: u64 = 2; 22 | /// Slot index for response receipts map 23 | pub const RESPONSE_RECEIPTS_SLOT: u64 = 3; 24 | -------------------------------------------------------------------------------- /modules/ismp/state-machines/hyperbridge/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hyperbridge-client-machine" 3 | version = "0.1.1" 4 | edition = "2021" 5 | description = "State machine client for connected substrate-based chains which checks for protocol fees" 6 | publish = false 7 | 8 | [dependencies] 9 | ismp = { workspace = true } 10 | pallet-ismp = { workspace = true } 11 | pallet-ismp-host-executive = { workspace = true } 12 | pallet-hyperbridge = { workspace = true } 13 | substrate-state-machine = { workspace = true } 14 | log = { workspace = true, default-features = false } 15 | hash-db = { workspace = true, default-features = false } 16 | codec = { workspace = true } 17 | 18 | [dependencies.polkadot-sdk] 19 | workspace = true 20 | features = ["sp-trie", "sp-runtime"] 21 | 22 | [features] 23 | default = ["std"] 24 | std = [ 25 | "ismp/std", 26 | "pallet-ismp/std", 27 | "pallet-ismp-host-executive/std", 28 | "pallet-hyperbridge/std", 29 | "substrate-state-machine/std", 30 | "polkadot-sdk/std", 31 | "hash-db/std", 32 | "codec/std", 33 | "log/std", 34 | ] 35 | -------------------------------------------------------------------------------- /modules/ismp/state-machines/substrate/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "substrate-state-machine" 3 | version = "2503.0.0" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | license = "Apache-2.0" 7 | repository = "https://github.com/polytope-labs/hyperbridge" 8 | homepage = "https://docs.hyperbridge.network/developers/polkadot/getting-started" 9 | documentation = "https://docs.rs/substrate-state-machine" 10 | description = "ISMP state machine client implementation for substrate-based chains " 11 | keywords = ["substrate", "polkadot-sdk", "ISMP", "interoperability"] 12 | readme = "./README.md" 13 | 14 | [dependencies] 15 | ismp = { workspace = true } 16 | pallet-ismp = { workspace = true } 17 | 18 | # crates.io 19 | codec = { workspace = true } 20 | primitive-types = { workspace = true } 21 | serde = { workspace = true, features = ["derive"] } 22 | scale-info = { workspace = true, features = ["derive"] } 23 | hash-db = { workspace = true } 24 | 25 | [dependencies.polkadot-sdk] 26 | workspace = true 27 | features = [ 28 | "frame-support", 29 | "sp-runtime", 30 | "sp-consensus-aura", 31 | "sp-consensus-babe", 32 | "sp-trie", 33 | ] 34 | 35 | [features] 36 | default = ["std"] 37 | std = [ 38 | "polkadot-sdk/std", 39 | "ismp/std", 40 | "codec/std", 41 | "primitive-types/std", 42 | "scale-info/std", 43 | "serde/std", 44 | "pallet-ismp/std", 45 | "hash-db/std", 46 | ] 47 | -------------------------------------------------------------------------------- /modules/ismp/state-machines/substrate/README.md: -------------------------------------------------------------------------------- 1 | # Substrate State Machine 2 | 3 | The [`StateMachineClient`](https://docs.rs/ismp/latest/ismp/consensus/trait.StateMachineClient.html) implementation for substrate state machines 4 | 5 | ## License 6 | 7 | This library is licensed under the Apache 2.0 License, Copyright (c) 2025 Polytope Labs. 8 | -------------------------------------------------------------------------------- /modules/ismp/testsuite/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ismp-testsuite" 3 | version = "0.1.1" 4 | edition = "2021" 5 | description = "Test suite for ISMP" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | [dependencies] 10 | ismp = { workspace = true } 11 | primitive-types = { workspace = true, default-features = true } 12 | codec = { package = "parity-scale-codec", version = "3.1.3" } 13 | once_cell = "1.19.0" 14 | anyhow = { workspace = true } 15 | 16 | [dependencies.polkadot-sdk] 17 | workspace = true 18 | default-features = true 19 | features = ["sp-core"] 20 | -------------------------------------------------------------------------------- /modules/pallets/bridge-drop/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pallet-bridge-airdrop" 3 | version = "0.1.1" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | description = "Pallet for airdropping Bridge tokens" 7 | publish = false 8 | 9 | [dependencies] 10 | scale-info = { workspace = true } 11 | codec = { workspace = true } 12 | rs_merkle = { version = "1.5.0", default-features = false } 13 | anyhow = { workspace = true } 14 | pallet-ismp = { workspace = true } 15 | log = { workspace = true, default-features = false } 16 | 17 | [dependencies.polkadot-sdk] 18 | workspace = true 19 | features = [ 20 | "frame-support", 21 | "frame-system", 22 | "sp-runtime", 23 | "sp-core", 24 | "sp-std", 25 | "sp-io", 26 | "pallet-balances", 27 | "pallet-vesting", 28 | ] 29 | 30 | [features] 31 | default = ["std"] 32 | std = [ 33 | "codec/std", 34 | "polkadot-sdk/std", 35 | "scale-info/std", 36 | "rs_merkle/std", 37 | "pallet-ismp/std", 38 | ] 39 | try-runtime = ["polkadot-sdk/try-runtime"] 40 | -------------------------------------------------------------------------------- /modules/pallets/call-decompressor/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pallet-call-decompressor" 3 | version = "0.1.1" 4 | edition = "2021" 5 | description = "Decompressing and Decoding Runtime Call" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | 10 | [dependencies] 11 | # crates.io 12 | codec = { workspace = true } 13 | scale-info = { workspace = true } 14 | ruzstd = { version = "0.6.0", default-features = false } 15 | log = { workspace = true } 16 | 17 | # polytope labs 18 | ismp = { workspace = true } 19 | pallet-ismp = { workspace = true, features = ["unsigned"] } 20 | pallet-ismp-relayer = { workspace = true } 21 | 22 | [dependencies.polkadot-sdk] 23 | workspace = true 24 | features = [ 25 | "frame-support", 26 | "frame-system", 27 | "sp-runtime", 28 | "sp-core", 29 | "sp-std", 30 | "sp-api", 31 | ] 32 | 33 | [features] 34 | default = ["std"] 35 | std = [ 36 | "codec/std", 37 | "log/std", 38 | "polkadot-sdk/std", 39 | "scale-info/std", 40 | "ismp/std", 41 | "pallet-ismp/std", 42 | "pallet-ismp-relayer/std", 43 | "ruzstd/std", 44 | ] 45 | try-runtime = ["polkadot-sdk/try-runtime"] 46 | -------------------------------------------------------------------------------- /modules/pallets/demo/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pallet-ismp-demo" 3 | version = "0.1.1" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | publish = false 7 | 8 | 9 | [package.metadata.docs.rs] 10 | targets = ["x86_64-unknown-linux-gnu"] 11 | 12 | [dependencies] 13 | # crates.io 14 | codec = { workspace = true } 15 | scale-info = { workspace = true } 16 | anyhow = { workspace = true, default-features = false } 17 | 18 | # polytope labs 19 | ismp = { workspace = true, default-features = false } 20 | pallet-ismp = { workspace = true, default-features = false } 21 | 22 | [dependencies.polkadot-sdk] 23 | workspace = true 24 | features = [ 25 | "frame-support", 26 | "frame-system", 27 | "pallet-balances", 28 | "sp-runtime", 29 | "sp-core", 30 | ] 31 | 32 | [features] 33 | default = ["std"] 34 | std = [ 35 | "codec/std", 36 | "scale-info/std", 37 | "ismp/std", 38 | "pallet-ismp/std", 39 | "anyhow/std", 40 | "polkadot-sdk/std", 41 | ] 42 | try-runtime = ["polkadot-sdk/try-runtime"] 43 | -------------------------------------------------------------------------------- /modules/pallets/fishermen/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pallet-fishermen" 3 | version = "0.1.1" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | description = "Pallet for veto-ing ISMP state commitments, using permissioned fishermen" 7 | publish = false 8 | 9 | [dependencies] 10 | scale-info = { workspace = true } 11 | codec = { workspace = true } 12 | 13 | # polytope labs 14 | ismp = { workspace = true } 15 | pallet-ismp = { workspace = true } 16 | 17 | [dependencies.polkadot-sdk] 18 | workspace = true 19 | features = [ 20 | "frame-support", 21 | "frame-system", 22 | "sp-runtime", 23 | "sp-core", 24 | "sp-std", 25 | "sp-io", 26 | ] 27 | 28 | [features] 29 | default = ["std"] 30 | std = [ 31 | "codec/std", 32 | "polkadot-sdk/std", 33 | "scale-info/std", 34 | "ismp/std", 35 | "pallet-ismp/std", 36 | ] 37 | try-runtime = ["polkadot-sdk/try-runtime"] 38 | -------------------------------------------------------------------------------- /modules/pallets/host-executive/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pallet-ismp-host-executive" 3 | version = "0.1.1" 4 | edition = "2021" 5 | description = "The host executive is responsible for tracking all connected hosts and is responsible for updating them" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | [dependencies] 10 | # polytope labs 11 | ismp = { workspace = true } 12 | pallet-ismp = { workspace = true } 13 | pallet-hyperbridge = { workspace = true } 14 | 15 | # crates.io 16 | codec = { workspace = true } 17 | scale-info = { workspace = true } 18 | anyhow = { workspace = true } 19 | primitive-types = { workspace = true } 20 | alloy-primitives = { workspace = true } 21 | alloy-sol-macro = { workspace = true } 22 | alloy-sol-types = { workspace = true } 23 | 24 | [dependencies.polkadot-sdk] 25 | workspace = true 26 | features = ["frame-support", "frame-system", "sp-runtime"] 27 | 28 | [features] 29 | default = ["std"] 30 | std = [ 31 | "codec/std", 32 | "scale-info/std", 33 | "polkadot-sdk/std", 34 | "alloy-primitives/std", 35 | "ismp/std", 36 | "anyhow/std", 37 | "pallet-ismp/std", 38 | "pallet-hyperbridge/std", 39 | "primitive-types/std", 40 | ] 41 | try-runtime = ["polkadot-sdk/try-runtime"] 42 | -------------------------------------------------------------------------------- /modules/pallets/hyperbridge/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pallet-hyperbridge" 3 | version = "2503.0.0" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | license = "Apache-2.0" 7 | repository = "https://github.com/polytope-labs/hyperbridge" 8 | homepage = "https://docs.hyperbridge.network/developers/polkadot/getting-started" 9 | documentation = "https://docs.rs/pallet-hyperbridge" 10 | description = "Pallet hyperbridge mediates the connection between hyperbridge and substrate-based chains." 11 | keywords = ["substrate", "polkadot-sdk", "ISMP", "interoperability"] 12 | readme = "README.md" 13 | 14 | [dependencies] 15 | ismp = { workspace = true } 16 | codec = { workspace = true } 17 | scale-info = { workspace = true } 18 | pallet-ismp = { workspace = true } 19 | primitive-types = { workspace = true } 20 | anyhow = { workspace = true, default-features = false } 21 | 22 | [dependencies.polkadot-sdk] 23 | workspace = true 24 | features = ["frame-support", "frame-system", "sp-std"] 25 | 26 | [features] 27 | default = ["std"] 28 | std = [ 29 | "ismp/std", 30 | "polkadot-sdk/std", 31 | "codec/std", 32 | "scale-info/std", 33 | "pallet-ismp/std", 34 | "primitive-types/std", 35 | "anyhow/std", 36 | ] 37 | try-runtime = ["polkadot-sdk/try-runtime"] 38 | -------------------------------------------------------------------------------- /modules/pallets/hyperbridge/README.md: -------------------------------------------------------------------------------- 1 | # Pallet Hyperbridge 2 | 3 | Pallet hyperbridge mediates the connection between hyperbridge and substrate-based chains. This pallet provides: 4 | 5 | - An [`IsmpDispatcher`] implementation which collects protocol fees and commits the reciepts for these fees to child storage. Hyperbridge only accepts messages that have been paid for using this module. 6 | - An [`IsmpModule`] which recieves and processes requests from hyperbridge. These requests are dispatched by hyperbridge governance and may adjust fees or request payouts for both relayers and protocol revenue. 7 | 8 | This pallet contains no calls and dispatches no requests. Substrate based chains should use this to dispatch requests that should be processed by hyperbridge. 9 | 10 | ## Usage 11 | 12 | This module must be configured as an [`IsmpModule`] in your [`IsmpRouter`] implementation so that it may receive 13 | important messages from hyperbridge such as paramter updates or relayer fee withdrawals. 14 | 15 | ```rust,ignore 16 | use ismp::Error; 17 | use ismp::module::IsmpModule; 18 | use ismp::router::IsmpRouter; 19 | use pallet_hyperbridge::PALLET_HYPERBRIDGE_ID; 20 | 21 | #[derive(Default)] 22 | struct ModuleRouter; 23 | 24 | impl IsmpRouter for ModuleRouter { 25 | fn module_for_id(&self, id: Vec) -> Result, Error> { 26 | return match id.as_slice() { 27 | PALLET_HYPERBRIDGE_ID => Ok(Box::new(pallet_hyperbridge::Pallet::::default())), 28 | _ => Err(Error::ModuleNotFound(id)), 29 | }; 30 | } 31 | } 32 | ``` 33 | 34 | ## License 35 | 36 | This library is licensed under the Apache 2.0 License, Copyright (c) 2025 Polytope Labs. 37 | -------------------------------------------------------------------------------- /modules/pallets/ismp/rpc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pallet-ismp-rpc" 3 | version = "2503.0.0" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | license = "Apache-2.0" 7 | repository = "https://github.com/polytope-labs/hyperbridge" 8 | homepage = "https://docs.hyperbridge.network/developers/polkadot/getting-started" 9 | documentation = "https://docs.rs/pallet-ismp-rpc" 10 | description = "RPC apis for pallet-ismp" 11 | keywords = ["substrate", "polkadot-sdk", "ISMP", "interoperability"] 12 | readme = "README.md" 13 | 14 | [package.metadata.docs.rs] 15 | targets = ["x86_64-unknown-linux-gnu"] 16 | 17 | [dependencies] 18 | anyhow = { workspace = true } 19 | hex = { workspace = true } 20 | codec = { workspace = true, features = ["derive"], default-features = true } 21 | hex-literal = { workspace = true, default-features = true } 22 | jsonrpsee = { workspace = true, features = ["client-core", "server", "macros"] } 23 | serde = { workspace = true, features = ["derive"], default-features = true } 24 | json = { workspace = true, default-features = true } 25 | tower = { version = "0.4.13", features = ["util"] } 26 | hash-db = { workspace = true, default-features = true } 27 | trie-db = { workspace = true, default-features = true } 28 | 29 | ismp = { workspace = true, default-features = true } 30 | pallet-ismp = { workspace = true, default-features = true } 31 | pallet-ismp-runtime-api = { workspace = true, default-features = true } 32 | 33 | [dependencies.polkadot-sdk] 34 | workspace = true 35 | default-features = true 36 | features = [ 37 | "frame-system", 38 | "sc-client-api", 39 | "sp-api", 40 | "sp-blockchain", 41 | "sp-core", 42 | "sp-runtime", 43 | "sp-trie", 44 | "sp-storage", 45 | "sc-rpc", 46 | ] 47 | -------------------------------------------------------------------------------- /modules/pallets/ismp/runtime-api/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pallet-ismp-runtime-api" 3 | version = "2503.0.0" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | license = "Apache-2.0" 7 | repository = "https://github.com/polytope-labs/hyperbridge" 8 | homepage = "https://docs.hyperbridge.network/developers/polkadot/getting-started" 9 | documentation = "https://docs.rs/pallet-ismp" 10 | description = "The substrate runtime API for pallet-ismp" 11 | keywords = ["substrate", "polkadot-sdk", "ISMP", "interoperability"] 12 | readme = "README.md" 13 | 14 | [dependencies] 15 | serde = { workspace = true, features = ["derive"], optional = true } 16 | codec = { workspace = true, features = ["derive"] } 17 | primitive-types = { workspace = true } 18 | 19 | ismp = { workspace = true } 20 | pallet-ismp = { workspace = true } 21 | 22 | [dependencies.polkadot-sdk] 23 | workspace = true 24 | features = ["sp-api"] 25 | 26 | [features] 27 | default = ["std"] 28 | std = [ 29 | "polkadot-sdk/std", 30 | "serde", 31 | "codec/std", 32 | "primitive-types/std", 33 | "ismp/std", 34 | "pallet-ismp/std", 35 | ] 36 | -------------------------------------------------------------------------------- /modules/pallets/ismp/src/errors.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Polytope Labs. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | //! Pallet error definitions and conversions 17 | use polkadot_sdk::*; 18 | 19 | use alloc::string::ToString; 20 | use codec::{Decode, DecodeWithMemTracking, Encode}; 21 | use sp_core::ConstU32; 22 | use sp_runtime::BoundedVec; 23 | use sp_std::prelude::*; 24 | 25 | #[derive( 26 | Clone, Debug, Encode, Decode, DecodeWithMemTracking, scale_info::TypeInfo, PartialEq, Eq, 27 | )] 28 | #[allow(missing_docs)] 29 | pub struct HandlingError { 30 | message: BoundedVec>, 31 | } 32 | 33 | impl From for HandlingError { 34 | fn from(value: anyhow::Error) -> Self { 35 | let mut message = value.to_string().as_bytes().to_vec(); 36 | message.truncate(1000); 37 | Self { message: message.try_into().unwrap_or_default() } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /modules/pallets/mmr/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pallet-mmr-tree" 3 | version = "0.1.1" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | license = "Apache-2.0" 7 | description = "A fork of the FRAME Merkle Mountain Range pallet which allows accumulating multiple leaves per block" 8 | publish = false 9 | 10 | [package.metadata.docs.rs] 11 | targets = ["x86_64-unknown-linux-gnu"] 12 | 13 | [dependencies] 14 | serde = { workspace = true, features = ["derive"] } 15 | codec = { workspace = true } 16 | log = { workspace = true } 17 | scale-info = { workspace = true } 18 | 19 | mmr-primitives = { workspace = true } 20 | merkle-mountain-range = { workspace = true } 21 | pallet-ismp = { workspace = true } 22 | 23 | [dependencies.polkadot-sdk] 24 | workspace = true 25 | features = [ 26 | "frame-support", 27 | "frame-system", 28 | "sp-core", 29 | "sp-io", 30 | "sp-mmr-primitives", 31 | "sp-runtime", 32 | "sp-std", 33 | ] 34 | 35 | [dev-dependencies] 36 | array-bytes = "6.1" 37 | env_logger = "0.11" 38 | itertools = "0.10.3" 39 | 40 | [features] 41 | default = ["std"] 42 | std = [ 43 | "codec/std", 44 | "log/std", 45 | "scale-info/std", 46 | "mmr-primitives/std", 47 | "merkle-mountain-range/std", 48 | "serde/default", 49 | "pallet-ismp/std", 50 | "polkadot-sdk/std", 51 | ] 52 | runtime-benchmarks = [ 53 | "polkadot-sdk/frame-benchmarking", 54 | "polkadot-sdk/runtime-benchmarks", 55 | ] 56 | try-runtime = ["polkadot-sdk/try-runtime"] 57 | -------------------------------------------------------------------------------- /modules/pallets/mmr/gadget/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mmr-gadget" 3 | version = "29.0.1" 4 | license = "GPL-3.0-or-later WITH Classpath-exception-2.0" 5 | description = "MMR Client gadget for substrate" 6 | homepage = "https://substrate.io" 7 | edition = "2021" 8 | publish = false 9 | 10 | [dependencies] 11 | codec = { workspace = true, default-features = true } 12 | futures = "0.3.30" 13 | pallet-ismp = { workspace = true, default-features = true } 14 | pallet-mmr-runtime-api = { workspace = true, default-features = true } 15 | pallet-mmr-tree = { workspace = true, default-features = true } 16 | mmr-primitives = { workspace = true, default-features = true } 17 | log = { workspace = true, default-features = true } 18 | 19 | [dependencies.polkadot-sdk] 20 | workspace = true 21 | features = [ 22 | "sp-api", 23 | "sp-blockchain", 24 | "sc-client-api", 25 | "sp-core", 26 | "sp-mmr-primitives", 27 | "sc-offchain", 28 | "sp-runtime", 29 | 30 | ] 31 | -------------------------------------------------------------------------------- /modules/pallets/mmr/primitives/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mmr-primitives" 3 | version = "1.15.2" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | license = "Apache-2.0" 7 | repository = "https://github.com/polytope-labs/hyperbridge" 8 | homepage = "https://docs.hyperbridge.network/developers/polkadot/getting-started" 9 | documentation = "https://docs.rs/ismp-parachain" 10 | description = "Merkle mountain range primitives for pallet-ismp" 11 | keywords = ["substrate", "polkadot-sdk", "ISMP", "interoperability"] 12 | publish = false 13 | 14 | [dependencies] 15 | merkle-mountain-range = { workspace = true } 16 | codec = { workspace = true } 17 | serde = { workspace = true, features = ["derive"] } 18 | scale-info = { workspace = true } 19 | ismp = { workspace = true } 20 | pallet-ismp = { workspace = true } 21 | 22 | [dependencies.polkadot-sdk] 23 | workspace = true 24 | features = [ 25 | "sp-core", 26 | "sp-runtime", 27 | "sp-std", 28 | "sp-mmr-primitives", 29 | "sp-io", 30 | "frame-system", 31 | ] 32 | 33 | [features] 34 | default = ["std"] 35 | std = [ 36 | "codec/std", 37 | "polkadot-sdk/std", 38 | "serde/default", 39 | "scale-info/std", 40 | "merkle-mountain-range/std", 41 | "ismp/std", 42 | "pallet-ismp/std", 43 | ] 44 | -------------------------------------------------------------------------------- /modules/pallets/mmr/primitives/README.md: -------------------------------------------------------------------------------- 1 | # MMR Primitives 2 | 3 | Merkle mountain range primitives for pallet-ismp 4 | 5 | ## License 6 | 7 | This library is licensed under the Apache 2.0 License, Copyright (c) 2023 Polytope Labs. 8 | -------------------------------------------------------------------------------- /modules/pallets/mmr/rpc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pallet-mmr-rpc" 3 | version = "0.1.0" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | license = "Apache-2.0" 7 | repository = "https://github.com/polytope-labs/hyperbridge" 8 | homepage = "https://docs.hyperbridge.network/developers/polkadot/getting-started" 9 | documentation = "https://docs.rs/pallet-ismp-rpc" 10 | description = "RPC apis for pallet-ismp" 11 | keywords = ["substrate", "polkadot-sdk", "ISMP", "interoperability"] 12 | publish = false 13 | 14 | [package.metadata.docs.rs] 15 | targets = ["x86_64-unknown-linux-gnu"] 16 | 17 | [dependencies] 18 | anyhow = { workspace = true } 19 | codec = { workspace = true, features = ["derive"], default-features = true } 20 | jsonrpsee = { workspace = true, features = ["client-core", "server", "macros"] } 21 | 22 | pallet-ismp = { workspace = true, default-features = true } 23 | pallet-ismp-rpc = { workspace = true, default-features = true } 24 | pallet-mmr-runtime-api = { workspace = true, default-features = true } 25 | 26 | [dependencies.polkadot-sdk] 27 | workspace = true 28 | default-features = true 29 | features = [ 30 | "sp-mmr-primitives", 31 | "sc-client-api", 32 | "sp-api", 33 | "sp-blockchain", 34 | "sp-core", 35 | "sp-runtime", 36 | ] 37 | -------------------------------------------------------------------------------- /modules/pallets/mmr/runtime-api/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pallet-mmr-runtime-api" 3 | version = "0.1.1" 4 | edition = "2021" 5 | publish = false 6 | 7 | [dependencies] 8 | serde = { workspace = true, features = ["derive"], optional = true } 9 | codec = { workspace = true } 10 | pallet-ismp = { workspace = true } 11 | 12 | [dependencies.polkadot-sdk] 13 | workspace = true 14 | features = ["sp-api", "sp-std", "sp-core", "sp-mmr-primitives"] 15 | 16 | [features] 17 | default = ["std"] 18 | std = ["polkadot-sdk/std", "codec/std", "serde", "pallet-ismp/std"] 19 | -------------------------------------------------------------------------------- /modules/pallets/mmr/runtime-api/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | //! Pallet-mmr runtime Apis 17 | 18 | #![cfg_attr(not(feature = "std"), no_std)] 19 | #![allow(clippy::too_many_arguments)] 20 | #![deny(missing_docs)] 21 | 22 | extern crate alloc; 23 | 24 | use alloc::vec::Vec; 25 | use pallet_ismp::offchain::{Proof, ProofKeys}; 26 | use polkadot_sdk::*; 27 | use sp_mmr_primitives::{Error, LeafIndex}; 28 | 29 | sp_api::decl_runtime_apis! { 30 | /// MmrRuntimeApi 31 | pub trait MmrRuntimeApi { 32 | /// Return Block number where pallet-mmr was added to the runtime 33 | fn pallet_genesis() -> Result, Error>; 34 | 35 | /// Return the number of MMR leaves. 36 | fn mmr_leaf_count() -> Result; 37 | 38 | /// Return the on-chain MMR root hash. 39 | fn mmr_root() -> Result; 40 | 41 | /// Return the unique hash used as the offchain prefix at a particular block 42 | fn fork_identifier() -> Result; 43 | 44 | /// Generate a proof for the provided leaf indices 45 | fn generate_proof( 46 | commitments: ProofKeys 47 | ) -> Result<(Vec, Proof), Error>; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /modules/pallets/mmr/src/mmr/mod.rs: -------------------------------------------------------------------------------- 1 | // This file is part of Substrate. 2 | 3 | // Copyright (C) Parity Technologies (UK) Ltd. 4 | // SPDX-License-Identifier: Apache-2.0 5 | 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | mod mmr; 19 | pub mod storage; 20 | use polkadot_sdk::*; 21 | 22 | use mmr_primitives::DataOrHash; 23 | use pallet_ismp::offchain::FullLeaf; 24 | use sp_runtime::traits; 25 | 26 | pub use self::mmr::Mmr; 27 | 28 | /// Node type for runtime `T`. 29 | pub type NodeOf = Node<>::Hashing, L>; 30 | 31 | /// A node stored in the MMR. 32 | pub type Node = DataOrHash; 33 | 34 | /// Default Merging & Hashing behavior for MMR. 35 | pub struct Hasher(core::marker::PhantomData<(H, L)>); 36 | 37 | impl merkle_mountain_range::Merge for Hasher { 38 | type Item = Node; 39 | 40 | fn merge(left: &Self::Item, right: &Self::Item) -> merkle_mountain_range::Result { 41 | let mut concat = left.hash().as_ref().to_vec(); 42 | concat.extend_from_slice(right.hash().as_ref()); 43 | 44 | Ok(Node::Hash(::hash(&concat))) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /modules/pallets/relayer-incentives/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pallet-relayer-incentives" 3 | version = "0.1.0" 4 | description = "FRAME pallet for incentivizing hyperbridge relayers with rewards" 5 | authors = ["Polytope Labs "] 6 | edition = "2021" 7 | publish = false 8 | 9 | [package.metadata.docs.rs] 10 | targets = ["x86_64-unknown-linux-gnu"] 11 | 12 | [dependencies] 13 | codec = { workspace = true } 14 | scale-info = { workspace = true } 15 | pallet-ismp = { workspace = true, default-features = false } 16 | ismp = { workspace = true, default-features = false } 17 | 18 | [dependencies.polkadot-sdk] 19 | workspace = true 20 | features = ["frame-support", "frame-system", "sp-runtime"] 21 | 22 | [features] 23 | default = ["std"] 24 | std = [ 25 | "codec/std", 26 | "scale-info/std", 27 | "polkadot-sdk/std", 28 | "pallet-ismp/std", 29 | "ismp/std", 30 | ] 31 | runtime-benchmarks = ["polkadot-sdk/runtime-benchmarks"] 32 | try-runtime = ["polkadot-sdk/try-runtime"] 33 | -------------------------------------------------------------------------------- /modules/pallets/state-coprocessor/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pallet-state-coprocessor" 3 | version = "0.1.0" 4 | edition = "2021" 5 | description = "The state coprocessor enables Hyperbridge to perform storage queries of connected chains" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | [dependencies] 10 | alloy-rlp = { workspace = true } 11 | alloy-primitives = { workspace = true } 12 | scale-info = { workspace = true } 13 | codec = { workspace = true } 14 | log = { workspace = true } 15 | 16 | # polytope labs 17 | ismp = { workspace = true } 18 | pallet-ismp = { workspace = true } 19 | mmr-primitives = { workspace = true } 20 | evm-state-machine = { workspace = true } 21 | pallet-ismp-relayer = { workspace = true } 22 | 23 | [dependencies.polkadot-sdk] 24 | workspace = true 25 | features = [ 26 | "frame-support", 27 | "frame-system", 28 | "sp-runtime", 29 | "sp-core", 30 | "sp-std", 31 | "sp-io", 32 | ] 33 | 34 | [features] 35 | default = ["std"] 36 | std = [ 37 | "codec/std", 38 | "log/std", 39 | "polkadot-sdk/std", 40 | "scale-info/std", 41 | "ismp/std", 42 | "pallet-ismp/std", 43 | "mmr-primitives/std", 44 | "evm-state-machine/std", 45 | "pallet-ismp-relayer/std", 46 | "alloy-primitives/std", 47 | ] 48 | try-runtime = ["polkadot-sdk/try-runtime"] 49 | -------------------------------------------------------------------------------- /modules/pallets/testsuite/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![recursion_limit = "256"] 2 | 3 | mod runtime; 4 | mod tests; 5 | 6 | pub mod relay_chain; 7 | pub mod xcm; 8 | -------------------------------------------------------------------------------- /modules/pallets/testsuite/src/tests/mod.rs: -------------------------------------------------------------------------------- 1 | mod child_trie_proof_check; 2 | mod pallet_call_decompressor; 3 | mod pallet_fishermen; 4 | mod pallet_hyperbridge; 5 | mod pallet_ismp; 6 | mod pallet_ismp_host_executive; 7 | mod pallet_ismp_relayer; 8 | mod pallet_xcm_gateway; 9 | 10 | mod xcm_integration_test; 11 | 12 | mod pallet_bridge_airdrop; 13 | mod pallet_relayer_incentives; 14 | mod pallet_token_gateway; 15 | -------------------------------------------------------------------------------- /modules/pallets/token-gateway-inspector/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pallet-token-gateway-inspector" 3 | version = "0.1.0" 4 | edition = "2021" 5 | description = "The token gateway inspector ensures the validity of token gateway messages coming from standalone chains" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | [dependencies] 10 | primitive-types = { workspace = true } 11 | log = { workspace = true } 12 | codec = { workspace = true } 13 | scale-info = { workspace = true } 14 | anyhow = { workspace = true } 15 | alloy-primitives = { workspace = true } 16 | alloy-sol-macro = { workspace = true } 17 | alloy-sol-types = { workspace = true } 18 | 19 | ismp = { workspace = true } 20 | pallet-ismp = { workspace = true } 21 | pallet-token-gateway = { workspace = true } 22 | pallet-token-governor = { workspace = true } 23 | 24 | [dependencies.polkadot-sdk] 25 | workspace = true 26 | features = ["frame-support", "frame-system", "sp-runtime", "sp-core", "sp-io"] 27 | 28 | [features] 29 | default = ["std"] 30 | std = [ 31 | "polkadot-sdk/std", 32 | "primitive-types/std", 33 | "ismp/std", 34 | "pallet-ismp/std", 35 | "log/std", 36 | "scale-info/std", 37 | "anyhow/std", 38 | "alloy-primitives/std", 39 | "pallet-token-gateway/std", 40 | "pallet-token-governor/std", 41 | ] 42 | try-runtime = ["polkadot-sdk/try-runtime"] 43 | -------------------------------------------------------------------------------- /modules/pallets/token-gateway/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pallet-token-gateway" 3 | version = "2503.0.0" 4 | edition = "2021" 5 | description = "A substrate implementation of the token gateway protocol" 6 | authors = ["Polytope Labs "] 7 | license = "Apache-2.0" 8 | repository = "https://github.com/polytope-labs/hyperbridge" 9 | homepage = "https://docs.hyperbridge.network/developers/polkadot/token-gateway" 10 | documentation = "https://docs.rs/pallet-token-gateway" 11 | keywords = [ 12 | "substrate", 13 | "polkadot-sdk", 14 | "ISMP", 15 | "interoperability", 16 | "pallet-assets", 17 | ] 18 | readme = "README.md" 19 | 20 | [dependencies] 21 | primitive-types = { workspace = true } 22 | log = { workspace = true } 23 | codec = { workspace = true } 24 | scale-info = { workspace = true } 25 | anyhow = { workspace = true } 26 | alloy-primitives = { workspace = true } 27 | alloy-sol-macro = { workspace = true } 28 | alloy-sol-types = { workspace = true } 29 | 30 | ismp = { workspace = true } 31 | pallet-ismp = { workspace = true } 32 | token-gateway-primitives = { workspace = true } 33 | pallet-hyperbridge = { workspace = true } 34 | 35 | [dependencies.polkadot-sdk] 36 | workspace = true 37 | features = ["frame-support", "frame-system", "sp-runtime", "sp-core", "sp-io"] 38 | 39 | [features] 40 | default = ["std"] 41 | std = [ 42 | "polkadot-sdk/std", 43 | "primitive-types/std", 44 | "ismp/std", 45 | "pallet-ismp/std", 46 | "log/std", 47 | "scale-info/std", 48 | "anyhow/std", 49 | "alloy-primitives/std", 50 | "pallet-hyperbridge/std", 51 | "token-gateway-primitives/std", 52 | ] 53 | runtime-benchmarks = [ 54 | "polkadot-sdk/frame-benchmarking", 55 | "polkadot-sdk/runtime-benchmarks", 56 | ] 57 | try-runtime = ["polkadot-sdk/try-runtime"] 58 | -------------------------------------------------------------------------------- /modules/pallets/token-gateway/primitives/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "token-gateway-primitives" 3 | version = "2503.0.0" 4 | edition = "2021" 5 | description = "A collection of types used by token gateway" 6 | authors = ["Polytope Labs "] 7 | license = "Apache-2.0" 8 | repository = "https://github.com/polytope-labs/hyperbridge" 9 | homepage = "https://docs.hyperbridge.network/developers/polkadot/tokengateway" 10 | documentation = "https://docs.rs/pallet-token-gateway" 11 | keywords = [ 12 | "substrate", 13 | "polkadot-sdk", 14 | "ISMP", 15 | "interoperability", 16 | "pallet-assets", 17 | ] 18 | readme = "README.md" 19 | 20 | [dependencies] 21 | primitive-types = { workspace = true } 22 | 23 | ismp = { workspace = true } 24 | pallet-ismp = { workspace = true } 25 | 26 | log = { workspace = true } 27 | codec = { workspace = true } 28 | scale-info = { workspace = true } 29 | anyhow = { workspace = true } 30 | 31 | alloy-primitives = { workspace = true } 32 | alloy-sol-macro = { workspace = true } 33 | alloy-sol-types = { workspace = true } 34 | 35 | [dependencies.polkadot-sdk] 36 | workspace = true 37 | features = ["frame-support", "frame-system", "sp-runtime", "sp-core", "sp-io"] 38 | 39 | [features] 40 | default = ["std"] 41 | std = [ 42 | "polkadot-sdk/std", 43 | "primitive-types/std", 44 | "ismp/std", 45 | "pallet-ismp/std", 46 | "log/std", 47 | "scale-info/std", 48 | "anyhow/std", 49 | "alloy-primitives/std", 50 | ] 51 | try-runtime = ["polkadot-sdk/try-runtime"] 52 | -------------------------------------------------------------------------------- /modules/pallets/token-gateway/primitives/README.md: -------------------------------------------------------------------------------- 1 | # Token Gateway Primitives 2 | 3 | A collection of types used by [pallet-token-gateway](https://crates.io/crates/pallet-token-gateway) 4 | 5 | ## License 6 | 7 | This library is licensed under the Apache 2.0 License, Copyright (c) 2025 Polytope Labs. 8 | -------------------------------------------------------------------------------- /modules/pallets/token-gateway/src/weights.rs: -------------------------------------------------------------------------------- 1 | use frame_support::weights::Weight; 2 | use polkadot_sdk::*; 3 | 4 | // ============================== INTERFACE ============================================ // 5 | /// Weight functions needed for `pallet_token_gateway. 6 | pub trait WeightInfo { 7 | fn create_erc6160_asset(x: u32) -> Weight; 8 | fn teleport() -> Weight; 9 | fn set_token_gateway_addresses(x: u32) -> Weight; 10 | fn update_erc6160_asset() -> Weight; 11 | fn update_asset_precision(x: u32) -> Weight; 12 | } 13 | 14 | impl WeightInfo for () { 15 | fn create_erc6160_asset(_x: u32) -> Weight { 16 | Weight::zero() 17 | } 18 | 19 | fn teleport() -> Weight { 20 | Weight::zero() 21 | } 22 | 23 | fn set_token_gateway_addresses(_x: u32) -> Weight { 24 | Weight::zero() 25 | } 26 | 27 | fn update_erc6160_asset() -> Weight { 28 | Weight::zero() 29 | } 30 | 31 | fn update_asset_precision(_x: u32) -> Weight { 32 | Weight::zero() 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /modules/pallets/token-governor/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pallet-token-governor" 3 | version = "0.1.0" 4 | edition = "2021" 5 | description = "The token governor tracks and governs multi-chain native tokens across all connected chains" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | [dependencies] 10 | primitive-types = { workspace = true } 11 | log = { workspace = true } 12 | codec = { workspace = true } 13 | scale-info = { workspace = true } 14 | anyhow = { workspace = true } 15 | alloy-primitives = { workspace = true } 16 | alloy-sol-macro = { workspace = true } 17 | alloy-sol-types = { workspace = true } 18 | 19 | ismp = { workspace = true } 20 | pallet-ismp = { workspace = true } 21 | pallet-ismp-host-executive = { workspace = true } 22 | token-gateway-primitives = { workspace = true } 23 | 24 | [dependencies.polkadot-sdk] 25 | workspace = true 26 | features = ["frame-support", "frame-system", "sp-runtime", "sp-core", "sp-io"] 27 | 28 | [features] 29 | default = ["std"] 30 | std = [ 31 | "polkadot-sdk/std", 32 | "primitive-types/std", 33 | "ismp/std", 34 | "pallet-ismp/std", 35 | "log/std", 36 | "scale-info/std", 37 | "anyhow/std", 38 | "alloy-primitives/std", 39 | "pallet-ismp-host-executive/std", 40 | "token-gateway-primitives/std", 41 | ] 42 | try-runtime = ["polkadot-sdk/try-runtime"] 43 | -------------------------------------------------------------------------------- /modules/pallets/xcm-gateway/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pallet-xcm-gateway" 3 | version = "0.1.1" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | description = "Pallet for custodying relay chain assets received through XCM" 7 | publish = false 8 | 9 | [dependencies] 10 | # polytope labs 11 | ismp = { workspace = true } 12 | pallet-ismp = { workspace = true } 13 | pallet-token-governor = { workspace = true } 14 | pallet-token-gateway = { workspace = true } 15 | 16 | # crates.io 17 | codec = { workspace = true } 18 | anyhow = { workspace = true } 19 | scale-info = { workspace = true } 20 | alloy-primitives = { workspace = true } 21 | alloy-rlp-derive = { workspace = true } 22 | alloy-sol-macro = { workspace = true } 23 | alloy-sol-types = { workspace = true } 24 | 25 | [dependencies.polkadot-sdk] 26 | workspace = true 27 | features = [ 28 | "frame-support", 29 | "frame-system", 30 | "sp-runtime", 31 | "sp-core", 32 | "sp-std", 33 | "sp-io", 34 | "pallet-xcm", 35 | "staging-xcm", 36 | "staging-xcm-builder", 37 | "staging-xcm-executor", 38 | ] 39 | 40 | [features] 41 | default = ["std"] 42 | std = [ 43 | "codec/std", 44 | "polkadot-sdk/std", 45 | "scale-info/std", 46 | "ismp/std", 47 | "pallet-ismp/std", 48 | "pallet-token-governor/std", 49 | "alloy-sol-types/std", 50 | "alloy-primitives/std", 51 | "anyhow/std", 52 | "pallet-token-gateway/std", 53 | ] 54 | try-runtime = ["polkadot-sdk/try-runtime"] 55 | -------------------------------------------------------------------------------- /modules/trees/ethereum/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ethereum-triedb" 3 | version = "0.1.1" 4 | edition = "2021" 5 | description = "EIP-1186 ethereum trie layout implementation for parity/trie" 6 | authors = ["Polytope Labs "] 7 | license = "Apache-2.0" 8 | repository = "https://github.com/polytope-labs/hyperbridge" 9 | documentation = "https://docs.rs/ethereum-triedb" 10 | keywords = ["merkle-patricia-trie", "ethereum", "state-proofs", "storage-proofs"] 11 | readme = "./README.md" 12 | 13 | [dependencies] 14 | trie-db = { workspace = true } 15 | hash-db = { workspace = true } 16 | memory-db = { workspace = true } 17 | codec = { workspace = true } 18 | rlp = { workspace = true } 19 | thiserror = { workspace = true } 20 | derive_more = { workspace = true, features = ["from"] } 21 | anyhow = { workspace = true } 22 | primitive-types = { workspace = true, features = ["rlp"] } 23 | hash256-std-hasher = { version = "0.15.2", optional = true } 24 | tiny-keccak = { version = "2.0.2", features = ["keccak"], optional = true } 25 | 26 | [dev-dependencies] 27 | hex = "0.4.3" 28 | hex-literal = "0.3.4" 29 | rlp-derive = "0.1.0" 30 | 31 | [features] 32 | default = ["std"] 33 | std = [ 34 | "trie-db/std", 35 | "hash-db/std", 36 | "memory-db/std", 37 | "codec/std", 38 | "thiserror/std", 39 | "rlp/std", 40 | "anyhow/std", 41 | "primitive-types/std", 42 | "hash256-std-hasher", 43 | "tiny-keccak", 44 | ] 45 | -------------------------------------------------------------------------------- /modules/utils/serde/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "serde-hex-utils" 3 | version = "0.1.0" 4 | edition = "2021" 5 | authors = ["Polytope Labs "] 6 | license = "Apache-2.0" 7 | repository = "https://github.com/polytope-labs/hyperbridge" 8 | documentation = "https://docs.rs/serde-hex-utils" 9 | description = "Collection of hexadecimal (De)serialization utilities for serde" 10 | keywords = ["serde", "utilities"] 11 | readme = "./README.md" 12 | 13 | [dependencies] 14 | # crates.io 15 | serde = { workspace = true, features = ["derive"] } 16 | hex = { workspace = true, features = ["alloc"], default-features = false } 17 | anyhow = { workspace = true, default-features = false } 18 | 19 | [features] 20 | default = ["std"] 21 | std = [ 22 | "serde/std", 23 | "anyhow/std", 24 | "hex/std" 25 | ] 26 | 27 | [dev-dependencies] 28 | ismp = { workspace = true, default-features = true } 29 | primitive-types = { workspace = true, features = ["codec", "scale-info", "serde_no_std"] } 30 | serde_json = { version = "1.0.99", default-features = false, features = ["alloc"] } 31 | -------------------------------------------------------------------------------- /modules/utils/serde/README.md: -------------------------------------------------------------------------------- 1 | # serde utilities 2 | 3 | Collection of useful (De)serialization utilities for serde -------------------------------------------------------------------------------- /modules/utils/subxt/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "subxt-utils" 3 | version = "0.1.1" 4 | edition = "2021" 5 | publish = false 6 | 7 | [dependencies] 8 | subxt = { workspace = true } 9 | ismp = { workspace = true } 10 | codec = { workspace = true } 11 | anyhow = { workspace = true } 12 | reconnecting-jsonrpsee-ws-client = { workspace = true } 13 | primitive-types = { workspace = true, features = ["scale-info", "serde"] } 14 | alloy-primitives = { workspace = true } 15 | pallet-ismp-host-executive = { workspace = true } 16 | pallet-hyperbridge = { workspace = true } 17 | derivative = { version = "2.2.0" } 18 | futures = "0.3.30" 19 | 20 | [dependencies.polkadot-sdk] 21 | workspace = true 22 | features = ["sp-crypto-hashing"] 23 | 24 | [features] 25 | default = ["std"] 26 | wasm = ["subxt/web", "subxt/jsonrpsee", "reconnecting-jsonrpsee-ws-client/web"] 27 | std = [ 28 | "subxt/native", 29 | "subxt/jsonrpsee", 30 | "ismp/std", 31 | "polkadot-sdk/std", 32 | "codec/std", 33 | "primitive-types/std", 34 | "alloy-primitives/std", 35 | "reconnecting-jsonrpsee-ws-client/native", 36 | "pallet-hyperbridge/std", 37 | "pallet-ismp-host-executive/std", 38 | "subxt/substrate-compat", 39 | ] 40 | -------------------------------------------------------------------------------- /parachain/node/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use polkadot_sdk::substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed}; 17 | 18 | fn main() { 19 | generate_cargo_keys(); 20 | 21 | rerun_if_git_head_changed(); 22 | } 23 | -------------------------------------------------------------------------------- /parachain/node/src/main.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | //! Substrate Parachain Node Template CLI 17 | 18 | #![warn(missing_docs)] 19 | 20 | mod chain_spec; 21 | #[macro_use] 22 | mod service; 23 | mod cli; 24 | // mod client; 25 | mod command; 26 | mod rpc; 27 | mod runtime_api; 28 | 29 | mod simnode; 30 | use polkadot_sdk::*; 31 | 32 | fn main() -> sc_cli::Result<()> { 33 | command::run() 34 | } 35 | -------------------------------------------------------------------------------- /parachain/runtimes/gargantua/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use substrate_wasm_builder::WasmBuilder; 17 | 18 | #[cfg(feature = "metadata-hash")] 19 | fn main() { 20 | WasmBuilder::new() 21 | .with_current_project() 22 | .export_heap_base() 23 | .import_memory() 24 | .enable_metadata_hash("tBRIDGE", 12) 25 | .build(); 26 | } 27 | 28 | #[cfg(not(feature = "metadata-hash"))] 29 | fn main() { 30 | WasmBuilder::new() 31 | .with_current_project() 32 | .export_heap_base() 33 | .import_memory() 34 | .build() 35 | } 36 | -------------------------------------------------------------------------------- /parachain/runtimes/gargantua/src/weights/mod.rs: -------------------------------------------------------------------------------- 1 | // This file is part of Substrate. 2 | 3 | // Copyright (C) 2022 Parity Technologies (UK) Ltd. 4 | // SPDX-License-Identifier: Apache-2.0 5 | 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | #![allow(unused_imports)] 18 | 19 | //! Expose the auto generated weight files. 20 | 21 | pub mod block_weights; 22 | pub mod extrinsic_weights; 23 | pub mod paritydb_weights; 24 | pub mod rocksdb_weights; 25 | 26 | pub mod cumulus_pallet_parachain_system; 27 | pub mod cumulus_pallet_xcmp_queue; 28 | pub mod frame_system; 29 | pub mod ismp_grandpa; 30 | pub mod ismp_parachain; 31 | pub mod pallet_asset_rate; 32 | pub mod pallet_assets; 33 | pub mod pallet_balances; 34 | pub mod pallet_collective; 35 | pub mod pallet_message_queue; 36 | pub mod pallet_session; 37 | pub mod pallet_sudo; 38 | pub mod pallet_timestamp; 39 | pub mod pallet_treasury; 40 | pub mod pallet_utility; 41 | 42 | pub use block_weights::constants::BlockExecutionWeight; 43 | pub use extrinsic_weights::constants::ExtrinsicBaseWeight; 44 | pub use paritydb_weights::constants::ParityDbWeight; 45 | pub use rocksdb_weights::constants::RocksDbWeight; 46 | -------------------------------------------------------------------------------- /parachain/runtimes/messier/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use substrate_wasm_builder::WasmBuilder; 17 | 18 | fn main() { 19 | WasmBuilder::new() 20 | .with_current_project() 21 | .export_heap_base() 22 | .import_memory() 23 | .build() 24 | } 25 | -------------------------------------------------------------------------------- /parachain/runtimes/messier/src/weights/block_weights.rs: -------------------------------------------------------------------------------- 1 | // This file is part of Substrate. 2 | 3 | // Copyright (C) 2022 Parity Technologies (UK) Ltd. 4 | // SPDX-License-Identifier: Apache-2.0 5 | 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | pub mod constants { 19 | use frame_support::{ 20 | parameter_types, 21 | weights::{constants, Weight}, 22 | }; 23 | 24 | parameter_types! { 25 | /// Importing a block with 0 Extrinsics. 26 | pub const BlockExecutionWeight: Weight = 27 | Weight::from_parts(constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(5_000_000), 0); 28 | } 29 | 30 | #[cfg(test)] 31 | mod test_weights { 32 | use frame_support::weights::constants; 33 | 34 | /// Checks that the weight exists and is sane. 35 | // NOTE: If this test fails but you are sure that the generated values are fine, 36 | // you can delete it. 37 | #[test] 38 | fn sane() { 39 | let w = super::constants::BlockExecutionWeight::get(); 40 | 41 | // At least 100 µs. 42 | assert!( 43 | w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS, 44 | "Weight should be at least 100 µs." 45 | ); 46 | // At most 50 ms. 47 | assert!( 48 | w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS, 49 | "Weight should be at most 50 ms." 50 | ); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /parachain/runtimes/messier/src/weights/cumulus_pallet_xcmp_queue.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/parachain/runtimes/messier/src/weights/cumulus_pallet_xcmp_queue.rs -------------------------------------------------------------------------------- /parachain/runtimes/messier/src/weights/extrinsic_weights.rs: -------------------------------------------------------------------------------- 1 | // This file is part of Substrate. 2 | 3 | // Copyright (C) 2022 Parity Technologies (UK) Ltd. 4 | // SPDX-License-Identifier: Apache-2.0 5 | 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | pub mod constants { 19 | use frame_support::{ 20 | parameter_types, 21 | weights::{constants, Weight}, 22 | }; 23 | 24 | parameter_types! { 25 | /// Executing a NO-OP `System::remarks` Extrinsic. 26 | pub const ExtrinsicBaseWeight: Weight = 27 | Weight::from_parts(constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(125_000), 0); 28 | } 29 | 30 | #[cfg(test)] 31 | mod test_weights { 32 | use frame_support::weights::constants; 33 | 34 | /// Checks that the weight exists and is sane. 35 | // NOTE: If this test fails but you are sure that the generated values are fine, 36 | // you can delete it. 37 | #[test] 38 | fn sane() { 39 | let w = super::constants::ExtrinsicBaseWeight::get(); 40 | 41 | // At least 10 µs. 42 | assert!( 43 | w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS, 44 | "Weight should be at least 10 µs." 45 | ); 46 | // At most 1 ms. 47 | assert!( 48 | w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, 49 | "Weight should be at most 1 ms." 50 | ); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /parachain/runtimes/messier/src/weights/frame_system.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/parachain/runtimes/messier/src/weights/frame_system.rs -------------------------------------------------------------------------------- /parachain/runtimes/messier/src/weights/mod.rs: -------------------------------------------------------------------------------- 1 | // This file is part of Substrate. 2 | 3 | // Copyright (C) 2022 Parity Technologies (UK) Ltd. 4 | // SPDX-License-Identifier: Apache-2.0 5 | 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | //! Expose the auto generated weight files. 19 | 20 | pub mod block_weights; 21 | pub mod extrinsic_weights; 22 | pub mod paritydb_weights; 23 | pub mod rocksdb_weights; 24 | 25 | pub use block_weights::constants::BlockExecutionWeight; 26 | pub use extrinsic_weights::constants::ExtrinsicBaseWeight; 27 | pub use rocksdb_weights::constants::RocksDbWeight; 28 | -------------------------------------------------------------------------------- /parachain/runtimes/messier/src/weights/pallet_assets.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/parachain/runtimes/messier/src/weights/pallet_assets.rs -------------------------------------------------------------------------------- /parachain/runtimes/messier/src/weights/pallet_balances.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/parachain/runtimes/messier/src/weights/pallet_balances.rs -------------------------------------------------------------------------------- /parachain/runtimes/messier/src/weights/pallet_message_queue.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/parachain/runtimes/messier/src/weights/pallet_message_queue.rs -------------------------------------------------------------------------------- /parachain/runtimes/messier/src/weights/pallet_sudo.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/parachain/runtimes/messier/src/weights/pallet_sudo.rs -------------------------------------------------------------------------------- /parachain/runtimes/messier/src/weights/pallet_timestamp.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/parachain/runtimes/messier/src/weights/pallet_timestamp.rs -------------------------------------------------------------------------------- /parachain/runtimes/nexus/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Polytope Labs Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use substrate_wasm_builder::WasmBuilder; 17 | 18 | #[cfg(feature = "metadata-hash")] 19 | fn main() { 20 | WasmBuilder::new() 21 | .with_current_project() 22 | .export_heap_base() 23 | .import_memory() 24 | .enable_metadata_hash("BRIDGE", 12) 25 | .build(); 26 | } 27 | 28 | #[cfg(not(feature = "metadata-hash"))] 29 | fn main() { 30 | WasmBuilder::new() 31 | .with_current_project() 32 | .export_heap_base() 33 | .import_memory() 34 | .build() 35 | } 36 | -------------------------------------------------------------------------------- /parachain/runtimes/nexus/src/weights/extrinsic_weights.rs: -------------------------------------------------------------------------------- 1 | // This file is part of Substrate. 2 | 3 | // Copyright (C) 2022 Parity Technologies (UK) Ltd. 4 | // SPDX-License-Identifier: Apache-2.0 5 | 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | pub mod constants { 19 | use frame_support::{ 20 | parameter_types, 21 | weights::{constants, Weight}, 22 | }; 23 | use polkadot_sdk::*; 24 | 25 | parameter_types! { 26 | /// Executing a NO-OP `System::remarks` Extrinsic. 27 | pub const ExtrinsicBaseWeight: Weight = 28 | Weight::from_parts(constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(125_000), 0); 29 | } 30 | 31 | #[cfg(test)] 32 | mod test_weights { 33 | use polkadot_sdk::frame_support::weights::constants; 34 | 35 | /// Checks that the weight exists and is sane. 36 | // NOTE: If this test fails but you are sure that the generated values are fine, 37 | // you can delete it. 38 | #[test] 39 | fn sane() { 40 | let w = super::constants::ExtrinsicBaseWeight::get(); 41 | 42 | // At least 10 µs. 43 | assert!( 44 | w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS, 45 | "Weight should be at least 10 µs." 46 | ); 47 | // At most 1 ms. 48 | assert!( 49 | w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, 50 | "Weight should be at most 1 ms." 51 | ); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /parachain/runtimes/nexus/src/weights/mod.rs: -------------------------------------------------------------------------------- 1 | // This file is part of Substrate. 2 | 3 | // Copyright (C) 2022 Parity Technologies (UK) Ltd. 4 | // SPDX-License-Identifier: Apache-2.0 5 | 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | //! Expose the auto generated weight files. 19 | 20 | pub mod block_weights; 21 | pub mod extrinsic_weights; 22 | pub mod paritydb_weights; 23 | pub mod rocksdb_weights; 24 | 25 | pub mod cumulus_pallet_parachain_system; 26 | pub mod cumulus_pallet_xcmp_queue; 27 | pub mod frame_system; 28 | pub mod ismp_grandpa; 29 | pub mod ismp_parachain; 30 | pub mod pallet_asset_rate; 31 | pub mod pallet_assets; 32 | pub mod pallet_balances; 33 | pub mod pallet_collator_selection; 34 | pub mod pallet_collective; 35 | pub mod pallet_message_queue; 36 | pub mod pallet_multisig; 37 | pub mod pallet_proxy; 38 | pub mod pallet_session; 39 | pub mod pallet_sudo; 40 | pub mod pallet_timestamp; 41 | pub mod pallet_treasury; 42 | pub mod pallet_utility; 43 | 44 | pub use block_weights::constants::BlockExecutionWeight; 45 | pub use extrinsic_weights::constants::ExtrinsicBaseWeight; 46 | pub use rocksdb_weights::constants::RocksDbWeight; 47 | -------------------------------------------------------------------------------- /parachain/simtests/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod hyperbridge_client; 2 | mod pallet_ismp; 3 | mod pallet_mmr; 4 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "stable" 3 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | # Basic 2 | hard_tabs = true 3 | max_width = 100 4 | use_small_heuristics = "Max" 5 | # Imports 6 | imports_granularity = "Crate" 7 | reorder_imports = true 8 | # Consistency 9 | newline_style = "Unix" 10 | # Format comments 11 | comment_width = 100 12 | wrap_comments = true 13 | # Misc 14 | chain_width = 80 15 | spaces_around_ranges = false 16 | binop_separator = "Back" 17 | reorder_impl_items = false 18 | match_arm_leading_pipes = "Preserve" 19 | match_arm_blocks = false 20 | match_block_trailing_comma = true 21 | trailing_comma = "Vertical" 22 | trailing_semicolon = false 23 | use_field_init_shorthand = true 24 | -------------------------------------------------------------------------------- /scripts/build_release_runtime.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cargo build -p $1 --features=metadata-hash --release -------------------------------------------------------------------------------- /scripts/docker/hyperbridge.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM docker.io/library/debian:bookworm-slim 2 | 3 | RUN apt-get update && apt-get install -y ca-certificates && update-ca-certificates 4 | 5 | WORKDIR / 6 | 7 | COPY ./target/release/hyperbridge ./ 8 | 9 | 10 | ENTRYPOINT ["./hyperbridge"] 11 | -------------------------------------------------------------------------------- /scripts/docker/telemetry.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM docker.io/library/debian:bookworm-slim 2 | 3 | RUN apt-get update && apt-get install -y ca-certificates gcc-4.9 libstdc++6 && update-ca-certificates 4 | 5 | WORKDIR / 6 | 7 | COPY ./target/release/telemetry-server ./ 8 | 9 | EXPOSE 3000 10 | 11 | ENTRYPOINT ["./telemetry-server"] -------------------------------------------------------------------------------- /scripts/docker/tesseract.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM docker.io/library/debian:bookworm-slim 2 | 3 | RUN apt-get update && apt-get install -y ca-certificates && update-ca-certificates 4 | 5 | WORKDIR / 6 | 7 | COPY ./target/release/tesseract ./ 8 | 9 | 10 | ENTRYPOINT ["./tesseract"] 11 | -------------------------------------------------------------------------------- /scripts/generate_subxt_types.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | subxt codegen --derive=PartialEq --derive=Eq --derive=Clone --url=$1 | rustfmt --edition=2018 --emit=stdout | tee ./modules/utils/subxt/src/$2.rs 4 | -------------------------------------------------------------------------------- /scripts/parachain-launch/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "parachain-launch", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "dev": "parachain-launch generate --config=./local_config.yml --yes --output=./" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "@open-web3/parachain-launch": "^1.4.2" 14 | } 15 | } -------------------------------------------------------------------------------- /scripts/parachain-launch/parachain-2000.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM polytopelabs/hyperbridge 2 | COPY . /app -------------------------------------------------------------------------------- /scripts/parachain-launch/relaychain.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM parity/polkadot:v1.1.0 2 | COPY . /app -------------------------------------------------------------------------------- /scripts/release-crates.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cargo release \ 4 | -p serde-hex-utils \ 5 | -p ismp \ 6 | -p pallet-hyperbridge \ 7 | -p pallet-ismp \ 8 | -p pallet-ismp-runtime-api \ 9 | -p pallet-ismp-rpc \ 10 | -p substrate-state-machine \ 11 | -p ismp-parachain \ 12 | -p grandpa-verifier-primitives \ 13 | -p grandpa-verifier \ 14 | -p ismp-grandpa \ 15 | -p ismp-parachain-runtime-api \ 16 | -p ismp-parachain-inherent \ 17 | -p token-gateway-primitives \ 18 | -p pallet-token-gateway \ 19 | --execute 20 | -------------------------------------------------------------------------------- /scripts/wait_for_tcp_port_opening.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | HOST=$1 4 | PORT=$2 5 | 6 | echo "Trying to connect to ${HOST}:${PORT}..." 7 | 8 | while ! nc -z $HOST $PORT; do 9 | echo "Waiting for $HOST:$PORT to become available" 10 | sleep 0.5 11 | done 12 | 13 | echo "${HOST}:${PORT} is ready for requests." -------------------------------------------------------------------------------- /tesseract/README.md: -------------------------------------------------------------------------------- 1 | # tesseract 2 | 3 | 4 | 5 | Tesseract is a multi-~~dimensional~~chain relayer implementation for Hyperbridge. Currently this supports relaying between: 6 | 7 | - [x] Substrate based chains 8 | - [x] EVM based chains 9 | 10 | ## Usage Guides 11 | 12 | Consult the [documentation](https://docs.hyperbridge.network/network/relayer) for more information on how to use this. 13 | 14 | ## Docker Guide 15 | 16 | Optionally build the image locally: 17 | 18 | ```bash 19 | DOCKER_BUILDKIT=0 docker build -t tesseract . 20 | ``` 21 | 22 | Next run the relayer given a config file 23 | 24 | ```bash 25 | docker run tesseract --config ./integration-tests/config.toml 26 | ``` 27 | 28 | Or run our pre build images: 29 | 30 | ```bash 31 | docker run polytopelabs/tesseract:latest --config ./integration-tests/config.toml 32 | ``` 33 | 34 | ## License 35 | 36 | This software is licensed under the Apache 2.0 License, Copyright (c) 2023 Polytope Labs. 37 | 38 | ## Notes 39 | 40 | We trace transactions in concurrently so it's necessary to increase the file open limit for the user session the process is running within. 41 | Your rpc provider must support processing requests well above 100 requests/second 42 | 43 | ```markdown 44 | Edit /etc/security/limits.conf and add the following using the appropriate username 45 | 46 | @username soft nofile 100000 47 | @username hard nofile 100000 48 | 49 | Edit /etc/pam.d/common-session and add the following 50 | 51 | session required pam_limits.so 52 | ``` 53 | 54 | Reboot the machine after making these changes. 55 | -------------------------------------------------------------------------------- /tesseract/assets/relayer.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polytope-labs/hyperbridge/f14b5afd0719c8f7652ac00ce65ea84cee38d7b4/tesseract/assets/relayer.webp -------------------------------------------------------------------------------- /tesseract/config/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tesseract-config" 3 | version = "0.1.0" 4 | edition = "2021" 5 | publish = false 6 | 7 | [dependencies] 8 | tesseract-substrate = { workspace = true } 9 | tesseract-primitives = { workspace = true } 10 | tesseract-evm = { workspace = true } 11 | 12 | ismp = { workspace = true, default-features = true } 13 | pallet-ismp = { workspace = true, default-features = true } 14 | ismp-sync-committee = { workspace = true, default-features = true } 15 | anyhow = { workspace = true, default-features = true } 16 | serde = { workspace = true, default-features = true, features = ["derive"] } 17 | substrate-state-machine = { workspace = true, default-features = true } 18 | sp-core = { workspace = true } 19 | -------------------------------------------------------------------------------- /tesseract/evm/build.rs: -------------------------------------------------------------------------------- 1 | use ethers_contract_abigen::MultiAbigen; 2 | use std::{env, fs}; 3 | 4 | fn main() -> anyhow::Result<()> { 5 | let base_dir = env::current_dir()?.display().to_string(); 6 | 7 | let sources = vec![ 8 | ("OVM_gasPriceOracle", format!("{base_dir}/abis/OVM_gasPriceOracle.json")), 9 | ("ArbGasInfo", format!("{base_dir}/abis/ArbGasInfo.json")), 10 | ("Erc20", format!("{base_dir}/abis/ERC20.json")), 11 | ]; 12 | 13 | MultiAbigen::new(sources) 14 | .unwrap() 15 | .build() 16 | .unwrap() 17 | .write_to_module(format!("{base_dir}/src/abi"), false) 18 | .unwrap(); 19 | 20 | // remove the added mod.rs 21 | fs::remove_file(format!("{base_dir}/src/abi/mod.rs"))?; 22 | 23 | println!("cargo:rerun-if-changed={base_dir}/abis"); 24 | 25 | Ok(()) 26 | } 27 | -------------------------------------------------------------------------------- /tesseract/evm/src/abi.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::all, ambiguous_glob_reexports)] 2 | #![allow(non_snake_case)] 3 | 4 | pub mod arb_gas_info; 5 | pub mod erc_20; 6 | pub mod ovm_gas_price_oracle; 7 | 8 | pub use ismp_solidity_abi::{beefy::*, evm_host::*, handler::*, ping_module::*}; 9 | -------------------------------------------------------------------------------- /tesseract/fees/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "transaction-fees" 3 | version = "0.1.0" 4 | edition = "2021" 5 | description = "Local tracking of relayer payments on all chains" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | [dependencies] 10 | anyhow = { workspace = true } 11 | async-trait = "0.1.53" 12 | futures = "0.3.28" 13 | tokio = { workspace = true, features = ["full"] } 14 | primitive-types = { workspace = true, default-features = true } 15 | prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust.git", tag = "0.6.11", features = ["sqlite", "migrations"] } 16 | serde = { version = "1.0.195", features = ["derive"] } 17 | itertools = "0.12.1" 18 | tracing = "0.1.40" 19 | sp-core = { workspace = true, default-features = true } 20 | hex = "0.4.3" 21 | subxt = { workspace = true, features = ["substrate-compat"] } 22 | chrono = "0.4.31" 23 | codec = { workspace = true, features = ["derive"] } 24 | 25 | tesseract-primitives = { workspace = true, default-features = true } 26 | pallet-ismp = { workspace = true, default-features = true } 27 | ismp = { workspace = true, default-features = true } 28 | pallet-ismp-relayer = { workspace = true, default-features = true } 29 | 30 | [dev-dependencies] 31 | tesseract-evm = { workspace = true } 32 | tesseract-substrate = { workspace = true } 33 | tesseract-primitives = { workspace = true, features = ["testing"] } 34 | -------------------------------------------------------------------------------- /tesseract/fees/prisma-cli/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "prisma-cli" 3 | version = "0.1.0" 4 | edition = "2021" 5 | publish = false 6 | 7 | [dependencies] 8 | prisma-client-rust-cli = { git = "https://github.com/Brendonovich/prisma-client-rust.git", tag = "0.6.11", features = ["sqlite", "migrations"] } 9 | -------------------------------------------------------------------------------- /tesseract/fees/prisma-cli/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | prisma_client_rust_cli::run(); 3 | } 4 | -------------------------------------------------------------------------------- /tesseract/fees/prisma/migrations/20240227154307_/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateTable 2 | CREATE TABLE "Deliveries" ( 3 | "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 4 | "hash" TEXT NOT NULL, 5 | "source_chain" TEXT NOT NULL, 6 | "dest_chain" TEXT NOT NULL, 7 | "delivery_type" INTEGER NOT NULL, 8 | "created_at" INTEGER NOT NULL, 9 | "height" INTEGER NOT NULL 10 | ); 11 | -------------------------------------------------------------------------------- /tesseract/fees/prisma/migrations/20240315095442_pending_withdrawals/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateTable 2 | CREATE TABLE "PendingWithdrawal" ( 3 | "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 4 | "dest" TEXT NOT NULL, 5 | "encoded" BLOB NOT NULL 6 | ); 7 | -------------------------------------------------------------------------------- /tesseract/fees/prisma/migrations/20240327084356_unproitable_retries/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateTable 2 | CREATE TABLE "UnprofitableMessages" ( 3 | "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 4 | "dest" TEXT NOT NULL, 5 | "encoded" BLOB NOT NULL 6 | ); 7 | -------------------------------------------------------------------------------- /tesseract/fees/prisma/migrations/migration_lock.toml: -------------------------------------------------------------------------------- 1 | # Please do not edit this file manually 2 | # It should be added in your version-control system (i.e. Git) 3 | provider = "sqlite" -------------------------------------------------------------------------------- /tesseract/fees/prisma/schema.prisma: -------------------------------------------------------------------------------- 1 | datasource db { 2 | provider = "sqlite" 3 | url = "file:./dev.db" 4 | } 5 | 6 | generator client { 7 | provider = "cargo prisma" 8 | output = "../src/db.rs" 9 | } 10 | 11 | model Deliveries { 12 | id Int @id @default(autoincrement()) 13 | hash String 14 | source_chain String 15 | dest_chain String 16 | delivery_type Int 17 | created_at Int 18 | height Int 19 | } 20 | 21 | model PendingWithdrawal { 22 | id Int @id @default(autoincrement()) 23 | dest String 24 | encoded Bytes 25 | } 26 | 27 | model UnprofitableMessages { 28 | id Int @id @default(autoincrement()) 29 | dest String 30 | encoded Bytes 31 | } 32 | -------------------------------------------------------------------------------- /tesseract/fisherman/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tesseract-fisherman" 3 | version = "0.1.0" 4 | edition = "2021" 5 | description = "A process that checks for malicious consensus updates" 6 | authors = ["Polytope Labs "] 7 | 8 | [dependencies] 9 | anyhow = { workspace = true } 10 | log = "0.4.17" 11 | futures = "0.3.28" 12 | tracing = "0.1.40" 13 | tokio = { workspace = true, features = ["full"] } 14 | sp-core = { workspace = true, features = ["full_crypto"] } 15 | 16 | ismp = { workspace = true } 17 | pallet-ismp = { workspace = true } 18 | 19 | tesseract-primitives = { workspace = true } 20 | 21 | [dependencies.polkadot-sdk] 22 | workspace = true 23 | default-features = true 24 | features = ["sc-service"] 25 | -------------------------------------------------------------------------------- /tesseract/integration-test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tesseract-integration-test" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | tesseract-messaging = { path = "../messaging" } 8 | tesseract-primitives = { path = "../primitives" } 9 | tesseract-config = { path = "../config" } 10 | tesseract-substrate = { path = "../substrate", features = ["testing"] } 11 | tesseract = { path = "../relayer" } 12 | substrate-state-machine = { workspace = true } 13 | pallet-ismp-host-executive = { workspace = true } 14 | pallet-hyperbridge = { workspace = true } 15 | pallet-ismp-demo = { workspace = true } 16 | 17 | anyhow = { workspace = true } 18 | tracing = "0.1.40" 19 | percentage = "0.1.0" 20 | futures = "0.3.28" 21 | tokio = { workspace = true, features = ["full"] } 22 | sp-core = { version = "21.0.0", features = ["full_crypto"] } 23 | hex = "0.4.3" 24 | tokio-stream = { workspace = true } 25 | toml = "0.7.4" 26 | ismp = { workspace = true, default-features = true } 27 | pallet-ismp = { workspace = true, default-features = true } 28 | tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } 29 | subxt = { workspace = true, features = ["substrate-compat"] } 30 | subxt-signer = "0.30.1" 31 | subxt-utils = { workspace = true, default-features = true } 32 | transaction-fees = { path = "../fees" } 33 | log = "0.4.19" 34 | 35 | [dependencies.polkadot-sdk] 36 | workspace = true 37 | default-features = true 38 | features = ["sc-service", "sp-keyring", "sc-consensus-manual-seal"] 39 | -------------------------------------------------------------------------------- /tesseract/messaging/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tesseract-messaging" 3 | version = "0.1.0" 4 | edition = "2021" 5 | description = "Chain agnostic ISMP request/response relay" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | [dependencies] 10 | anyhow = { workspace = true } 11 | tracing = "0.1.40" 12 | percentage = "0.1.0" 13 | futures = "0.3.28" 14 | tokio = { workspace = true, features = ["full"] } 15 | sp-core = { workspace = true, features = ["full_crypto"] } 16 | hex = "0.4.3" 17 | itertools = "0.13.0" 18 | tokio-stream = { workspace = true } 19 | 20 | ismp = { workspace = true, default-features = true } 21 | pallet-ismp = { workspace = true, default-features = true } 22 | pallet-state-coprocessor = { workspace = true, default-features = true } 23 | 24 | transaction-fees = { workspace = true } 25 | tesseract-primitives = { workspace = true } 26 | ismp-solidity-abi = { workspace = true, default-features = true } 27 | 28 | [dependencies.polkadot-sdk] 29 | workspace = true 30 | default-features = true 31 | features = ["sc-service"] 32 | -------------------------------------------------------------------------------- /tesseract/primitives/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tesseract-primitives" 3 | version = "0.1.0" 4 | edition = "2021" 5 | description = "Tesseract relayer primitives" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | [dependencies] 10 | anyhow = { workspace = true, default-features = true } 11 | async-trait = "0.1.53" 12 | futures = "0.3.28" 13 | tokio = { workspace = true, features = ["full"] } 14 | log = "0.4.17" 15 | 16 | serde = { version = "1.0.164", features = ["derive"] } 17 | primitive-types = { workspace = true, default-features = true } 18 | tracing = "0.1.40" 19 | parity-scale-codec = "3.2.2" 20 | ismp-solidity-abi = { workspace = true, default-features = true } 21 | 22 | pallet-ismp-relayer = { workspace = true, default-features = true } 23 | ismp = { workspace = true, default-features = true } 24 | sp-core = { workspace = true, default-features = true } 25 | pallet-ismp-host-executive = { workspace = true, default-features = true } 26 | pallet-state-coprocessor = { workspace = true, default-features = true } 27 | 28 | [features] 29 | testing = [] 30 | -------------------------------------------------------------------------------- /tesseract/primitives/src/queue.rs: -------------------------------------------------------------------------------- 1 | use futures::{ 2 | channel::{mpsc, oneshot}, 3 | SinkExt, StreamExt, 4 | }; 5 | use std::future::Future; 6 | 7 | /// Starts a pipelined task with the provided handler. The sender [`PipelineQueue`] always blocks 8 | /// until the pipelined task is completed. 9 | pub fn start_pipeline(handler: F) -> PipelineQueue 10 | where 11 | T: Send + Sync + 'static, 12 | R: Send + Sync + 'static, 13 | F: FnMut(T) -> Fut + Clone + Send + 'static, 14 | Fut: Future + Send + 'static, 15 | { 16 | let (sender, rx) = mpsc::channel::<(T, oneshot::Sender)>(64); 17 | 18 | let task = rx.for_each(move |(item, sender)| { 19 | let mut f = handler.clone(); 20 | async move { 21 | let res = f(item).await; 22 | let _ = sender.send(res); 23 | } 24 | }); 25 | 26 | tokio::spawn(task); 27 | 28 | PipelineQueue { sender } 29 | } 30 | 31 | /// Abstraction for dealing with pipelined tasks. 32 | pub struct PipelineQueue { 33 | /// Sending end of the pipeline 34 | sender: mpsc::Sender<(T, oneshot::Sender)>, 35 | } 36 | 37 | impl Clone for PipelineQueue { 38 | fn clone(&self) -> Self { 39 | Self { sender: self.sender.clone() } 40 | } 41 | } 42 | 43 | impl PipelineQueue { 44 | /// Send a unit of work to the pipeline. 45 | pub async fn send(&self, item: T) -> anyhow::Result { 46 | let (tx, rx) = oneshot::channel(); 47 | 48 | self.sender.clone().send((item, tx)).await?; 49 | 50 | // wait for the task to complete 51 | let res = rx.await?; 52 | 53 | Ok(res) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /tesseract/relayer/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod cli; 2 | mod config; 3 | pub mod logging; 4 | 5 | pub mod fees; 6 | 7 | pub use cli::*; 8 | -------------------------------------------------------------------------------- /tesseract/relayer/src/logging.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Polytope Labs. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use tracing_indicatif::IndicatifLayer; 17 | use tracing_subscriber::{filter::LevelFilter, layer::SubscriberExt, util::SubscriberInitExt}; 18 | 19 | pub fn setup() -> Result<(), anyhow::Error> { 20 | let filter = 21 | tracing_subscriber::EnvFilter::from_default_env().add_directive(LevelFilter::INFO.into()); 22 | tracing_subscriber::fmt().with_env_filter(filter).finish().try_init()?; 23 | 24 | Ok(()) 25 | } 26 | 27 | pub fn animated_logs() -> Result<(), anyhow::Error> { 28 | let indicatif_layer = IndicatifLayer::new(); 29 | let filter = 30 | tracing_subscriber::EnvFilter::from_default_env().add_directive(LevelFilter::INFO.into()); 31 | tracing_subscriber::fmt() 32 | .with_writer(indicatif_layer.get_stderr_writer()) 33 | .with_env_filter(filter) 34 | .finish() 35 | .with(indicatif_layer) 36 | .try_init()?; 37 | 38 | Ok(()) 39 | } 40 | -------------------------------------------------------------------------------- /tesseract/relayer/src/main.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Polytope Labs. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use clap::Parser; 17 | use tesseract::{fees::Subcommand, Cli}; 18 | 19 | #[tokio::main] 20 | async fn main() -> Result<(), anyhow::Error> { 21 | let cli = Cli::parse(); 22 | if let Some(command) = cli.subcommand { 23 | match command { 24 | Subcommand::AccumulateFees(cmd) => 25 | cmd.accumulate_fees(cli.config.clone(), cli.db.clone()).await?, 26 | } 27 | return Ok(()); 28 | } 29 | cli.run().await 30 | } 31 | -------------------------------------------------------------------------------- /tesseract/substrate/src/config.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Polytope Labs. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | //! Subxt [`Config`] implementations 17 | 18 | use codec::Encode; 19 | use sp_core::blake2_256; 20 | use subxt::{ 21 | config::{substrate::SubstrateHeader, Hasher}, 22 | utils::{AccountId32, MultiAddress, MultiSignature, H256}, 23 | }; 24 | 25 | pub use subxt_utils::{Hyperbridge as KeccakSubstrateChain, PolkadotExtrinsicParams}; 26 | 27 | /// Implements [`subxt::Config`] for substrate chains with blake2 as their hashing algorithm 28 | #[derive(Clone)] 29 | pub struct Blake2SubstrateChain; 30 | 31 | /// A type that can hash values using the keccak_256 algorithm. 32 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Encode)] 33 | pub struct Blake2Hasher; 34 | 35 | impl Hasher for Blake2Hasher { 36 | type Output = H256; 37 | fn hash(s: &[u8]) -> Self::Output { 38 | blake2_256(s).into() 39 | } 40 | } 41 | 42 | impl subxt::Config for Blake2SubstrateChain { 43 | type Hash = H256; 44 | type AccountId = AccountId32; 45 | type Address = MultiAddress; 46 | type Signature = MultiSignature; 47 | type Hasher = Blake2Hasher; 48 | type Header = SubstrateHeader; 49 | type ExtrinsicParams = PolkadotExtrinsicParams; 50 | } 51 | -------------------------------------------------------------------------------- /tesseract/telemetry/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "telemetry-server" 3 | version = "0.1.0" 4 | edition = "2021" 5 | description = "Tesseract socket.io telemetry server" 6 | authors = ["Polytope Labs "] 7 | publish = false 8 | 9 | [dependencies] 10 | socketioxide = { version = "0.10.2", features = ["state", "tracing"] } 11 | tokio = { workspace = true, features = ["rt-multi-thread", "macros", "sync"] } 12 | tracing = "0.1.40" 13 | tracing-subscriber = "0.3.18" 14 | serde = { version = "1.0.196", features = ["derive"] } 15 | serde_json = "1.0.112" 16 | tower = "0.4.13" 17 | tower-http = { version = "0.5.1", features = ["cors"] } 18 | anyhow = { workspace = true } 19 | axum = "0.7.4" 20 | sp-core = { workspace = true, features = ["full_crypto", "serde"] } 21 | ismp.workspace = true 22 | primitive-types = { workspace = true, default-features = true, features = ["serde", "scale-info"] } 23 | 24 | [dev-dependencies] 25 | rust_socketio = { version = "0.4.4" } 26 | -------------------------------------------------------------------------------- /tesseract/telemetry/src/lib.rs: -------------------------------------------------------------------------------- 1 | use ismp::host::StateMachine; 2 | use primitive_types::H160; 3 | use serde::{Deserialize, Serialize}; 4 | 5 | /// Message type to the telemetry server 6 | #[derive(Deserialize, Serialize, Debug, Clone)] 7 | pub struct Message { 8 | /// ecdsa signature of the metadata 9 | pub signature: Vec, 10 | /// metadata about the supported state machine and their signer 11 | pub metadata: Vec<(StateMachine, H160)>, 12 | } 13 | -------------------------------------------------------------------------------- /tesseract/test-config.toml: -------------------------------------------------------------------------------- 1 | # Required 2 | [hyperbridge] 3 | state_machine = "KUSAMA-4009" 4 | hashing = "Keccak" 5 | rpc_ws = "ws://127.0.0.1:9933" 6 | signer = "" 7 | 8 | # Required 9 | [relayer] 10 | consensus = false 11 | messaging = true 12 | fisherman = false 13 | router = { Kusama = 4296 } 14 | module_filter = [] 15 | minimum_profit_percentage = 0 16 | delivery_endpoints = [ 17 | "EVM-1", 18 | "EVM-97" 19 | ] 20 | 21 | [optimism] 22 | type = "evm" 23 | state_machine = "EVM-97" 24 | rpc_urls = [ 25 | "http://127.0.0.1:8345" 26 | ] 27 | etherscan_api_key = "CP3H4MAT8UU5KDYY5ZXH3E8UDV5V74B7R8" 28 | ismp_host = "0x8Ac39DfC1F2616e5e19B93420C6d008a8a8EE65f" 29 | consensus_state_id = "ETH0" 30 | signer = "0x8Ac39DfC1F2616e5e19B93420C6d008a8a8EE65f008a8a8EE65f" 31 | tracing_batch_size = 5 32 | query_batch_size = 10000 33 | gas_price_buffer = 5 34 | --------------------------------------------------------------------------------