{"id":24054623,"url":"https://github.com/cardinal-cryptography/most","last_synced_at":"2025-04-22T20:45:56.559Z","repository":{"id":218914522,"uuid":"685523395","full_name":"Cardinal-Cryptography/most","owner":"Cardinal-Cryptography","description":"Aleph Zero bridge to Ethereum","archived":false,"fork":false,"pushed_at":"2025-03-28T14:00:45.000Z","size":7529,"stargazers_count":23,"open_issues_count":3,"forks_count":7,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-14T07:52:42.265Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cardinal-Cryptography.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-08-31T12:28:33.000Z","updated_at":"2025-03-28T14:00:47.000Z","dependencies_parsed_at":"2024-02-19T12:35:34.151Z","dependency_job_id":"a8d1faba-f65e-440b-ab46-01c9d0857e70","html_url":"https://github.com/Cardinal-Cryptography/most","commit_stats":null,"previous_names":["cardinal-cryptography/most"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cardinal-Cryptography%2Fmost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cardinal-Cryptography%2Fmost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cardinal-Cryptography%2Fmost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cardinal-Cryptography%2Fmost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cardinal-Cryptography","download_url":"https://codeload.github.com/Cardinal-Cryptography/most/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250322044,"owners_count":21411694,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-09T03:49:04.093Z","updated_at":"2025-04-22T20:45:56.530Z","avatar_url":"https://github.com/Cardinal-Cryptography.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Built with ink!](https://raw.githubusercontent.com/paritytech/ink/master/.images/badge_flat.svg)](https://github.com/paritytech/ink)\n\n\u003cimg src=\"most_logo.png\" alt=\"Most logo\"\u003e\n\n# Aleph Zero MOST\u003csup\u003e*\u003c/sup\u003e (Guardian) Bridge\n\nBring your assets to Aleph Zero and benefit from its scalable privacy-enhancing ecosystem.\n\n\u003csup\u003e_\\*'bridge' in Slavic languages._\u003c/sup\u003e\n\n## Contents\n\n* `azero` - Aleph Zero contracts\n  * `azero/contracts/most` - the main bridge contract\n  * `azero/contracts/gas-price-oracle` - a contract for informing the guardians about Ethereum gas prices\n  * `azero/contracts/token` - a PSP22 token implementation for the tokens created by the bridge\n* `eth` - Ethereum contracts\n  * `eth/contracts/Most.sol` - the main bridge contract\n  * `eth/contracts/Governance.sol` - a contract for making governance decisions about the bridge contracts on Ethereum\n  * `eth/contracts/WETH9.sol` - a wrapped ethereum implementation for testing purposes\n  * `eth/contract/Token.sol` - an ERC20 token implementation for testing purposes\n* `relayer` - the component doing the actual bridging between the chains\n\n## Prerequisites\n\n1. Have docker and docker-compose (`1.29.2`)\n2. Have cargo-contract (`3.2.0`) installed:\n\n```bash\ncargo install cargo-contract --vers 3.2.0\n```\n\n## Testing the contracts\n\n### Solidity contracts\n\nTo run the tests for the Solidity `Most.sol` contract, run:\n\n```bash\nmake test-solidity\n```\n\nIt will run the tests using the Hardhat framework.\nAlternatively, you can run the tests directly from the selected file in the `eth` directory, for example:\n\n```bash\ncd eth\nnpx hardhat test test/Most.js\n```\n\n### Ink! contracts\n\n#### Unit tests\n\nTo run the unit tests for the ink! contracts, run:\n\n```bash\nmake test-ink-unit\n```\n\nThese will allow you to test the contracts in isolation, without the need for running a blockchain node in the background.\n\n#### DRink! tests\n\nTo run DRink! based tests, which allow for testing interactions between multiple contracts without the need to run a node, run:\n\n```bash\nmake drink-tests\n```\nDRink! tests are located in `azero/contracts/drink-tests/`.\n\n### ink_e2e tests\n\nTo run the end-to-end tests for the ink! `most` contracts, run (requires docker-compose `1.29.2`):\n\n```bash\nmake test-ink-e2e\n```\nThese tests are located at `azero/contracts/tests`.\n\n## Running the local development environment\n\nTo run a local development environment, run:\n\n```bash\nmake bridge\n```\n\nThis will start a local development environment with the following components:\n* Aleph Zero Development chain\n* Ethereum PoS Development chain\n* Bridge contracts deployed on both chains\n* Redis instance\n* Relayer process\n\n## Running local development chains\n\nTo run the development chain without deploying the contracts or running the relayer, run:\n\n```bash\nmake devnet-eth\n```\nor\n```bash\nmake devnet-azero\n```\n\n## Running a relayer with a signer locally\n\nFirst, run the signer:\n\n```bash\ncd relayer\nRELAYER_ID=1 scripts/run_signer.sh\n```\n\nThe signer will output the CID on which it is running, but you should also be able to just use 2 (meaning host) as the CID.\n\nNext, run the relayer, passing the signer CID to connect to:\n\n```bash\n# in most/relayer\nSIGNER_CID=2 scripts/run_relayer.sh\n```\n\n## Cleaning up\n\nTo stop the networks (and redis) and clean up:\n\n```bash\nmake clean\n```\n\n### Check eth nodes connectivity\n\nget a shell into running container:\n\n```bash\ndocker exec -it eth_bootnode \"geth attach /root/.ethereum/geth.ipc\"\n```\n\nattach console to the geth process:\n\n```bash\ngeth attach /root/.ethereum/geth.ipc\n```\n\nCheck the connected peers, confirm these are the correct nodes:\n\n```bash\nnet.peerCount\nadmin.peers\n```\n\n## Deploying contracts\n\nTo deploy the contracts on the EVM chain:\n\n```bash\nmake deploy-eth\n```\n\nThis command will deploy the contracts and print out the contract addresses.\n\nNow, open a Hardhat console:\n\n```bash\ncd eth \u0026\u0026 npx hardhat console --network development\n```\n\nInteract with the deployed contracts instance:\n\n```javascript\nlet Most = await ethers.getContractFactory(\"Most\")\nlet most = Most.attach(\"insert contract address here\")\nlet accounts = await ethers.getSigners();\n\nawait most.isGuardian(accounts[0])\nawait most.isGuardian(accounts[1])\n```\n\nTo deploy the contracts on the Aleph Zero chain:\n\n```bash\nmake deploy-azero\n```\n\n## Running the relayer processes\n\n```bash\nmake run-relayers\n```\n\n## Verifying deployed contracts against source code\n\nGiven a deployed (by us) Aleph Zero contract with some code hash `C` it's possible to check that the contract has been\nproduced from a certain version of the source code in this repo (say a given commit). To do so:\n\n1. `git checkout $COMMIT`\n2. `make print-azero-codehashes`\n3. Find the contract in question in the list and ensure that the printed code hash is the same as `C`\n\nThe contracts will be deployed using the same docker image as the one used for this procedure, which smooths out\nindeterminism in ink! contract compilation.\n\n## Verifying deployed contracts on etherscan\n\nGiven a deployed Ethereum contract address it's possible to post verified sources to etherscan and sourcify. You will\nneed an API key for etherscan - can be obtained at https://etherscan.io/myapikey if you have an account. To do so:\n\n1. `git checkout $COMMIT` - where `$COMMIT` is the commit from which the contract has been deployed\n2. `cd eth`\n3. `ETHERSCAN_API_KEY=[YOUR API KEY] npx hardhat verify [CONTRACT ADDRESS] [CONSTRUCTOR ARGS]`\n\nFor example, if you deploy `Token.sol` to the sepolia testnet like so:\n\n```js\nconst usdt = await Token.deploy(\n  \"12000000000000000000000000\",\n  \"Tether\",\n  \"USDT\",\n);\n```\n\nand the address is `0xbd737D2061ed3b24C95FA88566Ad896c9Fcc84b0`, then you would post verified sources like so:\n\n```bash\nETHERSCAN_API_KEY=[YOUR API KEY] npx hardhat --network sepolia verify \"0xbd737D2061ed3b24C95FA88566Ad896c9Fcc84b0\" \\\n  \"12000000000000000000000000\" \"Tether\" \"USDT\"\n```\n\n## Decoding a contract call on ethereum\n\nAssuming a contract verified on etherscan, there's a convenience script to decode a call to that contract. Just call:\n\n```bash\nNETWORK=[NETWORK NAME] CALL=[CALL DATA] CONTRACT=[CONTRACT ADDRESS] make decode-eth\n```\n\nValid values for `NETWORK` are `mainnet (default)`, `sepolia`, and `goerli`.\n\nFor example:\n\n```bash\nNETWORK=sepolia  \\\n  CALL=0x095ea7b30000000000000000000000005a344a8721d743393847c17613dd78c7776b271400000000000000000000000000000000000000000000000000000000000004d2 \\\n  CONTRACT=0x5a344a8721d743393847C17613dd78C7776b2714 \\\n  make decode-eth\n```\n\ngives:\n\n```\nContract: Token\nMethod: approve(address,uint256)\nArguments: Result(2) [ '0x5a344a8721d743393847C17613dd78C7776b2714', 1234n ]\n```\n\n## Documentation\n\nAdditional documentation is written in orgmode, diagrams are written using [plantuml](https://plantuml.com/download).\n\nOrgmode is suported by [VSCode](https://vscode-org-mode.github.io/vscode-org-mode), [Emacs](https://orgmode.org/) and [vim](https://github.com/jceb/vim-orgmode).\n\n### Diagrams\n\nIn order to render the diagrams:\n\n```bash\njava -jar plantuml.jar azero_eth_components.iuml eth_azero_components.iuml\n```\n\nThere are various online editors for plantuml that can render the format, e.g.:\n- [plantuml-previewer](https://sujoyu.github.io/plantuml-previewer/)\n\nIn Emacs you can pass the path to the plantuml executable in the orgmode config:\n\n```elisp\n(setq org-plantuml-jar-path\n      (expand-file-name \"/path/to/plantuml.jar\"))\n```\n\nThen you can use:\n\n```\nC-c C-e l p\n```\n\nto render the whole document and evaluate plantuml code blocks (this will produce png files).\n\n## Acknowledgments\n\nThis project includes code from the following MIT-licensed project:\n\n- [pancake-smart-contracts](https://github.com/pancakeswap/pancake-smart-contracts)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcardinal-cryptography%2Fmost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcardinal-cryptography%2Fmost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcardinal-cryptography%2Fmost/lists"}