Skip to content

feat(cache_model_0): refresh task-contract ABIs from foundry and fix deploy constructors (BL-25) - #261

Queued
robertocarlous wants to merge 8 commits into
InfiniteZeroFoundation:developfrom
robertocarlous:feat/issue-246-refresh-cache-model-abis
Queued

robertocarlous wants to merge 8 commits into
InfiniteZeroFoundation:developfrom
robertocarlous:feat/issue-246-refresh-cache-model-abis

Conversation

@robertocarlous

Copy link
Copy Markdown
Collaborator

Summary

  • Regenerated cache_model_0/abis/DINTaskCoordinator.json and DINTaskAuditor.json from foundry/out via dincli system dump-abi --bytecode, replacing stale hardhat artifacts that were missing ~67 and ~96 ABI entries respectively
  • Updated cache_model_0/manifest.json task_contracts blocks: artifact.type → foundry-artifact, refreshed IPFS CIDs, compilation.toolchain → foundry, optimizer.enabled → true, added via_ir: true, updated source/config paths to foundry/src and foundry/foundry.toml
  • Added --model-id option to dincli model-owner deploy task-coordinator and task-auditor; constructor calls now pass it as the third arg, matching the foundry signatures DINTaskCoordinator(address, uint256) and DINTaskAuditor(address, address, uint256)

Test plan

  • cache_model_0/abis/DINTaskCoordinator.json — verify ABI array is populated from foundry/out (constructor has two params: address, uint256)
  • cache_model_0/abis/DINTaskAuditor.json — verify ABI array is populated from foundry/out (constructor has three params: address, address, uint256)
  • cache_model_0/manifest.json — confirm task_contracts.*.artifact.type is foundry-artifact, compilation.toolchain is foundry, via_ir is true, optimizer.enabled is true
  • dincli model-owner deploy task-coordinator --help — --model-id option is listed
  • dincli model-owner deploy task-auditor --help — --model-id option is listed
  • Deploy smoke test on local anvil: both deploy commands succeed with --model-id 0

Closes #246

…deploy constructors (BL-25)

- Regenerate cache_model_0/abis/DINTaskCoordinator.json and DINTaskAuditor.json
  from foundry/out using `dincli system dump-abi --bytecode`, replacing stale
  hardhat artifacts that were missing ~67 / ~96 ABI entries respectively
- Update cache_model_0/manifest.json task_contracts blocks:
  - artifact.type: hardhat-artifact → foundry-artifact
  - artifact.ipfs: updated CIDs for both regenerated artifacts
  - compilation.toolchain: hardhat → foundry
  - compilation.optimizer.enabled: false → true (runs: 200)
  - compilation.via_ir: true (matches foundry/foundry.toml)
  - source/config/sources paths updated to foundry/src and foundry/foundry.toml
- Add --model-id option to `dincli model-owner deploy task-coordinator` and
  `dincli model-owner deploy task-auditor`; pass it as the third constructor arg
  so calls match DINTaskCoordinator(address, uint256) and
  DINTaskAuditor(address, address, uint256) in foundry/src
@robertocarlous

Copy link
Copy Markdown
Collaborator Author

Cc: @umeradl

@Santiagocetran
Santiagocetran self-requested a review October 22, 2026 13:38

@Santiagocetran Santiagocetran left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Robbert. Reviewed commit 00d410e against #246 and its approved amendments.

  1. P2: Validate the auditor’s model ID before deployment.

In task_auditor, the new --model-id is forwarded to the constructor without comparing it with the selected coordinator’s modelId().

This permits an auditor with ID 1 to be deployed and paired with a coordinator with ID 0. Neither the auditor constructor nor the coordinator’s pairing setter rejects that mismatch. Both IDs are immutable and select per-model stake floors, so the contracts can enforce different models’ requirements. Pairing is also one-shot, making the mistake costly to correct.

Please read the coordinator’s modelId() and reject a mismatch before sending the deployment transaction. Add a regression test showing that mismatched input sends no transaction and matching input still works. This is also the consistency check described in the #223 TP-3 plan.

This finding is based on source inspection. The broader model-ID allocation issue already exists in #223; I’m not asking this PR to implement that entire issue.

  1. Verification: confirm artifact availability.

The committed CIDs match the artifact contents, but that alone doesn’t establish pinning or retrieval. Could you provide the configured-provider pinning confirmation and fresh ensure_file_exists retrieval results for both artifacts, as requested in #246’s approval?

  1. Small correction: backlog reference.

BL-25 in Developer/BACK_LOG.md says “Fixed — PR #256”; this PR is #261. Please correct the reference.

Please address the ID guard and provide the remaining verification evidence before approval.

robertocarlous and others added 2 commits October 24, 2026 15:09
…loyment

Before sending the DINTaskAuditor constructor transaction, read the
coordinator's immutable modelId() and abort with exit 1 if --model-id
does not match. Both IDs select per-model stake floors; pairing is
one-shot and neither the constructor nor the coordinator's setter
reject a cross-model pair at the contract level.

- Add _MODEL_ID_ABI (minimal view ABI for the check)
- In task_auditor(): call coordinator.functions.modelId() before deploy;
  print a clear error and raise typer.Exit(1) on mismatch; no tx is sent
- Add tests/test_task_auditor_model_id_guard.py with two regression
  tests: mismatch sends no transaction (exit 1); match sends deployment tx
- Correct Developer/BACK_LOG.md BL-25 reference from "PR No. 256" to "PR No. 261"
@robertocarlous

Copy link
Copy Markdown
Collaborator Author

All three review items addressed in 36c0bee7.

P2 — model-ID guard
task_auditor() now reads coordinator.modelId() before sending any transaction. A _MODEL_ID_ABI (single view entry) is instantiated at task_coordinator_address, and if --model-id doesn't match the coordinator's returned value, the function prints a clear error ("does not match coordinator modelId()") and raises typer.Exit(1) — no constructor call, no transaction. Two regression tests in tests/test_task_auditor_model_id_guard.py cover both paths:

  • test_mismatch_sends_no_transaction: coord returns 0, CLI passes --model-id 1 → Exit(1), sent == []
  • test_model_id_match_sends_deployment_transaction: coord returns 1, CLI passes --model-id 1 → deployment tx sent

Backlog fix
Developer/BACK_LOG.md BL-25 Status cell corrected from "PR No. 256" to "PR No. 261".

Verification evidence
The review asked for configured-provider pinning confirmation and fresh ensure_file_exists retrieval results for both IPFS artifacts, as requested in issue No. 246's approval. That evidence is from live IPFS operations outside the repo — I'll add it as a separate comment with the pinning receipts and retrieval logs once the local pinning run completes (needs the IPFS node running against the committed CIDs). If you'd prefer to unblock review on the code changes now and treat the verification evidence as a follow-up, let me know.

@robertocarlous

Copy link
Copy Markdown
Collaborator Author

Cc: @Santiagocetran changes fixed can you review again

@Santiagocetran Santiagocetran left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Robbert. Rechecked 36c0bee against the previous review and #246’s approved amendments.

The model-ID guard addresses the original finding: it reads the selected coordinator’s modelId() and rejects a mismatch before constructing or sending the deployment transaction. The regression tests cover rejection without sending and the matching-ID path. The BL-25 reference is also corrected.

The remaining point is artifact availability. I’d keep this verification in the PR rather than defer it, since amendment 4 explicitly requires both artifacts to be pinned through the configured provider and freshly retrieved.

Please add:

  • Pin confirmations for both committed artifact CIDs.
  • Fresh ensure_file_exists retrieval results for each artifact into an empty cache. An existing file with a matching stored CID skips the download, so a cached run wouldn’t verify availability.

The committed content matching its CID doesn’t establish pinning or retrieval. This remains a verification gap, not evidence that the artifacts are unavailable.

CI run 40101597195 passed, but tested the earlier develop baseline. Please sync with current develop and obtain fresh CI; if the artifacts change, provide the pinning/retrieval evidence for the final CIDs.

The code fixes above are resolved. Approval remains pending the outstanding verification. This follow-up is based on source inspection and observed CI, not a new live-chain deployment or IPFS test.

@robertocarlous

Copy link
Copy Markdown
Collaborator Author

Addressed in 4c886b42 (synced with current develop at ee996199).

CID integrity — local verification

ipfs add -n -Q --cid-version=1 --raw-leaves=false on the committed files reproduces the manifest CIDs exactly:

$ ipfs add -n -Q --cid-version=1 --raw-leaves=false cache_model_0/abis/DINTaskCoordinator.json
bafybeie4fki5rhunywzk5rybd6cfrqf4oce4u6xyzgq3uyxobsmlml43hi   ✓

$ ipfs add -n -Q --cid-version=1 --raw-leaves=false cache_model_0/abis/DINTaskAuditor.json
bafybeic5e3e4b5ydtoicquggczta2ywxwoir4j53mutprfji5w4bjuzpj4   ✓

Pin confirmations — local IPFS node

Both files were added (and thereby pinned) to the local kubo node (v0.42.0):

$ ipfs add -Q --cid-version=1 --raw-leaves=false cache_model_0/abis/DINTaskCoordinator.json
bafybeie4fki5rhunywzk5rybd6cfrqf4oce4u6xyzgq3uyxobsmlml43hi

$ ipfs add -Q --cid-version=1 --raw-leaves=false cache_model_0/abis/DINTaskAuditor.json
bafybeic5e3e4b5ydtoicquggczta2ywxwoir4j53mutprfji5w4bjuzpj4

Fresh ensure_file_exists retrieval — empty cache, env provider → local IPFS API

With IPFS_API_URL_RETRIEVE=http://127.0.0.1:5001/api/v0 (env provider, local kubo node) and an empty temp directory (no CID store, no pre-existing file), ensure_file_exists retrieved both artifacts cleanly:

--- DINTaskCoordinator retrieval (empty cache, local IPFS API) ---
📥 Retrieving DINTaskCoordinator ABI from IPFS with CID:
    bafybeie4fki5rhunywzk5rybd6cfrqf4oce4u6xyzgq3uyxobsmlml43hi
INFO  Retrieved to: .../abis/DINTaskCoordinator.json
✓ DINTaskCoordinator ABI ready
  OK: 104000 bytes, 202 ABI entries

--- DINTaskAuditor retrieval (empty cache, local IPFS API) ---
📥 Retrieving DINTaskAuditor ABI from IPFS with CID:
    bafybeic5e3e4b5ydtoicquggczta2ywxwoir4j53mutprfji5w4bjuzpj4
INFO  Retrieved to: .../abis/DINTaskAuditor.json
✓ DINTaskAuditor ABI ready
  OK: 99766 bytes, 155 ABI entries

Both files land at the exact byte sizes from the committed files (104 000 B / 99 766 B) with 202 / 155 ABI entries respectively. The CID-verification path in _verify_downloaded_cid ran without error.

Sync with develop + fresh CI

Branch merged with upstream develop at ee996199 (PR No. 273 / the GI-states revert). CI triggered at push 4c886b42.

The two pre-existing test_integration_marker failures visible in local runs are caused by a cid package name collision on this machine (the Chinese-ID-card cid 0.1.3 shadows py-cid 0.5.0); they reproduce identically on the current develop branch and are not introduced by this PR. The PR's own tests (427 passing, including test_task_auditor_model_id_guard) are unaffected.

@Santiagocetran Santiagocetran left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Robbert. Rechecked 4c886b4 against the previous review. The model-ID guard and backlog reference are resolved. Your pinning and empty-cache retrieval results provide the requested evidence for both committed CIDs; I’m relying on your reported test results for that verification.

I found no new code blocker. CI run 40480635372 passed, but develop has since advanced to 6874a60. Please sync and obtain fresh CI before final approval.

One process clarification: this relies on author-run IPFS evidence rather than a separate reviewer run. @umeradl, is that sufficient under §4.2 for this PR?

@robertocarlous

robertocarlous commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator Author

Thanks, Santiago. Addressing both outstanding items from your last review:

Sync with develop

8dd63112 is a merge of 6874a607 (the develop tip you named) directly into the PR branch — the sync was already in place before your comment landed. The branch has been up to date with upstream develop since that push.

Fresh CI

CI run 40547698927 passed on 8dd63112 — all four checks green (Docs, Python, Solidity, CI OK).

Copy link
Copy Markdown
Collaborator

Thanks, Robbert. The previous fixes and IPFS verification are addressed. Once this is synced with the latest develop, the conflicts are resolved and CI passes, it should be ready to merge, provided the sync introduces no new issues. Thanks for the work!

BL-23: adopt develop's ✅ Fixed — PR No. 263 (already merged)
BL-24: adopt develop's 🟡 Partially addressed (Track A experimental
  reclassification landed on develop)
BL-25: keep PR branch's ✅ Fixed — PR No. 261 (this PR fixes it)
BL-26: adopt develop's version (issue No. 243 / PR No. 253 references)
BL-27: mark ✅ Fixed — PR No. 261 (this PR adds --model-id to both
  constructors, fixing the pre-foundry ABI encoding failure)
BL-28: adopt develop's version (task-plan reference, "not in PR No. 261" note)
@robertocarlous

robertocarlous commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator Author

@Santiagocetran

Synced with the current develop and resolved the Developer/BACK_LOG.md conflict in 698c216e. Resolution row-by-row:

  • BL-23: adopted develop's ✅ Fixed — PR No. 263 (already merged before this sync)
  • BL-24: adopted develop's 🟡 Partially addressed (Track A experimental reclassification landed on develop)
  • BL-25: kept PR branch's ✅ Fixed — PR No. 261 (this PR fixes it)
  • BL-26: adopted develop's version (issue No. 243 / PR No. 253 references)
  • BL-27: marked ✅ Fixed — PR No. 261 (this PR adds --model-id to both constructors, confirmed in dincli/cli/modelownerd/deploy.py diff)
  • BL-28: adopted develop's version (task-plan reference and "not in PR No. 261" note)

Branch is now MERGEABLE — CI running on 698c216e.

Copy link
Copy Markdown
Collaborator

Thanks, Robbert, and sorry we didn’t get this merged before develop moved again. I checked the sync and found no new issues, but the branch is now behind develop again. Could you sync it once more and let CI run?

We’re working on implementing the merge queue to avoid this repeated sync-and-review cycle. The CI trigger has landed; enabling the queue is the next step. Once this sync is green and introduces no new issues, it should be ready to merge. Thanks for your patience!

@Santiagocetran Santiagocetran left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Robbert! Rechecked 698c216 and the sync resolution. The constructor arguments, model-ID mismatch guard, regression coverage, manifest metadata and backlog references address the previous findings. Both artifact ABIs match the current bundled ABIs. The pinning and empty-cache retrieval evidence was supplied and accepted in the earlier follow-up; I am relying on those author-run IPFS results, not claiming a new independent IPFS or live-chain run. No new blocking findings. All four PR checks passed in CI run 41192823519, and the trial merge into develop at 8f291c1 is clean. This approval supersedes my earlier changes-requested verdict. Ready for the merge queue to validate against current develop.

Copy link
Copy Markdown
Collaborator

Thanks, Robbert, for the fixes and your patience with the repeated syncs! I’ve approved PR No. 261 at 698c216, superseding my earlier changes-requested review. The previous findings are addressed, all PR checks are green, and the merge with current develop is clean. Ready for the merge queue—no further sync is needed just because develop has advanced; queue CI will validate the combined result.

@Santiagocetran
Santiagocetran added this pull request to the merge queue Nov 2, 2026
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.

BL-25: cache_model_0/abis/ task-contract artifacts are stale vs. foundry/src (missing 67/96 ABI entries)

2 participants