@cofhe/foundry-plugin 0.0.0-beta-20260922043643 → 0.0.0-beta-20260922094916
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -7
- package/contracts/CofheTest.sol +5 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -66,17 +66,27 @@ contract MyTest is CofheTest {
|
|
|
66
66
|
}
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
+
## Gas reporting
|
|
70
|
+
|
|
71
|
+
Mock FHE operations replicate the off-chain CoFHE work on-chain, which would normally inflate reported gas 2–3×. Under forge, `deployMocks()` excludes that mock-only work from gas metering by default (via `pauseGasMetering` cheatcodes), so `forge test --gas-report`, `forge snapshot`, and `gasleft()` measurements report numbers close to real-network costs.
|
|
72
|
+
|
|
73
|
+
- Requires forge ≥ 1.0 (older versions had unreliable `pauseGasMetering` behavior). On unsupported setups the shim silently falls back to normal metering — correctness is never affected.
|
|
74
|
+
- Opt out with `mockTaskManager.setMockGasExcluded(false)` to see raw mock gas.
|
|
75
|
+
- When exclusion is off (or on Hardhat), the mock task manager instead emits a `MockGasConsumed(uint256)` event per block of mock-only work, so the overhead remains measurable from receipts.
|
|
76
|
+
|
|
77
|
+
Note: upgrading to a version with this feature will lower existing `forge snapshot` numbers — the drop is the mock overhead disappearing from the report, not a change in your contracts.
|
|
78
|
+
|
|
69
79
|
## API
|
|
70
80
|
|
|
71
81
|
### `CofheTest` (abstract base)
|
|
72
82
|
|
|
73
|
-
| Function | Description
|
|
74
|
-
| -------------------------------- |
|
|
75
|
-
| `deployMocks()` | Deploys all mock contracts and wires them together
|
|
76
|
-
| `createCofheClient()` | Returns a new unconnected `CofheClient`
|
|
77
|
-
| `enableLogs()` / `disableLogs()` | Toggle plaintext operation logging
|
|
78
|
-
| `getPlaintext(ctHash)` | Returns the stored plaintext for a ciphertext handle
|
|
79
|
-
| `expectPlaintext(handle, value)` | Asserts the plaintext of an encrypted handle matches `value`
|
|
83
|
+
| Function | Description |
|
|
84
|
+
| -------------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
85
|
+
| `deployMocks()` | Deploys all mock contracts and wires them together; enables mock-gas exclusion (see Gas reporting) |
|
|
86
|
+
| `createCofheClient()` | Returns a new unconnected `CofheClient` |
|
|
87
|
+
| `enableLogs()` / `disableLogs()` | Toggle plaintext operation logging |
|
|
88
|
+
| `getPlaintext(ctHash)` | Returns the stored plaintext for a ciphertext handle |
|
|
89
|
+
| `expectPlaintext(handle, value)` | Asserts the plaintext of an encrypted handle matches `value` |
|
|
80
90
|
|
|
81
91
|
`getPlaintext` and `expectPlaintext` have typed overloads for `ebool`, `euint8`, `euint16`, `euint32`, `euint64`, `euint128`, and `eaddress`.
|
|
82
92
|
|
package/contracts/CofheTest.sol
CHANGED
|
@@ -47,6 +47,11 @@ abstract contract CofheTest is Test {
|
|
|
47
47
|
mockTaskManager = MockTaskManager(TASK_MANAGER_ADDRESS);
|
|
48
48
|
mockTaskManager.initialize(TM_ADMIN);
|
|
49
49
|
mockTaskManager.setLogOps(false);
|
|
50
|
+
// Exclude mock-only plaintext replication from gas metering so reported gas is closer
|
|
51
|
+
// to the real task manager. Requires cheatcode access, which etched contracts don't
|
|
52
|
+
// inherit from the test contract.
|
|
53
|
+
vm.allowCheatcodes(TASK_MANAGER_ADDRESS);
|
|
54
|
+
mockTaskManager.setMockGasExcluded(true);
|
|
50
55
|
vm.label(address(mockTaskManager), 'MockTaskManager');
|
|
51
56
|
|
|
52
57
|
// 2. ACL (non-fixed deploy so constructor runs and EIP712 domain is set)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cofhe/foundry-plugin",
|
|
3
|
-
"version": "0.0.0-beta-
|
|
3
|
+
"version": "0.0.0-beta-20260922094916",
|
|
4
4
|
"description": "Foundry plugin for CoFHE — Write and test FHE enabled contracts",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@fhenixprotocol/cofhe-contracts": "0.2.0",
|
|
28
28
|
"@openzeppelin/contracts": "5.4.0",
|
|
29
|
-
"@cofhe/mock-contracts": "0.0.0-beta-
|
|
29
|
+
"@cofhe/mock-contracts": "0.0.0-beta-20260922094916"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"forge-std": "github:foundry-rs/forge-std#c0f966cb111f621bfb283b2a388bc7be18953bba",
|