@aztec/sequencer-client 0.0.0-test.1 → 0.0.1-commit.b655e406
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/client/sequencer-client.d.ts +25 -25
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +65 -51
- package/dest/config.d.ts +6 -14
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +50 -54
- package/dest/global_variable_builder/global_builder.d.ts +11 -6
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +39 -34
- package/dest/index.d.ts +1 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -2
- package/dest/publisher/config.d.ts +6 -8
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +19 -17
- package/dest/publisher/index.d.ts +2 -0
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/index.js +3 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +43 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -0
- package/dest/publisher/sequencer-publisher-factory.js +51 -0
- package/dest/publisher/sequencer-publisher-metrics.d.ts +2 -1
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +37 -2
- package/dest/publisher/sequencer-publisher.d.ts +102 -69
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +606 -212
- package/dest/sequencer/block_builder.d.ts +27 -0
- package/dest/sequencer/block_builder.d.ts.map +1 -0
- package/dest/sequencer/block_builder.js +130 -0
- package/dest/sequencer/config.d.ts +5 -0
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/errors.d.ts +11 -0
- package/dest/sequencer/errors.d.ts.map +1 -0
- package/dest/sequencer/errors.js +15 -0
- package/dest/sequencer/index.d.ts +1 -1
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +1 -1
- package/dest/sequencer/metrics.d.ts +18 -11
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +84 -50
- package/dest/sequencer/sequencer.d.ts +120 -81
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +589 -359
- package/dest/sequencer/timetable.d.ts +32 -20
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +57 -30
- package/dest/sequencer/utils.d.ts +11 -35
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +9 -47
- package/dest/test/index.d.ts +7 -0
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +0 -4
- package/dest/tx_validator/nullifier_cache.d.ts +0 -2
- package/dest/tx_validator/nullifier_cache.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.d.ts +9 -10
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.js +27 -24
- package/package.json +42 -43
- package/src/client/sequencer-client.ts +94 -84
- package/src/config.ts +57 -61
- package/src/global_variable_builder/global_builder.ts +44 -23
- package/src/index.ts +6 -2
- package/src/publisher/config.ts +26 -24
- package/src/publisher/index.ts +4 -0
- package/src/publisher/sequencer-publisher-factory.ts +90 -0
- package/src/publisher/sequencer-publisher-metrics.ts +24 -2
- package/src/publisher/sequencer-publisher.ts +729 -235
- package/src/sequencer/block_builder.ts +218 -0
- package/src/sequencer/config.ts +7 -0
- package/src/sequencer/errors.ts +21 -0
- package/src/sequencer/index.ts +1 -1
- package/src/sequencer/metrics.ts +109 -55
- package/src/sequencer/sequencer.ts +766 -415
- package/src/sequencer/timetable.ts +98 -33
- package/src/sequencer/utils.ts +17 -58
- package/src/test/index.ts +11 -4
- package/src/tx_validator/tx_validator_factory.ts +44 -32
- package/dest/sequencer/allowed.d.ts +0 -3
- package/dest/sequencer/allowed.d.ts.map +0 -1
- package/dest/sequencer/allowed.js +0 -27
- package/dest/slasher/factory.d.ts +0 -7
- package/dest/slasher/factory.d.ts.map +0 -1
- package/dest/slasher/factory.js +0 -8
- package/dest/slasher/index.d.ts +0 -3
- package/dest/slasher/index.d.ts.map +0 -1
- package/dest/slasher/index.js +0 -2
- package/dest/slasher/slasher_client.d.ts +0 -75
- package/dest/slasher/slasher_client.d.ts.map +0 -1
- package/dest/slasher/slasher_client.js +0 -132
- package/dest/tx_validator/archive_cache.d.ts +0 -14
- package/dest/tx_validator/archive_cache.d.ts.map +0 -1
- package/dest/tx_validator/archive_cache.js +0 -22
- package/dest/tx_validator/gas_validator.d.ts +0 -14
- package/dest/tx_validator/gas_validator.d.ts.map +0 -1
- package/dest/tx_validator/gas_validator.js +0 -78
- package/dest/tx_validator/phases_validator.d.ts +0 -12
- package/dest/tx_validator/phases_validator.d.ts.map +0 -1
- package/dest/tx_validator/phases_validator.js +0 -80
- package/dest/tx_validator/test_utils.d.ts +0 -23
- package/dest/tx_validator/test_utils.d.ts.map +0 -1
- package/dest/tx_validator/test_utils.js +0 -26
- package/src/sequencer/allowed.ts +0 -36
- package/src/slasher/factory.ts +0 -15
- package/src/slasher/index.ts +0 -2
- package/src/slasher/slasher_client.ts +0 -193
- package/src/tx_validator/archive_cache.ts +0 -28
- package/src/tx_validator/gas_validator.ts +0 -101
- package/src/tx_validator/phases_validator.ts +0 -98
- package/src/tx_validator/test_utils.ts +0 -48
|
@@ -1,38 +1,50 @@
|
|
|
1
1
|
import type { SequencerMetrics } from './metrics.js';
|
|
2
2
|
import { SequencerState } from './utils.js';
|
|
3
3
|
export declare class SequencerTimetable {
|
|
4
|
-
private readonly ethereumSlotDuration;
|
|
5
|
-
private readonly aztecSlotDuration;
|
|
6
|
-
private readonly maxL1TxInclusionTimeIntoSlot;
|
|
7
|
-
private readonly enforce;
|
|
8
4
|
private readonly metrics?;
|
|
9
5
|
private readonly log;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
readonly
|
|
16
|
-
/** How much time we spend validating and processing a block after building it, and assembling the proposal to send to attestors */
|
|
17
|
-
readonly blockValidationTime = 1;
|
|
6
|
+
/**
|
|
7
|
+
* How late into the slot can we be to start working. Computed as the total time needed for assembling and publishing a block,
|
|
8
|
+
* assuming an execution time equal to `minExecutionTime`, subtracted from the slot duration. This means that, if the proposer
|
|
9
|
+
* starts building at this time, and all times hold, it will have at least `minExecutionTime` to execute txs for the block.
|
|
10
|
+
*/
|
|
11
|
+
readonly initializeDeadline: number;
|
|
18
12
|
/**
|
|
19
13
|
* How long it takes to get a published block into L1. L1 builders typically accept txs up to 4 seconds into their slot,
|
|
20
14
|
* but we'll timeout sooner to give it more time to propagate (remember we also have blobs!). Still, when working in anvil,
|
|
21
15
|
* we can just post in the very last second of the L1 slot and still expect the tx to be accepted.
|
|
22
16
|
*/
|
|
23
17
|
readonly l1PublishingTime: number;
|
|
24
|
-
|
|
18
|
+
/** What's the minimum time we want to leave available for execution and reexecution (used to derive init deadline) */
|
|
19
|
+
readonly minExecutionTime: number;
|
|
20
|
+
/** How long it takes to get ready to start building */
|
|
21
|
+
readonly blockPrepareTime: number;
|
|
22
|
+
/** How long it takes to for proposals and attestations to travel across the p2p layer (one-way) */
|
|
23
|
+
readonly attestationPropagationTime: number;
|
|
24
|
+
/** How much time we spend validating and processing a block after building it, and assembling the proposal to send to attestors */
|
|
25
|
+
readonly blockValidationTime: number;
|
|
26
|
+
/** Ethereum slot duration in seconds */
|
|
27
|
+
readonly ethereumSlotDuration: number;
|
|
28
|
+
/** Aztec slot duration in seconds (must be multiple of ethereum slot duration) */
|
|
29
|
+
readonly aztecSlotDuration: number;
|
|
30
|
+
/** How late into an L1 slot we can send a tx to make sure it gets included in the immediate next block. Complement of l1PublishingTime. */
|
|
31
|
+
readonly maxL1TxInclusionTimeIntoSlot: number;
|
|
32
|
+
/** Whether assertTimeLeft will throw if not enough time. */
|
|
33
|
+
readonly enforce: boolean;
|
|
34
|
+
constructor(opts: {
|
|
35
|
+
ethereumSlotDuration: number;
|
|
36
|
+
aztecSlotDuration: number;
|
|
37
|
+
maxL1TxInclusionTimeIntoSlot: number;
|
|
38
|
+
attestationPropagationTime?: number;
|
|
39
|
+
enforce: boolean;
|
|
40
|
+
}, metrics?: SequencerMetrics | undefined, log?: import("@aztec/aztec.js/log").Logger);
|
|
25
41
|
private get afterBlockBuildingTimeNeededWithoutReexec();
|
|
26
42
|
getBlockProposalExecTimeEnd(secondsIntoSlot: number): number;
|
|
27
43
|
private get afterBlockReexecTimeNeeded();
|
|
28
|
-
getValidatorReexecTimeEnd(secondsIntoSlot
|
|
44
|
+
getValidatorReexecTimeEnd(secondsIntoSlot?: number): number;
|
|
45
|
+
getMaxAllowedTime(state: Extract<SequencerState, SequencerState.STOPPED | SequencerState.IDLE | SequencerState.SYNCHRONIZING>): undefined;
|
|
46
|
+
getMaxAllowedTime(state: Exclude<SequencerState, SequencerState.STOPPED | SequencerState.IDLE | SequencerState.SYNCHRONIZING>): number;
|
|
29
47
|
getMaxAllowedTime(state: SequencerState): number | undefined;
|
|
30
48
|
assertTimeLeft(newState: SequencerState, secondsIntoSlot: number): void;
|
|
31
49
|
}
|
|
32
|
-
export declare class SequencerTooSlowError extends Error {
|
|
33
|
-
readonly proposedState: SequencerState;
|
|
34
|
-
readonly maxAllowedTime: number;
|
|
35
|
-
readonly currentTime: number;
|
|
36
|
-
constructor(proposedState: SequencerState, maxAllowedTime: number, currentTime: number);
|
|
37
|
-
}
|
|
38
50
|
//# sourceMappingURL=timetable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timetable.d.ts","sourceRoot":"","sources":["../../src/sequencer/timetable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"timetable.d.ts","sourceRoot":"","sources":["../../src/sequencer/timetable.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAM5C,qBAAa,kBAAkB;IA+C3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,GAAG;IA/CtB;;;;OAIG;IACH,SAAgB,kBAAkB,EAAE,MAAM,CAAC;IAE3C;;;;OAIG;IACH,SAAgB,gBAAgB,SAAC;IAEjC,sHAAsH;IACtH,SAAgB,gBAAgB,EAAE,MAAM,CAAsB;IAE9D,uDAAuD;IACvD,SAAgB,gBAAgB,EAAE,MAAM,CAAsB;IAE9D,mGAAmG;IACnG,SAAgB,0BAA0B,EAAE,MAAM,CAAC;IAEnD,mIAAmI;IACnI,SAAgB,mBAAmB,EAAE,MAAM,CAAyB;IAEpE,wCAAwC;IACxC,SAAgB,oBAAoB,EAAE,MAAM,CAAC;IAE7C,kFAAkF;IAClF,SAAgB,iBAAiB,EAAE,MAAM,CAAC;IAE1C,2IAA2I;IAC3I,SAAgB,4BAA4B,EAAE,MAAM,CAAC;IAErD,4DAA4D;IAC5D,SAAgB,OAAO,EAAE,OAAO,CAAC;gBAG/B,IAAI,EAAE;QACJ,oBAAoB,EAAE,MAAM,CAAC;QAC7B,iBAAiB,EAAE,MAAM,CAAC;QAC1B,4BAA4B,EAAE,MAAM,CAAC;QACrC,0BAA0B,CAAC,EAAE,MAAM,CAAC;QACpC,OAAO,EAAE,OAAO,CAAC;KAClB,EACgB,OAAO,CAAC,EAAE,gBAAgB,YAAA,EAC1B,GAAG,uCAAsC;IA+C5D,OAAO,KAAK,yCAAyC,GAEpD;IAEM,2BAA2B,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM;IAenE,OAAO,KAAK,0BAA0B,GAErC;IAEM,yBAAyB,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM;IAU3D,iBAAiB,CACtB,KAAK,EAAE,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,OAAO,GAAG,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,aAAa,CAAC,GAC1G,SAAS;IACL,iBAAiB,CACtB,KAAK,EAAE,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,OAAO,GAAG,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,aAAa,CAAC,GAC1G,MAAM;IACF,iBAAiB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS;IAwB5D,cAAc,CAAC,QAAQ,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM;CAkBxE"}
|
|
@@ -1,33 +1,68 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/aztec.js';
|
|
1
|
+
import { createLogger } from '@aztec/aztec.js/log';
|
|
2
|
+
import { DEFAULT_ATTESTATION_PROPAGATION_TIME } from '../config.js';
|
|
3
|
+
import { SequencerTooSlowError } from './errors.js';
|
|
2
4
|
import { SequencerState } from './utils.js';
|
|
5
|
+
const MIN_EXECUTION_TIME = 1;
|
|
6
|
+
const BLOCK_PREPARE_TIME = 1;
|
|
7
|
+
const BLOCK_VALIDATION_TIME = 1;
|
|
3
8
|
export class SequencerTimetable {
|
|
4
|
-
ethereumSlotDuration;
|
|
5
|
-
aztecSlotDuration;
|
|
6
|
-
maxL1TxInclusionTimeIntoSlot;
|
|
7
|
-
enforce;
|
|
8
9
|
metrics;
|
|
9
10
|
log;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
/**
|
|
12
|
+
* How late into the slot can we be to start working. Computed as the total time needed for assembling and publishing a block,
|
|
13
|
+
* assuming an execution time equal to `minExecutionTime`, subtracted from the slot duration. This means that, if the proposer
|
|
14
|
+
* starts building at this time, and all times hold, it will have at least `minExecutionTime` to execute txs for the block.
|
|
15
|
+
*/ initializeDeadline;
|
|
14
16
|
/**
|
|
15
17
|
* How long it takes to get a published block into L1. L1 builders typically accept txs up to 4 seconds into their slot,
|
|
16
18
|
* but we'll timeout sooner to give it more time to propagate (remember we also have blobs!). Still, when working in anvil,
|
|
17
19
|
* we can just post in the very last second of the L1 slot and still expect the tx to be accepted.
|
|
18
20
|
*/ l1PublishingTime;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
/** What's the minimum time we want to leave available for execution and reexecution (used to derive init deadline) */ minExecutionTime;
|
|
22
|
+
/** How long it takes to get ready to start building */ blockPrepareTime;
|
|
23
|
+
/** How long it takes to for proposals and attestations to travel across the p2p layer (one-way) */ attestationPropagationTime;
|
|
24
|
+
/** How much time we spend validating and processing a block after building it, and assembling the proposal to send to attestors */ blockValidationTime;
|
|
25
|
+
/** Ethereum slot duration in seconds */ ethereumSlotDuration;
|
|
26
|
+
/** Aztec slot duration in seconds (must be multiple of ethereum slot duration) */ aztecSlotDuration;
|
|
27
|
+
/** How late into an L1 slot we can send a tx to make sure it gets included in the immediate next block. Complement of l1PublishingTime. */ maxL1TxInclusionTimeIntoSlot;
|
|
28
|
+
/** Whether assertTimeLeft will throw if not enough time. */ enforce;
|
|
29
|
+
constructor(opts, metrics, log = createLogger('sequencer:timetable')){
|
|
24
30
|
this.metrics = metrics;
|
|
25
31
|
this.log = log;
|
|
26
|
-
this.
|
|
27
|
-
this.blockPrepareTime =
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
32
|
+
this.minExecutionTime = MIN_EXECUTION_TIME;
|
|
33
|
+
this.blockPrepareTime = BLOCK_PREPARE_TIME;
|
|
34
|
+
this.blockValidationTime = BLOCK_VALIDATION_TIME;
|
|
35
|
+
this.ethereumSlotDuration = opts.ethereumSlotDuration;
|
|
36
|
+
this.aztecSlotDuration = opts.aztecSlotDuration;
|
|
37
|
+
this.maxL1TxInclusionTimeIntoSlot = opts.maxL1TxInclusionTimeIntoSlot;
|
|
38
|
+
this.attestationPropagationTime = opts.attestationPropagationTime ?? DEFAULT_ATTESTATION_PROPAGATION_TIME;
|
|
30
39
|
this.l1PublishingTime = this.ethereumSlotDuration - this.maxL1TxInclusionTimeIntoSlot;
|
|
40
|
+
this.enforce = opts.enforce;
|
|
41
|
+
// Assume zero-cost propagation time and faster runs in test environments where L1 slot duration is shortened
|
|
42
|
+
if (this.ethereumSlotDuration < 8) {
|
|
43
|
+
this.attestationPropagationTime = 0;
|
|
44
|
+
this.blockValidationTime = 0.5;
|
|
45
|
+
this.blockPrepareTime = 0.5;
|
|
46
|
+
}
|
|
47
|
+
const allWorkToDo = this.blockPrepareTime + this.minExecutionTime * 2 + this.attestationPropagationTime * 2 + this.blockValidationTime + this.l1PublishingTime;
|
|
48
|
+
const initializeDeadline = this.aztecSlotDuration - allWorkToDo;
|
|
49
|
+
this.initializeDeadline = initializeDeadline;
|
|
50
|
+
this.log.verbose(`Sequencer timetable initialized (${this.enforce ? 'enforced' : 'not enforced'})`, {
|
|
51
|
+
ethereumSlotDuration: this.ethereumSlotDuration,
|
|
52
|
+
aztecSlotDuration: this.aztecSlotDuration,
|
|
53
|
+
maxL1TxInclusionTimeIntoSlot: this.maxL1TxInclusionTimeIntoSlot,
|
|
54
|
+
l1PublishingTime: this.l1PublishingTime,
|
|
55
|
+
minExecutionTime: this.minExecutionTime,
|
|
56
|
+
blockPrepareTime: this.blockPrepareTime,
|
|
57
|
+
attestationPropagationTime: this.attestationPropagationTime,
|
|
58
|
+
blockValidationTime: this.blockValidationTime,
|
|
59
|
+
initializeDeadline: this.initializeDeadline,
|
|
60
|
+
enforce: this.enforce,
|
|
61
|
+
allWorkToDo
|
|
62
|
+
});
|
|
63
|
+
if (initializeDeadline <= 0) {
|
|
64
|
+
throw new Error(`Block proposal initialize deadline cannot be negative (got ${initializeDeadline} from total time needed ${allWorkToDo} and a slot duration of ${this.aztecSlotDuration}).`);
|
|
65
|
+
}
|
|
31
66
|
}
|
|
32
67
|
get afterBlockBuildingTimeNeededWithoutReexec() {
|
|
33
68
|
return this.blockValidationTime + this.attestationPropagationTime * 2 + this.l1PublishingTime;
|
|
@@ -61,14 +96,15 @@ export class SequencerTimetable {
|
|
|
61
96
|
getMaxAllowedTime(state) {
|
|
62
97
|
switch(state){
|
|
63
98
|
case SequencerState.STOPPED:
|
|
99
|
+
case SequencerState.STOPPING:
|
|
64
100
|
case SequencerState.IDLE:
|
|
65
101
|
case SequencerState.SYNCHRONIZING:
|
|
66
|
-
case SequencerState.PROPOSER_CHECK:
|
|
67
102
|
return; // We don't really care about times for this states
|
|
103
|
+
case SequencerState.PROPOSER_CHECK:
|
|
68
104
|
case SequencerState.INITIALIZING_PROPOSAL:
|
|
69
|
-
return this.
|
|
105
|
+
return this.initializeDeadline;
|
|
70
106
|
case SequencerState.CREATING_BLOCK:
|
|
71
|
-
return this.
|
|
107
|
+
return this.initializeDeadline + this.blockPrepareTime;
|
|
72
108
|
case SequencerState.COLLECTING_ATTESTATIONS:
|
|
73
109
|
return this.aztecSlotDuration - this.l1PublishingTime - 2 * this.attestationPropagationTime;
|
|
74
110
|
case SequencerState.PUBLISHING_BLOCK:
|
|
@@ -99,12 +135,3 @@ export class SequencerTimetable {
|
|
|
99
135
|
});
|
|
100
136
|
}
|
|
101
137
|
}
|
|
102
|
-
export class SequencerTooSlowError extends Error {
|
|
103
|
-
proposedState;
|
|
104
|
-
maxAllowedTime;
|
|
105
|
-
currentTime;
|
|
106
|
-
constructor(proposedState, maxAllowedTime, currentTime){
|
|
107
|
-
super(`Too far into slot for ${proposedState} (time into slot ${currentTime}s greater than ${maxAllowedTime}s allowance)`), this.proposedState = proposedState, this.maxAllowedTime = maxAllowedTime, this.currentTime = currentTime;
|
|
108
|
-
this.name = 'SequencerTooSlowError';
|
|
109
|
-
}
|
|
110
|
-
}
|
|
@@ -1,48 +1,24 @@
|
|
|
1
|
-
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
-
import { Signature } from '@aztec/foundation/eth-signature';
|
|
3
|
-
import type { BlockAttestation } from '@aztec/stdlib/p2p';
|
|
4
1
|
export declare enum SequencerState {
|
|
5
|
-
/**
|
|
6
|
-
* Sequencer is stopped and not processing any txs from the pool.
|
|
7
|
-
*/
|
|
2
|
+
/** Sequencer is stopped and not processing any txs from the pool. */
|
|
8
3
|
STOPPED = "STOPPED",
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
/** Sequencer is being stopped. Will move to STOPPED shortly. */
|
|
5
|
+
STOPPING = "STOPPING",
|
|
6
|
+
/** Sequencer is awaiting the next call to work(). */
|
|
12
7
|
IDLE = "IDLE",
|
|
13
|
-
/**
|
|
14
|
-
* Synchronizing with the L2 chain.
|
|
15
|
-
*/
|
|
8
|
+
/** Synchronizing with the L2 chain. */
|
|
16
9
|
SYNCHRONIZING = "SYNCHRONIZING",
|
|
17
|
-
/**
|
|
18
|
-
* Checking if we are the proposer for the current slot.
|
|
19
|
-
*/
|
|
10
|
+
/** Checking if we are the proposer for the current slot. */
|
|
20
11
|
PROPOSER_CHECK = "PROPOSER_CHECK",
|
|
21
|
-
/**
|
|
22
|
-
* Initializing the block proposal. Will move to CREATING_BLOCK if there are valid txs to include, or back to SYNCHRONIZING otherwise.
|
|
23
|
-
*/
|
|
12
|
+
/** Initializing the block proposal. Will move to CREATING_BLOCK if there are valid txs to include, or back to SYNCHRONIZING otherwise. */
|
|
24
13
|
INITIALIZING_PROPOSAL = "INITIALIZING_PROPOSAL",
|
|
25
|
-
/**
|
|
26
|
-
* Creating a new L2 block. Includes processing public function calls and running rollup circuits. Will move to PUBLISHING_CONTRACT_DATA.
|
|
27
|
-
*/
|
|
14
|
+
/** Creating a new L2 block. Includes processing public function calls and running rollup circuits. Will move to PUBLISHING_CONTRACT_DATA. */
|
|
28
15
|
CREATING_BLOCK = "CREATING_BLOCK",
|
|
29
|
-
/**
|
|
30
|
-
* Collecting attestations from its peers. Will move to PUBLISHING_BLOCK.
|
|
31
|
-
*/
|
|
16
|
+
/** Collecting attestations from its peers. Will move to PUBLISHING_BLOCK. */
|
|
32
17
|
COLLECTING_ATTESTATIONS = "COLLECTING_ATTESTATIONS",
|
|
33
|
-
/**
|
|
34
|
-
* Sending the tx to L1 with the L2 block data and awaiting it to be mined. Will move to SYNCHRONIZING.
|
|
35
|
-
*/
|
|
18
|
+
/** Sending the tx to L1 with the L2 block data and awaiting it to be mined. Will move to SYNCHRONIZING. */
|
|
36
19
|
PUBLISHING_BLOCK = "PUBLISHING_BLOCK"
|
|
37
20
|
}
|
|
21
|
+
export type SequencerStateWithSlot = SequencerState.INITIALIZING_PROPOSAL | SequencerState.CREATING_BLOCK | SequencerState.COLLECTING_ATTESTATIONS | SequencerState.PUBLISHING_BLOCK | SequencerState.PROPOSER_CHECK;
|
|
38
22
|
export type SequencerStateCallback = () => SequencerState;
|
|
39
23
|
export declare function sequencerStateToNumber(state: SequencerState): number;
|
|
40
|
-
/** Order Attestations
|
|
41
|
-
*
|
|
42
|
-
* Returns attestation signatures in the order of a series of provided ethereum addresses
|
|
43
|
-
* The rollup smart contract expects attestations to appear in the order of the committee
|
|
44
|
-
*
|
|
45
|
-
* @todo: perform this logic within the memory attestation store instead?
|
|
46
|
-
*/
|
|
47
|
-
export declare function orderAttestations(attestations: BlockAttestation[], orderAddresses: EthAddress[]): Promise<Signature[]>;
|
|
48
24
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/sequencer/utils.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/sequencer/utils.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACxB,qEAAqE;IACrE,OAAO,YAAY;IACnB,gEAAgE;IAChE,QAAQ,aAAa;IACrB,qDAAqD;IACrD,IAAI,SAAS;IACb,uCAAuC;IACvC,aAAa,kBAAkB;IAC/B,4DAA4D;IAC5D,cAAc,mBAAmB;IACjC,0IAA0I;IAC1I,qBAAqB,0BAA0B;IAC/C,6IAA6I;IAC7I,cAAc,mBAAmB;IACjC,6EAA6E;IAC7E,uBAAuB,4BAA4B;IACnD,2GAA2G;IAC3G,gBAAgB,qBAAqB;CACtC;AAED,MAAM,MAAM,sBAAsB,GAC9B,cAAc,CAAC,qBAAqB,GACpC,cAAc,CAAC,cAAc,GAC7B,cAAc,CAAC,uBAAuB,GACtC,cAAc,CAAC,gBAAgB,GAC/B,cAAc,CAAC,cAAc,CAAC;AAElC,MAAM,MAAM,sBAAsB,GAAG,MAAM,cAAc,CAAC;AAE1D,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAEpE"}
|
package/dest/sequencer/utils.js
CHANGED
|
@@ -1,53 +1,15 @@
|
|
|
1
|
-
import { Signature } from '@aztec/foundation/eth-signature';
|
|
2
1
|
export var SequencerState = /*#__PURE__*/ function(SequencerState) {
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Checking if we are the proposer for the current slot.
|
|
14
|
-
*/ SequencerState["PROPOSER_CHECK"] = "PROPOSER_CHECK";
|
|
15
|
-
/**
|
|
16
|
-
* Initializing the block proposal. Will move to CREATING_BLOCK if there are valid txs to include, or back to SYNCHRONIZING otherwise.
|
|
17
|
-
*/ SequencerState["INITIALIZING_PROPOSAL"] = "INITIALIZING_PROPOSAL";
|
|
18
|
-
/**
|
|
19
|
-
* Creating a new L2 block. Includes processing public function calls and running rollup circuits. Will move to PUBLISHING_CONTRACT_DATA.
|
|
20
|
-
*/ SequencerState["CREATING_BLOCK"] = "CREATING_BLOCK";
|
|
21
|
-
/**
|
|
22
|
-
* Collecting attestations from its peers. Will move to PUBLISHING_BLOCK.
|
|
23
|
-
*/ SequencerState["COLLECTING_ATTESTATIONS"] = "COLLECTING_ATTESTATIONS";
|
|
24
|
-
/**
|
|
25
|
-
* Sending the tx to L1 with the L2 block data and awaiting it to be mined. Will move to SYNCHRONIZING.
|
|
26
|
-
*/ SequencerState["PUBLISHING_BLOCK"] = "PUBLISHING_BLOCK";
|
|
2
|
+
/** Sequencer is stopped and not processing any txs from the pool. */ SequencerState["STOPPED"] = "STOPPED";
|
|
3
|
+
/** Sequencer is being stopped. Will move to STOPPED shortly. */ SequencerState["STOPPING"] = "STOPPING";
|
|
4
|
+
/** Sequencer is awaiting the next call to work(). */ SequencerState["IDLE"] = "IDLE";
|
|
5
|
+
/** Synchronizing with the L2 chain. */ SequencerState["SYNCHRONIZING"] = "SYNCHRONIZING";
|
|
6
|
+
/** Checking if we are the proposer for the current slot. */ SequencerState["PROPOSER_CHECK"] = "PROPOSER_CHECK";
|
|
7
|
+
/** Initializing the block proposal. Will move to CREATING_BLOCK if there are valid txs to include, or back to SYNCHRONIZING otherwise. */ SequencerState["INITIALIZING_PROPOSAL"] = "INITIALIZING_PROPOSAL";
|
|
8
|
+
/** Creating a new L2 block. Includes processing public function calls and running rollup circuits. Will move to PUBLISHING_CONTRACT_DATA. */ SequencerState["CREATING_BLOCK"] = "CREATING_BLOCK";
|
|
9
|
+
/** Collecting attestations from its peers. Will move to PUBLISHING_BLOCK. */ SequencerState["COLLECTING_ATTESTATIONS"] = "COLLECTING_ATTESTATIONS";
|
|
10
|
+
/** Sending the tx to L1 with the L2 block data and awaiting it to be mined. Will move to SYNCHRONIZING. */ SequencerState["PUBLISHING_BLOCK"] = "PUBLISHING_BLOCK";
|
|
27
11
|
return SequencerState;
|
|
28
12
|
}({});
|
|
29
13
|
export function sequencerStateToNumber(state) {
|
|
30
14
|
return Object.values(SequencerState).indexOf(state);
|
|
31
15
|
}
|
|
32
|
-
/** Order Attestations
|
|
33
|
-
*
|
|
34
|
-
* Returns attestation signatures in the order of a series of provided ethereum addresses
|
|
35
|
-
* The rollup smart contract expects attestations to appear in the order of the committee
|
|
36
|
-
*
|
|
37
|
-
* @todo: perform this logic within the memory attestation store instead?
|
|
38
|
-
*/ export async function orderAttestations(attestations, orderAddresses) {
|
|
39
|
-
// Create a map of sender addresses to BlockAttestations
|
|
40
|
-
const attestationMap = new Map();
|
|
41
|
-
for (const attestation of attestations){
|
|
42
|
-
const sender = await attestation.getSender();
|
|
43
|
-
if (sender) {
|
|
44
|
-
attestationMap.set(sender.toString(), attestation);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
// Create the ordered array based on the orderAddresses, else return an empty signature
|
|
48
|
-
const orderedAttestations = orderAddresses.map((address)=>{
|
|
49
|
-
const addressString = address.toString();
|
|
50
|
-
return attestationMap.get(addressString)?.signature || Signature.empty();
|
|
51
|
-
});
|
|
52
|
-
return orderedAttestations;
|
|
53
|
-
}
|
package/dest/test/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type { PublisherManager } from '@aztec/ethereum';
|
|
2
|
+
import type { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
|
|
1
3
|
import type { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
4
|
+
import type { ValidatorClient } from '@aztec/validator-client';
|
|
2
5
|
import { SequencerClient } from '../client/sequencer-client.js';
|
|
6
|
+
import type { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
|
|
3
7
|
import type { SequencerPublisher } from '../publisher/sequencer-publisher.js';
|
|
4
8
|
import { Sequencer } from '../sequencer/sequencer.js';
|
|
5
9
|
import type { SequencerTimetable } from '../sequencer/timetable.js';
|
|
@@ -7,10 +11,13 @@ declare class TestSequencer_ extends Sequencer {
|
|
|
7
11
|
publicProcessorFactory: PublicProcessorFactory;
|
|
8
12
|
timetable: SequencerTimetable;
|
|
9
13
|
publisher: SequencerPublisher;
|
|
14
|
+
publisherFactory: SequencerPublisherFactory;
|
|
15
|
+
validatorClient: ValidatorClient;
|
|
10
16
|
}
|
|
11
17
|
export type TestSequencer = TestSequencer_;
|
|
12
18
|
declare class TestSequencerClient_ extends SequencerClient {
|
|
13
19
|
sequencer: TestSequencer;
|
|
20
|
+
publisherManager: PublisherManager<L1TxUtilsWithBlobs>;
|
|
14
21
|
}
|
|
15
22
|
export type TestSequencerClient = TestSequencerClient_;
|
|
16
23
|
export {};
|
package/dest/test/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,cAAM,cAAe,SAAQ,SAAS;IACrB,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,SAAS,EAAE,kBAAkB,CAAC;IAC9B,SAAS,EAAE,kBAAkB,CAAC;IAC9B,gBAAgB,EAAE,yBAAyB,CAAC;IAC5C,eAAe,EAAE,eAAe,CAAC;CACjD;AAED,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC;AAE3C,cAAM,oBAAqB,SAAQ,eAAe;IACjC,SAAS,EAAE,aAAa,CAAC;IACzB,gBAAgB,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;CACvE;AAED,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,CAAC"}
|
package/dest/test/index.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { SequencerClient } from '../client/sequencer-client.js';
|
|
2
2
|
import { Sequencer } from '../sequencer/sequencer.js';
|
|
3
3
|
class TestSequencer_ extends Sequencer {
|
|
4
|
-
publicProcessorFactory;
|
|
5
|
-
timetable;
|
|
6
|
-
publisher;
|
|
7
4
|
}
|
|
8
5
|
class TestSequencerClient_ extends SequencerClient {
|
|
9
|
-
sequencer;
|
|
10
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nullifier_cache.d.ts","sourceRoot":"","sources":["../../src/tx_validator/nullifier_cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nullifier_cache.d.ts","sourceRoot":"","sources":["../../src/tx_validator/nullifier_cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAGhF;;;GAGG;AACH,qBAAa,cAAe,YAAW,eAAe;IAGxC,OAAO,CAAC,EAAE;IAFtB,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;gBAEJ,EAAE,EAAE,wBAAwB;IAInC,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAS/D,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE;CAK1C"}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
2
2
|
import type { GasFees } from '@aztec/stdlib/gas';
|
|
3
|
-
import type { AllowedElement, ClientProtocolCircuitVerifier, MerkleTreeReadOperations } from '@aztec/stdlib/interfaces/server';
|
|
4
|
-
import { GlobalVariables, type
|
|
5
|
-
import {
|
|
6
|
-
export declare function createValidatorForAcceptingTxs(db: MerkleTreeReadOperations, contractDataSource: ContractDataSource, verifier: ClientProtocolCircuitVerifier | undefined, {
|
|
7
|
-
blockNumber: number;
|
|
3
|
+
import type { AllowedElement, ClientProtocolCircuitVerifier, MerkleTreeReadOperations, PublicProcessorValidator } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import { GlobalVariables, type Tx, type TxValidator } from '@aztec/stdlib/tx';
|
|
5
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
6
|
+
export declare function createValidatorForAcceptingTxs(db: MerkleTreeReadOperations, contractDataSource: ContractDataSource, verifier: ClientProtocolCircuitVerifier | undefined, { l1ChainId, rollupVersion, setupAllowList, gasFees, skipFeeEnforcement, timestamp, blockNumber, txsPermitted, }: {
|
|
8
7
|
l1ChainId: number;
|
|
8
|
+
rollupVersion: number;
|
|
9
9
|
setupAllowList: AllowedElement[];
|
|
10
10
|
gasFees: GasFees;
|
|
11
11
|
skipFeeEnforcement?: boolean;
|
|
12
|
+
timestamp: UInt64;
|
|
13
|
+
blockNumber: number;
|
|
14
|
+
txsPermitted: boolean;
|
|
12
15
|
}): TxValidator<Tx>;
|
|
13
|
-
export declare function
|
|
14
|
-
preprocessValidator: TxValidator<Tx>;
|
|
15
|
-
postprocessValidator: TxValidator<ProcessedTx>;
|
|
16
|
-
nullifierCache: NullifierCache;
|
|
17
|
-
};
|
|
16
|
+
export declare function createValidatorForBlockBuilding(db: MerkleTreeReadOperations, contractDataSource: ContractDataSource, globalVariables: GlobalVariables, setupAllowList: AllowedElement[]): PublicProcessorValidator;
|
|
18
17
|
//# sourceMappingURL=tx_validator_factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx_validator_factory.d.ts","sourceRoot":"","sources":["../../src/tx_validator/tx_validator_factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tx_validator_factory.d.ts","sourceRoot":"","sources":["../../src/tx_validator/tx_validator_factory.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EACV,cAAc,EACd,6BAA6B,EAC7B,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,wBAAgB,8BAA8B,CAC5C,EAAE,EAAE,wBAAwB,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,QAAQ,EAAE,6BAA6B,GAAG,SAAS,EACnD,EACE,SAAS,EACT,aAAa,EACb,cAAc,EACd,OAAO,EACP,kBAAkB,EAClB,SAAS,EACT,WAAW,EACX,YAAY,GACb,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,cAAc,EAAE,CAAC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;CACvB,GACA,WAAW,CAAC,EAAE,CAAC,CA4BjB;AAED,wBAAgB,+BAA+B,CAC7C,EAAE,EAAE,wBAAwB,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAAE,GAC/B,wBAAwB,CAgB1B"}
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { GasTxValidator } from './gas_validator.js';
|
|
2
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
3
|
+
import { AggregateTxValidator, ArchiveCache, BlockHeaderTxValidator, DataTxValidator, DoubleSpendTxValidator, GasTxValidator, MetadataTxValidator, PhasesTxValidator, TimestampTxValidator, TxPermittedValidator, TxProofValidator } from '@aztec/p2p';
|
|
4
|
+
import { ProtocolContractAddress, protocolContractsHash } from '@aztec/protocol-contracts';
|
|
5
|
+
import { DatabasePublicStateSource } from '@aztec/stdlib/trees';
|
|
7
6
|
import { NullifierCache } from './nullifier_cache.js';
|
|
8
|
-
|
|
9
|
-
export function createValidatorForAcceptingTxs(db, contractDataSource, verifier, { blockNumber, l1ChainId, setupAllowList, gasFees, skipFeeEnforcement }) {
|
|
7
|
+
export function createValidatorForAcceptingTxs(db, contractDataSource, verifier, { l1ChainId, rollupVersion, setupAllowList, gasFees, skipFeeEnforcement, timestamp, blockNumber, txsPermitted }) {
|
|
10
8
|
const validators = [
|
|
9
|
+
new TxPermittedValidator(txsPermitted),
|
|
11
10
|
new DataTxValidator(),
|
|
12
|
-
new MetadataTxValidator(
|
|
11
|
+
new MetadataTxValidator({
|
|
12
|
+
l1ChainId: new Fr(l1ChainId),
|
|
13
|
+
rollupVersion: new Fr(rollupVersion),
|
|
14
|
+
protocolContractsHash,
|
|
15
|
+
vkTreeRoot: getVKTreeRoot()
|
|
16
|
+
}),
|
|
17
|
+
new TimestampTxValidator({
|
|
18
|
+
timestamp,
|
|
19
|
+
blockNumber
|
|
20
|
+
}),
|
|
13
21
|
new DoubleSpendTxValidator(new NullifierCache(db)),
|
|
14
|
-
new PhasesTxValidator(contractDataSource, setupAllowList),
|
|
22
|
+
new PhasesTxValidator(contractDataSource, setupAllowList, timestamp),
|
|
15
23
|
new BlockHeaderTxValidator(new ArchiveCache(db))
|
|
16
24
|
];
|
|
17
25
|
if (!skipFeeEnforcement) {
|
|
@@ -22,29 +30,24 @@ export function createValidatorForAcceptingTxs(db, contractDataSource, verifier,
|
|
|
22
30
|
}
|
|
23
31
|
return new AggregateTxValidator(...validators);
|
|
24
32
|
}
|
|
25
|
-
export function
|
|
33
|
+
export function createValidatorForBlockBuilding(db, contractDataSource, globalVariables, setupAllowList) {
|
|
26
34
|
const nullifierCache = new NullifierCache(db);
|
|
27
35
|
const archiveCache = new ArchiveCache(db);
|
|
28
36
|
const publicStateSource = new DatabasePublicStateSource(db);
|
|
29
37
|
return {
|
|
30
38
|
preprocessValidator: preprocessValidator(nullifierCache, archiveCache, publicStateSource, contractDataSource, globalVariables, setupAllowList),
|
|
31
|
-
postprocessValidator: postprocessValidator(nullifierCache),
|
|
32
39
|
nullifierCache
|
|
33
40
|
};
|
|
34
41
|
}
|
|
35
|
-
class DatabasePublicStateSource {
|
|
36
|
-
db;
|
|
37
|
-
constructor(db){
|
|
38
|
-
this.db = db;
|
|
39
|
-
}
|
|
40
|
-
storageRead(contractAddress, slot) {
|
|
41
|
-
return readPublicState(this.db, contractAddress, slot);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
42
|
function preprocessValidator(nullifierCache, archiveCache, publicStateSource, contractDataSource, globalVariables, setupAllowList) {
|
|
45
43
|
// We don't include the TxProofValidator nor the DataTxValidator here because they are already checked by the time we get to block building.
|
|
46
|
-
return new AggregateTxValidator(new MetadataTxValidator(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
return new AggregateTxValidator(new MetadataTxValidator({
|
|
45
|
+
l1ChainId: globalVariables.chainId,
|
|
46
|
+
rollupVersion: globalVariables.version,
|
|
47
|
+
protocolContractsHash,
|
|
48
|
+
vkTreeRoot: getVKTreeRoot()
|
|
49
|
+
}), new TimestampTxValidator({
|
|
50
|
+
timestamp: globalVariables.timestamp,
|
|
51
|
+
blockNumber: globalVariables.blockNumber
|
|
52
|
+
}), new DoubleSpendTxValidator(nullifierCache), new PhasesTxValidator(contractDataSource, setupAllowList, globalVariables.timestamp), new GasTxValidator(publicStateSource, ProtocolContractAddress.FeeJuice, globalVariables.gasFees), new BlockHeaderTxValidator(archiveCache));
|
|
50
53
|
}
|