@cofhe/hardhat-3-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 +21 -0
- package/README.md +44 -7
- package/dist/chunk-6G2MCXNM.js +217 -0
- package/dist/{chunk-IVRNGFNF.js → chunk-NYXXHYHW.js} +3 -3
- package/dist/{chunk-E7DR6EGV.js → chunk-W4H6WKGI.js} +50 -17
- package/dist/{config-YK3LB5IH.js → config-VUCAYBHC.js} +1 -0
- package/dist/{hre-CYH6NXPG.js → hre-MFXYQSRM.js} +18 -2
- package/dist/index.d.ts +73 -2
- package/dist/index.js +27 -7
- package/dist/{set-log-ops-GVEQWMZP.js → set-log-ops-2OIBBSDL.js} +1 -1
- package/dist/test-gas-summary-WK6CULNO.js +19 -0
- package/package.json +3 -3
- package/src/config.ts +1 -0
- package/src/deploy.ts +56 -15
- package/src/gas.ts +340 -0
- package/src/hooks/hre.ts +23 -0
- package/src/index.ts +7 -1
- package/src/logging.ts +3 -3
- package/src/tasks/test-gas-summary.ts +22 -0
- package/src/type-extensions.ts +31 -0
- package/src/utils.ts +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { HardhatPlugin } from 'hardhat/types/plugins';
|
|
|
2
2
|
import { PublicClient, WalletClient } from 'viem';
|
|
3
3
|
import { CofheInputConfig, CofheConfig, CofheClient } from '@cofhe/sdk';
|
|
4
4
|
import { ArtifactManager } from 'hardhat/types/artifacts';
|
|
5
|
-
import { MockTaskManagerArtifact, MockACLArtifact, MockZkVerifierArtifact, MockThresholdNetworkArtifact } from '@cofhe/mock-contracts';
|
|
5
|
+
import { MockCoFHEAddressBookArtifact, MockTaskManagerArtifact, MockACLArtifact, MockZkVerifierArtifact, MockThresholdNetworkArtifact } from '@cofhe/mock-contracts';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Controls deploy-mocks console output.
|
|
@@ -13,6 +13,7 @@ import { MockTaskManagerArtifact, MockACLArtifact, MockZkVerifierArtifact, MockT
|
|
|
13
13
|
type LogMocksDeploy = '' | 'v' | 'vv';
|
|
14
14
|
/** Keyed map of deployed mock contract addresses returned by `deployMocks`. */
|
|
15
15
|
type DeployedMockContracts = {
|
|
16
|
+
MockCoFHEAddressBook: `0x${string}`;
|
|
16
17
|
MockTaskManager: `0x${string}`;
|
|
17
18
|
MockACL: `0x${string}`;
|
|
18
19
|
ACPTimestampRevoker: `0x${string}`;
|
|
@@ -31,6 +32,47 @@ type DeployContext = {
|
|
|
31
32
|
};
|
|
32
33
|
declare function deployMocks(ctx: DeployContext, options?: DeployMocksArgs): Promise<DeployedMockContracts>;
|
|
33
34
|
|
|
35
|
+
declare const MOCK_GAS_CONSUMED_EVENT: {
|
|
36
|
+
readonly name: "MockGasConsumed";
|
|
37
|
+
readonly type: "event";
|
|
38
|
+
readonly inputs: readonly [{
|
|
39
|
+
readonly type: "uint256";
|
|
40
|
+
readonly name: "gas";
|
|
41
|
+
}];
|
|
42
|
+
};
|
|
43
|
+
declare const MOCK_GAS_CONSUMED_TOPIC: `0x${string}`;
|
|
44
|
+
type AdjustableGasReceipt = {
|
|
45
|
+
gasUsed: bigint | number | string;
|
|
46
|
+
logs?: ReadonlyArray<{
|
|
47
|
+
address: string;
|
|
48
|
+
topics: ReadonlyArray<string>;
|
|
49
|
+
data: string;
|
|
50
|
+
}>;
|
|
51
|
+
};
|
|
52
|
+
type AdjustedGasBreakdown = {
|
|
53
|
+
/** Raw gas used by the transaction (includes mock overhead). */
|
|
54
|
+
gasUsed: bigint;
|
|
55
|
+
/** Gas consumed by mock-only work (FHE op replication, decrypt-task storage, mock logging). */
|
|
56
|
+
mockGas: bigint;
|
|
57
|
+
/** gasUsed - mockGas: an estimate of what the transaction would cost on a real CoFHE network. */
|
|
58
|
+
adjustedGasUsed: bigint;
|
|
59
|
+
/** Number of MockGasConsumed events - roughly the number of mock-only blocks executed. */
|
|
60
|
+
mockGasEvents: number;
|
|
61
|
+
};
|
|
62
|
+
declare const mock_getAdjustedGasBreakdown: (receipt: AdjustableGasReceipt) => AdjustedGasBreakdown;
|
|
63
|
+
declare const mock_getAdjustedGasUsed: (receipt: AdjustableGasReceipt) => bigint;
|
|
64
|
+
type MockGasSummaryRow = {
|
|
65
|
+
contract: string;
|
|
66
|
+
method: string;
|
|
67
|
+
calls: number;
|
|
68
|
+
totalGasUsed: string;
|
|
69
|
+
totalMockGas: string;
|
|
70
|
+
};
|
|
71
|
+
declare const collectMockGasRows: (publicClient: PublicClient, artifacts: ArtifactManager, fromBlock?: bigint) => Promise<MockGasSummaryRow[]>;
|
|
72
|
+
declare const registerGasSummaryConnection: (publicClient: PublicClient, artifacts: ArtifactManager, cacheDir: string, fromBlock: bigint) => void;
|
|
73
|
+
declare const cleanGasSummaryDir: (cacheDir: string) => void;
|
|
74
|
+
declare const printMockGasSummaryFromDir: (cacheDir: string) => void;
|
|
75
|
+
|
|
34
76
|
interface CofheConnection {
|
|
35
77
|
/**
|
|
36
78
|
* Create a CoFHE configuration. Defaults to hardhat environment;
|
|
@@ -45,6 +87,20 @@ interface CofheConnection {
|
|
|
45
87
|
* first account from the connection is used automatically.
|
|
46
88
|
*/
|
|
47
89
|
createClientWithBatteries(walletClient?: WalletClient): Promise<CofheClient>;
|
|
90
|
+
/**
|
|
91
|
+
* Returns a transaction's gas usage excluding mock-only overhead (FHE op replication,
|
|
92
|
+
* decrypt-task storage, mock logging) - an estimate of what the transaction would cost
|
|
93
|
+
* on a real CoFHE network. Pure function of the receipt (sums the mock task manager's
|
|
94
|
+
* MockGasConsumed events from `receipt.logs`); on a real network the receipt carries no
|
|
95
|
+
* such events and the raw `gasUsed` is returned unchanged.
|
|
96
|
+
*/
|
|
97
|
+
getAdjustedGasUsed(receipt: AdjustableGasReceipt): bigint;
|
|
98
|
+
/**
|
|
99
|
+
* Full gas breakdown of a transaction receipt: raw `gasUsed`, the mock-only `mockGas`,
|
|
100
|
+
* the `adjustedGasUsed` (raw minus mock), and the number of mock gas events.
|
|
101
|
+
* See getAdjustedGasUsed.
|
|
102
|
+
*/
|
|
103
|
+
getAdjustedGasBreakdown(receipt: AdjustableGasReceipt): AdjustedGasBreakdown;
|
|
48
104
|
mocks: {
|
|
49
105
|
/** Deploy (or re-deploy) the mock contracts. */
|
|
50
106
|
deployMocks(options?: DeployMocksArgs): Promise<void>;
|
|
@@ -58,6 +114,11 @@ interface CofheConnection {
|
|
|
58
114
|
getPlaintext(ctHash: bigint | string): Promise<bigint>;
|
|
59
115
|
/** Assert that a ciphertext hash represents the expected plaintext value. */
|
|
60
116
|
expectPlaintext(ctHash: bigint | string, expectedValue: bigint): Promise<void>;
|
|
117
|
+
/** MockCoFHEAddressBook contract descriptor — spread into readContract / writeContract */
|
|
118
|
+
MockCoFHEAddressBook: {
|
|
119
|
+
address: `0x${string}`;
|
|
120
|
+
abi: typeof MockCoFHEAddressBookArtifact.abi;
|
|
121
|
+
};
|
|
61
122
|
/** MockTaskManager contract descriptor — spread into readContract / writeContract */
|
|
62
123
|
MockTaskManager: {
|
|
63
124
|
address: `0x${string}`;
|
|
@@ -87,6 +148,14 @@ declare module 'hardhat/types/config' {
|
|
|
87
148
|
logMocks?: boolean;
|
|
88
149
|
/** Whether to show gas usage warnings for mock operations (default: true) */
|
|
89
150
|
gasWarning?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Print a per-method gas summary after `hardhat test`, showing raw gas next to
|
|
153
|
+
* adjusted gas (mock-only overhead excluded - an estimate of real-network cost).
|
|
154
|
+
* Collected per test worker from chain history: transactions rolled back by
|
|
155
|
+
* snapshots won't appear, and the table is best-effort after forced exits -
|
|
156
|
+
* use getAdjustedGasUsed(receipt) for exact numbers. (default: false)
|
|
157
|
+
*/
|
|
158
|
+
gasSummary?: boolean;
|
|
90
159
|
/**
|
|
91
160
|
* Controls deploy-mocks console output.
|
|
92
161
|
* - `''` — silent, no output
|
|
@@ -100,6 +169,8 @@ declare module 'hardhat/types/config' {
|
|
|
100
169
|
cofhe: {
|
|
101
170
|
logMocks: boolean;
|
|
102
171
|
gasWarning: boolean;
|
|
172
|
+
/** Print a per-method adjusted-gas summary after `hardhat test` (default: false) */
|
|
173
|
+
gasSummary: boolean;
|
|
103
174
|
mocksDeployVerbosity: LogMocksDeploy;
|
|
104
175
|
};
|
|
105
176
|
}
|
|
@@ -148,4 +219,4 @@ declare function mock_expectPlaintext(publicClient: PublicClient, ctHash: bigint
|
|
|
148
219
|
|
|
149
220
|
declare const plugin: HardhatPlugin;
|
|
150
221
|
|
|
151
|
-
export { type DeployContext, type DeployMocksArgs, type DeployedMockContracts, type LogMocksDeploy, TASK_COFHE_SET_LOG_OPS, TASK_COFHE_USE_FAUCET, plugin as default, deployMocks, getMockContractsNpmPaths, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getPlaintext, mock_setLoggingEnabled, mock_withLogs };
|
|
222
|
+
export { type AdjustableGasReceipt, type AdjustedGasBreakdown, type DeployContext, type DeployMocksArgs, type DeployedMockContracts, type LogMocksDeploy, MOCK_GAS_CONSUMED_EVENT, MOCK_GAS_CONSUMED_TOPIC, type MockGasSummaryRow, TASK_COFHE_SET_LOG_OPS, TASK_COFHE_USE_FAUCET, cleanGasSummaryDir, collectMockGasRows, plugin as default, deployMocks, getMockContractsNpmPaths, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getAdjustedGasBreakdown, mock_getAdjustedGasUsed, mock_getPlaintext, mock_setLoggingEnabled, mock_withLogs, printMockGasSummaryFromDir, registerGasSummaryConnection };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
getMockContractsNpmPaths,
|
|
4
4
|
mock_expectPlaintext,
|
|
5
5
|
mock_getPlaintext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-W4H6WKGI.js";
|
|
7
7
|
import {
|
|
8
8
|
localcofheFundAccount,
|
|
9
9
|
localcofheFundWalletIfNeeded
|
|
@@ -11,10 +11,20 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
mock_setLoggingEnabled,
|
|
13
13
|
mock_withLogs
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-NYXXHYHW.js";
|
|
15
|
+
import {
|
|
16
|
+
MOCK_GAS_CONSUMED_EVENT,
|
|
17
|
+
MOCK_GAS_CONSUMED_TOPIC,
|
|
18
|
+
cleanGasSummaryDir,
|
|
19
|
+
collectMockGasRows,
|
|
20
|
+
mock_getAdjustedGasBreakdown,
|
|
21
|
+
mock_getAdjustedGasUsed,
|
|
22
|
+
printMockGasSummaryFromDir,
|
|
23
|
+
registerGasSummaryConnection
|
|
24
|
+
} from "./chunk-6G2MCXNM.js";
|
|
15
25
|
|
|
16
26
|
// src/index.ts
|
|
17
|
-
import { task } from "hardhat/config";
|
|
27
|
+
import { overrideTask, task } from "hardhat/config";
|
|
18
28
|
import { ArgumentType } from "hardhat/types/arguments";
|
|
19
29
|
|
|
20
30
|
// src/consts.ts
|
|
@@ -25,8 +35,8 @@ var TASK_COFHE_SET_LOG_OPS = "cofhe:set-log-ops";
|
|
|
25
35
|
var plugin = {
|
|
26
36
|
id: "@cofhe/hardhat-3-plugin",
|
|
27
37
|
hookHandlers: {
|
|
28
|
-
config: async () => import("./config-
|
|
29
|
-
hre: async () => import("./hre-
|
|
38
|
+
config: async () => import("./config-VUCAYBHC.js"),
|
|
39
|
+
hre: async () => import("./hre-MFXYQSRM.js")
|
|
30
40
|
},
|
|
31
41
|
tasks: [
|
|
32
42
|
task(TASK_COFHE_USE_FAUCET, "Fund an account via the localcofhe faucet").addOption({
|
|
@@ -35,20 +45,30 @@ var plugin = {
|
|
|
35
45
|
type: ArgumentType.STRING_WITHOUT_DEFAULT,
|
|
36
46
|
defaultValue: void 0
|
|
37
47
|
}).setAction(async () => import("./use-faucet-O732FNWJ.js")).build(),
|
|
38
|
-
task(TASK_COFHE_SET_LOG_OPS, "Enable or disable CoFHE mock contract logging").addFlag({ name: "enable", description: "Whether to enable logging" }).setAction(async () => import("./set-log-ops-
|
|
48
|
+
task(TASK_COFHE_SET_LOG_OPS, "Enable or disable CoFHE mock contract logging").addFlag({ name: "enable", description: "Whether to enable logging" }).setAction(async () => import("./set-log-ops-2OIBBSDL.js")).build(),
|
|
49
|
+
// Prints the adjusted-gas summary after `hardhat test` when cofhe.gasSummary is enabled.
|
|
50
|
+
overrideTask("test").setAction(async () => import("./test-gas-summary-WK6CULNO.js")).build()
|
|
39
51
|
]
|
|
40
52
|
};
|
|
41
53
|
var index_default = plugin;
|
|
42
54
|
export {
|
|
55
|
+
MOCK_GAS_CONSUMED_EVENT,
|
|
56
|
+
MOCK_GAS_CONSUMED_TOPIC,
|
|
43
57
|
TASK_COFHE_SET_LOG_OPS,
|
|
44
58
|
TASK_COFHE_USE_FAUCET,
|
|
59
|
+
cleanGasSummaryDir,
|
|
60
|
+
collectMockGasRows,
|
|
45
61
|
index_default as default,
|
|
46
62
|
deployMocks,
|
|
47
63
|
getMockContractsNpmPaths,
|
|
48
64
|
localcofheFundAccount,
|
|
49
65
|
localcofheFundWalletIfNeeded,
|
|
50
66
|
mock_expectPlaintext,
|
|
67
|
+
mock_getAdjustedGasBreakdown,
|
|
68
|
+
mock_getAdjustedGasUsed,
|
|
51
69
|
mock_getPlaintext,
|
|
52
70
|
mock_setLoggingEnabled,
|
|
53
|
-
mock_withLogs
|
|
71
|
+
mock_withLogs,
|
|
72
|
+
printMockGasSummaryFromDir,
|
|
73
|
+
registerGasSummaryConnection
|
|
54
74
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cleanGasSummaryDir,
|
|
3
|
+
printMockGasSummaryFromDir
|
|
4
|
+
} from "./chunk-6G2MCXNM.js";
|
|
5
|
+
|
|
6
|
+
// src/tasks/test-gas-summary.ts
|
|
7
|
+
var action = async (args, hre, runSuper) => {
|
|
8
|
+
if (!hre.config.cofhe.gasSummary) {
|
|
9
|
+
return runSuper(args);
|
|
10
|
+
}
|
|
11
|
+
cleanGasSummaryDir(hre.config.paths.cache);
|
|
12
|
+
const result = await runSuper(args);
|
|
13
|
+
printMockGasSummaryFromDir(hre.config.paths.cache);
|
|
14
|
+
return result;
|
|
15
|
+
};
|
|
16
|
+
var test_gas_summary_default = action;
|
|
17
|
+
export {
|
|
18
|
+
test_gas_summary_default as default
|
|
19
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cofhe/hardhat-3-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.0",
|
|
4
4
|
"description": "Hardhat 3 plugin for CoFHE — deploys mock contracts and wires up the hre.cofhe interface",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"chalk": "4.1.2",
|
|
30
30
|
"viem": "2.38.6",
|
|
31
|
-
"@cofhe/mock-contracts": "0.
|
|
32
|
-
"@cofhe/sdk": "0.
|
|
31
|
+
"@cofhe/mock-contracts": "1.0.0-alpha.0",
|
|
32
|
+
"@cofhe/sdk": "1.0.0-alpha.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "20.19.15",
|
package/src/config.ts
CHANGED
|
@@ -59,6 +59,7 @@ export function resolvePluginConfig(userConfig: HardhatUserConfig, resolvedConfi
|
|
|
59
59
|
resolvedConfig.cofhe = {
|
|
60
60
|
logMocks: userConfig.cofhe?.logMocks ?? false,
|
|
61
61
|
gasWarning: userConfig.cofhe?.gasWarning ?? false,
|
|
62
|
+
gasSummary: userConfig.cofhe?.gasSummary ?? false,
|
|
62
63
|
mocksDeployVerbosity: (userConfig.cofhe?.mocksDeployVerbosity ?? 'v') as LogMocksDeploy,
|
|
63
64
|
};
|
|
64
65
|
}
|
package/src/deploy.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import type { ArtifactManager } from 'hardhat/types/artifacts';
|
|
2
2
|
import type { PublicClient, WalletClient } from 'viem';
|
|
3
|
-
import { createTestClient, custom } from 'viem';
|
|
3
|
+
import { createTestClient, custom, encodeFunctionData } from 'viem';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
6
6
|
|
|
7
|
-
import { MockACLArtifact, MockTaskManagerArtifact, MockThresholdNetworkArtifact } from '@cofhe/mock-contracts';
|
|
8
7
|
import {
|
|
9
|
-
|
|
8
|
+
ACPShareRegistryArtifact,
|
|
9
|
+
MockACLArtifact,
|
|
10
|
+
MockCoFHEAddressBookArtifact,
|
|
11
|
+
MockTaskManagerArtifact,
|
|
12
|
+
MockThresholdNetworkArtifact,
|
|
13
|
+
} from '@cofhe/mock-contracts';
|
|
14
|
+
import {
|
|
15
|
+
COFHE_ADDRESS_BOOK_ADDRESS,
|
|
16
|
+
TASK_MANAGER_ID,
|
|
17
|
+
MOCKS_TASK_MANAGER_ADDRESS,
|
|
10
18
|
MOCKS_ZK_VERIFIER_ADDRESS,
|
|
11
19
|
MOCKS_ZK_VERIFIER_SIGNER_ADDRESS,
|
|
12
20
|
MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY,
|
|
@@ -24,6 +32,7 @@ export type LogMocksDeploy = '' | 'v' | 'vv';
|
|
|
24
32
|
|
|
25
33
|
/** Keyed map of deployed mock contract addresses returned by `deployMocks`. */
|
|
26
34
|
export type DeployedMockContracts = {
|
|
35
|
+
MockCoFHEAddressBook: `0x${string}`;
|
|
27
36
|
MockTaskManager: `0x${string}`;
|
|
28
37
|
MockACL: `0x${string}`;
|
|
29
38
|
ACPTimestampRevoker: `0x${string}`;
|
|
@@ -71,14 +80,18 @@ export async function deployMocks(ctx: DeployContext, options: DeployMocksArgs =
|
|
|
71
80
|
|
|
72
81
|
log('vv', chalk.bold('cofhe-hardhat-3-plugin :: deploy mocks'), 0);
|
|
73
82
|
|
|
83
|
+
// 0. Deploy CoFHEAddressBook to the address FHE.sol resolves the TaskManager through
|
|
84
|
+
await deployFixed(ctx.publicClient, 'MockCoFHEAddressBook', COFHE_ADDRESS_BOOK_ADDRESS, ctx.artifacts);
|
|
85
|
+
logDeployment('MockCoFHEAddressBook', COFHE_ADDRESS_BOOK_ADDRESS);
|
|
86
|
+
|
|
74
87
|
// 1. Deploy TaskManager to its fixed address
|
|
75
|
-
await deployFixed(ctx.publicClient, 'MockTaskManager',
|
|
76
|
-
logDeployment('MockTaskManager',
|
|
88
|
+
await deployFixed(ctx.publicClient, 'MockTaskManager', MOCKS_TASK_MANAGER_ADDRESS, ctx.artifacts);
|
|
89
|
+
logDeployment('MockTaskManager', MOCKS_TASK_MANAGER_ADDRESS);
|
|
77
90
|
|
|
78
91
|
// 2. Initialize TaskManager — owner = first connected account
|
|
79
92
|
const [account] = await ctx.walletClient.getAddresses();
|
|
80
93
|
await ctx.walletClient.writeContract({
|
|
81
|
-
address:
|
|
94
|
+
address: MOCKS_TASK_MANAGER_ADDRESS,
|
|
82
95
|
abi: MockTaskManagerArtifact.abi,
|
|
83
96
|
functionName: 'initialize',
|
|
84
97
|
args: [account],
|
|
@@ -86,9 +99,20 @@ export async function deployMocks(ctx: DeployContext, options: DeployMocksArgs =
|
|
|
86
99
|
chain: null,
|
|
87
100
|
});
|
|
88
101
|
|
|
102
|
+
// 2b. Register TaskManager in the CoFHEAddressBook
|
|
103
|
+
await ctx.walletClient.writeContract({
|
|
104
|
+
address: COFHE_ADDRESS_BOOK_ADDRESS,
|
|
105
|
+
abi: MockCoFHEAddressBookArtifact.abi,
|
|
106
|
+
functionName: 'setTm',
|
|
107
|
+
args: [TASK_MANAGER_ID, MOCKS_TASK_MANAGER_ADDRESS],
|
|
108
|
+
account,
|
|
109
|
+
chain: null,
|
|
110
|
+
});
|
|
111
|
+
log('vv', 'TaskManager registered in CoFHEAddressBook', 2);
|
|
112
|
+
|
|
89
113
|
// 3. Configure security zones
|
|
90
114
|
await ctx.walletClient.writeContract({
|
|
91
|
-
address:
|
|
115
|
+
address: MOCKS_TASK_MANAGER_ADDRESS,
|
|
92
116
|
abi: MockTaskManagerArtifact.abi,
|
|
93
117
|
functionName: 'setSecurityZones',
|
|
94
118
|
args: [0, 1],
|
|
@@ -102,7 +126,7 @@ export async function deployMocks(ctx: DeployContext, options: DeployMocksArgs =
|
|
|
102
126
|
|
|
103
127
|
// 5. Link ACL into TaskManager
|
|
104
128
|
await ctx.walletClient.writeContract({
|
|
105
|
-
address:
|
|
129
|
+
address: MOCKS_TASK_MANAGER_ADDRESS,
|
|
106
130
|
abi: MockTaskManagerArtifact.abi,
|
|
107
131
|
functionName: 'setACLContract',
|
|
108
132
|
args: [aclAddress],
|
|
@@ -111,6 +135,17 @@ export async function deployMocks(ctx: DeployContext, options: DeployMocksArgs =
|
|
|
111
135
|
});
|
|
112
136
|
log('vv', 'ACL address set in TaskManager', 2);
|
|
113
137
|
|
|
138
|
+
// 5a. Link TaskManager into ACL
|
|
139
|
+
await ctx.walletClient.writeContract({
|
|
140
|
+
address: aclAddress,
|
|
141
|
+
abi: MockACLArtifact.abi,
|
|
142
|
+
functionName: 'setTaskManager',
|
|
143
|
+
args: [MOCKS_TASK_MANAGER_ADDRESS],
|
|
144
|
+
account,
|
|
145
|
+
chain: null,
|
|
146
|
+
});
|
|
147
|
+
log('vv', 'TaskManager address set in ACL', 2);
|
|
148
|
+
|
|
114
149
|
// 5b. ACP (ACP V3): default revoker (verification is inherited by the ACL)
|
|
115
150
|
const acpRevokerAddress = await deployVariable(ctx, 'ACPTimestampRevoker', []);
|
|
116
151
|
logDeployment('ACPTimestampRevoker', acpRevokerAddress);
|
|
@@ -125,7 +160,12 @@ export async function deployMocks(ctx: DeployContext, options: DeployMocksArgs =
|
|
|
125
160
|
log('vv', 'Default revoker contract set in ACL', 2);
|
|
126
161
|
|
|
127
162
|
// 5c. ACP: on-chain hand-off for sharing ACPs
|
|
128
|
-
|
|
163
|
+
// The production contract (upgradeable): behind a proxy, initialized with the deployer as admin
|
|
164
|
+
const acpShareRegistryImpl = await deployVariable(ctx, 'ACPShareRegistry', []);
|
|
165
|
+
const acpShareRegistryAddress = await deployVariable(ctx, 'MockERC1967Proxy', [
|
|
166
|
+
acpShareRegistryImpl,
|
|
167
|
+
encodeFunctionData({ abi: ACPShareRegistryArtifact.abi, functionName: 'initialize', args: [account] }),
|
|
168
|
+
]);
|
|
129
169
|
logDeployment('ACPShareRegistry', acpShareRegistryAddress);
|
|
130
170
|
await ctx.walletClient.writeContract({
|
|
131
171
|
address: aclAddress,
|
|
@@ -140,7 +180,7 @@ export async function deployMocks(ctx: DeployContext, options: DeployMocksArgs =
|
|
|
140
180
|
// 6. Set ZkVerifier signer (the key is well-known and shared with the SDK)
|
|
141
181
|
const verifierSigner = privateKeyToAccount(MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY);
|
|
142
182
|
await ctx.walletClient.writeContract({
|
|
143
|
-
address:
|
|
183
|
+
address: MOCKS_TASK_MANAGER_ADDRESS,
|
|
144
184
|
abi: MockTaskManagerArtifact.abi,
|
|
145
185
|
functionName: 'setVerifierSigner',
|
|
146
186
|
args: [verifierSigner.address],
|
|
@@ -152,7 +192,7 @@ export async function deployMocks(ctx: DeployContext, options: DeployMocksArgs =
|
|
|
152
192
|
// 7. Set decrypt result signer
|
|
153
193
|
const decryptSigner = privateKeyToAccount(MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY);
|
|
154
194
|
await ctx.walletClient.writeContract({
|
|
155
|
-
address:
|
|
195
|
+
address: MOCKS_TASK_MANAGER_ADDRESS,
|
|
156
196
|
abi: MockTaskManagerArtifact.abi,
|
|
157
197
|
functionName: 'setDecryptResultSigner',
|
|
158
198
|
args: [decryptSigner.address],
|
|
@@ -187,7 +227,7 @@ export async function deployMocks(ctx: DeployContext, options: DeployMocksArgs =
|
|
|
187
227
|
address: MockThresholdNetworkArtifact.fixedAddress as `0x${string}`,
|
|
188
228
|
abi: MockThresholdNetworkArtifact.abi,
|
|
189
229
|
functionName: 'initialize',
|
|
190
|
-
args: [
|
|
230
|
+
args: [MOCKS_TASK_MANAGER_ADDRESS, aclAddress],
|
|
191
231
|
account,
|
|
192
232
|
chain: null,
|
|
193
233
|
});
|
|
@@ -197,8 +237,8 @@ export async function deployMocks(ctx: DeployContext, options: DeployMocksArgs =
|
|
|
197
237
|
if (gasWarning) {
|
|
198
238
|
logEmpty('v');
|
|
199
239
|
logWarning(
|
|
200
|
-
'When using mocks, FHE operations
|
|
201
|
-
|
|
240
|
+
'When using mocks, FHE operations consume extra gas replicating off-chain CoFHE work on-chain. ' +
|
|
241
|
+
"Use conn.cofhe.getAdjustedGasUsed(receipt) or set 'cofhe.gasSummary: true' to see gas numbers with that overhead excluded.\n" +
|
|
202
242
|
"(Disable this warning by setting 'cofhe.gasWarning: false' in your Hardhat config)",
|
|
203
243
|
0
|
|
204
244
|
);
|
|
@@ -207,7 +247,8 @@ export async function deployMocks(ctx: DeployContext, options: DeployMocksArgs =
|
|
|
207
247
|
logEmpty('v');
|
|
208
248
|
|
|
209
249
|
return {
|
|
210
|
-
|
|
250
|
+
MockCoFHEAddressBook: COFHE_ADDRESS_BOOK_ADDRESS,
|
|
251
|
+
MockTaskManager: MOCKS_TASK_MANAGER_ADDRESS,
|
|
211
252
|
MockACL: aclAddress,
|
|
212
253
|
ACPTimestampRevoker: acpRevokerAddress,
|
|
213
254
|
ACPShareRegistry: acpShareRegistryAddress,
|