@aztec/sequencer-client 0.87.6 → 1.0.0-nightly.20250604
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 +5 -5
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +8 -8
- package/dest/global_variable_builder/global_builder.d.ts +4 -1
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +14 -2
- 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.js +1 -4
- package/dest/publisher/sequencer-publisher.d.ts +4 -4
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +23 -14
- package/dest/sequencer/block_builder.d.ts +33 -0
- package/dest/sequencer/block_builder.d.ts.map +1 -0
- package/dest/sequencer/block_builder.js +109 -0
- package/dest/sequencer/index.d.ts +1 -0
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +1 -0
- package/dest/sequencer/sequencer.d.ts +17 -64
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +74 -173
- package/dest/sequencer/utils.d.ts +2 -2
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +6 -4
- package/dest/tx_validator/tx_validator_factory.d.ts +2 -6
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
- package/package.json +26 -25
- package/src/client/sequencer-client.ts +12 -20
- package/src/global_variable_builder/global_builder.ts +16 -2
- package/src/index.ts +1 -2
- package/src/publisher/config.ts +1 -1
- package/src/publisher/sequencer-publisher.ts +32 -21
- package/src/sequencer/block_builder.ts +192 -0
- package/src/sequencer/index.ts +1 -0
- package/src/sequencer/sequencer.ts +96 -221
- package/src/sequencer/utils.ts +14 -6
- package/src/tx_validator/tx_validator_factory.ts +2 -4
- 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 -135
- package/src/slasher/factory.ts +0 -15
- package/src/slasher/index.ts +0 -2
- package/src/slasher/slasher_client.ts +0 -199
|
@@ -4,17 +4,16 @@ import { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
|
|
|
4
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
5
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
6
6
|
import type { P2P } from '@aztec/p2p';
|
|
7
|
+
import type { SlasherClient } from '@aztec/slasher';
|
|
7
8
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
9
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
9
|
-
import type {
|
|
10
|
-
import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
10
|
+
import type { IFullNodeBlockBuilder, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
11
11
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
12
12
|
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
13
13
|
import type { ValidatorClient } from '@aztec/validator-client';
|
|
14
14
|
import type { SequencerClientConfig } from '../config.js';
|
|
15
15
|
import { SequencerPublisher } from '../publisher/index.js';
|
|
16
16
|
import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
|
|
17
|
-
import type { SlasherClient } from '../slasher/index.js';
|
|
18
17
|
/**
|
|
19
18
|
* Encapsulates the full sequencer and publisher.
|
|
20
19
|
*/
|
|
@@ -38,7 +37,7 @@ export declare class SequencerClient {
|
|
|
38
37
|
p2pClient: P2P;
|
|
39
38
|
worldStateSynchronizer: WorldStateSynchronizer;
|
|
40
39
|
slasherClient: SlasherClient;
|
|
41
|
-
|
|
40
|
+
blockBuilder: IFullNodeBlockBuilder;
|
|
42
41
|
l2BlockSource: L2BlockSource;
|
|
43
42
|
l1ToL2MessageSource: L1ToL2MessageSource;
|
|
44
43
|
telemetry: TelemetryClient;
|
|
@@ -63,10 +62,11 @@ export declare class SequencerClient {
|
|
|
63
62
|
* Restarts the sequencer after being stopped.
|
|
64
63
|
*/
|
|
65
64
|
restart(): void;
|
|
65
|
+
getSequencer(): Sequencer;
|
|
66
66
|
get coinbase(): EthAddress;
|
|
67
67
|
get feeRecipient(): AztecAddress;
|
|
68
68
|
get forwarderAddress(): EthAddress;
|
|
69
|
-
get
|
|
69
|
+
get validatorAddresses(): EthAddress[] | undefined;
|
|
70
70
|
get maxL2BlockGas(): number | undefined;
|
|
71
71
|
}
|
|
72
72
|
//# sourceMappingURL=sequencer-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequencer-client.d.ts","sourceRoot":"","sources":["../../src/client/sequencer-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAUhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"sequencer-client.d.ts","sourceRoot":"","sources":["../../src/client/sequencer-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAUhD,OAAO,E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,eAAe,CAAC;QAC3B,SAAS,CAAC,EAAE,kBAAkB,CAAC;QAC/B,cAAc,CAAC,EAAE,uBAAuB,CAAC;QACzC,YAAY,EAAE,YAAY,CAAC;QAC3B,UAAU,CAAC,EAAE,UAAU,CAAC;QACxB,SAAS,CAAC,EAAE,kBAAkB,CAAC;KAChC;IAiHH;;;OAGG;IACI,qBAAqB,CAAC,MAAM,EAAE,eAAe;IAIpD;;OAEG;IACU,IAAI;IAIjB,uGAAuG;IAChG,KAAK;IAIZ;;OAEG;IACI,OAAO;IAIP,YAAY,IAAI,SAAS;IAIhC,IAAI,QAAQ,IAAI,UAAU,CAEzB;IAED,IAAI,YAAY,IAAI,YAAY,CAE/B;IAED,IAAI,gBAAgB,IAAI,UAAU,CAEjC;IAED,IAAI,kBAAkB,IAAI,UAAU,EAAE,GAAG,SAAS,CAEjD;IAED,IAAI,aAAa,IAAI,MAAM,GAAG,SAAS,CAEtC;CACF"}
|
|
@@ -3,8 +3,6 @@ import { ForwarderContract, GovernanceProposerContract, RollupContract, Slashing
|
|
|
3
3
|
import { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
|
|
4
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
-
import { LightweightBlockBuilderFactory } from '@aztec/prover-client/block-builder';
|
|
7
|
-
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
8
6
|
import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
|
|
9
7
|
import { SequencerPublisher } from '../publisher/index.js';
|
|
10
8
|
import { Sequencer } from '../sequencer/index.js';
|
|
@@ -27,7 +25,7 @@ import { Sequencer } from '../sequencer/index.js';
|
|
|
27
25
|
* @param prover - An instance of a block prover
|
|
28
26
|
* @returns A new running instance.
|
|
29
27
|
*/ static async new(config, deps) {
|
|
30
|
-
const { validatorClient, p2pClient, worldStateSynchronizer, slasherClient,
|
|
28
|
+
const { validatorClient, p2pClient, worldStateSynchronizer, slasherClient, blockBuilder, l2BlockSource, l1ToL2MessageSource, telemetry: telemetryClient } = deps;
|
|
31
29
|
const { l1RpcUrls: rpcUrls, l1ChainId: chainId, publisherPrivateKey } = config;
|
|
32
30
|
const chain = createEthereumChain(rpcUrls, chainId);
|
|
33
31
|
const log = createLogger('sequencer-client');
|
|
@@ -38,7 +36,7 @@ import { Sequencer } from '../sequencer/index.js';
|
|
|
38
36
|
rollupContract.getL1GenesisTime(),
|
|
39
37
|
rollupContract.getSlotDuration()
|
|
40
38
|
]);
|
|
41
|
-
const forwarderContract = config.customForwarderContractAddress && config.customForwarderContractAddress !== EthAddress.ZERO ? new ForwarderContract(l1Client, config.customForwarderContractAddress.toString(), config.l1Contracts.rollupAddress.toString()) : await ForwarderContract.create(l1Client
|
|
39
|
+
const forwarderContract = config.customForwarderContractAddress && config.customForwarderContractAddress !== EthAddress.ZERO ? new ForwarderContract(l1Client, config.customForwarderContractAddress.toString(), config.l1Contracts.rollupAddress.toString()) : await ForwarderContract.create(l1Client, log, config.l1Contracts.rollupAddress.toString());
|
|
42
40
|
const governanceProposerContract = new GovernanceProposerContract(l1Client, config.l1Contracts.governanceProposerAddress.toString());
|
|
43
41
|
const slashingProposerAddress = await rollupContract.getSlashingProposerAddress();
|
|
44
42
|
const slashingProposerContract = new SlashingProposerContract(l1Client, slashingProposerAddress.toString());
|
|
@@ -64,7 +62,6 @@ import { Sequencer } from '../sequencer/index.js';
|
|
|
64
62
|
slashingProposerContract
|
|
65
63
|
});
|
|
66
64
|
const globalsBuilder = new GlobalVariableBuilder(config);
|
|
67
|
-
const publicProcessorFactory = new PublicProcessorFactory(contractDataSource, deps.dateProvider, telemetryClient);
|
|
68
65
|
const ethereumSlotDuration = config.ethereumSlotDuration;
|
|
69
66
|
const rollupManaLimit = Number(await rollupContract.getManaLimit());
|
|
70
67
|
let sequencerManaLimit = config.maxL2BlockGas ?? rollupManaLimit;
|
|
@@ -84,7 +81,7 @@ import { Sequencer } from '../sequencer/index.js';
|
|
|
84
81
|
slotDuration: Number(slotDuration),
|
|
85
82
|
ethereumSlotDuration
|
|
86
83
|
};
|
|
87
|
-
const sequencer = new Sequencer(publisher, validatorClient, globalsBuilder, p2pClient, worldStateSynchronizer, slasherClient,
|
|
84
|
+
const sequencer = new Sequencer(publisher, validatorClient, globalsBuilder, p2pClient, worldStateSynchronizer, slasherClient, l2BlockSource, l1ToL2MessageSource, blockBuilder, l1Constants, deps.dateProvider, {
|
|
88
85
|
...config,
|
|
89
86
|
maxL1TxInclusionTimeIntoSlot,
|
|
90
87
|
maxL2BlockGas: sequencerManaLimit
|
|
@@ -112,6 +109,9 @@ import { Sequencer } from '../sequencer/index.js';
|
|
|
112
109
|
*/ restart() {
|
|
113
110
|
this.sequencer.restart();
|
|
114
111
|
}
|
|
112
|
+
getSequencer() {
|
|
113
|
+
return this.sequencer;
|
|
114
|
+
}
|
|
115
115
|
get coinbase() {
|
|
116
116
|
return this.sequencer.coinbase;
|
|
117
117
|
}
|
|
@@ -121,8 +121,8 @@ import { Sequencer } from '../sequencer/index.js';
|
|
|
121
121
|
get forwarderAddress() {
|
|
122
122
|
return this.sequencer.getForwarderAddress();
|
|
123
123
|
}
|
|
124
|
-
get
|
|
125
|
-
return this.sequencer.
|
|
124
|
+
get validatorAddresses() {
|
|
125
|
+
return this.sequencer.getValidatorAddresses();
|
|
126
126
|
}
|
|
127
127
|
get maxL2BlockGas() {
|
|
128
128
|
return this.sequencer.maxL2BlockGas;
|
|
@@ -10,6 +10,8 @@ import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
12
12
|
private log;
|
|
13
|
+
private currentBaseFees;
|
|
14
|
+
private currentL1BlockNumber;
|
|
13
15
|
private readonly rollupContract;
|
|
14
16
|
private readonly publicClient;
|
|
15
17
|
private readonly ethereumSlotDuration;
|
|
@@ -18,8 +20,9 @@ export declare class GlobalVariableBuilder implements GlobalVariableBuilderInter
|
|
|
18
20
|
constructor(config: L1ReaderConfig & Pick<L1ContractsConfig, 'ethereumSlotDuration'>);
|
|
19
21
|
/**
|
|
20
22
|
* Computes the "current" base fees, e.g., the price that you currently should pay to get include in the next block
|
|
21
|
-
* @returns Base fees for the
|
|
23
|
+
* @returns Base fees for the next block
|
|
22
24
|
*/
|
|
25
|
+
private computeCurrentBaseFees;
|
|
23
26
|
getCurrentBaseFees(): Promise<GasFees>;
|
|
24
27
|
getGlobalConstantVariables(): Promise<Pick<GlobalVariables, 'chainId' | 'version'>>;
|
|
25
28
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global_builder.d.ts","sourceRoot":"","sources":["../../src/global_variable_builder/global_builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAIpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,EAAE,qBAAqB,IAAI,8BAA8B,EAAE,MAAM,kBAAkB,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAInD;;GAEG;AACH,qBAAa,qBAAsB,YAAW,8BAA8B;IAC1E,OAAO,CAAC,GAAG,CAAqD;
|
|
1
|
+
{"version":3,"file":"global_builder.d.ts","sourceRoot":"","sources":["../../src/global_variable_builder/global_builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAIpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,EAAE,qBAAqB,IAAI,8BAA8B,EAAE,MAAM,kBAAkB,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAInD;;GAEG;AACH,qBAAa,qBAAsB,YAAW,8BAA8B;IAC1E,OAAO,CAAC,GAAG,CAAqD;IAChE,OAAO,CAAC,eAAe,CAAoE;IAC3F,OAAO,CAAC,oBAAoB,CAAiC;IAE7D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAmB;IAChD,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAS;IAE9C,OAAO,CAAC,OAAO,CAAC,CAAK;IACrB,OAAO,CAAC,OAAO,CAAC,CAAK;gBAET,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC,iBAAiB,EAAE,sBAAsB,CAAC;IAgBpF;;;OAGG;YACW,sBAAsB;IAavB,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IAYtC,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;IAUhG;;;;;;;OAOG;IACU,oBAAoB,CAC/B,WAAW,EAAE,EAAE,EACf,QAAQ,EAAE,UAAU,EACpB,YAAY,EAAE,YAAY,EAC1B,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,eAAe,CAAC;CA6B5B"}
|
|
@@ -8,6 +8,8 @@ import { createPublicClient, fallback, http } from 'viem';
|
|
|
8
8
|
* Simple global variables builder.
|
|
9
9
|
*/ export class GlobalVariableBuilder {
|
|
10
10
|
log = createLogger('sequencer:global_variable_builder');
|
|
11
|
+
currentBaseFees = Promise.resolve(new GasFees(Fr.ZERO, Fr.ZERO));
|
|
12
|
+
currentL1BlockNumber = undefined;
|
|
11
13
|
rollupContract;
|
|
12
14
|
publicClient;
|
|
13
15
|
ethereumSlotDuration;
|
|
@@ -26,8 +28,8 @@ import { createPublicClient, fallback, http } from 'viem';
|
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* Computes the "current" base fees, e.g., the price that you currently should pay to get include in the next block
|
|
29
|
-
* @returns Base fees for the
|
|
30
|
-
*/ async
|
|
31
|
+
* @returns Base fees for the next block
|
|
32
|
+
*/ async computeCurrentBaseFees() {
|
|
31
33
|
// Since this might be called in the middle of a slot where a block might have been published,
|
|
32
34
|
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
33
35
|
// The timestamp of that last block will act as a lower bound for the next block.
|
|
@@ -37,6 +39,16 @@ import { createPublicClient, fallback, http } from 'viem';
|
|
|
37
39
|
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
38
40
|
return new GasFees(Fr.ZERO, new Fr(await this.rollupContract.getManaBaseFeeAt(timestamp, true)));
|
|
39
41
|
}
|
|
42
|
+
async getCurrentBaseFees() {
|
|
43
|
+
// Get the current block number
|
|
44
|
+
const blockNumber = await this.publicClient.getBlockNumber();
|
|
45
|
+
// If the L1 block number has changed then chain a new promise to get the current base fees
|
|
46
|
+
if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
|
|
47
|
+
this.currentL1BlockNumber = blockNumber;
|
|
48
|
+
this.currentBaseFees = this.currentBaseFees.then(()=>this.computeCurrentBaseFees());
|
|
49
|
+
}
|
|
50
|
+
return this.currentBaseFees;
|
|
51
|
+
}
|
|
40
52
|
async getGlobalConstantVariables() {
|
|
41
53
|
if (!this.chainId) {
|
|
42
54
|
this.chainId = new Fr(this.publicClient.chain.id);
|
package/dest/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export * from './client/index.js';
|
|
2
2
|
export * from './config.js';
|
|
3
3
|
export * from './publisher/index.js';
|
|
4
|
+
export { FullNodeBlockBuilder as BlockBuilder, Sequencer, SequencerState } from './sequencer/index.js';
|
|
4
5
|
export * from './tx_validator/tx_validator_factory.js';
|
|
5
|
-
export * from './slasher/index.js';
|
|
6
|
-
export { Sequencer, SequencerState } from './sequencer/index.js';
|
|
7
6
|
export * from './global_variable_builder/index.js';
|
|
8
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dest/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,oBAAoB,IAAI,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACvG,cAAc,wCAAwC,CAAC;AAIvD,cAAc,oCAAoC,CAAC"}
|
package/dest/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export * from './client/index.js';
|
|
2
2
|
export * from './config.js';
|
|
3
3
|
export * from './publisher/index.js';
|
|
4
|
+
export { FullNodeBlockBuilder as BlockBuilder, Sequencer, SequencerState } from './sequencer/index.js';
|
|
4
5
|
export * from './tx_validator/tx_validator_factory.js';
|
|
5
|
-
export * from './slasher/index.js';
|
|
6
|
-
export { Sequencer, SequencerState } from './sequencer/index.js';
|
|
7
6
|
// Used by the node to simulate public parts of transactions. Should these be moved to a shared library?
|
|
8
7
|
// ISSUE(#9832)
|
|
9
8
|
export * from './global_variable_builder/index.js';
|
package/dest/publisher/config.js
CHANGED
|
@@ -14,10 +14,7 @@ export const getTxSenderConfigMappings = (scope)=>({
|
|
|
14
14
|
env: scope === 'PROVER' ? `PROVER_PUBLISHER_PRIVATE_KEY` : `SEQ_PUBLISHER_PRIVATE_KEY`,
|
|
15
15
|
description: 'The private key to be used by the publisher.',
|
|
16
16
|
parseEnv: (val)=>val ? `0x${val.replace('0x', '')}` : NULL_KEY,
|
|
17
|
-
defaultValue: NULL_KEY
|
|
18
|
-
fallback: [
|
|
19
|
-
'VALIDATOR_PRIVATE_KEY'
|
|
20
|
-
]
|
|
17
|
+
defaultValue: NULL_KEY
|
|
21
18
|
}
|
|
22
19
|
});
|
|
23
20
|
export function getTxSenderConfigFromEnv(scope) {
|
|
@@ -5,7 +5,7 @@ import type { EpochCache } from '@aztec/epoch-cache';
|
|
|
5
5
|
import { type ForwarderContract, type GasPrice, type GovernanceProposerContract, type L1BlobInputs, type L1ContractsConfig, type L1GasConfig, type L1TxRequest, RollupContract, type SlashingProposerContract, type TransactionStats } from '@aztec/ethereum';
|
|
6
6
|
import type { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
|
|
7
7
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
8
|
-
import
|
|
8
|
+
import { CommitteeAttestation } from '@aztec/stdlib/block';
|
|
9
9
|
import { type ProposedBlockHeader, TxHash } from '@aztec/stdlib/tx';
|
|
10
10
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
11
11
|
import { type TransactionReceipt } from 'viem';
|
|
@@ -32,7 +32,7 @@ interface RequestWithExpiry {
|
|
|
32
32
|
export declare class SequencerPublisher {
|
|
33
33
|
private interrupted;
|
|
34
34
|
private metrics;
|
|
35
|
-
|
|
35
|
+
epochCache: EpochCache;
|
|
36
36
|
private forwarderContract;
|
|
37
37
|
protected governanceLog: import("@aztec/foundation/log").Logger;
|
|
38
38
|
protected governanceProposerAddress?: EthAddress;
|
|
@@ -108,7 +108,7 @@ export declare class SequencerPublisher {
|
|
|
108
108
|
*/
|
|
109
109
|
validateBlockForSubmission(header: ProposedBlockHeader, attestationData?: {
|
|
110
110
|
digest: Buffer;
|
|
111
|
-
|
|
111
|
+
attestations: CommitteeAttestation[];
|
|
112
112
|
}): Promise<bigint>;
|
|
113
113
|
getCurrentEpochCommittee(): Promise<EthAddress[]>;
|
|
114
114
|
private enqueueCastVoteHelper;
|
|
@@ -127,7 +127,7 @@ export declare class SequencerPublisher {
|
|
|
127
127
|
* @param block - L2 block to propose.
|
|
128
128
|
* @returns True if the tx has been enqueued, throws otherwise. See #9315
|
|
129
129
|
*/
|
|
130
|
-
enqueueProposeL2Block(block: L2Block, attestations?:
|
|
130
|
+
enqueueProposeL2Block(block: L2Block, attestations?: CommitteeAttestation[], txHashes?: TxHash[], opts?: {
|
|
131
131
|
txTimeoutAt?: Date;
|
|
132
132
|
}): Promise<boolean>;
|
|
133
133
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequencer-publisher.d.ts","sourceRoot":"","sources":["../../src/publisher/sequencer-publisher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,KAAK,uBAAuB,EAAwB,MAAM,yBAAyB,CAAC;AAC7F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EACb,KAAK,0BAA0B,EAE/B,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,cAAc,EACd,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"sequencer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AAC,OAAO,CAAC;IA+BnB;;;;;OAKG;IACI,SAAS;IAKhB,wDAAwD;IACjD,OAAO;YAKA,gBAAgB;YAkGhB,YAAY;IAoE1B;;;;;;;OAOG;IACH,SAAS,CAAC,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAGlF"}
|
|
@@ -6,6 +6,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
6
6
|
import { createLogger } from '@aztec/foundation/log';
|
|
7
7
|
import { Timer } from '@aztec/foundation/timer';
|
|
8
8
|
import { ForwarderAbi, RollupAbi } from '@aztec/l1-artifacts';
|
|
9
|
+
import { CommitteeAttestation } from '@aztec/stdlib/block';
|
|
9
10
|
import { ConsensusPayload, SignatureDomainSeparator, getHashedSignaturePayload } from '@aztec/stdlib/p2p';
|
|
10
11
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
11
12
|
import pick from 'lodash.pick';
|
|
@@ -162,6 +163,7 @@ export class SequencerPublisher {
|
|
|
162
163
|
* @param tipArchive - The archive to check
|
|
163
164
|
* @returns The slot and block number if it is possible to propose, undefined otherwise
|
|
164
165
|
*/ canProposeAtNextEthBlock(tipArchive) {
|
|
166
|
+
// TODO: #14291 - should loop through multiple keys to check if any of them can propose
|
|
165
167
|
const ignoredErrors = [
|
|
166
168
|
'SlotAlreadyInChain',
|
|
167
169
|
'InvalidProposer',
|
|
@@ -186,17 +188,24 @@ export class SequencerPublisher {
|
|
|
186
188
|
*
|
|
187
189
|
*/ async validateBlockForSubmission(header, attestationData = {
|
|
188
190
|
digest: Buffer.alloc(32),
|
|
189
|
-
|
|
191
|
+
attestations: []
|
|
190
192
|
}) {
|
|
191
193
|
const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);
|
|
192
|
-
|
|
194
|
+
// If we have no attestations, we still need to provide the empty attestations
|
|
195
|
+
// so that the committee is recalculated correctly
|
|
196
|
+
const ignoreSignatures = attestationData.attestations.length === 0;
|
|
197
|
+
if (ignoreSignatures) {
|
|
198
|
+
const committee = await this.epochCache.getCommittee(header.slotNumber.toBigInt());
|
|
199
|
+
attestationData.attestations = committee.committee.map((committeeMember)=>CommitteeAttestation.fromAddress(committeeMember));
|
|
200
|
+
}
|
|
201
|
+
const formattedAttestations = attestationData.attestations.map((attest)=>attest.toViem());
|
|
193
202
|
const flags = {
|
|
194
203
|
ignoreDA: true,
|
|
195
|
-
ignoreSignatures
|
|
204
|
+
ignoreSignatures
|
|
196
205
|
};
|
|
197
206
|
const args = [
|
|
198
207
|
toHex(header.toBuffer()),
|
|
199
|
-
|
|
208
|
+
formattedAttestations,
|
|
200
209
|
toHex(attestationData.digest),
|
|
201
210
|
ts,
|
|
202
211
|
toHex(header.contentCommitment.blobsHash),
|
|
@@ -217,22 +226,21 @@ export class SequencerPublisher {
|
|
|
217
226
|
return false;
|
|
218
227
|
}
|
|
219
228
|
const round = await base.computeRound(slotNumber);
|
|
220
|
-
const
|
|
221
|
-
this.rollupContract.getProposerAt(timestamp),
|
|
222
|
-
base.getRoundInfo(this.rollupContract.address, round)
|
|
223
|
-
]);
|
|
224
|
-
if (proposer.toLowerCase() !== this.getForwarderAddress().toString().toLowerCase()) {
|
|
225
|
-
return false;
|
|
226
|
-
}
|
|
229
|
+
const roundInfo = await base.getRoundInfo(this.rollupContract.address, round);
|
|
227
230
|
if (roundInfo.lastVote >= slotNumber) {
|
|
228
231
|
return false;
|
|
229
232
|
}
|
|
230
233
|
const cachedLastVote = this.myLastVotes[voteType];
|
|
231
234
|
this.myLastVotes[voteType] = slotNumber;
|
|
232
235
|
const action = voteType === 0 ? 'governance-vote' : 'slashing-vote';
|
|
236
|
+
const request = await base.createVoteRequestWithSignature(payload.toString(), this.l1TxUtils.client);
|
|
237
|
+
this.log.debug(`Created ${action} request with signature`, {
|
|
238
|
+
request,
|
|
239
|
+
signer: this.l1TxUtils.client.account?.address
|
|
240
|
+
});
|
|
233
241
|
this.addRequest({
|
|
234
242
|
action,
|
|
235
|
-
request
|
|
243
|
+
request,
|
|
236
244
|
lastValidL2Slot: slotNumber,
|
|
237
245
|
onResult: (_request, result)=>{
|
|
238
246
|
if (!result || result.receipt.status !== 'success') {
|
|
@@ -258,6 +266,7 @@ export class SequencerPublisher {
|
|
|
258
266
|
if (!slashPayload) {
|
|
259
267
|
return undefined;
|
|
260
268
|
}
|
|
269
|
+
this.log.info(`Slash payload: ${slashPayload}`);
|
|
261
270
|
return {
|
|
262
271
|
payload: slashPayload,
|
|
263
272
|
base: this.slashingProposerContract
|
|
@@ -304,7 +313,7 @@ export class SequencerPublisher {
|
|
|
304
313
|
// make time consistency checks break.
|
|
305
314
|
const ts = await this.validateBlockForSubmission(proposedBlockHeader, {
|
|
306
315
|
digest: digest.toBuffer(),
|
|
307
|
-
|
|
316
|
+
attestations: attestations ?? []
|
|
308
317
|
});
|
|
309
318
|
this.log.debug(`Submitting propose transaction`);
|
|
310
319
|
await this.addProposeTx(block, proposeTxArgs, opts, ts);
|
|
@@ -351,7 +360,7 @@ export class SequencerPublisher {
|
|
|
351
360
|
});
|
|
352
361
|
throw new Error('Failed to validate blobs');
|
|
353
362
|
});
|
|
354
|
-
const attestations = encodedData.attestations ? encodedData.attestations.map((attest)=>attest.
|
|
363
|
+
const attestations = encodedData.attestations ? encodedData.attestations.map((attest)=>attest.toViem()) : [];
|
|
355
364
|
const txHashes = encodedData.txHashes ? encodedData.txHashes.map((txHash)=>txHash.toString()) : [];
|
|
356
365
|
const args = [
|
|
357
366
|
{
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
2
|
+
import { PublicProcessor } from '@aztec/simulator/server';
|
|
3
|
+
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
4
|
+
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
5
|
+
import { type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
6
|
+
import type { BuildBlockOptions, BuildBlockResult, IFullNodeBlockBuilder, MerkleTreeWriteOperations, PublicProcessorValidator, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
7
|
+
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
8
|
+
import { GlobalVariables, Tx } from '@aztec/stdlib/tx';
|
|
9
|
+
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
10
|
+
export declare function buildBlock(pendingTxs: Iterable<Tx> | AsyncIterable<Tx>, newGlobalVariables: GlobalVariables, opts: BuildBlockOptions | undefined, l1ToL2MessageSource: L1ToL2MessageSource, worldStateFork: MerkleTreeWriteOperations, processor: PublicProcessor, validator: PublicProcessorValidator, l1Constants: Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration'>, dateProvider: DateProvider, telemetryClient?: TelemetryClient): Promise<BuildBlockResult>;
|
|
11
|
+
export declare class FullNodeBlockBuilder implements IFullNodeBlockBuilder {
|
|
12
|
+
private config;
|
|
13
|
+
private l1ToL2MessageSource;
|
|
14
|
+
private worldState;
|
|
15
|
+
private contractDataSource;
|
|
16
|
+
private dateProvider;
|
|
17
|
+
private telemetryClient;
|
|
18
|
+
constructor(config: Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration'> & Pick<ChainConfig, 'l1ChainId' | 'rollupVersion'>, l1ToL2MessageSource: L1ToL2MessageSource, worldState: WorldStateSynchronizer, contractDataSource: ContractDataSource, dateProvider: DateProvider, telemetryClient?: TelemetryClient);
|
|
19
|
+
getConfig(): {
|
|
20
|
+
l1GenesisTime: bigint;
|
|
21
|
+
slotDuration: number;
|
|
22
|
+
l1ChainId: number;
|
|
23
|
+
rollupVersion: number;
|
|
24
|
+
};
|
|
25
|
+
makeBlockBuilderDeps(globalVariables: GlobalVariables, opts: BuildBlockOptions): Promise<{
|
|
26
|
+
publicProcessorDBFork: MerkleTreeWriteOperations;
|
|
27
|
+
processor: PublicProcessor;
|
|
28
|
+
validator: PublicProcessorValidator;
|
|
29
|
+
}>;
|
|
30
|
+
private syncToPreviousBlock;
|
|
31
|
+
buildBlock(pendingTxs: Iterable<Tx> | AsyncIterable<Tx>, globalVariables: GlobalVariables, opts: BuildBlockOptions): Promise<BuildBlockResult>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=block_builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block_builder.d.ts","sourceRoot":"","sources":["../../src/sequencer/block_builder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAS,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAGL,eAAe,EAEhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,KAAK,iBAAiB,EAAuB,MAAM,6BAA6B,CAAC;AAE1F,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAMnF,wBAAsB,UAAU,CAC9B,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,EAAE,CAAC,EAC5C,kBAAkB,EAAE,eAAe,EACnC,IAAI,EAAE,iBAAiB,YAAK,EAC5B,mBAAmB,EAAE,mBAAmB,EACxC,cAAc,EAAE,yBAAyB,EACzC,SAAS,EAAE,eAAe,EAC1B,SAAS,EAAE,wBAAwB,EACnC,WAAW,EAAE,IAAI,CAAC,iBAAiB,EAAE,eAAe,GAAG,cAAc,CAAC,EACtE,YAAY,EAAE,YAAY,EAC1B,eAAe,GAAE,eAAsC,GACtD,OAAO,CAAC,gBAAgB,CAAC,CAyD3B;AAED,qBAAa,oBAAqB,YAAW,qBAAqB;IAE9D,OAAO,CAAC,MAAM;IAEd,OAAO,CAAC,mBAAmB;IAC3B,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,eAAe;gBANf,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,eAAe,GAAG,cAAc,CAAC,GACvE,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,eAAe,CAAC,EAC1C,mBAAmB,EAAE,mBAAmB,EACxC,UAAU,EAAE,sBAAsB,EAClC,kBAAkB,EAAE,kBAAkB,EACtC,YAAY,EAAE,YAAY,EAC1B,eAAe,GAAE,eAAsC;IAG1D,SAAS;;;;;;IASH,oBAAoB,CAAC,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,iBAAiB;;;;;YAqC7E,mBAAmB;IAU3B,UAAU,CACd,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,EAAE,CAAC,EAC5C,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,gBAAgB,CAAC;CAmB7B"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { elapsed } from '@aztec/aztec.js';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
4
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
5
|
+
import { LightweightBlockFactory } from '@aztec/prover-client/block-factory';
|
|
6
|
+
import { GuardedMerkleTreeOperations, PublicContractsDB, PublicProcessor, TelemetryPublicTxSimulator } from '@aztec/simulator/server';
|
|
7
|
+
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
8
|
+
import { Gas } from '@aztec/stdlib/gas';
|
|
9
|
+
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
10
|
+
import { createValidatorForBlockBuilding } from '../tx_validator/tx_validator_factory.js';
|
|
11
|
+
const log = createLogger('sequencer:block-builder');
|
|
12
|
+
export async function buildBlock(pendingTxs, newGlobalVariables, opts = {}, l1ToL2MessageSource, worldStateFork, processor, validator, l1Constants, dateProvider, telemetryClient = getTelemetryClient()) {
|
|
13
|
+
const blockBuildingTimer = new Timer();
|
|
14
|
+
const blockNumber = newGlobalVariables.blockNumber.toNumber();
|
|
15
|
+
const slot = newGlobalVariables.slotNumber.toBigInt();
|
|
16
|
+
log.debug(`Requesting L1 to L2 messages from contract for block ${blockNumber}`);
|
|
17
|
+
const l1ToL2Messages = await l1ToL2MessageSource.getL1ToL2Messages(BigInt(blockNumber));
|
|
18
|
+
const msgCount = l1ToL2Messages.length;
|
|
19
|
+
log.verbose(`Building block ${blockNumber} for slot ${slot}`, {
|
|
20
|
+
slot,
|
|
21
|
+
slotStart: new Date(Number(getTimestampForSlot(slot, l1Constants)) * 1000),
|
|
22
|
+
now: new Date(dateProvider.now()),
|
|
23
|
+
blockNumber,
|
|
24
|
+
msgCount,
|
|
25
|
+
opts
|
|
26
|
+
});
|
|
27
|
+
try {
|
|
28
|
+
const blockFactory = new LightweightBlockFactory(worldStateFork, telemetryClient);
|
|
29
|
+
await blockFactory.startNewBlock(newGlobalVariables, l1ToL2Messages);
|
|
30
|
+
const [publicProcessorDuration, [processedTxs, failedTxs, usedTxs]] = await elapsed(()=>processor.process(pendingTxs, opts, validator));
|
|
31
|
+
// All real transactions have been added, set the block as full and pad if needed
|
|
32
|
+
await blockFactory.addTxs(processedTxs);
|
|
33
|
+
const block = await blockFactory.setBlockCompleted();
|
|
34
|
+
// How much public gas was processed
|
|
35
|
+
const publicGas = processedTxs.reduce((acc, tx)=>acc.add(tx.gasUsed.publicGas), Gas.empty());
|
|
36
|
+
const res = {
|
|
37
|
+
block,
|
|
38
|
+
publicGas,
|
|
39
|
+
publicProcessorDuration,
|
|
40
|
+
numMsgs: l1ToL2Messages.length,
|
|
41
|
+
numTxs: processedTxs.length,
|
|
42
|
+
failedTxs: failedTxs,
|
|
43
|
+
blockBuildingTimer,
|
|
44
|
+
usedTxs
|
|
45
|
+
};
|
|
46
|
+
log.trace('Built block', res.block.header);
|
|
47
|
+
return res;
|
|
48
|
+
} finally{
|
|
49
|
+
// We wait a bit to close the forks since the processor may still be working on a dangling tx
|
|
50
|
+
// which was interrupted due to the processingDeadline being hit.
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
52
|
+
setTimeout(async ()=>{
|
|
53
|
+
try {
|
|
54
|
+
await worldStateFork.close();
|
|
55
|
+
} catch (err) {
|
|
56
|
+
// This can happen if the sequencer is stopped before we hit this timeout.
|
|
57
|
+
log.warn(`Error closing forks for block processing`, err);
|
|
58
|
+
}
|
|
59
|
+
}, 5000);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export class FullNodeBlockBuilder {
|
|
63
|
+
config;
|
|
64
|
+
l1ToL2MessageSource;
|
|
65
|
+
worldState;
|
|
66
|
+
contractDataSource;
|
|
67
|
+
dateProvider;
|
|
68
|
+
telemetryClient;
|
|
69
|
+
constructor(config, l1ToL2MessageSource, worldState, contractDataSource, dateProvider, telemetryClient = getTelemetryClient()){
|
|
70
|
+
this.config = config;
|
|
71
|
+
this.l1ToL2MessageSource = l1ToL2MessageSource;
|
|
72
|
+
this.worldState = worldState;
|
|
73
|
+
this.contractDataSource = contractDataSource;
|
|
74
|
+
this.dateProvider = dateProvider;
|
|
75
|
+
this.telemetryClient = telemetryClient;
|
|
76
|
+
}
|
|
77
|
+
getConfig() {
|
|
78
|
+
return {
|
|
79
|
+
l1GenesisTime: this.config.l1GenesisTime,
|
|
80
|
+
slotDuration: this.config.slotDuration,
|
|
81
|
+
l1ChainId: this.config.l1ChainId,
|
|
82
|
+
rollupVersion: this.config.rollupVersion
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
async makeBlockBuilderDeps(globalVariables, opts) {
|
|
86
|
+
const publicProcessorDBFork = await this.worldState.fork();
|
|
87
|
+
const contractsDB = new PublicContractsDB(this.contractDataSource);
|
|
88
|
+
const guardedFork = new GuardedMerkleTreeOperations(publicProcessorDBFork);
|
|
89
|
+
const publicTxSimulator = new TelemetryPublicTxSimulator(guardedFork, contractsDB, globalVariables, /*doMerkleOperations=*/ true, /*skipFeeEnforcement=*/ true, /*clientInitiatedSimulation=*/ false, this.telemetryClient);
|
|
90
|
+
const processor = new PublicProcessor(globalVariables, guardedFork, contractsDB, publicTxSimulator, this.dateProvider, this.telemetryClient);
|
|
91
|
+
const validator = createValidatorForBlockBuilding(publicProcessorDBFork, this.contractDataSource, globalVariables, opts.txPublicSetupAllowList ?? []);
|
|
92
|
+
return {
|
|
93
|
+
publicProcessorDBFork,
|
|
94
|
+
processor,
|
|
95
|
+
validator
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async syncToPreviousBlock(parentBlockNumber, timeout) {
|
|
99
|
+
await retryUntil(()=>this.worldState.syncImmediate(parentBlockNumber, true).then((syncedTo)=>syncedTo >= parentBlockNumber), 'sync to previous block', timeout, 0.1);
|
|
100
|
+
log.debug(`Synced to previous block ${parentBlockNumber}`);
|
|
101
|
+
}
|
|
102
|
+
async buildBlock(pendingTxs, globalVariables, opts) {
|
|
103
|
+
const parentBlockNumber = globalVariables.blockNumber.toNumber() - 1;
|
|
104
|
+
const syncTimeout = opts.deadline ? (opts.deadline.getTime() - this.dateProvider.now()) / 1000 : undefined;
|
|
105
|
+
await this.syncToPreviousBlock(parentBlockNumber, syncTimeout);
|
|
106
|
+
const { publicProcessorDBFork, processor, validator } = await this.makeBlockBuilderDeps(globalVariables, opts);
|
|
107
|
+
return buildBlock(pendingTxs, globalVariables, opts, this.l1ToL2MessageSource, publicProcessorDBFork, processor, validator, this.config, this.dateProvider, this.telemetryClient);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sequencer/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sequencer/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
|
package/dest/sequencer/index.js
CHANGED