SMC-1674: Crosschain stake and governance vote example - #35
Open
c0rv0s wants to merge 5 commits into
Open
Conversation
…ability Add a Governance example demonstrating crosschain GovernorBravo-style voting across 3+ chains, consolidated on Creditcoin USC: - StakedGovernanceVoting.sol: spoke deployed on each voting chain; users stake an ERC20 for voting weight, cast Bravo-style votes, and finalize a per-chain tally emitted as a single ChainTallyFinalized event. - CrossChainGovernorHub.sol: hub on Creditcoin USC that verifies USC readability queries proving each chain's tally event and consolidates the result once at least 3 chains have reported. - README.md: architecture, end-to-end flow, and query verification model. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
c0rv0s
marked this pull request as ready for review
July 9, 2026 19:47
The USC core (write-ability-research) has fully moved off the async `@gluwa/creditcoin-public-prover` query/result-segment readability model to the synchronous native query-verifier precompile (`IUSCProofVerifier` / `0xFD2`), as used by `USCLoanReadabilityManager`. Bring the crosschain governance example in line so it demonstrates the current integration pattern. - CrossChainGovernorHub: submitChainTally now takes (chainKey, blockHeight, inclusionProof, continuityProof); verifies via the shared USCProofVerifier, which returns the proved tx+receipt bytes, then decodes the receipt with EvmV1Decoder and reads the ChainTallyFinalized log directly. Single shared verifier (setProofVerifier) replaces the per-chain prover; replay id is keccak256(chainKey, blockHeight, txIndex). - Vendor the USC-core primitives under contracts/Governance/usc/ (IUSCProofVerifier, BlockProverTypes, EvmV1Decoder, QueryProofVerificationLib). - Replace MockCreditcoinPublicProver with MockUSCProofVerifier. - Replace buildGovernanceTallyQuery.js with buildGovernanceTallyProof.js, which packs inclusion/continuity proofs from the SDK's ProverAPIProofGenerator. - Rewrite tests (spoke test is now pure-spoke; hub suite covers edge cases plus a real end-to-end path through packTallyProof) and the README. StakedGovernanceVoting is unchanged (model-agnostic). The @gluwa/creditcoin-public-prover dependency stays for the bridge/loan examples. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
# Conflicts: # hardhat.config.ts # yarn.lock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a governance example demonstrating cross-chain GovernorBravo-style voting across three or more USC source chains, with results consolidated on Creditcoin USC using USC readability (the native proof-verifier model, matching the current USC core).
Changes
StakedGovernanceVoting.sol: Spoke contract deployed on each voting chain. Users stake an ERC20 token, cast weighted votes, and finalize a per-chain tally through aChainTallyFinalizedevent.CrossChainGovernorHub.sol: Hub contract that verifies a source-chain inclusion + continuity proof through the sharedUSCProofVerifier(native0xFD2precompile), decodes the proved receipt withEvmV1Decoder, records one tally per registered USC source-chain key, and consolidates the result after at least three chains report.contracts/Governance/usc/: USC-core readability primitives vendored for the example (IUSCProofVerifier,BlockProverTypes,EvmV1Decoder,QueryProofVerificationLib);MockUSCProofVerifier.solstands in for the verifier in tests.buildGovernanceTallyProof.js: Fetches and packs the inclusion/continuity proof payload forsubmitChainTallyvia@gluwa/usc-sdk'sProverAPIProofGenerator.README.md: Documents the architecture, end-to-end flow, chain-key configuration, proof construction, and the hub verification model.packTallyProof.