Skip to content

fix(tutorials): make ACL usage examples compile - #34

Open
memosr wants to merge 1 commit into
FhenixProtocol:masterfrom
memosr:fix/acl-examples-solidity-compile
Open

fix(tutorials): make ACL usage examples compile#34
memosr wants to merge 1 commit into
FhenixProtocol:masterfrom
memosr:fix/acl-examples-solidity-compile

Conversation

@memosr

@memosr memosr commented Aug 8, 2026

Copy link
Copy Markdown

Problem

All 7 Solidity snippets in tutorials/acl-usage-examples.mdx fail to compile.

Verified against solc 0.8.28 with the real @fhenixprotocol/cofhe-contracts@0.1.4 package. I extracted each code block from the .mdx programmatically (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.sol imports, 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)private before the type

8 | 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 specifier

9 | function doAdd(InEuint32 input1, InEuint32 input2) {
| ^ No visibility specified. Did you intend to add "public"?

Required since Solidity 0.5.

TypeError (6651) — missing data location

9 | function doAdd(InEuint32 input1, InEuint32 input2) {
| ^^^^^^^^^^^^^^^^
Data location must be "memory" or "calldata" for parameter in function, but none was given.

InEuint32 is a struct (ICofhe.sol:32), and the library's own signature is asEuint32(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 variable on the result line, which looks intentional since that snippet is teaching that the value does not persist. Left alone.

Scope

Syntax only. The documented API surface is correctallowThis, allow, allowTransient, allowPublic and allowSender all exist in cofhe-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, publicValue and an onlyOwner modifier 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 use allowPublic and allowSender.

Happy to adjust anything here.

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.
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