Skip to content

SMC-1674: Crosschain stake and governance vote example - #35

Open
c0rv0s wants to merge 5 commits into
mainfrom
feature/SMC-1674
Open

SMC-1674: Crosschain stake and governance vote example#35
c0rv0s wants to merge 5 commits into
mainfrom
feature/SMC-1674

Conversation

@c0rv0s

@c0rv0s c0rv0s commented Jul 8, 2026

Copy link
Copy Markdown

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 a ChainTallyFinalized event.
  • CrossChainGovernorHub.sol: Hub contract that verifies a source-chain inclusion + continuity proof through the shared USCProofVerifier (native 0xFD2 precompile), decodes the proved receipt with EvmV1Decoder, 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.sol stands in for the verifier in tests.
  • buildGovernanceTallyProof.js: Fetches and packs the inclusion/continuity proof payload for submitChainTally via @gluwa/usc-sdk's ProverAPIProofGenerator.
  • README.md: Documents the architecture, end-to-end flow, chain-key configuration, proof construction, and the hub verification model.
  • Tests cover three-chain consolidation, replay and proof validation, distinct chain keys, untrusted-caller rejection, staking, voting, and a real end-to-end path through packTallyProof.

c0rv0s and others added 3 commits July 8, 2026 14:53
…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
c0rv0s marked this pull request as ready for review July 9, 2026 19:47
@c0rv0s
c0rv0s requested a review from ohyung1287 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>
@c0rv0s
c0rv0s requested a review from kevinnguyen17 July 23, 2026 21:53
# Conflicts:
#	hardhat.config.ts
#	yarn.lock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant