Skip to content

fix(mock-contracts): revert extra inputs with the TaskManager's InvalidOperationInputs - #487

Open
olric3015 wants to merge 1 commit into
FhenixProtocol:masterfrom
olric3015:fix/mock-extra-inputs
Open

olric3015 wants to merge 1 commit into
FhenixProtocol:masterfrom
olric3015:fix/mock-extra-inputs

Conversation

@olric3015

@olric3015 olric3015 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #481, on the same createTask path. MockTaskManager.createTask only checked extra (plaintext) inputs for trivial encrypt and cast. Any other operation given extra inputs got through validation and then reverted later, in the mock's own evaluation, with the mock-only InvalidThreeInputOperation / InvalidTwoInputOperation. The real TaskManager rejects it up front with InvalidOperationInputs(<op>) (validateExtraInputs, cofhe-contracts v1.0.2 TaskManager.sol:649-663, called at :719-721 only when extraInputs.length > 0).

Impact

Low and narrow: FHE.sol only passes extra inputs to trivial encrypt and cast, so this is reached only by calling the TaskManager's createTask directly. In that case a test written against the mock saw an error selector that does not exist on chain, e.g. add with one extra input: mock InvalidThreeInputOperation("add"), TaskManager InvalidOperationInputs("add").

Fix

Adds validateExtraInputs to MockTaskManager, with the same shape as the TaskManager's: trivial encrypt → the existing validateTrivialEncryptInputs, cast → UnsupportedType for an unknown target type (unchanged from #481), anything else → InvalidOperationInputs(<op>). Like the TaskManager, it runs only when there are extra inputs. Calls without extra inputs, and every call FHE.sol makes, behave as before.

Test plan

  • New packages/foundry-plugin/test/MockExtraInputs.t.sol: add and not with an extra input revert with InvalidOperationInputs; cast with a target type and add without extra inputs still work
  • Mutation-verified: removing the InvalidOperationInputs branch makes only the two revert tests fail (InvalidThreeInputOperation("add") != InvalidOperationInputs("add"), InvalidTwoInputOperation("not") != InvalidOperationInputs("not")); the other 2 tests here and the 9 in fix(mock-contracts): reject the types the TaskManager rejects #481's MockUnsupportedType.t.sol still pass; restored → pass
  • forge test in packages/foundry-plugin (132 passed) and packages/mock-contracts (8 passed), Foundry 1.7.1 as in CI
  • prettier --check on the changeset
  • Changeset added (@cofhe/mock-contracts: patch)

Competitor check

Searched extraInputs, InvalidOperationInputs, validateExtraInputs, extra inputs, createTask mock in PRs and issues: only the merged #403 and #481 touch this path; no open PR or issue covers it. Open #463 changes createRandomTask, not createTask.


Note

Low Risk
Narrow mock validation parity fix on a path FHE.sol does not use; normal mock tests and cast/trivialEncrypt behavior stay the same.

Overview
Aligns MockTaskManager.createTask with the on-chain TaskManager when callers pass plaintext extra inputs for operations that should not accept them.

The mock now runs a new validateExtraInputs step (only when extraInputs.length > 0): trivialEncrypt and cast keep their existing checks; every other op (add, not, etc.) reverts immediately with InvalidOperationInputs(<op>). Before this change, those calls slipped past validation and failed later in mock evaluation with mock-only InvalidTwoInputOperation / InvalidThreeInputOperation, which do not exist on chain.

Adds MockExtraInputs.t.sol to lock in the revert selector and confirm cast and normal calls without extra inputs are unchanged. Patch changeset for @cofhe/mock-contracts.

Reviewed by Cursor Bugbot for commit 6bf86ab. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6bf86ab

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@cofhe/mock-contracts Patch
@cofhe/foundry-plugin Patch
@cofhe/hardhat-3-plugin Patch
@cofhe/hardhat-plugin Patch
@cofhe/site Patch
@cofhe/abi Patch
@cofhe/react Patch
@cofhe/sdk Patch
@cofhe/example-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
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