@aztec/aztec 4.0.0-rc.5 → 4.0.0-rc.7
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/cli/aztec_start_action.js +2 -2
- package/dest/local-network/local-network.d.ts +1 -1
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +15 -0
- package/dest/testing/anvil_test_watcher.d.ts +9 -1
- package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
- package/dest/testing/anvil_test_watcher.js +52 -15
- package/package.json +34 -34
- package/src/cli/aztec_start_action.ts +2 -2
- package/src/local-network/local-network.ts +16 -0
- package/src/testing/anvil_test_watcher.ts +59 -15
|
@@ -25,11 +25,11 @@ export async function aztecStart(options, userLog, debugLogger) {
|
|
|
25
25
|
l1RpcUrls: options.l1RpcUrls,
|
|
26
26
|
testAccounts: localNetwork.testAccounts,
|
|
27
27
|
realProofs: false,
|
|
28
|
-
// Setting the epoch duration to
|
|
28
|
+
// Setting the epoch duration to 2 by default for local network. This allows the epoch to be "proven" faster, so
|
|
29
29
|
// the users can consume out hash without having to wait for a long time.
|
|
30
30
|
// Note: We are not proving anything in the local network (realProofs == false). But in `createLocalNetwork`,
|
|
31
31
|
// the EpochTestSettler will set the out hash to the outbox when an epoch is complete.
|
|
32
|
-
aztecEpochDuration:
|
|
32
|
+
aztecEpochDuration: 2
|
|
33
33
|
}, userLog);
|
|
34
34
|
// Start Node and PXE JSON-RPC server
|
|
35
35
|
signalHandlers.push(stop);
|
|
@@ -70,4 +70,4 @@ export declare function createAztecNode(config?: Partial<AztecNodeConfig>, deps?
|
|
|
70
70
|
}, options?: {
|
|
71
71
|
prefilledPublicData?: PublicDataTreeLeaf[];
|
|
72
72
|
}): Promise<AztecNodeService>;
|
|
73
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
73
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9jYWwtbmV0d29y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C,EAAE,OAAO,EAAE,KAAK;;;GAgJhG;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,EACrC,IAAI,GAAE;IACJ,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,YAAY,CAAC,EAAE,gBAAgB,CAAC;CAC5B,EACN,OAAO,GAAE;IAAE,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAAO,6BAe7D"}
|
|
@@ -17,6 +17,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
17
17
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
18
18
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
19
19
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
20
|
+
import { SequencerState } from '@aztec/sequencer-client';
|
|
20
21
|
import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
21
22
|
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
22
23
|
import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
|
|
@@ -141,6 +142,20 @@ const localAnvil = foundry;
|
|
|
141
142
|
}, {
|
|
142
143
|
prefilledPublicData
|
|
143
144
|
});
|
|
145
|
+
// Now that the node is up, let the watcher check for pending txs so it can skip unfilled slots faster when
|
|
146
|
+
// transactions are waiting in the mempool. Also let it check if the sequencer is actively building, to avoid
|
|
147
|
+
// warping time out from under an in-progress block.
|
|
148
|
+
watcher?.setGetPendingTxCount(()=>node.getPendingTxCount());
|
|
149
|
+
const sequencer = node.getSequencer()?.getSequencer();
|
|
150
|
+
if (sequencer) {
|
|
151
|
+
const idleStates = new Set([
|
|
152
|
+
SequencerState.STOPPED,
|
|
153
|
+
SequencerState.STOPPING,
|
|
154
|
+
SequencerState.IDLE,
|
|
155
|
+
SequencerState.SYNCHRONIZING
|
|
156
|
+
]);
|
|
157
|
+
watcher?.setIsSequencerBuilding(()=>!idleStates.has(sequencer.getState()));
|
|
158
|
+
}
|
|
144
159
|
let epochTestSettler;
|
|
145
160
|
if (!aztecNodeConfig.p2pEnabled) {
|
|
146
161
|
epochTestSettler = new EpochTestSettler(cheatcodes, rollupAddress, node.getBlockSource(), logger.createChild('epoch-settler'), {
|
|
@@ -21,14 +21,22 @@ export declare class AnvilTestWatcher {
|
|
|
21
21
|
private markingAsProvenRunningPromise?;
|
|
22
22
|
private logger;
|
|
23
23
|
private isMarkingAsProven;
|
|
24
|
+
private getPendingTxCount?;
|
|
25
|
+
private isSequencerBuilding?;
|
|
26
|
+
private unfilledSlotFirstSeen?;
|
|
24
27
|
constructor(cheatcodes: EthCheatCodes, rollupAddress: EthAddress, l1Client: ViemClient, dateProvider?: TestDateProvider | undefined);
|
|
25
28
|
setIsMarkingAsProven(isMarkingAsProven: boolean): void;
|
|
26
29
|
setisLocalNetwork(isLocalNetwork: boolean): void;
|
|
30
|
+
/** Sets a callback to check for pending txs, used to skip unfilled slots faster when txs are waiting. */
|
|
31
|
+
setGetPendingTxCount(fn: () => Promise<number>): void;
|
|
32
|
+
/** Sets a callback to check if the sequencer is actively building, to avoid warping while it works. */
|
|
33
|
+
setIsSequencerBuilding(fn: () => boolean): void;
|
|
27
34
|
start(): Promise<void>;
|
|
28
35
|
stop(): Promise<void>;
|
|
29
36
|
trigger(): Promise<void>;
|
|
30
37
|
markAsProven(): Promise<void>;
|
|
31
38
|
syncDateProviderToL1IfBehind(): Promise<void>;
|
|
32
39
|
warpTimeIfNeeded(): Promise<void>;
|
|
40
|
+
private warpToTimestamp;
|
|
33
41
|
}
|
|
34
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
42
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW52aWxfdGVzdF93YXRjaGVyLmQudHMiLCJzb3VyY2V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FBQVEsRUFBRSxVQUFVLEVBQ1osWUFBWSxDQUFDLDhCQUFrQixFQWF4QztJQUVELG9CQUFvQixDQUFDLGlCQUFpQixFQUFFLE9BQU8sUUFHOUM7SUFFRCxpQkFBaUIsQ0FBQyxjQUFjLEVBQUUsT0FBTyxRQUV4QztJQUVELHlHQUF5RztJQUN6RyxvQkFBb0IsQ0FBQyxFQUFFLEVBQUUsTUFBTSxPQUFPLENBQUMsTUFBTSxDQUFDLFFBRTdDO0lBRUQsdUdBQXVHO0lBQ3ZHLHNCQUFzQixDQUFDLEVBQUUsRUFBRSxNQUFNLE9BQU8sUUFFdkM7SUFFSyxLQUFLLGtCQXlCVjtJQUVLLElBQUksa0JBSVQ7SUFFSyxPQUFPLGtCQUlaO0lBRUssWUFBWSxrQkFLakI7SUFFSyw0QkFBNEIsa0JBZWpDO0lBRUssZ0JBQWdCLGtCQXlEckI7WUFFYSxlQUFlO0NBTzlCIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anvil_test_watcher.d.ts","sourceRoot":"","sources":["../../src/testing/anvil_test_watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoB,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE;;;;;;GAMG;AACH,qBAAa,gBAAgB;
|
|
1
|
+
{"version":3,"file":"anvil_test_watcher.d.ts","sourceRoot":"","sources":["../../src/testing/anvil_test_watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoB,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG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callback to check if there are pending txs in the mempool.
|
|
26
|
+
getPendingTxCount;
|
|
27
|
+
// Optional callback to check if the sequencer is actively building a block.
|
|
28
|
+
isSequencerBuilding;
|
|
29
|
+
// Tracks when we first observed the current unfilled slot with pending txs (real wall time).
|
|
30
|
+
unfilledSlotFirstSeen;
|
|
25
31
|
constructor(cheatcodes, rollupAddress, l1Client, dateProvider){
|
|
26
32
|
this.cheatcodes = cheatcodes;
|
|
27
33
|
this.dateProvider = dateProvider;
|
|
@@ -45,6 +51,12 @@ import { getAddress, getContract } from 'viem';
|
|
|
45
51
|
setisLocalNetwork(isLocalNetwork) {
|
|
46
52
|
this.isLocalNetwork = isLocalNetwork;
|
|
47
53
|
}
|
|
54
|
+
/** Sets a callback to check for pending txs, used to skip unfilled slots faster when txs are waiting. */ setGetPendingTxCount(fn) {
|
|
55
|
+
this.getPendingTxCount = fn;
|
|
56
|
+
}
|
|
57
|
+
/** Sets a callback to check if the sequencer is actively building, to avoid warping while it works. */ setIsSequencerBuilding(fn) {
|
|
58
|
+
this.isSequencerBuilding = fn;
|
|
59
|
+
}
|
|
48
60
|
async start() {
|
|
49
61
|
if (this.filledRunningPromise) {
|
|
50
62
|
throw new Error('Watcher already watching for filled slot');
|
|
@@ -111,14 +123,8 @@ import { getAddress, getContract } from 'viem';
|
|
|
111
123
|
BigInt(nextSlot)
|
|
112
124
|
]));
|
|
113
125
|
if (BigInt(currentSlot) === checkpointLog.slotNumber) {
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
await this.cheatcodes.warp(nextSlotTimestamp, {
|
|
117
|
-
resetBlockInterval: true
|
|
118
|
-
});
|
|
119
|
-
} catch (e) {
|
|
120
|
-
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
121
|
-
}
|
|
126
|
+
// The current slot has been filled, we should jump to the next slot.
|
|
127
|
+
await this.warpToTimestamp(nextSlotTimestamp);
|
|
122
128
|
this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
|
|
123
129
|
return;
|
|
124
130
|
}
|
|
@@ -126,19 +132,50 @@ import { getAddress, getContract } from 'viem';
|
|
|
126
132
|
if (!this.isLocalNetwork) {
|
|
127
133
|
return;
|
|
128
134
|
}
|
|
135
|
+
// If there are pending txs and the sequencer missed them, warp quickly (after a 2s real-time debounce) so the
|
|
136
|
+
// sequencer can retry in the next slot. Without this, we'd have to wait a full real-time slot duration (~36s) for
|
|
137
|
+
// the dateProvider to catch up to the next slot timestamp. We skip the warp if the sequencer is actively building
|
|
138
|
+
// to avoid invalidating its in-progress work.
|
|
139
|
+
if (this.getPendingTxCount) {
|
|
140
|
+
const pendingTxs = await this.getPendingTxCount();
|
|
141
|
+
if (pendingTxs > 0) {
|
|
142
|
+
if (this.isSequencerBuilding?.()) {
|
|
143
|
+
this.unfilledSlotFirstSeen = undefined;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const realNow = Date.now();
|
|
147
|
+
if (!this.unfilledSlotFirstSeen || this.unfilledSlotFirstSeen.slot !== currentSlot) {
|
|
148
|
+
this.unfilledSlotFirstSeen = {
|
|
149
|
+
slot: currentSlot,
|
|
150
|
+
realTime: realNow
|
|
151
|
+
};
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (realNow - this.unfilledSlotFirstSeen.realTime > 2000) {
|
|
155
|
+
await this.warpToTimestamp(nextSlotTimestamp);
|
|
156
|
+
this.unfilledSlotFirstSeen = undefined;
|
|
157
|
+
this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
|
|
158
|
+
}
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Fallback: warp when the dateProvider time has passed the next slot timestamp.
|
|
129
163
|
const currentTimestamp = this.dateProvider?.now() ?? Date.now();
|
|
130
164
|
if (currentTimestamp > nextSlotTimestamp * 1000) {
|
|
131
|
-
|
|
132
|
-
await this.cheatcodes.warp(nextSlotTimestamp, {
|
|
133
|
-
resetBlockInterval: true
|
|
134
|
-
});
|
|
135
|
-
} catch (e) {
|
|
136
|
-
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
137
|
-
}
|
|
165
|
+
await this.warpToTimestamp(nextSlotTimestamp);
|
|
138
166
|
this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
|
|
139
167
|
}
|
|
140
168
|
} catch {
|
|
141
169
|
this.logger.error('mineIfSlotFilled failed');
|
|
142
170
|
}
|
|
143
171
|
}
|
|
172
|
+
async warpToTimestamp(timestamp) {
|
|
173
|
+
try {
|
|
174
|
+
await this.cheatcodes.warp(timestamp, {
|
|
175
|
+
resetBlockInterval: true
|
|
176
|
+
});
|
|
177
|
+
} catch (e) {
|
|
178
|
+
this.logger.error(`Failed to warp to timestamp ${timestamp}: ${e}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
144
181
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -28,39 +28,39 @@
|
|
|
28
28
|
"../package.common.json"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@aztec/accounts": "4.0.0-rc.
|
|
32
|
-
"@aztec/archiver": "4.0.0-rc.
|
|
33
|
-
"@aztec/aztec-faucet": "4.0.0-rc.
|
|
34
|
-
"@aztec/aztec-node": "4.0.0-rc.
|
|
35
|
-
"@aztec/aztec.js": "4.0.0-rc.
|
|
36
|
-
"@aztec/bb-prover": "4.0.0-rc.
|
|
37
|
-
"@aztec/bb.js": "4.0.0-rc.
|
|
38
|
-
"@aztec/blob-client": "4.0.0-rc.
|
|
39
|
-
"@aztec/bot": "4.0.0-rc.
|
|
40
|
-
"@aztec/builder": "4.0.0-rc.
|
|
41
|
-
"@aztec/cli": "4.0.0-rc.
|
|
42
|
-
"@aztec/constants": "4.0.0-rc.
|
|
43
|
-
"@aztec/entrypoints": "4.0.0-rc.
|
|
44
|
-
"@aztec/ethereum": "4.0.0-rc.
|
|
45
|
-
"@aztec/foundation": "4.0.0-rc.
|
|
46
|
-
"@aztec/kv-store": "4.0.0-rc.
|
|
47
|
-
"@aztec/l1-artifacts": "4.0.0-rc.
|
|
48
|
-
"@aztec/node-lib": "4.0.0-rc.
|
|
49
|
-
"@aztec/noir-contracts.js": "4.0.0-rc.
|
|
50
|
-
"@aztec/noir-protocol-circuits-types": "4.0.0-rc.
|
|
51
|
-
"@aztec/p2p": "4.0.0-rc.
|
|
52
|
-
"@aztec/p2p-bootstrap": "4.0.0-rc.
|
|
53
|
-
"@aztec/protocol-contracts": "4.0.0-rc.
|
|
54
|
-
"@aztec/prover-client": "4.0.0-rc.
|
|
55
|
-
"@aztec/prover-node": "4.0.0-rc.
|
|
56
|
-
"@aztec/pxe": "4.0.0-rc.
|
|
57
|
-
"@aztec/sequencer-client": "4.0.0-rc.
|
|
58
|
-
"@aztec/stdlib": "4.0.0-rc.
|
|
59
|
-
"@aztec/telemetry-client": "4.0.0-rc.
|
|
60
|
-
"@aztec/txe": "4.0.0-rc.
|
|
61
|
-
"@aztec/validator-ha-signer": "4.0.0-rc.
|
|
62
|
-
"@aztec/wallets": "4.0.0-rc.
|
|
63
|
-
"@aztec/world-state": "4.0.0-rc.
|
|
31
|
+
"@aztec/accounts": "4.0.0-rc.7",
|
|
32
|
+
"@aztec/archiver": "4.0.0-rc.7",
|
|
33
|
+
"@aztec/aztec-faucet": "4.0.0-rc.7",
|
|
34
|
+
"@aztec/aztec-node": "4.0.0-rc.7",
|
|
35
|
+
"@aztec/aztec.js": "4.0.0-rc.7",
|
|
36
|
+
"@aztec/bb-prover": "4.0.0-rc.7",
|
|
37
|
+
"@aztec/bb.js": "4.0.0-rc.7",
|
|
38
|
+
"@aztec/blob-client": "4.0.0-rc.7",
|
|
39
|
+
"@aztec/bot": "4.0.0-rc.7",
|
|
40
|
+
"@aztec/builder": "4.0.0-rc.7",
|
|
41
|
+
"@aztec/cli": "4.0.0-rc.7",
|
|
42
|
+
"@aztec/constants": "4.0.0-rc.7",
|
|
43
|
+
"@aztec/entrypoints": "4.0.0-rc.7",
|
|
44
|
+
"@aztec/ethereum": "4.0.0-rc.7",
|
|
45
|
+
"@aztec/foundation": "4.0.0-rc.7",
|
|
46
|
+
"@aztec/kv-store": "4.0.0-rc.7",
|
|
47
|
+
"@aztec/l1-artifacts": "4.0.0-rc.7",
|
|
48
|
+
"@aztec/node-lib": "4.0.0-rc.7",
|
|
49
|
+
"@aztec/noir-contracts.js": "4.0.0-rc.7",
|
|
50
|
+
"@aztec/noir-protocol-circuits-types": "4.0.0-rc.7",
|
|
51
|
+
"@aztec/p2p": "4.0.0-rc.7",
|
|
52
|
+
"@aztec/p2p-bootstrap": "4.0.0-rc.7",
|
|
53
|
+
"@aztec/protocol-contracts": "4.0.0-rc.7",
|
|
54
|
+
"@aztec/prover-client": "4.0.0-rc.7",
|
|
55
|
+
"@aztec/prover-node": "4.0.0-rc.7",
|
|
56
|
+
"@aztec/pxe": "4.0.0-rc.7",
|
|
57
|
+
"@aztec/sequencer-client": "4.0.0-rc.7",
|
|
58
|
+
"@aztec/stdlib": "4.0.0-rc.7",
|
|
59
|
+
"@aztec/telemetry-client": "4.0.0-rc.7",
|
|
60
|
+
"@aztec/txe": "4.0.0-rc.7",
|
|
61
|
+
"@aztec/validator-ha-signer": "4.0.0-rc.7",
|
|
62
|
+
"@aztec/wallets": "4.0.0-rc.7",
|
|
63
|
+
"@aztec/world-state": "4.0.0-rc.7",
|
|
64
64
|
"@types/chalk": "^2.2.0",
|
|
65
65
|
"abitype": "^0.8.11",
|
|
66
66
|
"chalk": "^5.3.0",
|
|
@@ -37,11 +37,11 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
37
37
|
l1RpcUrls: options.l1RpcUrls,
|
|
38
38
|
testAccounts: localNetwork.testAccounts,
|
|
39
39
|
realProofs: false,
|
|
40
|
-
// Setting the epoch duration to
|
|
40
|
+
// Setting the epoch duration to 2 by default for local network. This allows the epoch to be "proven" faster, so
|
|
41
41
|
// the users can consume out hash without having to wait for a long time.
|
|
42
42
|
// Note: We are not proving anything in the local network (realProofs == false). But in `createLocalNetwork`,
|
|
43
43
|
// the EpochTestSettler will set the out hash to the outbox when an epoch is complete.
|
|
44
|
-
aztecEpochDuration:
|
|
44
|
+
aztecEpochDuration: 2,
|
|
45
45
|
},
|
|
46
46
|
userLog,
|
|
47
47
|
);
|
|
@@ -18,6 +18,7 @@ import type { LogFn } from '@aztec/foundation/log';
|
|
|
18
18
|
import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
19
19
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
20
20
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
21
|
+
import { SequencerState } from '@aztec/sequencer-client';
|
|
21
22
|
import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
22
23
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
23
24
|
import {
|
|
@@ -181,6 +182,21 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
181
182
|
const blobClient = createBlobClient();
|
|
182
183
|
const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { prefilledPublicData });
|
|
183
184
|
|
|
185
|
+
// Now that the node is up, let the watcher check for pending txs so it can skip unfilled slots faster when
|
|
186
|
+
// transactions are waiting in the mempool. Also let it check if the sequencer is actively building, to avoid
|
|
187
|
+
// warping time out from under an in-progress block.
|
|
188
|
+
watcher?.setGetPendingTxCount(() => node.getPendingTxCount());
|
|
189
|
+
const sequencer = node.getSequencer()?.getSequencer();
|
|
190
|
+
if (sequencer) {
|
|
191
|
+
const idleStates: Set<string> = new Set([
|
|
192
|
+
SequencerState.STOPPED,
|
|
193
|
+
SequencerState.STOPPING,
|
|
194
|
+
SequencerState.IDLE,
|
|
195
|
+
SequencerState.SYNCHRONIZING,
|
|
196
|
+
]);
|
|
197
|
+
watcher?.setIsSequencerBuilding(() => !idleStates.has(sequencer.getState()));
|
|
198
|
+
}
|
|
199
|
+
|
|
184
200
|
let epochTestSettler: EpochTestSettler | undefined;
|
|
185
201
|
if (!aztecNodeConfig.p2pEnabled) {
|
|
186
202
|
epochTestSettler = new EpochTestSettler(
|
|
@@ -31,6 +31,15 @@ export class AnvilTestWatcher {
|
|
|
31
31
|
|
|
32
32
|
private isMarkingAsProven = true;
|
|
33
33
|
|
|
34
|
+
// Optional callback to check if there are pending txs in the mempool.
|
|
35
|
+
private getPendingTxCount?: () => Promise<number>;
|
|
36
|
+
|
|
37
|
+
// Optional callback to check if the sequencer is actively building a block.
|
|
38
|
+
private isSequencerBuilding?: () => boolean;
|
|
39
|
+
|
|
40
|
+
// Tracks when we first observed the current unfilled slot with pending txs (real wall time).
|
|
41
|
+
private unfilledSlotFirstSeen?: { slot: number; realTime: number };
|
|
42
|
+
|
|
34
43
|
constructor(
|
|
35
44
|
private cheatcodes: EthCheatCodes,
|
|
36
45
|
rollupAddress: EthAddress,
|
|
@@ -59,6 +68,16 @@ export class AnvilTestWatcher {
|
|
|
59
68
|
this.isLocalNetwork = isLocalNetwork;
|
|
60
69
|
}
|
|
61
70
|
|
|
71
|
+
/** Sets a callback to check for pending txs, used to skip unfilled slots faster when txs are waiting. */
|
|
72
|
+
setGetPendingTxCount(fn: () => Promise<number>) {
|
|
73
|
+
this.getPendingTxCount = fn;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Sets a callback to check if the sequencer is actively building, to avoid warping while it works. */
|
|
77
|
+
setIsSequencerBuilding(fn: () => boolean) {
|
|
78
|
+
this.isSequencerBuilding = fn;
|
|
79
|
+
}
|
|
80
|
+
|
|
62
81
|
async start() {
|
|
63
82
|
if (this.filledRunningPromise) {
|
|
64
83
|
throw new Error('Watcher already watching for filled slot');
|
|
@@ -131,15 +150,8 @@ export class AnvilTestWatcher {
|
|
|
131
150
|
const nextSlotTimestamp = Number(await this.rollup.read.getTimestampForSlot([BigInt(nextSlot)]));
|
|
132
151
|
|
|
133
152
|
if (BigInt(currentSlot) === checkpointLog.slotNumber) {
|
|
134
|
-
//
|
|
135
|
-
|
|
136
|
-
await this.cheatcodes.warp(nextSlotTimestamp, {
|
|
137
|
-
resetBlockInterval: true,
|
|
138
|
-
});
|
|
139
|
-
} catch (e) {
|
|
140
|
-
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
141
|
-
}
|
|
142
|
-
|
|
153
|
+
// The current slot has been filled, we should jump to the next slot.
|
|
154
|
+
await this.warpToTimestamp(nextSlotTimestamp);
|
|
143
155
|
this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
|
|
144
156
|
return;
|
|
145
157
|
}
|
|
@@ -149,18 +161,50 @@ export class AnvilTestWatcher {
|
|
|
149
161
|
return;
|
|
150
162
|
}
|
|
151
163
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
164
|
+
// If there are pending txs and the sequencer missed them, warp quickly (after a 2s real-time debounce) so the
|
|
165
|
+
// sequencer can retry in the next slot. Without this, we'd have to wait a full real-time slot duration (~36s) for
|
|
166
|
+
// the dateProvider to catch up to the next slot timestamp. We skip the warp if the sequencer is actively building
|
|
167
|
+
// to avoid invalidating its in-progress work.
|
|
168
|
+
if (this.getPendingTxCount) {
|
|
169
|
+
const pendingTxs = await this.getPendingTxCount();
|
|
170
|
+
if (pendingTxs > 0) {
|
|
171
|
+
if (this.isSequencerBuilding?.()) {
|
|
172
|
+
this.unfilledSlotFirstSeen = undefined;
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const realNow = Date.now();
|
|
177
|
+
if (!this.unfilledSlotFirstSeen || this.unfilledSlotFirstSeen.slot !== currentSlot) {
|
|
178
|
+
this.unfilledSlotFirstSeen = { slot: currentSlot, realTime: realNow };
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (realNow - this.unfilledSlotFirstSeen.realTime > 2000) {
|
|
183
|
+
await this.warpToTimestamp(nextSlotTimestamp);
|
|
184
|
+
this.unfilledSlotFirstSeen = undefined;
|
|
185
|
+
this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return;
|
|
158
189
|
}
|
|
190
|
+
}
|
|
159
191
|
|
|
192
|
+
// Fallback: warp when the dateProvider time has passed the next slot timestamp.
|
|
193
|
+
const currentTimestamp = this.dateProvider?.now() ?? Date.now();
|
|
194
|
+
if (currentTimestamp > nextSlotTimestamp * 1000) {
|
|
195
|
+
await this.warpToTimestamp(nextSlotTimestamp);
|
|
160
196
|
this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
|
|
161
197
|
}
|
|
162
198
|
} catch {
|
|
163
199
|
this.logger.error('mineIfSlotFilled failed');
|
|
164
200
|
}
|
|
165
201
|
}
|
|
202
|
+
|
|
203
|
+
private async warpToTimestamp(timestamp: number) {
|
|
204
|
+
try {
|
|
205
|
+
await this.cheatcodes.warp(timestamp, { resetBlockInterval: true });
|
|
206
|
+
} catch (e) {
|
|
207
|
+
this.logger.error(`Failed to warp to timestamp ${timestamp}: ${e}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
166
210
|
}
|