{"id":22118329,"url":"https://github.com/manav2401/pos-consensus-proof","last_synced_at":"2026-02-14T10:02:52.338Z","repository":{"id":250915419,"uuid":"830484525","full_name":"manav2401/pos-consensus-proof","owner":"manav2401","description":"Generate consensus proof for Polygon PoS using SP1","archived":false,"fork":false,"pushed_at":"2025-01-20T13:24:08.000Z","size":4715,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-19T06:42:32.951Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/manav2401.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-07-18T11:12:20.000Z","updated_at":"2025-01-20T13:24:06.000Z","dependencies_parsed_at":"2024-07-30T20:56:10.312Z","dependency_job_id":"cd61d4a6-f3d3-4e5a-b01d-bfe11ed98412","html_url":"https://github.com/manav2401/pos-consensus-proof","commit_stats":null,"previous_names":["manav2401/pos-consensus-proof"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/manav2401/pos-consensus-proof","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manav2401%2Fpos-consensus-proof","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manav2401%2Fpos-consensus-proof/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manav2401%2Fpos-consensus-proof/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manav2401%2Fpos-consensus-proof/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/manav2401","download_url":"https://codeload.github.com/manav2401/pos-consensus-proof/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manav2401%2Fpos-consensus-proof/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29442333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T07:24:13.446Z","status":"ssl_error","status_checked_at":"2026-02-14T07:23:58.969Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2024-12-01T13:49:17.221Z","updated_at":"2026-02-14T10:02:52.322Z","avatar_url":"https://github.com/manav2401.png","language":"Rust","readme":"# pos-consensus-proof\nGenerate consensus proof for Polygon PoS chain using SP1.\n\n\u003e [!WARNING]\n\u003e This work is not audited. Please use at your own risk.\n\n### Background\n\nPolygon PoS contains 2 layers — bor (execution layer based on geth/erigon) and heimdall (consensus layer based on tendermint). Polygon is also building [AggLayer](https://github.com/agglayer), which expects each chain to generate a ZK proof with different security assumptions. A full execution proof is practically infeasible with a 2s block time for PoS. Hence, as an excercise to plug PoS into AggLayer, we rely on consensus proofs.\n\n### Proving Consensus\n\nConsensus proofs asserts that the majority (\u003e2/3) of PoS validator set agree on a specific state of chain. This allows an external layer (e.g. AggLayer) to verify that the chain is operating honestly assuming the majority validator set is honest. To elaoborate a bit more, the specific state of chain here means a particular state of the execution layer. This is achieved using milestones, which is a also used for finality in PoS. Milestones are messages which are proposed in heimdall representing a range of bor blocks and is being voted upon and persisted. While there is more nuance to it, at a high level consensus proofs basically validates if majority of validators voted upon / signed a milestone message through signature verification.\n\n### Repository Overview\n\nThis repositories is organised into the following directories:\n- `consensus-proof`: Contains the ZK circuit of verifying a milestone message and respective helper functions.\n- `operator`: Implementation of an operator which assembles inputs used to generate the proof.\n- `common`: Contains generic global types.\n- `contracts`: The solidity contracts for on-chain verification and fetching validator set data.\n\n### Proof Generation\n\nMake sure you've [Rust](https://rustup.rs/) and [SP1](https://docs.succinct.xyz/docs/getting-started/install) installed.\n\n#### Contract Deployments\n\nFor proof generation (except the on-chain verification component), the `StakeInfo` contract acts as a proxy to fetch validator set and stake distribution from the respective L1 Stake Manager Contracts (already deployed for PoS mainnet and Amoy). \n\nExisting deployments for `StakeInfo`:\n- Ethereum Mainnet: [0x173ca2f40a37f62527713Bf72b085675A0D5e200](https://etherscan.io/address/0x173ca2f40a37f62527713Bf72b085675A0D5e200)\n- Sepolia: [0x978D36Ed8c03EBF2d3b93b492aF8D37aD56ad1B5](https://sepolia.etherscan.io/address/0x978D36Ed8c03EBF2d3b93b492aF8D37aD56ad1B5)\n\nMake a fresh deployment:\n1. Make sure you have environment variables set corresponding to the chain you're deploying on.\n    ```sh\n    RPC=\u003crpc\u003e # rpc endpoint of chain to be deployed on\n    PK=\u003cpk\u003e # private key of account with funds to be used for deployment\n    SM=\u003csm\u003e # stake manager proxy address\n    ```\n2. Run the forge command to deploy inside the `contracts` directory.\n    ```\n    forge create --broadcast --rpc-url $RPC --private-key $PK --via-ir src/StakingInfo.sol:StakingInfo --constructor-args $SM\n    ```\n\n#### Using operator for proof generation\n\nThe `operator` service can be used for generating consensus proofs for any PoS chain given appropriate configurations are provided. Below are the steps to do the same.\n\n1. Create an environment file using the example. Fill in all relevant details which will be used for assembling the inputs. It needs information about L1 (eth mainnet / sepolia), PoS endpoints (mainnet / amoy for heimdall and bor).\n    ```sh\n    cp .env.example .env\n    ```\n2. Make sure you're able to build the operator.\n    ```sh\n    cd operator\n    cargo build\n    ```\n3. Run the operator service\n    ```sh\n    RUST_LOG=info cargo run --release -- \u003cflags\u003e\n    ```\n    Following flags are supported:\n    - `--prove`: Generates an actual zk proof if set. If not, only executes the code with inputs.\n    - `--proof-type`: Type of proof to be generated. Either `compressed` or `plonk`.\n    - `--skip-l1-block-validation`: Skip validating the height of L1 block. Useful when testing against a fork.\n4. Operator also has some helper commands.\n    ```sh\n    # To print the vkey\n    RUST_LOG=info cargo run --release --bin vkey\n\n    # To verify the proof generated\n    RUST_LOG=info cargo run --release --bin verify\n    ```\n\nIf you want to use the SP1 prover network, set the `SP1_PROVER` env variable to `network` and set the `SP1_PRIVATE_KEY` environment variable to your whitelisted private key. For more information, see the [setup guide](https://docs.succinct.xyz/docs/generating-proofs/prover-network).\n\n### Acknowledgements\n\n- [SP1](https://github.com/succinctlabs/sp1)\n- A PoC [polygon-pos-light](https://github.com/paulgoleary/polygon-pos-light) by [Paul](https://github.com/paulgoleary).","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanav2401%2Fpos-consensus-proof","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanav2401%2Fpos-consensus-proof","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanav2401%2Fpos-consensus-proof/lists"}