fix(tutorials): make ACL usage examples compile - #34
Open
memosr wants to merge 1 commit into
Open
Conversation
All 7 Solidity snippets in tutorials/acl-usage-examples.mdx fail to compile with solc 0.8.28 and cofhe-contracts@0.1.4. Three issues: - InEuint32 is a struct (ICofhe.sol), so parameters need an explicit data location (TypeError 6651, 9 occurrences) - Several functions have no visibility specifier (SyntaxError 4937) - Three state variables put private before the type, which is a ParserError (9182) that masked further errors in two blocks The documented API surface itself is correct: allowThis, allow, allowTransient, allowPublic and allowSender all exist in cofhe-contracts@0.1.4. Only the Solidity syntax is fixed here.
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.
Problem
All 7 Solidity snippets in
tutorials/acl-usage-examples.mdxfail to compile.Verified against
solc 0.8.28with the real@fhenixprotocol/cofhe-contracts@0.1.4package. I extracted each code block from the.mdxprogrammatically (not retyped) and compiled it twice:Verbatim, exactly as shown on the page: 7/7 fail.
With a generous harness (SPDX, pragma, real
FHE.sol/ICofhe.solimports, a wrapping contract for bare functions, and the missing state variables the snippets reference): still 7/7 fail.The second pass matters. It rules out "these are just fragments" as the explanation. The displayed lines themselves are the problem.
Three error classes
ParserError (9182)—privatebefore the type8 | private euint32 result;
| ^^^^^^^
Function, variable, struct or modifier declaration expected.
This one aborts parsing, so it was masking further errors in blocks 2 and 3. Fixing just that line surfaced 4 more errors in block 2 and 2 more in block 3.
SyntaxError (4937)— no visibility specifier9 | function doAdd(InEuint32 input1, InEuint32 input2) {
| ^ No visibility specified. Did you intend to add "public"?
Required since Solidity 0.5.
TypeError (6651)— missing data location9 | function doAdd(InEuint32 input1, InEuint32 input2) {
| ^^^^^^^^^^^^^^^^
Data location must be "memory" or "calldata" for parameter in function, but none was given.
InEuint32is a struct (ICofhe.sol:32), and the library's own signature isasEuint32(InEuint32 memory value). All 9 parameters across the page were missing this. It's the single issue that hits every block.Fix
11 lines, one file. After the change, all 7 blocks compile with the same harness:
PASS Block1_AutoTransient.sol errors=0 warnings=1
PASS Block2_PersistentAllowance.sol errors=0 warnings=0
PASS Block3_AllowanceForDecryptions.sol errors=0 warnings=0
PASS Block4_AllowOtherContracts.sol errors=0 warnings=0
PASS Block5_Pattern1_ContractAndUser.sol errors=0 warnings=0
PASS Block6_Pattern2_AllowSender.sol errors=0 warnings=0
PASS Block7_Pattern3_GlobalAccess.sol errors=0 warnings=0
The remaining warning in block 1 is
Unused local variableon theresultline, which looks intentional since that snippet is teaching that the value does not persist. Left alone.Scope
Syntax only. The documented API surface is correct —
allowThis,allow,allowTransient,allowPublicandallowSenderall exist incofhe-contracts@0.1.4(FHE.sol:3010-3319). Nothing about the ACL semantics this page teaches is changed.Deliberately left out, happy to do any of these separately if useful:
The snippets reference
addressB,IContractB,balances,storedData,publicValueand anonlyOwnermodifier that are never declared. Making each block self-contained would mean expanding them, which is a bigger editorial call than a syntax fix.The "Solidity API" list at lines 16-18 mentions
allowThis/allow/allowTransient, but the examples below also useallowPublicandallowSender.Happy to adjust anything here.