Skip to content

feat(inference): add continuous PoC foundation#845

Open
AlexeySamosadov wants to merge 1 commit intogonka-ai:upgrade-v0.2.11from
AlexeySamosadov:feature/821-continuous-poc
Open

feat(inference): add continuous PoC foundation#845
AlexeySamosadov wants to merge 1 commit intogonka-ai:upgrade-v0.2.11from
AlexeySamosadov:feature/821-continuous-poc

Conversation

@AlexeySamosadov
Copy link
Contributor

Summary

Adds the foundational types, params, keeper infrastructure, and message handler for continuous Proof of Computation -- allowing GPU nodes to prove spare computational capacity by generating PoC nonces in parallel with inference work, rather than requiring separate PoC-only phases.

Closes #821

What's included

  • Proto definitions: ContinuousPoCCommit, ContinuousPoCEpochSummary, ContinuousPoCParams, MsgSubmitContinuousPoCCommit message and query types
  • New governance params (all configurable, disabled by default):
    • EnableContinuousPoC -- feature toggle
    • PocUtilizationTargetBps -- idle GPU capacity fraction for PoC (default: 99.5%)
    • NonceWeight -- how many nonces equal one inference unit (default: 10)
    • MaxCommitsPerEpoch -- anti-spam limit (default: 100)
    • MinNoncesPerCommit -- minimum work per commit (default: 10)
    • ValidationSampleRateBps -- random validation probability (default: 5%)
  • Keeper collections: ContinuousPoCCommits (triple key: epoch+address+height) and ContinuousPoCEpochSummaries (pair key: epoch+address)
  • Message handler (SubmitContinuousPoCCommit) with full validation:
    • Participant registration check
    • Rate limiting (one commit per block)
    • Nonce minimum enforcement
    • Commit count cap per epoch
    • GPU utilization bounds check
    • Automatic epoch summary aggregation and weight calculation
  • Codec registration for the new message type
  • Error sentinel values for continuous PoC validation failures

Design decisions

  • Lightweight on-chain commits: Only count + Merkle root stored on-chain; actual artifacts stored locally (consistent with existing PoCV2 pattern)
  • Epoch summaries: Aggregated in real-time as commits arrive, providing EffectivePocWeight for settlement
  • Disabled by default: EnableContinuousPoC=false ensures zero impact on existing behavior until governance activates it

Note

Proto-gen needs to be run to regenerate .pb.go files from the updated .proto definitions. Hand-written Go types bridge the gap until then.

Test plan

  • Verify go build ./... passes
  • Run proto-gen to regenerate pb.go files
  • Unit test for SubmitContinuousPoCCommit happy path and validation edge cases
  • Integration test with continuous PoC enabled via params update
  • Verify default params don't affect existing PoC behavior

Add the foundation for continuous Proof of Computation that runs in
parallel with inference. This allows GPU nodes to prove their spare
computational capacity by generating PoC nonces alongside real
inference work, rather than requiring separate PoC-only phases.

Changes:
- New proto definitions: ContinuousPoCCommit, ContinuousPoCEpochSummary,
  ContinuousPoCParams, MsgSubmitContinuousPoCCommit
- New params: EnableContinuousPoC, PocUtilizationTargetBps, NonceWeight,
  MaxCommitsPerEpoch, MinNoncesPerCommit, ValidationSampleRateBps
- Keeper collections for commits and epoch summaries
- Message handler with validation (participant check, rate limiting,
  nonce minimum, commit count cap, GPU utilization bounds)
- Query proto definitions for epoch summaries
- Codec registration for new message type
- Disabled by default via EnableContinuousPoC=false

Note: proto-gen needs to be run to regenerate pb.go files from the
updated .proto definitions. Hand-written Go types bridge the gap
until then.
Mayveskii pushed a commit to Mayveskii/gonka that referenced this pull request Mar 3, 2026
…, nonce validation

Builds on the continuous PoC foundation (GiP gonka-ai#821) with three critical
missing components:

## 1. Pruning (application.db growth prevention)
- Extend PruningState with ContinuousPoCCommitsPrunedEpoch and
  ContinuousPoCChallengePrunedEpoch fields (pruning_state.proto + .pb.go)
- Add GetContinuousPoCCommitsPruner and GetContinuousPoCChallengesPruner
  to pruning.go using the same Pruner[K,V] pattern as existing collections
- Wire into Keeper.Prune(), called from EndBlock every block

## 2. Epoch settlement (EffectivePocWeight → validator weight)
- Add ContinuousPoCEpochSummaries map to WeightCalculator
- GetAllContinuousPoCEpochSummariesForEpoch loads all summaries at settlement
- calculateParticipantWeight adds effective_poc_weight to baseCount before
  applying combinedFactor — disabled if PenaltyApplied is true

## 3. Nonce validation (challenge / response)
- ContinuousPoCChallenge type with full Marshal/Unmarshal/Size
- IssueContinuousPoCChallenges: called each block, samples commits by
  ValidationSampleRateBps using app_hash as deterministic entropy
- RespondContinuousPoCChallenge: verifies sha256-based Merkle proof;
  invalid proof or expired challenge zeros the epoch EffectivePocWeight
- ExpireContinuousPoCChallenges: zeroes weight for unanswered challenges

## Bug fix vs PR gonka-ai#845
PR gonka-ai#845 adds ContinuousPocParams to Params but omits MarshalToSizedBuffer,
Size, and Unmarshal changes in params.pb.go, so the field would never be
persisted. This PR adds the full hand-written codec for ContinuousPoCParams,
ContinuousPoCCommit, ContinuousPoCEpochSummary, and ContinuousPoCChallenge
in types/continuous_poc.go, and wires field 14 into params.pb.go.

Closes gonka-ai#821

Made-with: Cursor
Mayveskii pushed a commit to Mayveskii/gonka that referenced this pull request Mar 4, 2026
…, nonce validation

Builds on the continuous PoC foundation (GiP gonka-ai#821) with three critical
missing components:

- Extend PruningState with ContinuousPoCCommitsPrunedEpoch and
  ContinuousPoCChallengePrunedEpoch fields (pruning_state.proto + .pb.go)
- Add GetContinuousPoCCommitsPruner and GetContinuousPoCChallengesPruner
  to pruning.go using the same Pruner[K,V] pattern as existing collections
- Wire into Keeper.Prune(), called from EndBlock every block

- Add ContinuousPoCEpochSummaries map to WeightCalculator
- GetAllContinuousPoCEpochSummariesForEpoch loads all summaries at settlement
- calculateParticipantWeight adds effective_poc_weight to baseCount before
  applying combinedFactor — disabled if PenaltyApplied is true

- ContinuousPoCChallenge type with full Marshal/Unmarshal/Size
- IssueContinuousPoCChallenges: called each block, samples commits by
  ValidationSampleRateBps using app_hash as deterministic entropy
- RespondContinuousPoCChallenge: verifies sha256-based Merkle proof;
  invalid proof or expired challenge zeros the epoch EffectivePocWeight
- ExpireContinuousPoCChallenges: zeroes weight for unanswered challenges

PR gonka-ai#845 adds ContinuousPocParams to Params but omits MarshalToSizedBuffer,
Size, and Unmarshal changes in params.pb.go, so the field would never be
persisted. This PR adds the full hand-written codec for ContinuousPoCParams,
ContinuousPoCCommit, ContinuousPoCEpochSummary, and ContinuousPoCChallenge
in types/continuous_poc.go, and wires field 14 into params.pb.go.

Closes gonka-ai#821

Made-with: Cursor
@akup
Copy link
Contributor

akup commented Mar 6, 2026

At this long-running task we first should have tested and reliable way to precisely enough estimate mlnodes load and should accurately test how it load.
There are problems with inference recording performance, and dev-chains are proposed, it is hard to estimate the load of mlnodes driven by dev-chains, there are so lot of unknown things, that implementing it in code is not in time.

Such task should first have detailed whitepaper proposal and after all utility classes. Design still not discussed and proposed, but code is already proposed, but it is useless as it will change when design is discussed and choosen.

This PR is running ahead of steps that should be done first (actually it introduces the last step being first).

@AlexeySamosadov please first write your proposal with design in discussion #802

And please move this PR to draft or close it.

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.

2 participants