Skip to content

Feature/821 continuous poc complete#856

Open
Mayveskii wants to merge 6 commits intogonka-ai:upgrade-v0.2.11from
Mayveskii:feature/821-continuous-poc-complete
Open

Feature/821 continuous poc complete#856
Mayveskii wants to merge 6 commits intogonka-ai:upgrade-v0.2.11from
Mayveskii:feature/821-continuous-poc-complete

Conversation

@Mayveskii
Copy link

Summary

Builds on PR #845 (AlexeySamosadov) to deliver a production-ready continuous PoC system.
PR #845 introduced the data structures; this PR makes them work end-to-end and fixes a
critical serialisation bug in #845.

What this PR adds

1. Fix: ContinuousPocParams serialisation bug in PR #845

params.pb.go added ContinuousPocParams to the Params struct but never updated
MarshalToSizedBuffer, Size, or Unmarshal. The field silently vanished on every
round-trip — making continuous PoC impossible to enable via governance.

2. Pruning for continuous PoC collections

Extends PruningState (proto fields 4–6) with epoch counters for commits, challenges,
and summaries. Adds three Pruner implementations wired into Keeper.Prune():

  • GetContinuousPoCCommitsPrunerTriple[uint64, AccAddress, int64]
  • GetContinuousPoCChallengesPruner — same key shape
  • GetContinuousPoCEpochSummariesPrunerPair[uint64, AccAddress]

All three reuse existing PocDataPruningEpochThreshold / PocPruningMax parameters.

3. Epoch settlement integration

WeightCalculator gains a ContinuousPoCEpochSummaries map. During ComputeNewWeights,
EffectivePocWeight from each participant's ContinuousPoCEpochSummary is added to their
standard PoC weight — unless PenaltyApplied is set (failed/expired challenge).

4. Merkle-proof nonce validation

  • SubmitContinuousPoCCommit — validates params, enforces MaxCommitsPerEpoch and MinNoncesPerCommit, upserts ContinuousPoCEpochSummary.
  • IssueContinuousPoCChallenges (EndBlock) — deterministically samples commits using sha256(app_hash || block_height) as entropy.
  • RespondContinuousPoCChallenge — verifies the Merkle proof and resolves the challenge.
  • ExpireContinuousPoCChallenges (EndBlock) — applies PenaltyApplied to summaries whose deadline passed.

Testing

  • 21 unit tests in x/inference/types — all pass
  • Full module build verified on Debian bookworm / Go 1.22.8

Note on PR #845

This PR intentionally overlaps with #845 — it is a superset. If #845 merges first, I will
rebase and remove the duplicate definitions. Happy to coordinate with the author.

Closes #821

cisco added 5 commits March 3, 2026 16:42
…, 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
- Rename proto field 5 from continuous_poc_summaries_pruned_epoch
  to continuous_poc_challenges_pruned_epoch (naming matched its use)
- Add proto field 6 continuous_poc_summaries_pruned_epoch for the
  ContinuousPoCEpochSummaries collection
- Add GetContinuousPoCEpochSummariesPruner keyed on Pair[uint64, AccAddress]
  and wire it into Keeper.Prune() to prevent summaries accumulating forever
- Update PruningState round-trip and backward-compat tests for field 6

Made-with: Cursor
@tcharchian
Copy link
Collaborator

@Mayveskii can I kindly ask you to contact me via tania.charchian at productscience.ai

Mayveskii pushed a commit to Mayveskii/gonka that referenced this pull request Mar 4, 2026
Nodes that produce high-quality inference results and serve them from cache
earn CacheQualityWeight — an additive bonus on top of standard PoC weight.
This creates an economic feedback loop: better GPU → better results → more
reuse → higher weight → more rewards.

Two lookup levels:
  L1 — PromptHash exact-match (sha256 of canonical JSON), O(1), 100% certain.
  L2 — cosine similarity via all-MiniLM-L6-v2, governance-controlled threshold.

MsgFinishInference is sent on every HIT so the node closes the on-chain cycle.
Feature disabled by default; activated via CacheQualityParams governance.

inference-chain:
- cache_quality.proto: proto source for CacheQualityEpochSummary (new)
- params.proto: CacheQualityParams added (field 14)
- tx.proto: MsgSubmitCacheQualitySummary RPC added
- types/cache_quality.go: params and summary types with serialisation
- keeper/msg_server_cache_quality.go: submission handler with bounds checks
- keeper/pruning.go: CacheQualityEpochSummaries pruner
- module/chainvalidation.go: CacheQualityWeight integration at epoch settlement
- app/upgrades/v0_2_11: seeds CacheQualityParams defaults on upgrade

decentralized-api:
- semanticcache/cache.go: SemanticCache with LookupByPromptHash (L1) + Lookup (L2)
- semanticcache/memory_store.go: InMemoryCacheStore, zero external dependencies
- semanticcache/embedder.go: MLNodeEmbedder + StubEmbedder
- semanticcache/quality_reporter.go: QualityReporter submits per-epoch summary
- semanticcache/cache_test.go + cache_http_test.go: 20 tests, full matrix
- post_chat_handler.go: L1/L2 integration in executor path
- main.go: cache initialisation wired to governance params and epoch events
- mlnodeclient: Embed() method added to interface and client

mlnode:
- packages/api/src/api/embed_routes.py: /api/v1/embed endpoint (CPU, fastembed)

docs:
- docs/specs/semantic-cache.md: two-level architecture, developer simulation

Depends on continuous PoC (gonka-ai#856). Closes gonka-ai#821.
…Performance)

Merge origin/upgrade-v0.2.11 into feature/821-continuous-poc-complete.

Resolved collisions:
- keys.go: upstream took prefixes 44-46 (ActiveParticipantsCache,
  ModelLoad/InferenceCount rolling windows); moved ContinuousPoC
  collections to 48-50 to avoid collision
- errors.go: upstream took error codes 1166-1169 (Unified Permissions
  gonka-ai#760); renumbered ContinuousPoC errors to 1170-1176
- keeper.go: added both ActiveParticipantsSet and ContinuousPoC
  collection fields/init

Made-with: Cursor
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