@aztec/end-to-end 2.1.0-rc.1 → 2.1.0-rc.11
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_cross_chain_messaging/cross_chain_messaging_test.js +1 -1
- package/dest/e2e_epochs/epochs_test.d.ts +4 -2
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +8 -8
- package/dest/e2e_fees/fees_test.js +1 -1
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -1
- package/dest/e2e_multi_validator/utils.js +4 -10
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
- package/dest/e2e_p2p/inactivity_slash_test.js +132 -0
- package/dest/e2e_p2p/p2p_network.d.ts +19 -17
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +4 -2
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +4 -3
- package/dest/fixtures/l1_to_l2_messaging.d.ts +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +1 -1
- package/dest/fixtures/setup_l1_contracts.d.ts +1 -1
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/setup_l1_contracts.js +1 -1
- package/dest/fixtures/setup_p2p_test.d.ts +6 -2
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +2 -1
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +18 -15
- package/dest/fixtures/utils.d.ts +4 -2
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +8 -6
- package/dest/shared/cross_chain_test_harness.d.ts +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +1 -1
- package/dest/shared/uniswap_l1_l2.js +1 -1
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +1 -1
- package/package.json +37 -37
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +1 -1
- package/src/e2e_epochs/epochs_test.ts +12 -10
- package/src/e2e_fees/bridging_race.notest.ts +1 -1
- package/src/e2e_fees/fees_test.ts +1 -1
- package/src/e2e_multi_validator/utils.ts +4 -10
- package/src/e2e_p2p/inactivity_slash_test.ts +174 -0
- package/src/e2e_p2p/p2p_network.ts +6 -6
- package/src/fixtures/e2e_prover_test.ts +3 -2
- package/src/fixtures/l1_to_l2_messaging.ts +1 -1
- package/src/fixtures/setup_l1_contracts.ts +2 -2
- package/src/fixtures/setup_p2p_test.ts +7 -3
- package/src/fixtures/snapshot_manager.ts +22 -14
- package/src/fixtures/utils.ts +9 -7
- package/src/shared/cross_chain_test_harness.ts +1 -1
- package/src/shared/uniswap_l1_l2.ts +1 -1
- package/src/spartan/utils.ts +1 -1
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import type { AztecNodeService } from '@aztec/aztec-node';
|
|
2
|
+
import { EthAddress } from '@aztec/aztec.js';
|
|
3
|
+
import { RollupContract } from '@aztec/ethereum';
|
|
4
|
+
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import 'jest-extended';
|
|
7
|
+
import os from 'os';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
|
|
10
|
+
import { createNodes } from '../fixtures/setup_p2p_test.js';
|
|
11
|
+
import { P2PNetworkTest } from './p2p_network.js';
|
|
12
|
+
|
|
13
|
+
const NUM_NODES = 6;
|
|
14
|
+
const NUM_VALIDATORS = NUM_NODES;
|
|
15
|
+
const COMMITTEE_SIZE = NUM_VALIDATORS;
|
|
16
|
+
const SLASHING_QUORUM = 3;
|
|
17
|
+
const EPOCH_DURATION = 2;
|
|
18
|
+
const SLASHING_ROUND_SIZE_IN_EPOCHS = 2;
|
|
19
|
+
const BOOT_NODE_UDP_PORT = 4500;
|
|
20
|
+
const ETHEREUM_SLOT_DURATION = 4;
|
|
21
|
+
const AZTEC_SLOT_DURATION = 8;
|
|
22
|
+
const SLASHING_UNIT = BigInt(1e18);
|
|
23
|
+
const SLASHING_AMOUNT = SLASHING_UNIT * 3n;
|
|
24
|
+
|
|
25
|
+
// How many epochs it may take to set everything up, so we dont slash during this period
|
|
26
|
+
const SETUP_EPOCH_DURATION = 5;
|
|
27
|
+
|
|
28
|
+
export class P2PInactivityTest {
|
|
29
|
+
public nodes!: AztecNodeService[];
|
|
30
|
+
public activeNodes!: AztecNodeService[];
|
|
31
|
+
public inactiveNodes!: AztecNodeService[];
|
|
32
|
+
|
|
33
|
+
public rollup!: RollupContract;
|
|
34
|
+
public offlineValidators!: EthAddress[];
|
|
35
|
+
|
|
36
|
+
private dataDir: string;
|
|
37
|
+
private inactiveNodeCount: number;
|
|
38
|
+
private keepInitialNode: boolean;
|
|
39
|
+
|
|
40
|
+
constructor(
|
|
41
|
+
public readonly test: P2PNetworkTest,
|
|
42
|
+
opts: { inactiveNodeCount: number; keepInitialNode?: boolean },
|
|
43
|
+
) {
|
|
44
|
+
this.dataDir = fs.mkdtempSync(path.join(os.tmpdir(), test.testName));
|
|
45
|
+
this.inactiveNodeCount = opts.inactiveNodeCount;
|
|
46
|
+
this.keepInitialNode = opts.keepInitialNode ?? false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static async create(
|
|
50
|
+
testName: string,
|
|
51
|
+
opts: { slashInactivityConsecutiveEpochThreshold: number; inactiveNodeCount: number; keepInitialNode?: boolean },
|
|
52
|
+
) {
|
|
53
|
+
const test = await P2PNetworkTest.create({
|
|
54
|
+
testName,
|
|
55
|
+
numberOfNodes: 0,
|
|
56
|
+
numberOfValidators: NUM_VALIDATORS,
|
|
57
|
+
basePort: BOOT_NODE_UDP_PORT,
|
|
58
|
+
startProverNode: true,
|
|
59
|
+
initialConfig: {
|
|
60
|
+
proverNodeConfig: { proverNodeEpochProvingDelayMs: AZTEC_SLOT_DURATION * 1000 },
|
|
61
|
+
aztecTargetCommitteeSize: COMMITTEE_SIZE,
|
|
62
|
+
aztecSlotDuration: AZTEC_SLOT_DURATION,
|
|
63
|
+
ethereumSlotDuration: ETHEREUM_SLOT_DURATION,
|
|
64
|
+
aztecProofSubmissionEpochs: 1024, // effectively do not reorg
|
|
65
|
+
listenAddress: '127.0.0.1',
|
|
66
|
+
minTxsPerBlock: 0,
|
|
67
|
+
aztecEpochDuration: EPOCH_DURATION,
|
|
68
|
+
validatorReexecute: false,
|
|
69
|
+
sentinelEnabled: true,
|
|
70
|
+
slashingQuorum: SLASHING_QUORUM,
|
|
71
|
+
slashingRoundSizeInEpochs: SLASHING_ROUND_SIZE_IN_EPOCHS,
|
|
72
|
+
slashInactivityTargetPercentage: 0.8,
|
|
73
|
+
slashGracePeriodL2Slots: SETUP_EPOCH_DURATION * EPOCH_DURATION, // do not slash during setup
|
|
74
|
+
slashAmountSmall: SLASHING_UNIT,
|
|
75
|
+
slashAmountMedium: SLASHING_UNIT * 2n,
|
|
76
|
+
slashAmountLarge: SLASHING_UNIT * 3n,
|
|
77
|
+
...opts,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
return new P2PInactivityTest(test, opts);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public async setup() {
|
|
84
|
+
await this.test.applyBaseSnapshots();
|
|
85
|
+
await this.test.setup();
|
|
86
|
+
|
|
87
|
+
// Set slashing penalties for inactivity
|
|
88
|
+
const { rollup } = await this.test.getContracts();
|
|
89
|
+
const [activationThreshold, ejectionThreshold, localEjectionThreshold] = await Promise.all([
|
|
90
|
+
rollup.getActivationThreshold(),
|
|
91
|
+
rollup.getEjectionThreshold(),
|
|
92
|
+
rollup.getLocalEjectionThreshold(),
|
|
93
|
+
]);
|
|
94
|
+
const biggestEjection = ejectionThreshold > localEjectionThreshold ? ejectionThreshold : localEjectionThreshold;
|
|
95
|
+
expect(activationThreshold - SLASHING_AMOUNT).toBeLessThan(biggestEjection);
|
|
96
|
+
this.test.ctx.aztecNodeConfig.slashInactivityPenalty = SLASHING_AMOUNT;
|
|
97
|
+
this.rollup = rollup;
|
|
98
|
+
|
|
99
|
+
if (!this.keepInitialNode) {
|
|
100
|
+
await this.test.ctx.aztecNode.stop();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Create all active nodes
|
|
104
|
+
this.activeNodes = await createNodes(
|
|
105
|
+
this.test.ctx.aztecNodeConfig,
|
|
106
|
+
this.test.ctx.dateProvider,
|
|
107
|
+
this.test.bootstrapNodeEnr,
|
|
108
|
+
NUM_NODES - this.inactiveNodeCount - Number(this.keepInitialNode),
|
|
109
|
+
BOOT_NODE_UDP_PORT,
|
|
110
|
+
this.test.prefilledPublicData,
|
|
111
|
+
this.dataDir,
|
|
112
|
+
undefined,
|
|
113
|
+
Number(this.keepInitialNode),
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
// And the ones with an initially disabled sequencer
|
|
117
|
+
const inactiveConfig = { ...this.test.ctx.aztecNodeConfig, dontStartSequencer: true };
|
|
118
|
+
this.inactiveNodes = await createNodes(
|
|
119
|
+
inactiveConfig,
|
|
120
|
+
this.test.ctx.dateProvider,
|
|
121
|
+
this.test.bootstrapNodeEnr,
|
|
122
|
+
this.inactiveNodeCount,
|
|
123
|
+
BOOT_NODE_UDP_PORT,
|
|
124
|
+
this.test.prefilledPublicData,
|
|
125
|
+
this.dataDir,
|
|
126
|
+
undefined,
|
|
127
|
+
NUM_NODES - this.inactiveNodeCount,
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
this.nodes = [
|
|
131
|
+
...(this.keepInitialNode ? [this.test.ctx.aztecNode] : []),
|
|
132
|
+
...this.activeNodes,
|
|
133
|
+
...this.inactiveNodes,
|
|
134
|
+
];
|
|
135
|
+
|
|
136
|
+
if (this.nodes.length !== NUM_NODES) {
|
|
137
|
+
throw new Error(`Expected ${NUM_NODES} nodes but got ${this.nodes.length}`);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
this.offlineValidators = this.test.validators
|
|
141
|
+
.slice(this.test.validators.length - this.inactiveNodeCount)
|
|
142
|
+
.map(a => a.attester);
|
|
143
|
+
|
|
144
|
+
this.test.logger.warn(`Setup complete. Offline validators are ${this.offlineValidators.join(', ')}.`, {
|
|
145
|
+
validators: this.test.validators,
|
|
146
|
+
offlineValidators: this.offlineValidators,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
this.test.logger.warn(`Advancing to epoch ${SETUP_EPOCH_DURATION + 1} to start slashing`);
|
|
150
|
+
await this.test.ctx.cheatCodes.rollup.advanceToEpoch(SETUP_EPOCH_DURATION + 1);
|
|
151
|
+
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
public async teardown() {
|
|
156
|
+
await this.test.stopNodes(this.nodes);
|
|
157
|
+
await this.test.teardown();
|
|
158
|
+
for (let i = 0; i < NUM_NODES; i++) {
|
|
159
|
+
fs.rmSync(`${this.dataDir}-${i}`, { recursive: true, force: true, maxRetries: 3 });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
public get ctx() {
|
|
164
|
+
return this.test.ctx;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
public get logger() {
|
|
168
|
+
return this.test.logger;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public get slashingAmount() {
|
|
172
|
+
return SLASHING_AMOUNT;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -28,9 +28,9 @@ import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
|
28
28
|
import { ZkPassportProofParams } from '@aztec/stdlib/zkpassport';
|
|
29
29
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
30
30
|
|
|
31
|
+
import { type GetContractReturnType, getAddress, getContract } from '@spalladino/viem';
|
|
32
|
+
import { privateKeyToAccount } from '@spalladino/viem/accounts';
|
|
31
33
|
import getPort from 'get-port';
|
|
32
|
-
import { type GetContractReturnType, getAddress, getContract } from 'viem';
|
|
33
|
-
import { privateKeyToAccount } from 'viem/accounts';
|
|
34
34
|
|
|
35
35
|
import {
|
|
36
36
|
ATTESTER_PRIVATE_KEYS_START_INDEX,
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
createSnapshotManager,
|
|
44
44
|
deployAccounts,
|
|
45
45
|
} from '../fixtures/snapshot_manager.js';
|
|
46
|
-
import { getPrivateKeyFromIndex, getSponsoredFPCAddress } from '../fixtures/utils.js';
|
|
46
|
+
import { type SetupOptions, getPrivateKeyFromIndex, getSponsoredFPCAddress } from '../fixtures/utils.js';
|
|
47
47
|
import { getEndToEndTestTelemetryClient } from '../fixtures/with_telemetry_utils.js';
|
|
48
48
|
|
|
49
49
|
// Use a fixed bootstrap node private key so that we can re-use the same snapshot and the nodes can find each other
|
|
@@ -82,11 +82,11 @@ export class P2PNetworkTest {
|
|
|
82
82
|
public bootstrapNode?: BootstrapNode;
|
|
83
83
|
|
|
84
84
|
constructor(
|
|
85
|
-
testName: string,
|
|
85
|
+
public readonly testName: string,
|
|
86
86
|
public bootstrapNodeEnr: string,
|
|
87
87
|
public bootNodePort: number,
|
|
88
88
|
public numberOfValidators: number,
|
|
89
|
-
initialValidatorConfig:
|
|
89
|
+
initialValidatorConfig: SetupOptions,
|
|
90
90
|
public numberOfNodes = 0,
|
|
91
91
|
// If set enable metrics collection
|
|
92
92
|
private metricsPort?: number,
|
|
@@ -162,7 +162,7 @@ export class P2PNetworkTest {
|
|
|
162
162
|
numberOfValidators: number;
|
|
163
163
|
basePort?: number;
|
|
164
164
|
metricsPort?: number;
|
|
165
|
-
initialConfig?:
|
|
165
|
+
initialConfig?: SetupOptions;
|
|
166
166
|
startProverNode?: boolean;
|
|
167
167
|
mockZkPassportVerifier?: boolean;
|
|
168
168
|
}) {
|
|
@@ -33,8 +33,8 @@ import type { PXEService } from '@aztec/pxe/server';
|
|
|
33
33
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
34
34
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
35
35
|
|
|
36
|
-
import { type Hex, getContract } from 'viem';
|
|
37
|
-
import { privateKeyToAddress } from 'viem/accounts';
|
|
36
|
+
import { type Hex, getContract } from '@spalladino/viem';
|
|
37
|
+
import { privateKeyToAddress } from '@spalladino/viem/accounts';
|
|
38
38
|
|
|
39
39
|
import { TokenSimulator } from '../simulators/token_simulator.js';
|
|
40
40
|
import { getACVMConfig } from './get_acvm_config.js';
|
|
@@ -308,6 +308,7 @@ export class FullProverTest {
|
|
|
308
308
|
txGatheringMaxParallelRequestsPerNode: 100,
|
|
309
309
|
txGatheringTimeoutMs: 24_000,
|
|
310
310
|
proverNodeFailedEpochStore: undefined,
|
|
311
|
+
proverNodeEpochProvingDelayMs: undefined,
|
|
311
312
|
};
|
|
312
313
|
const sponsoredFPCAddress = await getSponsoredFPCAddress();
|
|
313
314
|
const { prefilledPublicData } = await getGenesisValues(
|
|
@@ -4,7 +4,7 @@ import { tryJsonStringify } from '@aztec/foundation/json-rpc';
|
|
|
4
4
|
import { InboxAbi } from '@aztec/l1-artifacts';
|
|
5
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
6
|
|
|
7
|
-
import { decodeEventLog, getContract } from 'viem';
|
|
7
|
+
import { decodeEventLog, getContract } from '@spalladino/viem';
|
|
8
8
|
|
|
9
9
|
import { getLogger } from './utils.js';
|
|
10
10
|
|
|
@@ -3,8 +3,8 @@ import { type DeployL1ContractsArgs, type L1ContractsConfig, deployL1Contracts }
|
|
|
3
3
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
4
4
|
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
5
5
|
|
|
6
|
-
import type { HDAccount, PrivateKeyAccount } from 'viem';
|
|
7
|
-
import { foundry } from 'viem/chains';
|
|
6
|
+
import type { HDAccount, PrivateKeyAccount } from '@spalladino/viem';
|
|
7
|
+
import { foundry } from '@spalladino/viem/chains';
|
|
8
8
|
|
|
9
9
|
export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';
|
|
10
10
|
|
|
@@ -39,7 +39,7 @@ export function generatePrivateKeys(startIndex: number, numberOfKeys: number): `
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export async function createNodes(
|
|
42
|
-
config: AztecNodeConfig,
|
|
42
|
+
config: AztecNodeConfig & { dontStartSequencer?: boolean },
|
|
43
43
|
dateProvider: DateProvider,
|
|
44
44
|
bootstrapNodeEnr: string,
|
|
45
45
|
numNodes: number,
|
|
@@ -88,7 +88,7 @@ export async function createNodes(
|
|
|
88
88
|
|
|
89
89
|
/** Creates a P2P enabled instance of Aztec Node Service with a validator */
|
|
90
90
|
export async function createNode(
|
|
91
|
-
config: AztecNodeConfig,
|
|
91
|
+
config: AztecNodeConfig & { dontStartSequencer?: boolean },
|
|
92
92
|
dateProvider: DateProvider,
|
|
93
93
|
tcpPort: number,
|
|
94
94
|
bootstrapNode: string | undefined,
|
|
@@ -101,7 +101,11 @@ export async function createNode(
|
|
|
101
101
|
const createNode = async () => {
|
|
102
102
|
const validatorConfig = await createValidatorConfig(config, bootstrapNode, tcpPort, addressIndex, dataDirectory);
|
|
103
103
|
const telemetry = getEndToEndTestTelemetryClient(metricsPort);
|
|
104
|
-
return await AztecNodeService.createAndSync(
|
|
104
|
+
return await AztecNodeService.createAndSync(
|
|
105
|
+
validatorConfig,
|
|
106
|
+
{ telemetry, dateProvider },
|
|
107
|
+
{ prefilledPublicData, dontStartSequencer: config.dontStartSequencer },
|
|
108
|
+
);
|
|
105
109
|
};
|
|
106
110
|
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createNode) : createNode();
|
|
107
111
|
}
|
|
@@ -40,6 +40,9 @@ import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
|
40
40
|
import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
41
41
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
42
42
|
|
|
43
|
+
import type { Hex } from '@spalladino/viem';
|
|
44
|
+
import { mnemonicToAccount } from '@spalladino/viem/accounts';
|
|
45
|
+
import { foundry } from '@spalladino/viem/chains';
|
|
43
46
|
import type { Anvil } from '@viem/anvil';
|
|
44
47
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
45
48
|
import { copySync, removeSync } from 'fs-extra/esm';
|
|
@@ -47,9 +50,6 @@ import fs from 'fs/promises';
|
|
|
47
50
|
import getPort from 'get-port';
|
|
48
51
|
import { tmpdir } from 'os';
|
|
49
52
|
import path, { join } from 'path';
|
|
50
|
-
import type { Hex } from 'viem';
|
|
51
|
-
import { mnemonicToAccount } from 'viem/accounts';
|
|
52
|
-
import { foundry } from 'viem/chains';
|
|
53
53
|
|
|
54
54
|
import { MNEMONIC, TEST_MAX_TX_POOL_SIZE, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
55
55
|
import { getACVMConfig } from './get_acvm_config.js';
|
|
@@ -333,14 +333,6 @@ async function setupFromFresh(
|
|
|
333
333
|
}
|
|
334
334
|
aztecNodeConfig.blobSinkUrl = `http://127.0.0.1:${blobSinkPort}`;
|
|
335
335
|
|
|
336
|
-
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
337
|
-
logger.verbose('Starting anvil...');
|
|
338
|
-
const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
|
|
339
|
-
const anvil = res.anvil;
|
|
340
|
-
aztecNodeConfig.l1RpcUrls = [res.rpcUrl];
|
|
341
|
-
|
|
342
|
-
// Deploy our L1 contracts.
|
|
343
|
-
logger.verbose('Deploying L1 contracts...');
|
|
344
336
|
const hdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: 0 });
|
|
345
337
|
const publisherPrivKeyRaw = hdAccount.getHdKey().privateKey;
|
|
346
338
|
const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
|
|
@@ -354,8 +346,17 @@ async function setupFromFresh(
|
|
|
354
346
|
aztecNodeConfig.validatorPrivateKeys = new SecretValue([`0x${validatorPrivKey!.toString('hex')}`]);
|
|
355
347
|
aztecNodeConfig.coinbase = opts.coinbase ?? EthAddress.fromString(`${hdAccount.address}`);
|
|
356
348
|
|
|
349
|
+
logger.info(`Setting up environment with config`, aztecNodeConfig);
|
|
350
|
+
|
|
351
|
+
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
352
|
+
logger.verbose('Starting anvil...');
|
|
353
|
+
const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
|
|
354
|
+
const anvil = res.anvil;
|
|
355
|
+
aztecNodeConfig.l1RpcUrls = [res.rpcUrl];
|
|
357
356
|
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
|
|
358
357
|
|
|
358
|
+
// Deploy our L1 contracts.
|
|
359
|
+
logger.verbose('Deploying L1 contracts...');
|
|
359
360
|
if (opts.l1StartTime) {
|
|
360
361
|
await ethCheatCodes.warp(opts.l1StartTime, { resetBlockInterval: true });
|
|
361
362
|
}
|
|
@@ -379,7 +380,6 @@ async function setupFromFresh(
|
|
|
379
380
|
});
|
|
380
381
|
aztecNodeConfig.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
|
|
381
382
|
aztecNodeConfig.rollupVersion = deployL1ContractsValues.rollupVersion;
|
|
382
|
-
aztecNodeConfig.l1PublishRetryIntervalMS = 100;
|
|
383
383
|
|
|
384
384
|
const dateProvider = new TestDateProvider();
|
|
385
385
|
|
|
@@ -432,7 +432,11 @@ async function setupFromFresh(
|
|
|
432
432
|
proverNode = await createAndSyncProverNode(
|
|
433
433
|
`0x${proverNodePrivateKey!.toString('hex')}`,
|
|
434
434
|
aztecNodeConfig,
|
|
435
|
-
{
|
|
435
|
+
{
|
|
436
|
+
...aztecNodeConfig.proverNodeConfig,
|
|
437
|
+
dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
438
|
+
p2pEnabled: false,
|
|
439
|
+
},
|
|
436
440
|
aztecNode,
|
|
437
441
|
prefilledPublicData,
|
|
438
442
|
);
|
|
@@ -558,7 +562,11 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
558
562
|
proverNode = await createAndSyncProverNode(
|
|
559
563
|
proverNodePrivateKeyHex,
|
|
560
564
|
aztecNodeConfig,
|
|
561
|
-
{
|
|
565
|
+
{
|
|
566
|
+
...aztecNodeConfig.proverNodeConfig,
|
|
567
|
+
dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
568
|
+
p2pEnabled: false,
|
|
569
|
+
},
|
|
562
570
|
aztecNode,
|
|
563
571
|
prefilledPublicData,
|
|
564
572
|
);
|
package/src/fixtures/utils.ts
CHANGED
|
@@ -93,14 +93,14 @@ import {
|
|
|
93
93
|
import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
|
|
94
94
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
95
95
|
|
|
96
|
+
import { type Chain, type HDAccount, type Hex, type PrivateKeyAccount, getContract } from '@spalladino/viem';
|
|
97
|
+
import { generatePrivateKey, mnemonicToAccount, privateKeyToAccount } from '@spalladino/viem/accounts';
|
|
98
|
+
import { foundry } from '@spalladino/viem/chains';
|
|
96
99
|
import type { Anvil } from '@viem/anvil';
|
|
97
100
|
import fs from 'fs/promises';
|
|
98
101
|
import getPort from 'get-port';
|
|
99
102
|
import { tmpdir } from 'os';
|
|
100
103
|
import * as path from 'path';
|
|
101
|
-
import { type Chain, type HDAccount, type Hex, type PrivateKeyAccount, getContract } from 'viem';
|
|
102
|
-
import { generatePrivateKey, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
|
|
103
|
-
import { foundry } from 'viem/chains';
|
|
104
104
|
|
|
105
105
|
import { MNEMONIC, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
106
106
|
import { getACVMConfig } from './get_acvm_config.js';
|
|
@@ -576,7 +576,7 @@ export async function setup(
|
|
|
576
576
|
await blobSink.start();
|
|
577
577
|
config.blobSinkUrl = `http://localhost:${blobSinkPort}`;
|
|
578
578
|
|
|
579
|
-
logger.verbose('Creating and synching an aztec node
|
|
579
|
+
logger.verbose('Creating and synching an aztec node', config);
|
|
580
580
|
|
|
581
581
|
const acvmConfig = await getACVMConfig(logger);
|
|
582
582
|
if (acvmConfig) {
|
|
@@ -589,7 +589,6 @@ export async function setup(
|
|
|
589
589
|
config.bbBinaryPath = bbConfig.bbBinaryPath;
|
|
590
590
|
config.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
|
|
591
591
|
}
|
|
592
|
-
config.l1PublishRetryIntervalMS = 100;
|
|
593
592
|
|
|
594
593
|
const blobSinkClient = createBlobSinkClient(config, { logger: createLogger('node:blob-sink:client') });
|
|
595
594
|
|
|
@@ -927,7 +926,7 @@ export async function waitForProvenChain(node: AztecNode, targetBlock?: number,
|
|
|
927
926
|
export function createAndSyncProverNode(
|
|
928
927
|
proverNodePrivateKey: `0x${string}`,
|
|
929
928
|
aztecNodeConfig: AztecNodeConfig,
|
|
930
|
-
proverNodeConfig: Partial<ProverNodeConfig> & Pick<DataStoreConfig, 'dataDirectory'
|
|
929
|
+
proverNodeConfig: Partial<ProverNodeConfig> & Pick<DataStoreConfig, 'dataDirectory'> & { dontStart?: boolean },
|
|
931
930
|
aztecNode: AztecNode | undefined,
|
|
932
931
|
prefilledPublicData: PublicDataTreeLeaf[] = [],
|
|
933
932
|
proverNodeDeps: ProverNodeDeps = {},
|
|
@@ -963,6 +962,7 @@ export function createAndSyncProverNode(
|
|
|
963
962
|
txGatheringTimeoutMs: 24_000,
|
|
964
963
|
proverNodeFailedEpochStore: undefined,
|
|
965
964
|
proverId: EthAddress.fromNumber(1),
|
|
965
|
+
proverNodeEpochProvingDelayMs: undefined,
|
|
966
966
|
...proverNodeConfig,
|
|
967
967
|
};
|
|
968
968
|
|
|
@@ -979,7 +979,9 @@ export function createAndSyncProverNode(
|
|
|
979
979
|
{ prefilledPublicData },
|
|
980
980
|
);
|
|
981
981
|
getLogger().info(`Created and synced prover node`, { publisherAddress: l1TxUtils.client.account!.address });
|
|
982
|
-
|
|
982
|
+
if (!proverNodeConfig.dontStart) {
|
|
983
|
+
await proverNode.start();
|
|
984
|
+
}
|
|
983
985
|
return proverNode;
|
|
984
986
|
});
|
|
985
987
|
}
|
|
@@ -23,7 +23,7 @@ import { TestERC20Abi, TokenPortalAbi, TokenPortalBytecode } from '@aztec/l1-art
|
|
|
23
23
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
24
24
|
import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
|
|
25
25
|
|
|
26
|
-
import { type Hex, getContract } from 'viem';
|
|
26
|
+
import { type Hex, getContract } from '@spalladino/viem';
|
|
27
27
|
|
|
28
28
|
import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
29
29
|
|
|
@@ -24,7 +24,7 @@ import { computeL2ToL1MessageHash } from '@aztec/stdlib/hash';
|
|
|
24
24
|
import { computeL2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
|
|
25
25
|
|
|
26
26
|
import { jest } from '@jest/globals';
|
|
27
|
-
import { type GetContractReturnType, getContract, parseEther, toFunctionSelector } from 'viem';
|
|
27
|
+
import { type GetContractReturnType, getContract, parseEther, toFunctionSelector } from '@spalladino/viem';
|
|
28
28
|
|
|
29
29
|
import { ensureAccountContractsPublished } from '../fixtures/utils.js';
|
|
30
30
|
import { CrossChainTestHarness } from './cross_chain_test_harness.js';
|
package/src/spartan/utils.ts
CHANGED
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
createAztecNodeClient,
|
|
12
12
|
} from '@aztec/stdlib/interfaces/client';
|
|
13
13
|
|
|
14
|
+
import { createPublicClient, fallback, http } from '@spalladino/viem';
|
|
14
15
|
import { ChildProcess, exec, execSync, spawn } from 'child_process';
|
|
15
16
|
import path from 'path';
|
|
16
17
|
import { promisify } from 'util';
|
|
17
|
-
import { createPublicClient, fallback, http } from 'viem';
|
|
18
18
|
import { z } from 'zod';
|
|
19
19
|
|
|
20
20
|
const execAsync = promisify(exec);
|