Repository navigation
fix(mock-contracts): reject the types the TaskManager rejects - #481
Merged
alexshchur merged 1 commit intoNov 2, 2026
Merged
Conversation
The TaskManager reverts with UnsupportedType when a task's return type, a trivialEncrypt or cast target type, or a random type is not one of the supported types, and with DecryptFunctionNotSupported when createTask is asked for a decrypt. MockTaskManager accepted the types and returned a handle, and answered a decrypt task with InvalidOperationInputs. Utils.EUINT256_TFHE is still declared in ICofhe.sol, but the TaskManager dropped euint256, so encrypting, casting or generating a random value as that type passed in local tests and reverted on chain. The checks and their order follow TaskManager.createTask, validateTrivialEncryptInputs, validateExtraInputs and createRandomTask in cofhe-contracts 1.0.0 and 1.0.2.
🦋 Changeset detectedLatest commit: d29172a The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
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 |
alexshchur
approved these changes
Nov 2, 2026
alexshchur
left a comment
Contributor
There was a problem hiding this comment.
Thanks @olric3015, nice one. The mock was more forgiving than the real TaskManager, so a contract could pass local tests and still revert on chain. Now they fail the same way. Merging.
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The TaskManager reverts with
UnsupportedTypewhen a type is not one it supports, in four places: a task's return type (createTask), thetrivialEncrypttarget type (validateTrivialEncryptInputs), thecasttarget type (validateExtraInputs) and thecreateRandomTasktype. It reverts withDecryptFunctionNotSupportedwhencreateTaskis asked for a decrypt.MockTaskManagerhad none of the type checks, so it returned a handle, and it answered a decrypt task withInvalidOperationInputs("decrypt").Same family as #403, which added the
trivialEncryptvalue range checks.Impact
Utils.EUINT256_TFHE(8) is still declared inICofhe.sol, but the TaskManager dropped euint256 (cofhe-contracts #31) andisValidTypeno longer accepts it. A contract that callsImpl.trivialEncrypt(x, Utils.EUINT256_TFHE, 0),Impl.cast(h, Utils.EUINT256_TFHE)orImpl.random(Utils.EUINT256_TFHE)passes its Hardhat / Foundry tests and reverts withUnsupportedType(8)once deployed. The typedFHE.asE*/FHE.randomE*helpers only pass supported types, so they are not affected.Fix
UnsupportedType(uint256)andDecryptFunctionNotSupported()with the TaskManager's signatures, and addsisValidTypewith the same seven types.createTask: rejectsdecrypt, then an unsupported return type, before the other checks, asTaskManager.createTaskdoes. Rejects an unsupportedcasttarget type.validateTrivialEncryptInputs: rejects a target type aboveuint8before the security zone check, and an unknown target type instead of returning.createRandomTask: rejects an unsupported type before the security zone check.The checks and their order match TaskManager in cofhe-contracts 1.0.0 (the pinned version) and 1.0.2. Calls with supported types are unchanged. The two errors are added to the checked-in
MockTaskManagerABI (regenerated with the package's build steps; the typechain output does not change).Test plan
MockUnsupportedType.t.sol(9 tests): euint256 viaImpl.trivialEncrypt/Impl.cast/Impl.random, an unknowntrivialEncrypttarget type, a target type aboveuint8together with an out of range zone, an unknowncasttarget type, an unsupported return type, a decrypt task, and all seven supported types still workingtestCreateTaskUnsupportedReturnTypeRevertsfails withnext call did not revert; without the decrypt check,InvalidOperationInputs("decrypt") != DecryptFunctionNotSupported); restored → 9/9 passpnpm --filter @cofhe/mock-contracts test,@cofhe/foundry-plugin(127 tests),@cofhe/hardhat-plugin,@cofhe/hardhat-plugin-test(102 passing),@cofhe/hardhat-3-plugin-test(45 passing), with Foundry 1.7.1 as in CIpnpm check:formatting,check:pinned-deps,check:circles@cofhe/mock-contracts: patch)Competitor check
Searched
UnsupportedType,DecryptFunctionNotSupported,isValidType,euint256,unsupported type,random typeacross open and closed PRs and issues: none adds these checks. #463, #459 and #445 also touchMockTaskManager.sol; none of them changes type validation, and this branch merges cleanly with each.Note
Low Risk
Changes are limited to mock contracts and test fidelity; supported-type behavior is unchanged and production TaskManager code is untouched.
Overview
Aligns
MockTaskManagerwith the real TaskManager so local Foundry/Hardhat tests fail the same way mainnet would, instead of returning ciphertext handles for unsupported operations.The mock now defines
UnsupportedType(uint256)andDecryptFunctionNotSupported(), plusisValidTypefor the seven supported TFHE types (excluding droppedUtils.EUINT256_TFHE).createTaskreverts on decrypt tasks, bad return types, and invalidcasttargets (matching check order on chain).validateTrivialEncryptInputsreverts on target types aboveuint8or unknown types rather than silently succeeding.createRandomTaskrejects unsupported return types before zone checks.Adds
MockUnsupportedType.t.sol(nine tests covering euint256 paths, edge cases, decrypt, and supported types), regenerates the checked-in ABI artifact, and a patch changeset for@cofhe/mock-contracts.Reviewed by Cursor Bugbot for commit d29172a. Bugbot is set up for automated code reviews on this repo. Configure here.