@aztec/end-to-end 2.0.3-rc.16 → 2.0.3-rc.18
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/dest/e2e_p2p/shared.d.ts +2 -1
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +5 -3
- package/dest/fixtures/setup_p2p_test.d.ts +4 -0
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +37 -20
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +42 -0
- package/package.json +36 -36
- package/src/e2e_p2p/shared.ts +6 -2
- package/src/fixtures/setup_p2p_test.ts +53 -16
- package/src/fixtures/web3signer.ts +46 -0
package/dest/e2e_p2p/shared.d.ts
CHANGED
|
@@ -23,11 +23,12 @@ export declare function awaitCommitteeExists({ rollup, logger, }: {
|
|
|
23
23
|
rollup: RollupContract;
|
|
24
24
|
logger: Logger;
|
|
25
25
|
}): Promise<readonly `0x${string}`[]>;
|
|
26
|
-
export declare function awaitOffenseDetected({ logger, nodeAdmin, slashingRoundSize, epochDuration, }: {
|
|
26
|
+
export declare function awaitOffenseDetected({ logger, nodeAdmin, slashingRoundSize, epochDuration, waitUntilOffenseCount, }: {
|
|
27
27
|
nodeAdmin: AztecNodeAdmin;
|
|
28
28
|
logger: Logger;
|
|
29
29
|
slashingRoundSize: number;
|
|
30
30
|
epochDuration: number;
|
|
31
|
+
waitUntilOffenseCount?: number;
|
|
31
32
|
}): Promise<import("@aztec/slasher").Offense[]>;
|
|
32
33
|
/**
|
|
33
34
|
* Await the committee to be slashed out of the validator set.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/e2e_p2p/shared.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBA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,MAAM,EAAE,cAAc,CAAC;IACvB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,SAAS,EAAE,SAAS,KAAK,MAAM,EAAE,EAAE,CAAC;IACpC,YAAY,EAAE,oBAAoB,CAAC;IACnC,gBAAgB,EAAE,8BAA8B,GAAG,6BAA6B,GAAG,SAAS,CAAC;IAC7F,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,gBAAgB,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;CAChB,iBAkEA"}
|
package/dest/e2e_p2p/shared.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
|
|
2
2
|
import { Fr, TxStatus, getContractInstanceFromInstantiationParams, retryUntil } from '@aztec/aztec.js';
|
|
3
3
|
import { timesAsync, unique } from '@aztec/foundation/collection';
|
|
4
|
+
import { pluralize } from '@aztec/foundation/string';
|
|
4
5
|
import { TestContract, TestContractArtifact } from '@aztec/noir-test-contracts.js/Test';
|
|
5
6
|
import { createPXEService, getPXEServiceConfig as getRpcConfig } from '@aztec/pxe/server';
|
|
6
7
|
import { getRoundForOffense } from '@aztec/slasher';
|
|
@@ -107,11 +108,12 @@ export async function awaitCommitteeExists({ rollup, logger }) {
|
|
|
107
108
|
}, 'non-empty committee', 60);
|
|
108
109
|
return committee;
|
|
109
110
|
}
|
|
110
|
-
export async function awaitOffenseDetected({ logger, nodeAdmin, slashingRoundSize, epochDuration }) {
|
|
111
|
-
|
|
111
|
+
export async function awaitOffenseDetected({ logger, nodeAdmin, slashingRoundSize, epochDuration, waitUntilOffenseCount }) {
|
|
112
|
+
const targetOffenseCount = waitUntilOffenseCount ?? 1;
|
|
113
|
+
logger.warn(`Waiting for ${pluralize('offense', targetOffenseCount)} to be detected`);
|
|
112
114
|
const offenses = await retryUntil(async ()=>{
|
|
113
115
|
const offenses = await nodeAdmin.getSlashOffenses('all');
|
|
114
|
-
if (offenses.length
|
|
116
|
+
if (offenses.length >= targetOffenseCount) {
|
|
115
117
|
return offenses;
|
|
116
118
|
}
|
|
117
119
|
}, 'non-empty offenses', 60);
|
|
@@ -16,7 +16,11 @@ export interface NodeContext {
|
|
|
16
16
|
}
|
|
17
17
|
export declare function generatePrivateKeys(startIndex: number, numberOfKeys: number): `0x${string}`[];
|
|
18
18
|
export declare function createNodes(config: AztecNodeConfig, dateProvider: DateProvider, bootstrapNodeEnr: string, numNodes: number, bootNodePort: number, prefilledPublicData?: PublicDataTreeLeaf[], dataDirectory?: string, metricsPort?: number, indexOffset?: number): Promise<AztecNodeService[]>;
|
|
19
|
+
/** Creates a P2P enabled instance of Aztec Node Service with a validator */
|
|
19
20
|
export declare function createNode(config: AztecNodeConfig, dateProvider: DateProvider, tcpPort: number, bootstrapNode: string | undefined, addressIndex: number, prefilledPublicData?: PublicDataTreeLeaf[], dataDirectory?: string, metricsPort?: number, loggerIdStorage?: AsyncLocalStorage<string>): Promise<AztecNodeService>;
|
|
21
|
+
/** Creates a P2P enabled instance of Aztec Node Service without a validator */
|
|
22
|
+
export declare function createNonValidatorNode(baseConfig: AztecNodeConfig, dateProvider: DateProvider, tcpPort: number, bootstrapNode: string | undefined, prefilledPublicData?: PublicDataTreeLeaf[], dataDirectory?: string, metricsPort?: number, loggerIdStorage?: AsyncLocalStorage<string>): Promise<AztecNodeService>;
|
|
20
23
|
export declare function createProverNode(config: AztecNodeConfig, tcpPort: number, bootstrapNode: string | undefined, addressIndex: number, proverNodeDeps: ProverNodeDeps & Required<Pick<ProverNodeDeps, 'dateProvider'>>, prefilledPublicData?: PublicDataTreeLeaf[], dataDirectory?: string, metricsPort?: number, loggerIdStorage?: AsyncLocalStorage<string>): Promise<import("@aztec/prover-node").ProverNode>;
|
|
24
|
+
export declare function createP2PConfig(config: AztecNodeConfig, bootstrapNodeEnr?: string, port?: number, dataDirectory?: string): Promise<AztecNodeConfig>;
|
|
21
25
|
export declare function createValidatorConfig(config: AztecNodeConfig, bootstrapNodeEnr?: string, port?: number, addressIndex?: number, dataDirectory?: string): Promise<AztecNodeConfig>;
|
|
22
26
|
//# sourceMappingURL=setup_p2p_test.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup_p2p_test.d.ts","sourceRoot":"","sources":["../../src/fixtures/setup_p2p_test.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,KAAK,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAI9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAoB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AASrD,eAAO,MAAM,iCAAiC,IAAI,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,gBAAgB,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,GAAG,EAAE,MAAM,EAAE,CAAC;CACf;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,KAAK,MAAM,EAAE,EAAE,CAO7F;AAED,wBAAsB,WAAW,CAC/B,MAAM,EAAE,eAAe,EACvB,YAAY,EAAE,YAAY,EAC1B,gBAAgB,EAAE,MAAM,EACxB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,EAC1C,aAAa,CAAC,EAAE,MAAM,EACtB,WAAW,CAAC,EAAE,MAAM,EACpB,WAAW,SAAI,GACd,OAAO,CAAC,gBA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AYvB"}
|
|
@@ -43,8 +43,7 @@ export async function createNodes(config, dateProvider, bootstrapNodeEnr, numNod
|
|
|
43
43
|
removeLogNameHandler(logNameHandler);
|
|
44
44
|
return nodes;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
export async function createNode(config, dateProvider, tcpPort, bootstrapNode, addressIndex, prefilledPublicData, dataDirectory, metricsPort, loggerIdStorage) {
|
|
46
|
+
/** Creates a P2P enabled instance of Aztec Node Service with a validator */ export async function createNode(config, dateProvider, tcpPort, bootstrapNode, addressIndex, prefilledPublicData, dataDirectory, metricsPort, loggerIdStorage) {
|
|
48
47
|
const createNode = async ()=>{
|
|
49
48
|
const validatorConfig = await createValidatorConfig(config, bootstrapNode, tcpPort, addressIndex, dataDirectory);
|
|
50
49
|
const telemetry = getEndToEndTestTelemetryClient(metricsPort);
|
|
@@ -57,20 +56,30 @@ export async function createNode(config, dateProvider, tcpPort, bootstrapNode, a
|
|
|
57
56
|
};
|
|
58
57
|
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createNode) : createNode();
|
|
59
58
|
}
|
|
59
|
+
/** Creates a P2P enabled instance of Aztec Node Service without a validator */ export async function createNonValidatorNode(baseConfig, dateProvider, tcpPort, bootstrapNode, prefilledPublicData, dataDirectory, metricsPort, loggerIdStorage) {
|
|
60
|
+
const createNode = async ()=>{
|
|
61
|
+
const p2pConfig = await createP2PConfig(baseConfig, bootstrapNode, tcpPort, dataDirectory);
|
|
62
|
+
const config = {
|
|
63
|
+
...p2pConfig,
|
|
64
|
+
disableValidator: true,
|
|
65
|
+
validatorPrivateKeys: undefined,
|
|
66
|
+
publisherPrivateKeys: []
|
|
67
|
+
};
|
|
68
|
+
const telemetry = getEndToEndTestTelemetryClient(metricsPort);
|
|
69
|
+
return await AztecNodeService.createAndSync(config, {
|
|
70
|
+
telemetry,
|
|
71
|
+
dateProvider
|
|
72
|
+
}, {
|
|
73
|
+
prefilledPublicData
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createNode) : createNode();
|
|
77
|
+
}
|
|
60
78
|
export async function createProverNode(config, tcpPort, bootstrapNode, addressIndex, proverNodeDeps, prefilledPublicData, dataDirectory, metricsPort, loggerIdStorage) {
|
|
61
79
|
const createProverNode = async ()=>{
|
|
62
80
|
const proverNodePrivateKey = getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex);
|
|
63
81
|
const telemetry = getEndToEndTestTelemetryClient(metricsPort);
|
|
64
|
-
const proverConfig =
|
|
65
|
-
p2pIp: `127.0.0.1`,
|
|
66
|
-
p2pPort: tcpPort ?? await getPort(),
|
|
67
|
-
p2pEnabled: true,
|
|
68
|
-
peerCheckIntervalMS: TEST_PEER_CHECK_INTERVAL_MS,
|
|
69
|
-
blockCheckIntervalMS: 1000,
|
|
70
|
-
bootstrapNodes: bootstrapNode ? [
|
|
71
|
-
bootstrapNode
|
|
72
|
-
] : []
|
|
73
|
-
};
|
|
82
|
+
const proverConfig = await createP2PConfig(config, bootstrapNode, tcpPort, dataDirectory);
|
|
74
83
|
const aztecNodeRpcTxProvider = undefined;
|
|
75
84
|
return await createAndSyncProverNode(bufferToHex(proverNodePrivateKey), config, {
|
|
76
85
|
...proverConfig,
|
|
@@ -82,15 +91,8 @@ export async function createProverNode(config, tcpPort, bootstrapNode, addressIn
|
|
|
82
91
|
};
|
|
83
92
|
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createProverNode) : createProverNode();
|
|
84
93
|
}
|
|
85
|
-
export async function
|
|
94
|
+
export async function createP2PConfig(config, bootstrapNodeEnr, port, dataDirectory) {
|
|
86
95
|
port = port ?? await getPort();
|
|
87
|
-
const attesterPrivateKey = bufferToHex(getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex));
|
|
88
|
-
config.validatorPrivateKeys = new SecretValue([
|
|
89
|
-
attesterPrivateKey
|
|
90
|
-
]);
|
|
91
|
-
config.publisherPrivateKeys = [
|
|
92
|
-
new SecretValue(attesterPrivateKey)
|
|
93
|
-
];
|
|
94
96
|
const nodeConfig = {
|
|
95
97
|
...config,
|
|
96
98
|
p2pIp: `127.0.0.1`,
|
|
@@ -105,3 +107,18 @@ export async function createValidatorConfig(config, bootstrapNodeEnr, port, addr
|
|
|
105
107
|
};
|
|
106
108
|
return nodeConfig;
|
|
107
109
|
}
|
|
110
|
+
export async function createValidatorConfig(config, bootstrapNodeEnr, port, addressIndex = 1, dataDirectory) {
|
|
111
|
+
const attesterPrivateKey = bufferToHex(getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex));
|
|
112
|
+
const p2pConfig = await createP2PConfig(config, bootstrapNodeEnr, port, dataDirectory);
|
|
113
|
+
const nodeConfig = {
|
|
114
|
+
...config,
|
|
115
|
+
...p2pConfig,
|
|
116
|
+
validatorPrivateKeys: new SecretValue([
|
|
117
|
+
attesterPrivateKey
|
|
118
|
+
]),
|
|
119
|
+
publisherPrivateKeys: [
|
|
120
|
+
new SecretValue(attesterPrivateKey)
|
|
121
|
+
]
|
|
122
|
+
};
|
|
123
|
+
return nodeConfig;
|
|
124
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function createWeb3SignerKeystore(dir: string, ...privateKeys: string[]): Promise<void>;
|
|
2
|
+
export declare function refreshWeb3Signer(url: string): Promise<void>;
|
|
3
|
+
export declare function getWeb3SignerTestKeystoreDir(): string;
|
|
4
|
+
export declare function getWeb3SignerUrl(): string;
|
|
5
|
+
//# sourceMappingURL=web3signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web3signer.d.ts","sourceRoot":"","sources":["../../src/fixtures/web3signer.ts"],"names":[],"mappings":"AAOA,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,iBAcnF;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,iBAKlD;AAED,wBAAgB,4BAA4B,IAAI,MAAM,CAOrD;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAMzC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { sleep } from '@aztec/aztec.js';
|
|
2
|
+
import { randomBytes } from '@aztec/foundation/crypto';
|
|
3
|
+
import { mkdirSync } from 'node:fs';
|
|
4
|
+
import { writeFile } from 'node:fs/promises';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
export async function createWeb3SignerKeystore(dir, ...privateKeys) {
|
|
7
|
+
const yaml = privateKeys.map((pk)=>`\
|
|
8
|
+
type: file-raw
|
|
9
|
+
keyType: SECP256K1
|
|
10
|
+
privateKey: ${pk}`).join('\n---\n');
|
|
11
|
+
// NOTE: nodejs stdlib can only create temp directories, not temp files!
|
|
12
|
+
// this write uses wx (write-exclusive) so it'll throw if the file already exists
|
|
13
|
+
const path = join(dir, `keystore-${randomBytes(4).toString('hex')}.yaml`);
|
|
14
|
+
await writeFile(path, yaml, {
|
|
15
|
+
flag: 'wx'
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export async function refreshWeb3Signer(url) {
|
|
19
|
+
await fetch(new URL('reload', url), {
|
|
20
|
+
method: 'POST'
|
|
21
|
+
});
|
|
22
|
+
// give the service a chance to load up the new files
|
|
23
|
+
// 1s might not be enough if there are a lot of files to scan
|
|
24
|
+
await sleep(1000);
|
|
25
|
+
}
|
|
26
|
+
export function getWeb3SignerTestKeystoreDir() {
|
|
27
|
+
if (process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR) {
|
|
28
|
+
mkdirSync(process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR, {
|
|
29
|
+
recursive: true
|
|
30
|
+
});
|
|
31
|
+
return process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR;
|
|
32
|
+
} else {
|
|
33
|
+
throw new Error('Web3signer not running');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function getWeb3SignerUrl() {
|
|
37
|
+
if (process.env.WEB3_SIGNER_URL) {
|
|
38
|
+
return process.env.WEB3_SIGNER_URL;
|
|
39
|
+
} else {
|
|
40
|
+
throw new Error('Web3signer not running');
|
|
41
|
+
}
|
|
42
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/end-to-end",
|
|
3
|
-
"version": "2.0.3-rc.
|
|
3
|
+
"version": "2.0.3-rc.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dest/index.js",
|
|
6
6
|
"inherits": [
|
|
@@ -25,41 +25,41 @@
|
|
|
25
25
|
"formatting": "run -T prettier --check ./src && run -T eslint ./src"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aztec/accounts": "2.0.3-rc.
|
|
29
|
-
"@aztec/archiver": "2.0.3-rc.
|
|
30
|
-
"@aztec/aztec": "2.0.3-rc.
|
|
31
|
-
"@aztec/aztec-node": "2.0.3-rc.
|
|
32
|
-
"@aztec/aztec.js": "2.0.3-rc.
|
|
33
|
-
"@aztec/bb-prover": "2.0.3-rc.
|
|
34
|
-
"@aztec/blob-lib": "2.0.3-rc.
|
|
35
|
-
"@aztec/blob-sink": "2.0.3-rc.
|
|
36
|
-
"@aztec/bot": "2.0.3-rc.
|
|
37
|
-
"@aztec/cli": "2.0.3-rc.
|
|
38
|
-
"@aztec/constants": "2.0.3-rc.
|
|
39
|
-
"@aztec/entrypoints": "2.0.3-rc.
|
|
40
|
-
"@aztec/epoch-cache": "2.0.3-rc.
|
|
41
|
-
"@aztec/ethereum": "2.0.3-rc.
|
|
42
|
-
"@aztec/foundation": "2.0.3-rc.
|
|
43
|
-
"@aztec/kv-store": "2.0.3-rc.
|
|
44
|
-
"@aztec/l1-artifacts": "2.0.3-rc.
|
|
45
|
-
"@aztec/merkle-tree": "2.0.3-rc.
|
|
46
|
-
"@aztec/node-keystore": "2.0.3-rc.
|
|
47
|
-
"@aztec/noir-contracts.js": "2.0.3-rc.
|
|
48
|
-
"@aztec/noir-noirc_abi": "2.0.3-rc.
|
|
49
|
-
"@aztec/noir-protocol-circuits-types": "2.0.3-rc.
|
|
50
|
-
"@aztec/noir-test-contracts.js": "2.0.3-rc.
|
|
51
|
-
"@aztec/p2p": "2.0.3-rc.
|
|
52
|
-
"@aztec/protocol-contracts": "2.0.3-rc.
|
|
53
|
-
"@aztec/prover-client": "2.0.3-rc.
|
|
54
|
-
"@aztec/prover-node": "2.0.3-rc.
|
|
55
|
-
"@aztec/pxe": "2.0.3-rc.
|
|
56
|
-
"@aztec/sequencer-client": "2.0.3-rc.
|
|
57
|
-
"@aztec/simulator": "2.0.3-rc.
|
|
58
|
-
"@aztec/slasher": "2.0.3-rc.
|
|
59
|
-
"@aztec/stdlib": "2.0.3-rc.
|
|
60
|
-
"@aztec/telemetry-client": "2.0.3-rc.
|
|
61
|
-
"@aztec/validator-client": "2.0.3-rc.
|
|
62
|
-
"@aztec/world-state": "2.0.3-rc.
|
|
28
|
+
"@aztec/accounts": "2.0.3-rc.18",
|
|
29
|
+
"@aztec/archiver": "2.0.3-rc.18",
|
|
30
|
+
"@aztec/aztec": "2.0.3-rc.18",
|
|
31
|
+
"@aztec/aztec-node": "2.0.3-rc.18",
|
|
32
|
+
"@aztec/aztec.js": "2.0.3-rc.18",
|
|
33
|
+
"@aztec/bb-prover": "2.0.3-rc.18",
|
|
34
|
+
"@aztec/blob-lib": "2.0.3-rc.18",
|
|
35
|
+
"@aztec/blob-sink": "2.0.3-rc.18",
|
|
36
|
+
"@aztec/bot": "2.0.3-rc.18",
|
|
37
|
+
"@aztec/cli": "2.0.3-rc.18",
|
|
38
|
+
"@aztec/constants": "2.0.3-rc.18",
|
|
39
|
+
"@aztec/entrypoints": "2.0.3-rc.18",
|
|
40
|
+
"@aztec/epoch-cache": "2.0.3-rc.18",
|
|
41
|
+
"@aztec/ethereum": "2.0.3-rc.18",
|
|
42
|
+
"@aztec/foundation": "2.0.3-rc.18",
|
|
43
|
+
"@aztec/kv-store": "2.0.3-rc.18",
|
|
44
|
+
"@aztec/l1-artifacts": "2.0.3-rc.18",
|
|
45
|
+
"@aztec/merkle-tree": "2.0.3-rc.18",
|
|
46
|
+
"@aztec/node-keystore": "2.0.3-rc.18",
|
|
47
|
+
"@aztec/noir-contracts.js": "2.0.3-rc.18",
|
|
48
|
+
"@aztec/noir-noirc_abi": "2.0.3-rc.18",
|
|
49
|
+
"@aztec/noir-protocol-circuits-types": "2.0.3-rc.18",
|
|
50
|
+
"@aztec/noir-test-contracts.js": "2.0.3-rc.18",
|
|
51
|
+
"@aztec/p2p": "2.0.3-rc.18",
|
|
52
|
+
"@aztec/protocol-contracts": "2.0.3-rc.18",
|
|
53
|
+
"@aztec/prover-client": "2.0.3-rc.18",
|
|
54
|
+
"@aztec/prover-node": "2.0.3-rc.18",
|
|
55
|
+
"@aztec/pxe": "2.0.3-rc.18",
|
|
56
|
+
"@aztec/sequencer-client": "2.0.3-rc.18",
|
|
57
|
+
"@aztec/simulator": "2.0.3-rc.18",
|
|
58
|
+
"@aztec/slasher": "2.0.3-rc.18",
|
|
59
|
+
"@aztec/stdlib": "2.0.3-rc.18",
|
|
60
|
+
"@aztec/telemetry-client": "2.0.3-rc.18",
|
|
61
|
+
"@aztec/validator-client": "2.0.3-rc.18",
|
|
62
|
+
"@aztec/world-state": "2.0.3-rc.18",
|
|
63
63
|
"@iarna/toml": "^2.2.5",
|
|
64
64
|
"@jest/globals": "^30.0.0",
|
|
65
65
|
"@noble/curves": "=1.0.0",
|
package/src/e2e_p2p/shared.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
import type { RollupCheatCodes } from '@aztec/aztec/testing';
|
|
15
15
|
import type { EmpireSlashingProposerContract, RollupContract, TallySlashingProposerContract } from '@aztec/ethereum';
|
|
16
16
|
import { timesAsync, unique } from '@aztec/foundation/collection';
|
|
17
|
+
import { pluralize } from '@aztec/foundation/string';
|
|
17
18
|
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
18
19
|
import type { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
19
20
|
import { TestContract, TestContractArtifact } from '@aztec/noir-test-contracts.js/Test';
|
|
@@ -164,17 +165,20 @@ export async function awaitOffenseDetected({
|
|
|
164
165
|
nodeAdmin,
|
|
165
166
|
slashingRoundSize,
|
|
166
167
|
epochDuration,
|
|
168
|
+
waitUntilOffenseCount,
|
|
167
169
|
}: {
|
|
168
170
|
nodeAdmin: AztecNodeAdmin;
|
|
169
171
|
logger: Logger;
|
|
170
172
|
slashingRoundSize: number;
|
|
171
173
|
epochDuration: number;
|
|
174
|
+
waitUntilOffenseCount?: number;
|
|
172
175
|
}) {
|
|
173
|
-
|
|
176
|
+
const targetOffenseCount = waitUntilOffenseCount ?? 1;
|
|
177
|
+
logger.warn(`Waiting for ${pluralize('offense', targetOffenseCount)} to be detected`);
|
|
174
178
|
const offenses = await retryUntil(
|
|
175
179
|
async () => {
|
|
176
180
|
const offenses = await nodeAdmin.getSlashOffenses('all');
|
|
177
|
-
if (offenses.length
|
|
181
|
+
if (offenses.length >= targetOffenseCount) {
|
|
178
182
|
return offenses;
|
|
179
183
|
}
|
|
180
184
|
},
|
|
@@ -86,7 +86,7 @@ export async function createNodes(
|
|
|
86
86
|
return nodes;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
/** Creates a P2P enabled instance of Aztec Node Service with a validator */
|
|
90
90
|
export async function createNode(
|
|
91
91
|
config: AztecNodeConfig,
|
|
92
92
|
dateProvider: DateProvider,
|
|
@@ -106,6 +106,31 @@ export async function createNode(
|
|
|
106
106
|
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createNode) : createNode();
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
/** Creates a P2P enabled instance of Aztec Node Service without a validator */
|
|
110
|
+
export async function createNonValidatorNode(
|
|
111
|
+
baseConfig: AztecNodeConfig,
|
|
112
|
+
dateProvider: DateProvider,
|
|
113
|
+
tcpPort: number,
|
|
114
|
+
bootstrapNode: string | undefined,
|
|
115
|
+
prefilledPublicData?: PublicDataTreeLeaf[],
|
|
116
|
+
dataDirectory?: string,
|
|
117
|
+
metricsPort?: number,
|
|
118
|
+
loggerIdStorage?: AsyncLocalStorage<string>,
|
|
119
|
+
) {
|
|
120
|
+
const createNode = async () => {
|
|
121
|
+
const p2pConfig = await createP2PConfig(baseConfig, bootstrapNode, tcpPort, dataDirectory);
|
|
122
|
+
const config: AztecNodeConfig = {
|
|
123
|
+
...p2pConfig,
|
|
124
|
+
disableValidator: true,
|
|
125
|
+
validatorPrivateKeys: undefined,
|
|
126
|
+
publisherPrivateKeys: [],
|
|
127
|
+
};
|
|
128
|
+
const telemetry = getEndToEndTestTelemetryClient(metricsPort);
|
|
129
|
+
return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, { prefilledPublicData });
|
|
130
|
+
};
|
|
131
|
+
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createNode) : createNode();
|
|
132
|
+
}
|
|
133
|
+
|
|
109
134
|
export async function createProverNode(
|
|
110
135
|
config: AztecNodeConfig,
|
|
111
136
|
tcpPort: number,
|
|
@@ -121,14 +146,13 @@ export async function createProverNode(
|
|
|
121
146
|
const proverNodePrivateKey = getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!;
|
|
122
147
|
const telemetry = getEndToEndTestTelemetryClient(metricsPort);
|
|
123
148
|
|
|
124
|
-
const proverConfig: Partial<ProverNodeConfig> =
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
};
|
|
149
|
+
const proverConfig: Partial<ProverNodeConfig> = await createP2PConfig(
|
|
150
|
+
config,
|
|
151
|
+
bootstrapNode,
|
|
152
|
+
tcpPort,
|
|
153
|
+
dataDirectory,
|
|
154
|
+
);
|
|
155
|
+
|
|
132
156
|
const aztecNodeRpcTxProvider = undefined;
|
|
133
157
|
return await createAndSyncProverNode(
|
|
134
158
|
bufferToHex(proverNodePrivateKey),
|
|
@@ -142,20 +166,14 @@ export async function createProverNode(
|
|
|
142
166
|
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createProverNode) : createProverNode();
|
|
143
167
|
}
|
|
144
168
|
|
|
145
|
-
export async function
|
|
169
|
+
export async function createP2PConfig(
|
|
146
170
|
config: AztecNodeConfig,
|
|
147
171
|
bootstrapNodeEnr?: string,
|
|
148
172
|
port?: number,
|
|
149
|
-
addressIndex: number = 1,
|
|
150
173
|
dataDirectory?: string,
|
|
151
174
|
) {
|
|
152
175
|
port = port ?? (await getPort());
|
|
153
176
|
|
|
154
|
-
const attesterPrivateKey = bufferToHex(getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!);
|
|
155
|
-
|
|
156
|
-
config.validatorPrivateKeys = new SecretValue([attesterPrivateKey]);
|
|
157
|
-
config.publisherPrivateKeys = [new SecretValue(attesterPrivateKey)];
|
|
158
|
-
|
|
159
177
|
const nodeConfig: AztecNodeConfig = {
|
|
160
178
|
...config,
|
|
161
179
|
p2pIp: `127.0.0.1`,
|
|
@@ -169,3 +187,22 @@ export async function createValidatorConfig(
|
|
|
169
187
|
|
|
170
188
|
return nodeConfig;
|
|
171
189
|
}
|
|
190
|
+
|
|
191
|
+
export async function createValidatorConfig(
|
|
192
|
+
config: AztecNodeConfig,
|
|
193
|
+
bootstrapNodeEnr?: string,
|
|
194
|
+
port?: number,
|
|
195
|
+
addressIndex: number = 1,
|
|
196
|
+
dataDirectory?: string,
|
|
197
|
+
) {
|
|
198
|
+
const attesterPrivateKey = bufferToHex(getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!);
|
|
199
|
+
const p2pConfig = await createP2PConfig(config, bootstrapNodeEnr, port, dataDirectory);
|
|
200
|
+
const nodeConfig: AztecNodeConfig = {
|
|
201
|
+
...config,
|
|
202
|
+
...p2pConfig,
|
|
203
|
+
validatorPrivateKeys: new SecretValue([attesterPrivateKey]),
|
|
204
|
+
publisherPrivateKeys: [new SecretValue(attesterPrivateKey)],
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
return nodeConfig;
|
|
208
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { sleep } from '@aztec/aztec.js';
|
|
2
|
+
import { randomBytes } from '@aztec/foundation/crypto';
|
|
3
|
+
|
|
4
|
+
import { mkdirSync } from 'node:fs';
|
|
5
|
+
import { writeFile } from 'node:fs/promises';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
|
|
8
|
+
export async function createWeb3SignerKeystore(dir: string, ...privateKeys: string[]) {
|
|
9
|
+
const yaml = privateKeys
|
|
10
|
+
.map(
|
|
11
|
+
pk => `\
|
|
12
|
+
type: file-raw
|
|
13
|
+
keyType: SECP256K1
|
|
14
|
+
privateKey: ${pk}`,
|
|
15
|
+
)
|
|
16
|
+
.join('\n---\n');
|
|
17
|
+
|
|
18
|
+
// NOTE: nodejs stdlib can only create temp directories, not temp files!
|
|
19
|
+
// this write uses wx (write-exclusive) so it'll throw if the file already exists
|
|
20
|
+
const path = join(dir, `keystore-${randomBytes(4).toString('hex')}.yaml`);
|
|
21
|
+
await writeFile(path, yaml, { flag: 'wx' });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function refreshWeb3Signer(url: string) {
|
|
25
|
+
await fetch(new URL('reload', url), { method: 'POST' });
|
|
26
|
+
// give the service a chance to load up the new files
|
|
27
|
+
// 1s might not be enough if there are a lot of files to scan
|
|
28
|
+
await sleep(1000);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function getWeb3SignerTestKeystoreDir(): string {
|
|
32
|
+
if (process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR) {
|
|
33
|
+
mkdirSync(process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR, { recursive: true });
|
|
34
|
+
return process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR;
|
|
35
|
+
} else {
|
|
36
|
+
throw new Error('Web3signer not running');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function getWeb3SignerUrl(): string {
|
|
41
|
+
if (process.env.WEB3_SIGNER_URL) {
|
|
42
|
+
return process.env.WEB3_SIGNER_URL;
|
|
43
|
+
} else {
|
|
44
|
+
throw new Error('Web3signer not running');
|
|
45
|
+
}
|
|
46
|
+
}
|