Skip to content

Excise V9 SDK scaffolding from chain-adapter / dkg-agent / daemon routes #520

@zsculac

Description

@zsculac

Summary

#500 archived V8/V9 contracts at the Solidity, deploy script, and test layers. But V9-shaped TypeScript scaffolding remains in packages/chain, packages/agent, and packages/cli: null stubs, V9 method signatures in the public adapter interface, contract-resolution attempts that always fail, V9 response serializers, V9 ABI bundles, and a /api/pca/* route family that returns 503 because its underlying impl is wired to a contract that no longer exists.

Excising this scaffolding is a precondition for a clean V10 SDK surface (see #519 — V10 PCA NFT wiring) and removes maintenance burden on dead code paths.

Inventory

packages/agent/src/dkg-agent.ts

Five PCA stubs at L3978-4013 that return null and accept V9-shaped args:

  • createPublishingConvictionAccount(_amount: bigint, _lockEpochs: number)_lockEpochs is V9-only; V10 NFT lock is global.
  • addPublishingConvictionAccountFunds(_accountId, _amount).
  • addPCAAuthorizedKey(_accountId, _key) — V9 "key" terminology; V10 uses "agent".
  • isPCAAuthorizedKey(_accountId, _key).
  • getPublishingConvictionAccountInfo(_accountId) returning V9 shape {accountId, admin, balance, initialDeposit, lockEpochs, conviction, discountBps}.

Action: delete all five stubs after the V10 NFT wiring lands. Replace with V10-shaped methods.

packages/chain/src/evm-adapter.ts

  • L705-709: V9 publishingConvictionAccount slot init (resolves Hub key "PublishingConvictionAccount"):

    try {
      this.contracts.publishingConvictionAccount = await this.resolveContract('PublishingConvictionAccount');
    } catch {
      // PublishingConvictionAccount not deployed
    }

    Action: delete; V9 contract will never be deployed again.

  • V9-touching production methods still live and called from the publisher path. Each needs audit:

    • reserveUALRange — reads V9 knowledgeCollection storage
    • verifyKAUpdate — reads V9 KA fields
    • getRequiredPublishTokenAmount — V9 pricing path
    • verifyPublisherOwnsRange — V9 KA owner check
    • publishToContextGraph — V9 entrypoint
    • resolvePublishByTxHash — parses V9 KnowledgeCollectionCreated event
    • createKnowledgeAssetsV10 — V10 method but contains V9 fallback / lookup branch
    • updateKnowledgeCollectionV10 — same

    Action: for each, either drop the V9 branch (if a V10 equivalent exists, e.g. KAv10 publish()), or archive the whole method.

packages/chain/src/chain-adapter.ts (interface)

V9 method signatures still declared even though impls return null:

createPublishingConvictionAccount(amount: bigint, lockEpochs: number): Promise<{...} | null>;
addPublishingConvictionAccountFunds(accountId: bigint, amount: bigint): Promise<{...} | null>;
addPCAAuthorizedKey(accountId: bigint, key: string): Promise<{...} | null>;
isPCAAuthorizedKey(accountId: bigint, key: string): Promise<boolean | null>;
getPublishingConvictionAccountInfo(accountId: bigint): Promise<{...} | null>;

Action: remove. Replace with V10 surface during PCA NFT wiring.

packages/chain/src/mock-adapter.ts, packages/chain/src/no-chain-adapter.ts

V9 PCA method stubs for adapter-interface parity. Action: remove alongside the interface.

packages/chain/abi/

Bundled JSON ABIs for archived contracts. Action: drop ABIs for:

  • PublishingConvictionAccount
  • KnowledgeAssets (V8 KA)
  • KnowledgeCollection (V8 KC)
  • Staking (V8)
  • Paymaster
  • PaymasterManager
  • DelegatorsInfo
  • KnowledgeAssetsStorage
  • ContextGraphNameRegistry
  • IPaymaster

packages/cli/src/daemon/routes/pca.ts

  • File header (L5-7) references V9 PublishingConvictionAccount contract by name.
  • serializeAccountInfo returns V9 fields.
  • Routes call V9-shaped agent stubs (return 503 because stubs return null).

Action: rewrite handlers against V10 NFT API once the SDK wiring (issue #519) lands. Until then, the 503 responses are correct.

packages/chain/src/archive/evm-adapter-v8-v9-methods.ts

~5K LOC reference snapshot preserved as part of #500. Not imported anywhere. Action: keep as historical reference for the duration of V10.1; remove in V10.2 once V9 lessons-learned are codified in docs/migration/v9-to-v10-pca.md.

Phasing

This is naturally two phases. Phase A is mechanical removal of dead scaffolding; Phase B is structural refactoring of methods that still read archived storage.

Phase A — Remove dead code

  • Delete the five dkg-agent.ts PCA null stubs.
  • Delete V9 method signatures from chain-adapter.ts interface.
  • Delete V9 stubs from mock-adapter.ts and no-chain-adapter.ts.
  • Delete publishingConvictionAccount contract resolution in evm-adapter.ts:705-709.
  • Drop archived-contract ABIs from packages/chain/abi/.
  • Daemon /api/pca/* routes: short-circuit to 410 GONE with link to migration doc, instead of 503. (Or remove the routes entirely until the V10 wiring lands in SDK + daemon PCA write surface is wired to archived V9 contract; V10 PCA NFT has no SDK path #519.)

Phase B — V9 method excision in evm-adapter.ts

  • Audit each remaining V9-touching method (reserveUALRange, verifyKAUpdate, getRequiredPublishTokenAmount, verifyPublisherOwnsRange, publishToContextGraph, resolvePublishByTxHash, createKnowledgeAssetsV10 V9 fallback, updateKnowledgeCollectionV10 V9 fallback).
  • For each: drop V9 branch if V10 equivalent exists; otherwise archive the whole method.
  • After this phase, evm-adapter.ts references no archived Hub contract key.

Acceptance

Phase A

  • No return null PCA stubs in dkg-agent.ts.
  • No V9 PCA signatures in chain-adapter.ts interface.
  • No V9 PCA stubs in mock-adapter.ts / no-chain-adapter.ts.
  • No publishingConvictionAccount references in evm-adapter.ts outside the archive subdir.
  • packages/chain/abi/ contains only V10-active contract ABIs.
  • Daemon /api/pca/* returns 410 Gone (or routes removed), not 503.
  • pnpm -r build green.
  • pnpm --filter @origintrail-official/dkg-chain test green.

Phase B

  • evm-adapter.ts has no this.contracts.knowledgeAssets, this.contracts.knowledgeCollection, this.contracts.staking (V8), this.contracts.paymaster*, this.contracts.delegatorsInfo, this.contracts.knowledgeAssetsStorage, this.contracts.contextGraphNameRegistry, this.contracts.publishingConvictionAccount references.
  • Publisher path uses only V10 entrypoints (KnowledgeAssetsV10, V10 storages).
  • Devnet smoke test (DKG_HOME=.devnet/node1 NODE2_DKG_HOME=.devnet/node2 node run.mjs --no-pause) exits 0.

Out of scope

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions