@cofhe/hardhat-plugin 0.7.1 → 1.0.0-alpha.0
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/CHANGELOG.md +24 -0
- package/README.md +57 -11
- package/dist/index.d.mts +59 -3
- package/dist/index.d.ts +59 -3
- package/dist/index.js +226 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +224 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -6
- package/src/deploy.ts +46 -7
- package/src/gas.ts +227 -0
- package/src/index.ts +75 -20
- package/src/utils.ts +13 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @cofhe/hardhat-plugin Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6f7a4c5: Resolve the Task Manager through the `CoFHEAddressBook` (`@fhenixprotocol/cofhe-contracts@1.0.0`). **Breaking:** `TASK_MANAGER_ADDRESS` is removed from `@cofhe/sdk`. Use `getTaskManagerAddress(publicClient)`, which reads `getTm(TASK_MANAGER_ID)` from the book at `COFHE_ADDRESS_BOOK_ADDRESS` (both exported) and caches the result per chain. If the chain has no book, or the id is unset, it throws `TASK_MANAGER_UNRESOLVED`. `verifyDecryptResult`, the ACL/ACP lookups and `useCofheEnabled` / `useCofheReadDecryptionResults` now resolve the Task Manager this way. `@cofhe/react` adds `useCofheTaskManagerAddress()`.
|
|
8
|
+
|
|
9
|
+
Mocks: a new `MockCoFHEAddressBook` is deployed at FHE.sol's `COFHE_ADDRESS_BOOK`, and `MockTaskManager` moves to `MOCKS_TASK_MANAGER_ADDRESS` (`0x…5000`) and is registered in the book. `MockACL` now stores its Task Manager (`setTaskManager` / `getTaskManagerAddress`) instead of reading a constant, so its `TASK_MANAGER_ADDRESS_()` getter is gone. All three plugins deploy and wire the book. Hardhat 2 exposes `hre.cofhe.mocks.getMockCoFHEAddressBook()`, Hardhat 3 exposes `conn.cofhe.mocks.MockCoFHEAddressBook`, and Foundry exposes `CofheTest.mockAddressBook`. Contracts must be built against `@fhenixprotocol/cofhe-contracts@1.0.0` or later (the hardhat plugin's peer range is now `>=1.0.0`). Each FHE op now makes one extra `getTm` call on the book, as it does on real networks, so expect slightly higher gas numbers.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 38c34cd: The Hardhat 2 mock deployment now sets the same security zone range (`0..1`) on the mock TaskManager that the Hardhat 3 plugin uses, so inputs for security zone 1 no longer fail in Hardhat 2 mock tests.
|
|
14
|
+
- 9f76f2b: Defining your own `networks.localcofhe` no longer skips the rest of the plugin's config setup. The Sepolia presets and `config.cofhe` are still applied, matching `@cofhe/hardhat-3-plugin`; previously reading `hre.config.cofhe` would crash.
|
|
15
|
+
- b648307: `mock_getPlaintext`, `mock_getPlaintextExists` and `mock_expectPlaintext` now skip on non-mock networks as intended. The check compared `getCode`'s result to an empty string, but `eth_getCode` returns `"0x"` for an empty address, so on a real network these helpers called into the TaskManager and failed with an opaque error. It now matches `@cofhe/hardhat-3-plugin`.
|
|
16
|
+
- ccb7b68: Realistic gas reporting for mocks. Under Foundry, mock-only work is now excluded from gas metering by default (opt out with `mockTaskManager.setMockGasExcluded(false)`), so expect `forge snapshot` numbers to drop. Under Hardhat, mock transactions emit `MockGasConsumed` events (extra receipt logs), and the plugins add `getAdjustedGasUsed(receipt)` / `getAdjustedGasBreakdown(receipt)` plus an opt-in `cofhe.gasSummary` report.
|
|
17
|
+
- Updated dependencies [17ff23e]
|
|
18
|
+
- Updated dependencies [0fe40c3]
|
|
19
|
+
- Updated dependencies [6f7a4c5]
|
|
20
|
+
- Updated dependencies [552d118]
|
|
21
|
+
- Updated dependencies [22eebcc]
|
|
22
|
+
- Updated dependencies [ccb7b68]
|
|
23
|
+
- Updated dependencies [42fccae]
|
|
24
|
+
- @cofhe/sdk@0.8.0
|
|
25
|
+
- @cofhe/mock-contracts@0.8.0
|
|
26
|
+
|
|
3
27
|
## 0.7.1
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -25,7 +25,9 @@ import '@cofhe/hardhat-plugin';
|
|
|
25
25
|
module.exports = {
|
|
26
26
|
// ... other config
|
|
27
27
|
cofhe: {
|
|
28
|
-
logMocks: true, // Optional:
|
|
28
|
+
logMocks: true, // Optional: Log mock FHE operations to the console (default: false)
|
|
29
|
+
gasSummary: true, // Optional: Print a per-method adjusted-gas summary after tests (default: false)
|
|
30
|
+
gasWarning: false, // Optional: Warn that mock gas differs from live FHE (default: false)
|
|
29
31
|
},
|
|
30
32
|
// Network configuration is automatically added by the plugin
|
|
31
33
|
};
|
|
@@ -45,6 +47,7 @@ This plugin uses [@cofhe/mock-contracts](https://github.com/FhenixProtocol/cofhe
|
|
|
45
47
|
|
|
46
48
|
The mock contracts include:
|
|
47
49
|
|
|
50
|
+
- MockCoFHEAddressBook: Resolves the TaskManager for FHE.sol, deployed at FHE.sol's `COFHE_ADDRESS_BOOK`
|
|
48
51
|
- MockTaskManager: Manages FHE operations and stores plaintext values
|
|
49
52
|
- MockThresholdNetwork: Handles decryption requests
|
|
50
53
|
- MockZkVerifier: Simulates verification of encrypted inputs
|
|
@@ -57,6 +60,44 @@ Key differences from the real CoFHE system:
|
|
|
57
60
|
- Decryption operations are simulated with mock delays
|
|
58
61
|
- Operations are logged using hardhat/console.sol
|
|
59
62
|
|
|
63
|
+
### Gas Reporting
|
|
64
|
+
|
|
65
|
+
The on-chain replication of off-chain FHE work makes mock transactions consume more gas than they would on a real CoFHE network. The mock task manager measures this overhead and emits a `MockGasConsumed(uint256)` event for every block of mock-only work, so the plugin can report corrected numbers:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
const tx = await myContract.doFheThings();
|
|
69
|
+
const receipt = await tx.wait();
|
|
70
|
+
|
|
71
|
+
// Gas usage excluding mock overhead — an estimate of real-network cost.
|
|
72
|
+
const adjusted = hre.cofhe.getAdjustedGasUsed(receipt);
|
|
73
|
+
|
|
74
|
+
// Or the full breakdown:
|
|
75
|
+
const { gasUsed, mockGas, adjustedGasUsed, mockGasEvents } = hre.cofhe.getAdjustedGasBreakdown(receipt);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Both are pure functions of the receipt (no RPC calls). On a real network the receipt carries no mock events, so `adjustedGasUsed` equals `gasUsed` — the same code works everywhere.
|
|
79
|
+
|
|
80
|
+
To get a per-method overview after every test run, enable the summary table in your config:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
cofhe: {
|
|
84
|
+
gasSummary: true,
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
[COFHE-MOCKS] Gas summary — adjusted ≈ cost excluding mock-only overhead
|
|
90
|
+
┌──────────────────┬──────────────────────────┬───────┬─────────────────┬────────────────────┬───────────────┐
|
|
91
|
+
│ Contract │ Method │ Calls │ Avg gas (mocks) │ Avg gas (adjusted) │ Mock overhead │
|
|
92
|
+
├──────────────────┼──────────────────────────┼───────┼─────────────────┼────────────────────┼───────────────┤
|
|
93
|
+
│ MyFHEContract │ storeEncrypted(uint256) │ 11 │ 179,897 │ 141,482 │ 21% │
|
|
94
|
+
└──────────────────┴──────────────────────────┴───────┴─────────────────┴────────────────────┴───────────────┘
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Note: `eth_estimateGas` is not adjusted — the mock work really does execute, so transactions still need the raw gas limit. Use a testnet for estimate-sensitive flows.
|
|
98
|
+
|
|
99
|
+
The summary table is reconstructed from chain history after the run: transactions rolled back by `loadFixture` or `evm_snapshot`/`evm_revert` won't appear, and the table is best-effort after forced exits — use `getAdjustedGasUsed(receipt)` inside tests for exact per-transaction numbers.
|
|
100
|
+
|
|
60
101
|
### Mock Contracts Deployment
|
|
61
102
|
|
|
62
103
|
Core mock contracts are automatically deployed when using the Hardhat network:
|
|
@@ -96,22 +137,27 @@ import { mock_expectPlaintext } from '@cofhe/hardhat-plugin';
|
|
|
96
137
|
await mock_expectPlaintext(provider, ctHash, expectedValue);
|
|
97
138
|
```
|
|
98
139
|
|
|
99
|
-
####
|
|
140
|
+
#### Creating a Client
|
|
100
141
|
|
|
101
142
|
```typescript
|
|
102
|
-
//
|
|
103
|
-
|
|
104
|
-
const
|
|
143
|
+
// One call: config, client, connected signer, and a self ACP
|
|
144
|
+
const [signer] = await hre.ethers.getSigners();
|
|
145
|
+
const client = await hre.cofhe.createClientWithBatteries(signer);
|
|
146
|
+
```
|
|
105
147
|
|
|
106
|
-
|
|
107
|
-
import { isPermittedCofheEnvironment } from '@cofhe/hardhat-plugin';
|
|
108
|
-
const isPermitted = isPermittedCofheEnvironment(hre, environmentName);
|
|
148
|
+
Or step by step, to customize the config:
|
|
109
149
|
|
|
110
|
-
|
|
111
|
-
import {
|
|
112
|
-
|
|
150
|
+
```typescript
|
|
151
|
+
import { hardhat } from '@cofhe/sdk/chains';
|
|
152
|
+
|
|
153
|
+
const [signer] = await hre.ethers.getSigners();
|
|
154
|
+
const config = await hre.cofhe.createConfig({ supportedChains: [hardhat] });
|
|
155
|
+
const client = hre.cofhe.createClient(config);
|
|
156
|
+
await hre.cofhe.connectWithHardhatSigner(client, signer);
|
|
113
157
|
```
|
|
114
158
|
|
|
159
|
+
Use `hre.cofhe.createConfig` rather than `createCofheConfig` from `@cofhe/sdk/node`: it sets the Hardhat environment and wires up the mock ZK verifier signer.
|
|
160
|
+
|
|
115
161
|
## Usage in Tests
|
|
116
162
|
|
|
117
163
|
The plugin automatically deploys mock contracts when running tests:
|
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { PublicClient, WalletClient } from 'viem';
|
|
|
2
2
|
import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers';
|
|
3
3
|
import { CofheInputConfig, CofheConfig, CofheClient } from '@cofhe/sdk';
|
|
4
4
|
import { HardhatRuntimeEnvironment } from 'hardhat/types';
|
|
5
|
-
import { MockArtifact, MockTaskManager, MockACL, MockThresholdNetwork, MockZkVerifier } from '@cofhe/mock-contracts';
|
|
5
|
+
import { MockArtifact, MockCoFHEAddressBook, MockTaskManager, MockACL, MockThresholdNetwork, MockZkVerifier } from '@cofhe/mock-contracts';
|
|
6
6
|
import * as ethers from 'ethers';
|
|
7
7
|
import { Contract, ethers as ethers$1 } from 'ethers';
|
|
8
8
|
import { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';
|
|
@@ -20,11 +20,34 @@ type DeployMocksArgs = {
|
|
|
20
20
|
};
|
|
21
21
|
declare const deployMocks: (hre: HardhatRuntimeEnvironment, options?: DeployMocksArgs) => Promise<void>;
|
|
22
22
|
|
|
23
|
+
declare const MOCK_GAS_CONSUMED_TOPIC: string;
|
|
24
|
+
type AdjustableGasReceipt = {
|
|
25
|
+
gasUsed: bigint | number | string;
|
|
26
|
+
logs?: ReadonlyArray<{
|
|
27
|
+
address: string;
|
|
28
|
+
topics: ReadonlyArray<string>;
|
|
29
|
+
data: string;
|
|
30
|
+
}>;
|
|
31
|
+
};
|
|
32
|
+
type AdjustedGasBreakdown = {
|
|
33
|
+
/** Raw gas used by the transaction (includes mock overhead). */
|
|
34
|
+
gasUsed: bigint;
|
|
35
|
+
/** Gas consumed by mock-only work (FHE op replication, decrypt-task storage, mock logging). */
|
|
36
|
+
mockGas: bigint;
|
|
37
|
+
/** gasUsed - mockGas: an estimate of what the transaction would cost on a real CoFHE network. */
|
|
38
|
+
adjustedGasUsed: bigint;
|
|
39
|
+
/** Number of MockGasConsumed events - roughly the number of mock-only blocks executed. */
|
|
40
|
+
mockGasEvents: number;
|
|
41
|
+
};
|
|
42
|
+
declare const mock_getAdjustedGasBreakdown: (receipt: AdjustableGasReceipt) => AdjustedGasBreakdown;
|
|
43
|
+
declare const mock_getAdjustedGasUsed: (receipt: AdjustableGasReceipt) => bigint;
|
|
44
|
+
declare const printMockGasSummary: (hre: HardhatRuntimeEnvironment) => Promise<void>;
|
|
45
|
+
|
|
23
46
|
declare const TASK_COFHE_USE_FAUCET = "task:cofhe:usefaucet";
|
|
24
47
|
declare const TASK_COFHE_MOCKS_SET_LOG_OPS = "task:cofhe-mocks:setlogops";
|
|
25
48
|
declare const TASK_COFHE_MOCKS_DEPLOY = "task:cofhe-mocks:deploy";
|
|
26
49
|
|
|
27
|
-
declare const deployMockContractFromArtifact: (hre: HardhatRuntimeEnvironment, artifact: MockArtifact) => Promise<Contract>;
|
|
50
|
+
declare const deployMockContractFromArtifact: (hre: HardhatRuntimeEnvironment, artifact: MockArtifact, constructorArgs?: readonly unknown[]) => Promise<Contract>;
|
|
28
51
|
declare const getFixedMockContract: (hre: HardhatRuntimeEnvironment, artifact: MockArtifact) => Promise<Contract>;
|
|
29
52
|
declare const mock_getPlaintext: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint | string) => Promise<any>;
|
|
30
53
|
declare const mock_getPlaintextExists: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint | string) => Promise<any>;
|
|
@@ -60,6 +83,14 @@ declare module 'hardhat/types/config' {
|
|
|
60
83
|
logMocks?: boolean;
|
|
61
84
|
/** Whether to show gas usage warnings for mock operations (default: true) */
|
|
62
85
|
gasWarning?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Print a per-method gas summary after `hardhat test`, showing raw gas next to
|
|
88
|
+
* adjusted gas (mock-only overhead excluded - an estimate of real-network cost).
|
|
89
|
+
* Reconstructed from chain history: transactions rolled back by loadFixture /
|
|
90
|
+
* evm_revert won't appear - use getAdjustedGasUsed(receipt) for exact numbers.
|
|
91
|
+
* (default: false)
|
|
92
|
+
*/
|
|
93
|
+
gasSummary?: boolean;
|
|
63
94
|
/**
|
|
64
95
|
* Controls deploy-mocks console output.
|
|
65
96
|
* - `''` — silent, no output
|
|
@@ -75,6 +106,8 @@ declare module 'hardhat/types/config' {
|
|
|
75
106
|
logMocks: boolean;
|
|
76
107
|
/** Whether to show gas usage warnings for mock operations (default: true) */
|
|
77
108
|
gasWarning: boolean;
|
|
109
|
+
/** Print a per-method adjusted-gas summary after `hardhat test` (default: false) */
|
|
110
|
+
gasSummary: boolean;
|
|
78
111
|
mocksDeployVerbosity: LogMocksDeploy;
|
|
79
112
|
};
|
|
80
113
|
}
|
|
@@ -123,6 +156,24 @@ declare module 'hardhat/types/runtime' {
|
|
|
123
156
|
* @returns {Promise<CofheClient>} The CoFHE client instance
|
|
124
157
|
*/
|
|
125
158
|
createClientWithBatteries: (signer?: HardhatEthersSigner) => Promise<CofheClient>;
|
|
159
|
+
/**
|
|
160
|
+
* Returns a transaction's gas usage excluding mock-only overhead (FHE op replication,
|
|
161
|
+
* decrypt-task storage, mock logging) - an estimate of what the transaction would cost
|
|
162
|
+
* on a real CoFHE network. Pure function of the receipt (sums the mock task manager's
|
|
163
|
+
* MockGasConsumed events from `receipt.logs`); on a real network the receipt carries no
|
|
164
|
+
* such events and the raw `gasUsed` is returned unchanged.
|
|
165
|
+
* @param {AdjustableGasReceipt} receipt - The transaction receipt (ethers or viem shape)
|
|
166
|
+
* @returns {bigint} gasUsed minus mock overhead
|
|
167
|
+
*/
|
|
168
|
+
getAdjustedGasUsed: (receipt: AdjustableGasReceipt) => bigint;
|
|
169
|
+
/**
|
|
170
|
+
* Full gas breakdown of a transaction receipt: raw `gasUsed`, the mock-only `mockGas`,
|
|
171
|
+
* the `adjustedGasUsed` (raw minus mock), and the number of mock gas events.
|
|
172
|
+
* See getAdjustedGasUsed.
|
|
173
|
+
* @param {AdjustableGasReceipt} receipt - The transaction receipt (ethers or viem shape)
|
|
174
|
+
* @returns {AdjustedGasBreakdown} The breakdown
|
|
175
|
+
*/
|
|
176
|
+
getAdjustedGasBreakdown: (receipt: AdjustableGasReceipt) => AdjustedGasBreakdown;
|
|
126
177
|
mocks: {
|
|
127
178
|
/**
|
|
128
179
|
* **[MOCKS ONLY]**
|
|
@@ -189,6 +240,11 @@ declare module 'hardhat/types/runtime' {
|
|
|
189
240
|
* @param {bigint} expectedValue - The expected plaintext value
|
|
190
241
|
*/
|
|
191
242
|
expectPlaintext: (ctHash: bigint | string, expectedValue: bigint) => Promise<void>;
|
|
243
|
+
/**
|
|
244
|
+
* Get the MockCoFHEAddressBook contract (typed via typechain)
|
|
245
|
+
* @returns {Promise<MockCoFHEAddressBook>} The MockCoFHEAddressBook contract
|
|
246
|
+
*/
|
|
247
|
+
getMockCoFHEAddressBook: () => Promise<MockCoFHEAddressBook>;
|
|
192
248
|
/**
|
|
193
249
|
* Get the MockTaskManager contract (typed via typechain)
|
|
194
250
|
* @returns {Promise<MockTaskManager>} The MockTaskManager contract
|
|
@@ -220,4 +276,4 @@ declare module 'hardhat/types/runtime' {
|
|
|
220
276
|
*/
|
|
221
277
|
declare function buildHardhatPluginMocksConfig(mocksConfig: CofheInputConfig['mocks']): NonNullable<CofheInputConfig['mocks']>;
|
|
222
278
|
|
|
223
|
-
export { type DeployMocksArgs, type LogMocksDeploy, TASK_COFHE_MOCKS_DEPLOY, TASK_COFHE_MOCKS_SET_LOG_OPS, TASK_COFHE_USE_FAUCET, buildHardhatPluginMocksConfig, deployMockContractFromArtifact, deployMocks, getFixedMockContract, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getPlaintext, mock_getPlaintextExists, mock_setLoggingEnabled, mock_withLogs };
|
|
279
|
+
export { type AdjustableGasReceipt, type AdjustedGasBreakdown, type DeployMocksArgs, type LogMocksDeploy, MOCK_GAS_CONSUMED_TOPIC, TASK_COFHE_MOCKS_DEPLOY, TASK_COFHE_MOCKS_SET_LOG_OPS, TASK_COFHE_USE_FAUCET, buildHardhatPluginMocksConfig, deployMockContractFromArtifact, deployMocks, getFixedMockContract, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getAdjustedGasBreakdown, mock_getAdjustedGasUsed, mock_getPlaintext, mock_getPlaintextExists, mock_setLoggingEnabled, mock_withLogs, printMockGasSummary };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { PublicClient, WalletClient } from 'viem';
|
|
|
2
2
|
import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers';
|
|
3
3
|
import { CofheInputConfig, CofheConfig, CofheClient } from '@cofhe/sdk';
|
|
4
4
|
import { HardhatRuntimeEnvironment } from 'hardhat/types';
|
|
5
|
-
import { MockArtifact, MockTaskManager, MockACL, MockThresholdNetwork, MockZkVerifier } from '@cofhe/mock-contracts';
|
|
5
|
+
import { MockArtifact, MockCoFHEAddressBook, MockTaskManager, MockACL, MockThresholdNetwork, MockZkVerifier } from '@cofhe/mock-contracts';
|
|
6
6
|
import * as ethers from 'ethers';
|
|
7
7
|
import { Contract, ethers as ethers$1 } from 'ethers';
|
|
8
8
|
import { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';
|
|
@@ -20,11 +20,34 @@ type DeployMocksArgs = {
|
|
|
20
20
|
};
|
|
21
21
|
declare const deployMocks: (hre: HardhatRuntimeEnvironment, options?: DeployMocksArgs) => Promise<void>;
|
|
22
22
|
|
|
23
|
+
declare const MOCK_GAS_CONSUMED_TOPIC: string;
|
|
24
|
+
type AdjustableGasReceipt = {
|
|
25
|
+
gasUsed: bigint | number | string;
|
|
26
|
+
logs?: ReadonlyArray<{
|
|
27
|
+
address: string;
|
|
28
|
+
topics: ReadonlyArray<string>;
|
|
29
|
+
data: string;
|
|
30
|
+
}>;
|
|
31
|
+
};
|
|
32
|
+
type AdjustedGasBreakdown = {
|
|
33
|
+
/** Raw gas used by the transaction (includes mock overhead). */
|
|
34
|
+
gasUsed: bigint;
|
|
35
|
+
/** Gas consumed by mock-only work (FHE op replication, decrypt-task storage, mock logging). */
|
|
36
|
+
mockGas: bigint;
|
|
37
|
+
/** gasUsed - mockGas: an estimate of what the transaction would cost on a real CoFHE network. */
|
|
38
|
+
adjustedGasUsed: bigint;
|
|
39
|
+
/** Number of MockGasConsumed events - roughly the number of mock-only blocks executed. */
|
|
40
|
+
mockGasEvents: number;
|
|
41
|
+
};
|
|
42
|
+
declare const mock_getAdjustedGasBreakdown: (receipt: AdjustableGasReceipt) => AdjustedGasBreakdown;
|
|
43
|
+
declare const mock_getAdjustedGasUsed: (receipt: AdjustableGasReceipt) => bigint;
|
|
44
|
+
declare const printMockGasSummary: (hre: HardhatRuntimeEnvironment) => Promise<void>;
|
|
45
|
+
|
|
23
46
|
declare const TASK_COFHE_USE_FAUCET = "task:cofhe:usefaucet";
|
|
24
47
|
declare const TASK_COFHE_MOCKS_SET_LOG_OPS = "task:cofhe-mocks:setlogops";
|
|
25
48
|
declare const TASK_COFHE_MOCKS_DEPLOY = "task:cofhe-mocks:deploy";
|
|
26
49
|
|
|
27
|
-
declare const deployMockContractFromArtifact: (hre: HardhatRuntimeEnvironment, artifact: MockArtifact) => Promise<Contract>;
|
|
50
|
+
declare const deployMockContractFromArtifact: (hre: HardhatRuntimeEnvironment, artifact: MockArtifact, constructorArgs?: readonly unknown[]) => Promise<Contract>;
|
|
28
51
|
declare const getFixedMockContract: (hre: HardhatRuntimeEnvironment, artifact: MockArtifact) => Promise<Contract>;
|
|
29
52
|
declare const mock_getPlaintext: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint | string) => Promise<any>;
|
|
30
53
|
declare const mock_getPlaintextExists: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint | string) => Promise<any>;
|
|
@@ -60,6 +83,14 @@ declare module 'hardhat/types/config' {
|
|
|
60
83
|
logMocks?: boolean;
|
|
61
84
|
/** Whether to show gas usage warnings for mock operations (default: true) */
|
|
62
85
|
gasWarning?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Print a per-method gas summary after `hardhat test`, showing raw gas next to
|
|
88
|
+
* adjusted gas (mock-only overhead excluded - an estimate of real-network cost).
|
|
89
|
+
* Reconstructed from chain history: transactions rolled back by loadFixture /
|
|
90
|
+
* evm_revert won't appear - use getAdjustedGasUsed(receipt) for exact numbers.
|
|
91
|
+
* (default: false)
|
|
92
|
+
*/
|
|
93
|
+
gasSummary?: boolean;
|
|
63
94
|
/**
|
|
64
95
|
* Controls deploy-mocks console output.
|
|
65
96
|
* - `''` — silent, no output
|
|
@@ -75,6 +106,8 @@ declare module 'hardhat/types/config' {
|
|
|
75
106
|
logMocks: boolean;
|
|
76
107
|
/** Whether to show gas usage warnings for mock operations (default: true) */
|
|
77
108
|
gasWarning: boolean;
|
|
109
|
+
/** Print a per-method adjusted-gas summary after `hardhat test` (default: false) */
|
|
110
|
+
gasSummary: boolean;
|
|
78
111
|
mocksDeployVerbosity: LogMocksDeploy;
|
|
79
112
|
};
|
|
80
113
|
}
|
|
@@ -123,6 +156,24 @@ declare module 'hardhat/types/runtime' {
|
|
|
123
156
|
* @returns {Promise<CofheClient>} The CoFHE client instance
|
|
124
157
|
*/
|
|
125
158
|
createClientWithBatteries: (signer?: HardhatEthersSigner) => Promise<CofheClient>;
|
|
159
|
+
/**
|
|
160
|
+
* Returns a transaction's gas usage excluding mock-only overhead (FHE op replication,
|
|
161
|
+
* decrypt-task storage, mock logging) - an estimate of what the transaction would cost
|
|
162
|
+
* on a real CoFHE network. Pure function of the receipt (sums the mock task manager's
|
|
163
|
+
* MockGasConsumed events from `receipt.logs`); on a real network the receipt carries no
|
|
164
|
+
* such events and the raw `gasUsed` is returned unchanged.
|
|
165
|
+
* @param {AdjustableGasReceipt} receipt - The transaction receipt (ethers or viem shape)
|
|
166
|
+
* @returns {bigint} gasUsed minus mock overhead
|
|
167
|
+
*/
|
|
168
|
+
getAdjustedGasUsed: (receipt: AdjustableGasReceipt) => bigint;
|
|
169
|
+
/**
|
|
170
|
+
* Full gas breakdown of a transaction receipt: raw `gasUsed`, the mock-only `mockGas`,
|
|
171
|
+
* the `adjustedGasUsed` (raw minus mock), and the number of mock gas events.
|
|
172
|
+
* See getAdjustedGasUsed.
|
|
173
|
+
* @param {AdjustableGasReceipt} receipt - The transaction receipt (ethers or viem shape)
|
|
174
|
+
* @returns {AdjustedGasBreakdown} The breakdown
|
|
175
|
+
*/
|
|
176
|
+
getAdjustedGasBreakdown: (receipt: AdjustableGasReceipt) => AdjustedGasBreakdown;
|
|
126
177
|
mocks: {
|
|
127
178
|
/**
|
|
128
179
|
* **[MOCKS ONLY]**
|
|
@@ -189,6 +240,11 @@ declare module 'hardhat/types/runtime' {
|
|
|
189
240
|
* @param {bigint} expectedValue - The expected plaintext value
|
|
190
241
|
*/
|
|
191
242
|
expectPlaintext: (ctHash: bigint | string, expectedValue: bigint) => Promise<void>;
|
|
243
|
+
/**
|
|
244
|
+
* Get the MockCoFHEAddressBook contract (typed via typechain)
|
|
245
|
+
* @returns {Promise<MockCoFHEAddressBook>} The MockCoFHEAddressBook contract
|
|
246
|
+
*/
|
|
247
|
+
getMockCoFHEAddressBook: () => Promise<MockCoFHEAddressBook>;
|
|
192
248
|
/**
|
|
193
249
|
* Get the MockTaskManager contract (typed via typechain)
|
|
194
250
|
* @returns {Promise<MockTaskManager>} The MockTaskManager contract
|
|
@@ -220,4 +276,4 @@ declare module 'hardhat/types/runtime' {
|
|
|
220
276
|
*/
|
|
221
277
|
declare function buildHardhatPluginMocksConfig(mocksConfig: CofheInputConfig['mocks']): NonNullable<CofheInputConfig['mocks']>;
|
|
222
278
|
|
|
223
|
-
export { type DeployMocksArgs, type LogMocksDeploy, TASK_COFHE_MOCKS_DEPLOY, TASK_COFHE_MOCKS_SET_LOG_OPS, TASK_COFHE_USE_FAUCET, buildHardhatPluginMocksConfig, deployMockContractFromArtifact, deployMocks, getFixedMockContract, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getPlaintext, mock_getPlaintextExists, mock_setLoggingEnabled, mock_withLogs };
|
|
279
|
+
export { type AdjustableGasReceipt, type AdjustedGasBreakdown, type DeployMocksArgs, type LogMocksDeploy, MOCK_GAS_CONSUMED_TOPIC, TASK_COFHE_MOCKS_DEPLOY, TASK_COFHE_MOCKS_SET_LOG_OPS, TASK_COFHE_USE_FAUCET, buildHardhatPluginMocksConfig, deployMockContractFromArtifact, deployMocks, getFixedMockContract, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getAdjustedGasBreakdown, mock_getAdjustedGasUsed, mock_getPlaintext, mock_getPlaintextExists, mock_setLoggingEnabled, mock_withLogs, printMockGasSummary };
|