@aztec/sequencer-client 0.59.0 → 0.61.0
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/block_builder/light.d.ts.map +1 -1
- package/dest/block_builder/light.js +5 -5
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +7 -1
- package/dest/publisher/l1-publisher.d.ts +8 -1
- package/dest/publisher/l1-publisher.d.ts.map +1 -1
- package/dest/publisher/l1-publisher.js +86 -8
- package/dest/publisher/utils.d.ts +1 -0
- package/dest/publisher/utils.d.ts.map +1 -1
- package/dest/publisher/utils.js +9 -3
- package/dest/sequencer/sequencer.d.ts +1 -0
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +12 -17
- package/dest/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/tx_validator/gas_validator.js +3 -4
- package/dest/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/tx_validator/phases_validator.js +4 -4
- package/dest/tx_validator/test_utils.js +4 -4
- package/package.json +19 -19
- package/src/block_builder/light.ts +4 -16
- package/src/config.ts +6 -0
- package/src/publisher/l1-publisher.ts +106 -7
- package/src/publisher/utils.ts +9 -2
- package/src/sequencer/sequencer.ts +22 -22
- package/src/tx_validator/gas_validator.ts +2 -3
- package/src/tx_validator/phases_validator.ts +3 -6
- package/src/tx_validator/test_utils.ts +3 -3
|
@@ -40,7 +40,7 @@ import { inspect } from 'util';
|
|
|
40
40
|
import { type BlockBuilderFactory } from '../block_builder/index.js';
|
|
41
41
|
import { type GlobalVariableBuilder } from '../global_variable_builder/global_builder.js';
|
|
42
42
|
import { type L1Publisher } from '../publisher/l1-publisher.js';
|
|
43
|
-
import {
|
|
43
|
+
import { prettyLogViemErrorMsg } from '../publisher/utils.js';
|
|
44
44
|
import { type TxValidatorFactory } from '../tx_validator/tx_validator_factory.js';
|
|
45
45
|
import { type SequencerConfig } from './config.js';
|
|
46
46
|
import { SequencerMetrics } from './metrics.js';
|
|
@@ -137,6 +137,10 @@ export class Sequencer {
|
|
|
137
137
|
if (config.allowedInTeardown) {
|
|
138
138
|
this.allowedInTeardown = config.allowedInTeardown;
|
|
139
139
|
}
|
|
140
|
+
if (config.gerousiaPayload) {
|
|
141
|
+
this.publisher.setPayload(config.gerousiaPayload);
|
|
142
|
+
}
|
|
143
|
+
|
|
140
144
|
// TODO: Just read everything from the config object as needed instead of copying everything into local vars.
|
|
141
145
|
this.config = config;
|
|
142
146
|
}
|
|
@@ -223,6 +227,15 @@ export class Sequencer {
|
|
|
223
227
|
return;
|
|
224
228
|
}
|
|
225
229
|
|
|
230
|
+
const newGlobalVariables = await this.globalsBuilder.buildGlobalVariables(
|
|
231
|
+
new Fr(newBlockNumber),
|
|
232
|
+
this._coinbase,
|
|
233
|
+
this._feeRecipient,
|
|
234
|
+
slot,
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
void this.publisher.castVote(slot, newGlobalVariables.timestamp.toBigInt());
|
|
238
|
+
|
|
226
239
|
if (!this.shouldProposeBlock(historicalHeader, {})) {
|
|
227
240
|
return;
|
|
228
241
|
}
|
|
@@ -237,13 +250,6 @@ export class Sequencer {
|
|
|
237
250
|
}
|
|
238
251
|
this.log.debug(`Retrieved ${pendingTxs.length} txs from P2P pool`);
|
|
239
252
|
|
|
240
|
-
const newGlobalVariables = await this.globalsBuilder.buildGlobalVariables(
|
|
241
|
-
new Fr(newBlockNumber),
|
|
242
|
-
this._coinbase,
|
|
243
|
-
this._feeRecipient,
|
|
244
|
-
slot,
|
|
245
|
-
);
|
|
246
|
-
|
|
247
253
|
// If I created a "partial" header here that should make our job much easier.
|
|
248
254
|
const proposalHeader = new Header(
|
|
249
255
|
new AppendOnlyTreeSnapshot(Fr.fromBuffer(chainTipArchive), 1),
|
|
@@ -309,8 +315,10 @@ export class Sequencer {
|
|
|
309
315
|
this.log.debug(`Can propose block ${proposalBlockNumber} at slot ${slot}`);
|
|
310
316
|
return slot;
|
|
311
317
|
} catch (err) {
|
|
312
|
-
|
|
313
|
-
|
|
318
|
+
const msg = prettyLogViemErrorMsg(err);
|
|
319
|
+
this.log.verbose(
|
|
320
|
+
`Rejected from being able to propose at next block with ${tipArchive.toString('hex')}: ${msg ? `${msg}` : ''}`,
|
|
321
|
+
);
|
|
314
322
|
throw err;
|
|
315
323
|
}
|
|
316
324
|
}
|
|
@@ -548,20 +556,12 @@ export class Sequencer {
|
|
|
548
556
|
protected async createProofClaimForPreviousEpoch(slotNumber: bigint): Promise<EpochProofQuote | undefined> {
|
|
549
557
|
try {
|
|
550
558
|
// Find out which epoch we are currently in
|
|
551
|
-
const
|
|
552
|
-
if (
|
|
553
|
-
|
|
554
|
-
this.log.verbose(`First epoch has no claim`);
|
|
555
|
-
return undefined;
|
|
556
|
-
}
|
|
557
|
-
const epochToProve = epochForBlock - 1n;
|
|
558
|
-
// Find out the next epoch that can be claimed
|
|
559
|
-
const canClaim = await this.publisher.nextEpochToClaim();
|
|
560
|
-
if (canClaim != epochToProve) {
|
|
561
|
-
// It's not the one we are looking to claim
|
|
562
|
-
this.log.verbose(`Unable to claim previous epoch (${canClaim} != ${epochToProve})`);
|
|
559
|
+
const epochToProve = await this.publisher.getClaimableEpoch();
|
|
560
|
+
if (epochToProve === undefined) {
|
|
561
|
+
this.log.verbose(`No epoch to prove`);
|
|
563
562
|
return undefined;
|
|
564
563
|
}
|
|
564
|
+
|
|
565
565
|
// Get quotes for the epoch to be proven
|
|
566
566
|
const quotes = await this.p2pClient.getEpochProofQuotes(epochToProve);
|
|
567
567
|
this.log.verbose(`Retrieved ${quotes.length} quotes, slot: ${slotNumber}, epoch to prove: ${epochToProve}`);
|
|
@@ -61,14 +61,13 @@ export class GasTxValidator implements TxValidator<Tx> {
|
|
|
61
61
|
const setupFns = EnqueuedCallsProcessor.getExecutionRequestsByPhase(tx, PublicKernelPhase.SETUP);
|
|
62
62
|
const claimFunctionCall = setupFns.find(
|
|
63
63
|
fn =>
|
|
64
|
-
fn.contractAddress.equals(this.#feeJuiceAddress) &&
|
|
64
|
+
fn.callContext.contractAddress.equals(this.#feeJuiceAddress) &&
|
|
65
65
|
fn.callContext.msgSender.equals(this.#feeJuiceAddress) &&
|
|
66
66
|
fn.args.length > 2 &&
|
|
67
67
|
// Public functions get routed through the dispatch function, whose first argument is the target function selector.
|
|
68
68
|
fn.args[0].equals(FunctionSelector.fromSignature('_increase_public_balance((Field),Field)').toField()) &&
|
|
69
69
|
fn.args[1].equals(feePayer) &&
|
|
70
|
-
!fn.callContext.isStaticCall
|
|
71
|
-
!fn.callContext.isDelegateCall,
|
|
70
|
+
!fn.callContext.isStaticCall,
|
|
72
71
|
);
|
|
73
72
|
|
|
74
73
|
const balance = claimFunctionCall ? initialBalance.add(claimFunctionCall.args[2]) : initialBalance;
|
|
@@ -50,7 +50,7 @@ export class PhasesTxValidator implements TxValidator<Tx> {
|
|
|
50
50
|
if (!(await this.isOnAllowList(setupFn, this.setupAllowList))) {
|
|
51
51
|
this.#log.warn(
|
|
52
52
|
`Rejecting tx ${Tx.getHash(tx)} because it calls setup function not on allow list: ${
|
|
53
|
-
setupFn.contractAddress
|
|
53
|
+
setupFn.callContext.contractAddress
|
|
54
54
|
}:${setupFn.callContext.functionSelector}`,
|
|
55
55
|
);
|
|
56
56
|
|
|
@@ -66,10 +66,7 @@ export class PhasesTxValidator implements TxValidator<Tx> {
|
|
|
66
66
|
return true;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
const {
|
|
70
|
-
contractAddress,
|
|
71
|
-
callContext: { functionSelector },
|
|
72
|
-
} = publicCall;
|
|
69
|
+
const { contractAddress, functionSelector } = publicCall.callContext;
|
|
73
70
|
|
|
74
71
|
// do these checks first since they don't require the contract class
|
|
75
72
|
for (const entry of allowList) {
|
|
@@ -88,7 +85,7 @@ export class PhasesTxValidator implements TxValidator<Tx> {
|
|
|
88
85
|
const contractClass = await this.contractDataSource.getContractInstance(contractAddress);
|
|
89
86
|
|
|
90
87
|
if (!contractClass) {
|
|
91
|
-
throw new Error(`Contract not found: ${
|
|
88
|
+
throw new Error(`Contract not found: ${contractAddress}`);
|
|
92
89
|
}
|
|
93
90
|
|
|
94
91
|
if ('classId' in entry && !('selector' in entry)) {
|
|
@@ -25,20 +25,20 @@ function patchFn(
|
|
|
25
25
|
overrides: { address?: AztecAddress; selector: FunctionSelector; args?: Fr[]; msgSender?: AztecAddress },
|
|
26
26
|
): { address: AztecAddress; selector: FunctionSelector } {
|
|
27
27
|
const fn = tx.enqueuedPublicFunctionCalls.at(-1 * index - 1)!;
|
|
28
|
-
fn.contractAddress = overrides.address ?? fn.contractAddress;
|
|
28
|
+
fn.callContext.contractAddress = overrides.address ?? fn.callContext.contractAddress;
|
|
29
29
|
fn.callContext.functionSelector = overrides.selector;
|
|
30
30
|
fn.args = overrides.args ?? fn.args;
|
|
31
31
|
fn.callContext.msgSender = overrides.msgSender ?? fn.callContext.msgSender;
|
|
32
32
|
tx.enqueuedPublicFunctionCalls[index] = fn;
|
|
33
33
|
|
|
34
34
|
const request = tx.data.forPublic![where].publicCallStack[index];
|
|
35
|
-
request.contractAddress = fn.contractAddress;
|
|
35
|
+
request.callContext.contractAddress = fn.callContext.contractAddress;
|
|
36
36
|
request.callContext = fn.callContext;
|
|
37
37
|
request.argsHash = computeVarArgsHash(fn.args);
|
|
38
38
|
tx.data.forPublic![where].publicCallStack[index] = request;
|
|
39
39
|
|
|
40
40
|
return {
|
|
41
|
-
address: fn.contractAddress,
|
|
41
|
+
address: fn.callContext.contractAddress,
|
|
42
42
|
selector: fn.callContext.functionSelector,
|
|
43
43
|
};
|
|
44
44
|
}
|