@aztec/sequencer-client 0.81.0 → 0.82.1-alpha-testnet.1
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/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +10 -29
- package/dest/publisher/sequencer-publisher.d.ts +3 -3
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +10 -0
- package/dest/sequencer/sequencer.d.ts +1 -0
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +7 -1
- package/dest/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/tx_validator/gas_validator.js +7 -9
- package/dest/tx_validator/phases_validator.d.ts +2 -2
- package/dest/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/tx_validator/phases_validator.js +5 -4
- package/dest/tx_validator/test_utils.d.ts +3 -9
- package/dest/tx_validator/test_utils.d.ts.map +1 -1
- package/dest/tx_validator/test_utils.js +12 -16
- package/package.json +25 -25
- package/src/global_variable_builder/global_builder.ts +11 -15
- package/src/sequencer/metrics.ts +10 -0
- package/src/sequencer/sequencer.ts +14 -1
- package/src/tx_validator/gas_validator.ts +13 -14
- package/src/tx_validator/phases_validator.ts +11 -7
- package/src/tx_validator/test_utils.ts +15 -20
|
@@ -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,
|
|
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;IAEhE,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,oBAAoB,CAAS;gBAEzB,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC,iBAAiB,EAAE,sBAAsB,CAAC;IAgBpF;;;OAGG;IACU,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IAanD;;;;;;;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;CA8B5B"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { createEthereumChain } from '@aztec/ethereum';
|
|
1
|
+
import { RollupContract, createEthereumChain } from '@aztec/ethereum';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { RollupAbi } from '@aztec/l1-artifacts';
|
|
5
4
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
6
5
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
7
|
-
import { createPublicClient, fallback,
|
|
6
|
+
import { createPublicClient, fallback, http } from 'viem';
|
|
8
7
|
/**
|
|
9
8
|
* Simple global variables builder.
|
|
10
9
|
*/ export class GlobalVariableBuilder {
|
|
@@ -21,11 +20,7 @@ import { createPublicClient, fallback, getAddress, getContract, http } from 'vie
|
|
|
21
20
|
transport: fallback(chain.rpcUrls.map((url)=>http(url))),
|
|
22
21
|
pollingInterval: config.viemPollingIntervalMS
|
|
23
22
|
});
|
|
24
|
-
this.rollupContract =
|
|
25
|
-
address: getAddress(l1Contracts.rollupAddress.toString()),
|
|
26
|
-
abi: RollupAbi,
|
|
27
|
-
client: this.publicClient
|
|
28
|
-
});
|
|
23
|
+
this.rollupContract = new RollupContract(this.publicClient, l1Contracts.rollupAddress);
|
|
29
24
|
}
|
|
30
25
|
/**
|
|
31
26
|
* Computes the "current" base fees, e.g., the price that you currently should pay to get include in the next block
|
|
@@ -34,18 +29,11 @@ import { createPublicClient, fallback, getAddress, getContract, http } from 'vie
|
|
|
34
29
|
// Since this might be called in the middle of a slot where a block might have been published,
|
|
35
30
|
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
36
31
|
// The timestamp of that last block will act as a lower bound for the next block.
|
|
37
|
-
const lastBlock = await this.rollupContract.
|
|
38
|
-
|
|
39
|
-
]);
|
|
40
|
-
const earliestTimestamp = await this.rollupContract.read.getTimestampForSlot([
|
|
41
|
-
lastBlock.slotNumber + 1n
|
|
42
|
-
]);
|
|
32
|
+
const lastBlock = await this.rollupContract.getBlock(await this.rollupContract.getBlockNumber());
|
|
33
|
+
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(lastBlock.slotNumber + 1n);
|
|
43
34
|
const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
44
35
|
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
45
|
-
return new GasFees(Fr.ZERO, new Fr(await this.rollupContract.
|
|
46
|
-
timestamp,
|
|
47
|
-
true
|
|
48
|
-
])));
|
|
36
|
+
return new GasFees(Fr.ZERO, new Fr(await this.rollupContract.getManaBaseFeeAt(timestamp, true)));
|
|
49
37
|
}
|
|
50
38
|
/**
|
|
51
39
|
* Simple builder of global variables that use the minimum time possible.
|
|
@@ -55,24 +43,17 @@ import { createPublicClient, fallback, getAddress, getContract, http } from 'vie
|
|
|
55
43
|
* @param slotNumber - The slot number to use for the global variables, if undefined it will be calculated.
|
|
56
44
|
* @returns The global variables for the given block number.
|
|
57
45
|
*/ async buildGlobalVariables(blockNumber, coinbase, feeRecipient, slotNumber) {
|
|
58
|
-
const version = new Fr(await this.rollupContract.
|
|
46
|
+
const version = new Fr(await this.rollupContract.getVersion());
|
|
59
47
|
const chainId = new Fr(this.publicClient.chain.id);
|
|
60
48
|
if (slotNumber === undefined) {
|
|
61
49
|
const ts = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
62
|
-
slotNumber = await this.rollupContract.
|
|
63
|
-
ts
|
|
64
|
-
]);
|
|
50
|
+
slotNumber = await this.rollupContract.getSlotAt(ts);
|
|
65
51
|
}
|
|
66
|
-
const timestamp = await this.rollupContract.
|
|
67
|
-
slotNumber
|
|
68
|
-
]);
|
|
52
|
+
const timestamp = await this.rollupContract.getTimestampForSlot(slotNumber);
|
|
69
53
|
const slotFr = new Fr(slotNumber);
|
|
70
54
|
const timestampFr = new Fr(timestamp);
|
|
71
55
|
// We can skip much of the logic in getCurrentBaseFees since it we already check that we are not within a slot elsewhere.
|
|
72
|
-
const gasFees = new GasFees(Fr.ZERO, new Fr(await this.rollupContract.
|
|
73
|
-
timestamp,
|
|
74
|
-
true
|
|
75
|
-
])));
|
|
56
|
+
const gasFees = new GasFees(Fr.ZERO, new Fr(await this.rollupContract.getManaBaseFeeAt(timestamp, true)));
|
|
76
57
|
const globalVariables = new GlobalVariables(chainId, version, blockNumber, slotFr, timestampFr, coinbase, feeRecipient, gasFees);
|
|
77
58
|
return globalVariables;
|
|
78
59
|
}
|
|
@@ -36,14 +36,14 @@ export declare class SequencerPublisher {
|
|
|
36
36
|
private metrics;
|
|
37
37
|
private epochCache;
|
|
38
38
|
private forwarderContract;
|
|
39
|
-
protected governanceLog: import("@aztec/
|
|
39
|
+
protected governanceLog: import("@aztec/foundation/log").Logger;
|
|
40
40
|
protected governanceProposerAddress?: EthAddress;
|
|
41
41
|
private governancePayload;
|
|
42
|
-
protected slashingLog: import("@aztec/
|
|
42
|
+
protected slashingLog: import("@aztec/foundation/log").Logger;
|
|
43
43
|
protected slashingProposerAddress?: EthAddress;
|
|
44
44
|
private getSlashPayload?;
|
|
45
45
|
private myLastVotes;
|
|
46
|
-
protected log: import("@aztec/
|
|
46
|
+
protected log: import("@aztec/foundation/log").Logger;
|
|
47
47
|
protected ethereumSlotDuration: bigint;
|
|
48
48
|
private blobSinkClient;
|
|
49
49
|
static PROPOSE_GAS_GUESS: bigint;
|
|
@@ -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;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAMjE,OAA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,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAGlF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/sequencer/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,MAAM,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,sBAAsB,EAA0B,MAAM,YAAY,CAAC;AAEtG,qBAAa,gBAAgB;IAC3B,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,kBAAkB,CAAY;IACtC,OAAO,CAAC,uBAAuB,CAAQ;IACvC,OAAO,CAAC,6BAA6B,CAAY;IACjD,OAAO,CAAC,kBAAkB,CAAQ;IAClC,OAAO,CAAC,gBAAgB,CAAQ;IAChC,OAAO,CAAC,sBAAsB,CAAY;IAE1C,OAAO,CAAC,yBAAyB,CAAQ;gBAE7B,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,sBAAsB,EAAE,IAAI,SAAc;
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/sequencer/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,MAAM,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,sBAAsB,EAA0B,MAAM,YAAY,CAAC;AAEtG,qBAAa,gBAAgB;IAC3B,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,kBAAkB,CAAY;IACtC,OAAO,CAAC,uBAAuB,CAAQ;IACvC,OAAO,CAAC,6BAA6B,CAAY;IACjD,OAAO,CAAC,kBAAkB,CAAQ;IAClC,OAAO,CAAC,gBAAgB,CAAQ;IAChC,OAAO,CAAC,sBAAsB,CAAY;IAE1C,OAAO,CAAC,yBAAyB,CAAQ;gBAE7B,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,sBAAsB,EAAE,IAAI,SAAc;IAmEzF,gCAAgC,IAAI,MAAM,IAAI;IAS9C,+BAA+B,CAAC,IAAI,EAAE,MAAM;IAI5C,gCAAgC,CAAC,MAAM,EAAE,MAAM;IAI/C,oBAAoB;IAOpB,gBAAgB,CAAC,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAQ3D,iBAAiB;IAOjB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAInD,6BAA6B,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc;IAMvE,OAAO,CAAC,eAAe;CAIxB"}
|
|
@@ -52,7 +52,17 @@ export class SequencerMetrics {
|
|
|
52
52
|
unit: 'us',
|
|
53
53
|
valueType: ValueType.INT
|
|
54
54
|
});
|
|
55
|
+
// Init gauges and counters
|
|
55
56
|
this.setCurrentBlock(0, 0);
|
|
57
|
+
this.blockCounter.add(0, {
|
|
58
|
+
[Attributes.STATUS]: 'cancelled'
|
|
59
|
+
});
|
|
60
|
+
this.blockCounter.add(0, {
|
|
61
|
+
[Attributes.STATUS]: 'failed'
|
|
62
|
+
});
|
|
63
|
+
this.blockCounter.add(0, {
|
|
64
|
+
[Attributes.STATUS]: 'built'
|
|
65
|
+
});
|
|
56
66
|
}
|
|
57
67
|
startCollectingAttestationsTimer() {
|
|
58
68
|
const startTime = Date.now();
|
|
@@ -63,6 +63,7 @@ export declare class Sequencer {
|
|
|
63
63
|
private maxBlockSizeInBytes;
|
|
64
64
|
private maxBlockGas;
|
|
65
65
|
private metrics;
|
|
66
|
+
private l1Metrics;
|
|
66
67
|
private isFlushing;
|
|
67
68
|
/** The maximum number of seconds that the sequencer can be into a slot to transition to a particular state. */
|
|
68
69
|
protected timetable: SequencerTimetable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequencer.d.ts","sourceRoot":"","sources":["../../src/sequencer/sequencer.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,EAAW,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAGL,KAAK,sBAAsB,EAE5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAInE,OAAO,EAGL,KAAK,eAAe,EAEpB,EAAE,EACF,KAAK,MAAM,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"sequencer.d.ts","sourceRoot":"","sources":["../../src/sequencer/sequencer.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,MAAM,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B,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,EAAE,CAAC,EAC5C,kBAAkB,EAAE,eAAe,EACnC,IAAI,GAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAO;;;;;;;;;IAgIvC;;;;;;;;OAQG;YAIW,2BAA2B;cAkEzB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,GAAG,SAAS,CAAC;IA6CzG;;;OAGG;cAIa,qBAAqB,CACnC,KAAK,EAAE,OAAO,EACd,YAAY,CAAC,EAAE,SAAS,EAAE,EAC1B,QAAQ,CAAC,EAAE,MAAM,EAAE,GAClB,OAAO,CAAC,IAAI,CAAC;IAiBhB;;;;OAIG;cACa,WAAW,IAAI,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,EAAE,CAAA;KAAE,GAAG,SAAS,CAAC;IAsDxF,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,kBAAkB;IAK1B,IAAI,iBAAiB,WAEpB;IAED,IAAI,QAAQ,IAAI,UAAU,CAEzB;IAED,IAAI,YAAY,IAAI,YAAY,CAE/B;CACF"}
|
|
@@ -17,7 +17,7 @@ import { SequencerConfigSchema } from '@aztec/stdlib/interfaces/server';
|
|
|
17
17
|
import { pickFromSchema } from '@aztec/stdlib/schemas';
|
|
18
18
|
import { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
19
19
|
import { BlockHeader, ContentCommitment, StateReference, Tx } from '@aztec/stdlib/tx';
|
|
20
|
-
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
20
|
+
import { Attributes, L1Metrics, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
21
21
|
import { VoteType } from '../publisher/sequencer-publisher.js';
|
|
22
22
|
import { createValidatorsForBlockBuilding } from '../tx_validator/tx_validator_factory.js';
|
|
23
23
|
import { getDefaultAllowedSetupFunctions } from './allowed.js';
|
|
@@ -62,6 +62,7 @@ export { SequencerState };
|
|
|
62
62
|
maxBlockSizeInBytes;
|
|
63
63
|
maxBlockGas;
|
|
64
64
|
metrics;
|
|
65
|
+
l1Metrics;
|
|
65
66
|
isFlushing;
|
|
66
67
|
/** The maximum number of seconds that the sequencer can be into a slot to transition to a particular state. */ timetable;
|
|
67
68
|
enforceTimeTable;
|
|
@@ -94,6 +95,9 @@ export { SequencerState };
|
|
|
94
95
|
this.isFlushing = false;
|
|
95
96
|
this.enforceTimeTable = false;
|
|
96
97
|
this.metrics = new SequencerMetrics(telemetry, ()=>this.state, 'Sequencer');
|
|
98
|
+
this.l1Metrics = new L1Metrics(telemetry.getMeter('SequencerL1Metrics'), publisher.l1TxUtils.publicClient, [
|
|
99
|
+
publisher.getSenderAddress()
|
|
100
|
+
]);
|
|
97
101
|
// Register the block builder with the validator client for re-execution
|
|
98
102
|
this.validatorClient?.registerBlockBuilder(this.buildBlock.bind(this));
|
|
99
103
|
// Register the slasher on the publisher to fetch slashing payloads
|
|
@@ -165,6 +169,7 @@ export { SequencerState };
|
|
|
165
169
|
this.runningPromise = new RunningPromise(this.work.bind(this), this.log, this.pollingIntervalMs);
|
|
166
170
|
this.setState(SequencerState.IDLE, 0n, true);
|
|
167
171
|
this.runningPromise.start();
|
|
172
|
+
this.l1Metrics.start();
|
|
168
173
|
this.log.info(`Sequencer started with address ${this.publisher.getSenderAddress().toString()}`);
|
|
169
174
|
}
|
|
170
175
|
/**
|
|
@@ -176,6 +181,7 @@ export { SequencerState };
|
|
|
176
181
|
this.slasherClient.stop();
|
|
177
182
|
this.publisher.interrupt();
|
|
178
183
|
this.setState(SequencerState.STOPPED, 0n, true);
|
|
184
|
+
this.l1Metrics.stop();
|
|
179
185
|
this.log.info('Stopped sequencer');
|
|
180
186
|
}
|
|
181
187
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gas_validator.d.ts","sourceRoot":"","sources":["../../src/tx_validator/gas_validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAK9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,EAAoB,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAExG,iDAAiD;AACjD,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,KAAK,OAAO,CAAC,EAAE,CAAC,CAAC;CACvE;AAED,qBAAa,cAAe,YAAW,WAAW,CAAC,EAAE,CAAC;;gBAMxC,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO;IAM1F,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"gas_validator.d.ts","sourceRoot":"","sources":["../../src/tx_validator/gas_validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAK9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,EAAoB,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAExG,iDAAiD;AACjD,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,KAAK,OAAO,CAAC,EAAE,CAAC,CAAC;CACvE;AAED,qBAAa,cAAe,YAAW,WAAW,CAAC,EAAE,CAAC;;gBAMxC,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO;IAM1F,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAyEtD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
3
|
-
import {
|
|
3
|
+
import { getCallRequestsWithCalldataByPhase } from '@aztec/simulator/server';
|
|
4
4
|
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
5
|
import { TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
6
6
|
export class GasTxValidator {
|
|
@@ -49,15 +49,13 @@ export class GasTxValidator {
|
|
|
49
49
|
// Read current balance of the feePayer
|
|
50
50
|
const initialBalance = await this.#publicDataSource.storageRead(this.#feeJuiceAddress, await computeFeePayerBalanceStorageSlot(feePayer));
|
|
51
51
|
// If there is a claim in this tx that increases the fee payer balance in Fee Juice, add it to balance
|
|
52
|
-
const setupFns =
|
|
52
|
+
const setupFns = getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.SETUP);
|
|
53
53
|
const increasePublicBalanceSelector = await FunctionSelector.fromSignature('_increase_public_balance((Field),u128)');
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// - Index 2: Amount being claimed
|
|
60
|
-
const balance = claimFunctionCall ? initialBalance.add(claimFunctionCall.args[2]) : initialBalance;
|
|
54
|
+
// Arguments of the claim function call:
|
|
55
|
+
// - args[0]: Amount recipient.
|
|
56
|
+
// - args[1]: Amount being claimed.
|
|
57
|
+
const claimFunctionCall = setupFns.find((fn)=>fn.request.contractAddress.equals(this.#feeJuiceAddress) && fn.request.msgSender.equals(this.#feeJuiceAddress) && fn.calldata.length > 2 && fn.functionSelector.equals(increasePublicBalanceSelector) && fn.args[0].equals(feePayer.toField()) && !fn.request.isStaticCall);
|
|
58
|
+
const balance = claimFunctionCall ? initialBalance.add(claimFunctionCall.args[1]) : initialBalance;
|
|
61
59
|
if (balance.lt(feeLimit)) {
|
|
62
60
|
this.#log.warn(`Rejecting transaction due to not enough fee payer balance`, {
|
|
63
61
|
feePayer,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
2
2
|
import type { AllowedElement } from '@aztec/stdlib/interfaces/server';
|
|
3
|
-
import {
|
|
3
|
+
import { Tx, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
|
|
4
4
|
export declare class PhasesTxValidator implements TxValidator<Tx> {
|
|
5
5
|
#private;
|
|
6
6
|
private setupAllowList;
|
|
@@ -8,6 +8,6 @@ export declare class PhasesTxValidator implements TxValidator<Tx> {
|
|
|
8
8
|
private contractsDB;
|
|
9
9
|
constructor(contracts: ContractDataSource, setupAllowList: AllowedElement[], blockNumber: number);
|
|
10
10
|
validateTx(tx: Tx): Promise<TxValidationResult>;
|
|
11
|
-
isOnAllowList
|
|
11
|
+
private isOnAllowList;
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=phases_validator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phases_validator.d.ts","sourceRoot":"","sources":["../../src/tx_validator/phases_validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,
|
|
1
|
+
{"version":3,"file":"phases_validator.d.ts","sourceRoot":"","sources":["../../src/tx_validator/phases_validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAEL,EAAE,EAEF,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,iBAAkB,YAAW,WAAW,CAAC,EAAE,CAAC;;IAIZ,OAAO,CAAC,cAAc;IAAoB,OAAO,CAAC,WAAW;IAFxG,OAAO,CAAC,WAAW,CAAoB;gBAE3B,SAAS,EAAE,kBAAkB,EAAU,cAAc,EAAE,cAAc,EAAE,EAAU,WAAW,EAAE,MAAM;IAI1G,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAkCvC,aAAa;CAiD5B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { PublicContractsDB,
|
|
2
|
+
import { PublicContractsDB, getCallRequestsWithCalldataByPhase } from '@aztec/simulator/server';
|
|
3
3
|
import { Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
4
4
|
export class PhasesTxValidator {
|
|
5
5
|
setupAllowList;
|
|
@@ -24,10 +24,10 @@ export class PhasesTxValidator {
|
|
|
24
24
|
result: 'valid'
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
const setupFns =
|
|
27
|
+
const setupFns = getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.SETUP);
|
|
28
28
|
for (const setupFn of setupFns){
|
|
29
29
|
if (!await this.isOnAllowList(setupFn, this.setupAllowList)) {
|
|
30
|
-
this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)} because it calls setup function not on allow list: ${setupFn.
|
|
30
|
+
this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)} because it calls setup function not on allow list: ${setupFn.request.contractAddress}:${setupFn.functionSelector}`, {
|
|
31
31
|
allowList: this.setupAllowList
|
|
32
32
|
});
|
|
33
33
|
return {
|
|
@@ -49,7 +49,8 @@ export class PhasesTxValidator {
|
|
|
49
49
|
if (publicCall.isEmpty()) {
|
|
50
50
|
return true;
|
|
51
51
|
}
|
|
52
|
-
const
|
|
52
|
+
const contractAddress = publicCall.request.contractAddress;
|
|
53
|
+
const functionSelector = publicCall.functionSelector;
|
|
53
54
|
// do these checks first since they don't require the contract class
|
|
54
55
|
for (const entry of allowList){
|
|
55
56
|
if ('address' in entry && !('selector' in entry)) {
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import type
|
|
4
|
+
import { type Tx } from '@aztec/stdlib/tx';
|
|
5
5
|
export declare function patchNonRevertibleFn(tx: Tx, index: number, overrides: {
|
|
6
6
|
address?: AztecAddress;
|
|
7
7
|
selector: FunctionSelector;
|
|
8
8
|
args?: Fr[];
|
|
9
9
|
msgSender?: AztecAddress;
|
|
10
|
-
}): Promise<
|
|
11
|
-
address: AztecAddress;
|
|
12
|
-
selector: FunctionSelector;
|
|
13
|
-
}>;
|
|
10
|
+
}): Promise<AztecAddress>;
|
|
14
11
|
export declare function patchRevertibleFn(tx: Tx, index: number, overrides: {
|
|
15
12
|
address?: AztecAddress;
|
|
16
13
|
selector: FunctionSelector;
|
|
17
14
|
args?: Fr[];
|
|
18
15
|
msgSender?: AztecAddress;
|
|
19
|
-
}): Promise<
|
|
20
|
-
address: AztecAddress;
|
|
21
|
-
selector: FunctionSelector;
|
|
22
|
-
}>;
|
|
16
|
+
}): Promise<AztecAddress>;
|
|
23
17
|
//# sourceMappingURL=test_utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_utils.d.ts","sourceRoot":"","sources":["../../src/tx_validator/test_utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"test_utils.d.ts","sourceRoot":"","sources":["../../src/tx_validator/test_utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAgB,KAAK,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAEzD,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,EAAE,EACN,KAAK,EAAE,MAAM,EACb,SAAS,EAAE;IAAE,OAAO,CAAC,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,gBAAgB,CAAC;IAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC;IAAC,SAAS,CAAC,EAAE,YAAY,CAAA;CAAE,GACvG,OAAO,CAAC,YAAY,CAAC,CAEvB;AAED,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,EAAE,EACN,KAAK,EAAE,MAAM,EACb,SAAS,EAAE;IAAE,OAAO,CAAC,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,gBAAgB,CAAC;IAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC;IAAC,SAAS,CAAC,EAAE,YAAY,CAAA;CAAE,GACvG,OAAO,CAAC,YAAY,CAAC,CAEvB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HashedValues } from '@aztec/stdlib/tx';
|
|
2
2
|
export function patchNonRevertibleFn(tx, index, overrides) {
|
|
3
3
|
return patchFn('nonRevertibleAccumulatedData', tx, index, overrides);
|
|
4
4
|
}
|
|
@@ -6,21 +6,17 @@ export function patchRevertibleFn(tx, index, overrides) {
|
|
|
6
6
|
return patchFn('revertibleAccumulatedData', tx, index, overrides);
|
|
7
7
|
}
|
|
8
8
|
async function patchFn(where, tx, index, overrides) {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const calldataIndex = where === 'nonRevertibleAccumulatedData' ? index : index + tx.data.forPublic.nonRevertibleAccumulatedData.publicCallRequests.length;
|
|
10
|
+
const calldata = [
|
|
11
|
+
overrides.selector.toField(),
|
|
12
|
+
...overrides.args ?? []
|
|
13
|
+
];
|
|
14
|
+
const hashedCalldata = await HashedValues.fromCalldata(calldata);
|
|
15
|
+
tx.publicFunctionCalldata[calldataIndex] = hashedCalldata;
|
|
15
16
|
const request = tx.data.forPublic[where].publicCallRequests[index];
|
|
16
|
-
request.contractAddress =
|
|
17
|
-
request.msgSender =
|
|
18
|
-
request.
|
|
19
|
-
request.isStaticCall = fn.callContext.isStaticCall;
|
|
20
|
-
request.argsHash = await computeVarArgsHash(fn.args);
|
|
17
|
+
request.contractAddress = overrides.address ?? request.contractAddress;
|
|
18
|
+
request.msgSender = overrides.msgSender ?? request.msgSender;
|
|
19
|
+
request.calldataHash = hashedCalldata.hash;
|
|
21
20
|
tx.data.forPublic[where].publicCallRequests[index] = request;
|
|
22
|
-
return
|
|
23
|
-
address: fn.callContext.contractAddress,
|
|
24
|
-
selector: fn.callContext.functionSelector
|
|
25
|
-
};
|
|
21
|
+
return request.contractAddress;
|
|
26
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/sequencer-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.82.1-alpha-testnet.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -28,36 +28,36 @@
|
|
|
28
28
|
"test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --config jest.integration.config.json"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@aztec/aztec.js": "0.
|
|
32
|
-
"@aztec/bb-prover": "0.
|
|
33
|
-
"@aztec/blob-lib": "0.
|
|
34
|
-
"@aztec/blob-sink": "0.
|
|
35
|
-
"@aztec/constants": "0.
|
|
36
|
-
"@aztec/epoch-cache": "0.
|
|
37
|
-
"@aztec/ethereum": "0.
|
|
38
|
-
"@aztec/foundation": "0.
|
|
39
|
-
"@aztec/l1-artifacts": "0.
|
|
40
|
-
"@aztec/merkle-tree": "0.
|
|
41
|
-
"@aztec/noir-acvm_js": "0.
|
|
42
|
-
"@aztec/noir-contracts.js": "0.
|
|
43
|
-
"@aztec/noir-protocol-circuits-types": "0.
|
|
44
|
-
"@aztec/noir-types": "0.
|
|
45
|
-
"@aztec/p2p": "0.
|
|
46
|
-
"@aztec/protocol-contracts": "0.
|
|
47
|
-
"@aztec/prover-client": "0.
|
|
48
|
-
"@aztec/simulator": "0.
|
|
49
|
-
"@aztec/stdlib": "0.
|
|
50
|
-
"@aztec/telemetry-client": "0.
|
|
51
|
-
"@aztec/validator-client": "0.
|
|
52
|
-
"@aztec/world-state": "0.
|
|
31
|
+
"@aztec/aztec.js": "0.82.1-alpha-testnet.1",
|
|
32
|
+
"@aztec/bb-prover": "0.82.1-alpha-testnet.1",
|
|
33
|
+
"@aztec/blob-lib": "0.82.1-alpha-testnet.1",
|
|
34
|
+
"@aztec/blob-sink": "0.82.1-alpha-testnet.1",
|
|
35
|
+
"@aztec/constants": "0.82.1-alpha-testnet.1",
|
|
36
|
+
"@aztec/epoch-cache": "0.82.1-alpha-testnet.1",
|
|
37
|
+
"@aztec/ethereum": "0.82.1-alpha-testnet.1",
|
|
38
|
+
"@aztec/foundation": "0.82.1-alpha-testnet.1",
|
|
39
|
+
"@aztec/l1-artifacts": "0.82.1-alpha-testnet.1",
|
|
40
|
+
"@aztec/merkle-tree": "0.82.1-alpha-testnet.1",
|
|
41
|
+
"@aztec/noir-acvm_js": "0.82.1-alpha-testnet.1",
|
|
42
|
+
"@aztec/noir-contracts.js": "0.82.1-alpha-testnet.1",
|
|
43
|
+
"@aztec/noir-protocol-circuits-types": "0.82.1-alpha-testnet.1",
|
|
44
|
+
"@aztec/noir-types": "0.82.1-alpha-testnet.1",
|
|
45
|
+
"@aztec/p2p": "0.82.1-alpha-testnet.1",
|
|
46
|
+
"@aztec/protocol-contracts": "0.82.1-alpha-testnet.1",
|
|
47
|
+
"@aztec/prover-client": "0.82.1-alpha-testnet.1",
|
|
48
|
+
"@aztec/simulator": "0.82.1-alpha-testnet.1",
|
|
49
|
+
"@aztec/stdlib": "0.82.1-alpha-testnet.1",
|
|
50
|
+
"@aztec/telemetry-client": "0.82.1-alpha-testnet.1",
|
|
51
|
+
"@aztec/validator-client": "0.82.1-alpha-testnet.1",
|
|
52
|
+
"@aztec/world-state": "0.82.1-alpha-testnet.1",
|
|
53
53
|
"lodash.chunk": "^4.2.0",
|
|
54
54
|
"lodash.pick": "^4.4.0",
|
|
55
55
|
"tslib": "^2.4.0",
|
|
56
56
|
"viem": "2.23.7"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@aztec/archiver": "0.
|
|
60
|
-
"@aztec/kv-store": "0.
|
|
59
|
+
"@aztec/archiver": "0.82.1-alpha-testnet.1",
|
|
60
|
+
"@aztec/kv-store": "0.82.1-alpha-testnet.1",
|
|
61
61
|
"@jest/globals": "^29.5.0",
|
|
62
62
|
"@types/jest": "^29.5.0",
|
|
63
63
|
"@types/levelup": "^5.1.2",
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type L1ContractsConfig,
|
|
3
3
|
type L1ReaderConfig,
|
|
4
|
+
RollupContract,
|
|
4
5
|
type ViemPublicClient,
|
|
5
6
|
createEthereumChain,
|
|
6
7
|
} from '@aztec/ethereum';
|
|
7
8
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
8
9
|
import { Fr } from '@aztec/foundation/fields';
|
|
9
10
|
import { createLogger } from '@aztec/foundation/log';
|
|
10
|
-
import { RollupAbi } from '@aztec/l1-artifacts';
|
|
11
11
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
12
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
13
13
|
import type { GlobalVariableBuilder as GlobalVariableBuilderInterface } from '@aztec/stdlib/tx';
|
|
14
14
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { createPublicClient, fallback, http } from 'viem';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Simple global variables builder.
|
|
@@ -21,7 +21,7 @@ import { type GetContractReturnType, createPublicClient, fallback, getAddress, g
|
|
|
21
21
|
export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
22
22
|
private log = createLogger('sequencer:global_variable_builder');
|
|
23
23
|
|
|
24
|
-
private rollupContract:
|
|
24
|
+
private rollupContract: RollupContract;
|
|
25
25
|
private publicClient: ViemPublicClient;
|
|
26
26
|
private ethereumSlotDuration: number;
|
|
27
27
|
|
|
@@ -38,11 +38,7 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
38
38
|
pollingInterval: config.viemPollingIntervalMS,
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
this.rollupContract =
|
|
42
|
-
address: getAddress(l1Contracts.rollupAddress.toString()),
|
|
43
|
-
abi: RollupAbi,
|
|
44
|
-
client: this.publicClient,
|
|
45
|
-
});
|
|
41
|
+
this.rollupContract = new RollupContract(this.publicClient, l1Contracts.rollupAddress);
|
|
46
42
|
}
|
|
47
43
|
|
|
48
44
|
/**
|
|
@@ -54,12 +50,12 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
54
50
|
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
55
51
|
// The timestamp of that last block will act as a lower bound for the next block.
|
|
56
52
|
|
|
57
|
-
const lastBlock = await this.rollupContract.
|
|
58
|
-
const earliestTimestamp = await this.rollupContract.
|
|
53
|
+
const lastBlock = await this.rollupContract.getBlock(await this.rollupContract.getBlockNumber());
|
|
54
|
+
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(lastBlock.slotNumber + 1n);
|
|
59
55
|
const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
60
56
|
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
61
57
|
|
|
62
|
-
return new GasFees(Fr.ZERO, new Fr(await this.rollupContract.
|
|
58
|
+
return new GasFees(Fr.ZERO, new Fr(await this.rollupContract.getManaBaseFeeAt(timestamp, true)));
|
|
63
59
|
}
|
|
64
60
|
|
|
65
61
|
/**
|
|
@@ -76,21 +72,21 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
76
72
|
feeRecipient: AztecAddress,
|
|
77
73
|
slotNumber?: bigint,
|
|
78
74
|
): Promise<GlobalVariables> {
|
|
79
|
-
const version = new Fr(await this.rollupContract.
|
|
75
|
+
const version = new Fr(await this.rollupContract.getVersion());
|
|
80
76
|
const chainId = new Fr(this.publicClient.chain.id);
|
|
81
77
|
|
|
82
78
|
if (slotNumber === undefined) {
|
|
83
79
|
const ts = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
84
|
-
slotNumber = await this.rollupContract.
|
|
80
|
+
slotNumber = await this.rollupContract.getSlotAt(ts);
|
|
85
81
|
}
|
|
86
82
|
|
|
87
|
-
const timestamp = await this.rollupContract.
|
|
83
|
+
const timestamp = await this.rollupContract.getTimestampForSlot(slotNumber);
|
|
88
84
|
|
|
89
85
|
const slotFr = new Fr(slotNumber);
|
|
90
86
|
const timestampFr = new Fr(timestamp);
|
|
91
87
|
|
|
92
88
|
// We can skip much of the logic in getCurrentBaseFees since it we already check that we are not within a slot elsewhere.
|
|
93
|
-
const gasFees = new GasFees(Fr.ZERO, new Fr(await this.rollupContract.
|
|
89
|
+
const gasFees = new GasFees(Fr.ZERO, new Fr(await this.rollupContract.getManaBaseFeeAt(timestamp, true)));
|
|
94
90
|
|
|
95
91
|
const globalVariables = new GlobalVariables(
|
|
96
92
|
chainId,
|
package/src/sequencer/metrics.ts
CHANGED
|
@@ -78,7 +78,17 @@ export class SequencerMetrics {
|
|
|
78
78
|
valueType: ValueType.INT,
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
+
// Init gauges and counters
|
|
81
82
|
this.setCurrentBlock(0, 0);
|
|
83
|
+
this.blockCounter.add(0, {
|
|
84
|
+
[Attributes.STATUS]: 'cancelled',
|
|
85
|
+
});
|
|
86
|
+
this.blockCounter.add(0, {
|
|
87
|
+
[Attributes.STATUS]: 'failed',
|
|
88
|
+
});
|
|
89
|
+
this.blockCounter.add(0, {
|
|
90
|
+
[Attributes.STATUS]: 'built',
|
|
91
|
+
});
|
|
82
92
|
}
|
|
83
93
|
|
|
84
94
|
startCollectingAttestationsTimer(): () => void {
|
|
@@ -33,7 +33,14 @@ import {
|
|
|
33
33
|
Tx,
|
|
34
34
|
type TxHash,
|
|
35
35
|
} from '@aztec/stdlib/tx';
|
|
36
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
Attributes,
|
|
38
|
+
L1Metrics,
|
|
39
|
+
type TelemetryClient,
|
|
40
|
+
type Tracer,
|
|
41
|
+
getTelemetryClient,
|
|
42
|
+
trackSpan,
|
|
43
|
+
} from '@aztec/telemetry-client';
|
|
37
44
|
import type { ValidatorClient } from '@aztec/validator-client';
|
|
38
45
|
|
|
39
46
|
import type { GlobalVariableBuilder } from '../global_variable_builder/global_builder.js';
|
|
@@ -73,6 +80,7 @@ export class Sequencer {
|
|
|
73
80
|
private maxBlockSizeInBytes: number = 1024 * 1024;
|
|
74
81
|
private maxBlockGas: Gas = new Gas(100e9, 100e9);
|
|
75
82
|
private metrics: SequencerMetrics;
|
|
83
|
+
private l1Metrics: L1Metrics;
|
|
76
84
|
private isFlushing: boolean = false;
|
|
77
85
|
|
|
78
86
|
/** The maximum number of seconds that the sequencer can be into a slot to transition to a particular state. */
|
|
@@ -99,6 +107,9 @@ export class Sequencer {
|
|
|
99
107
|
protected log = createLogger('sequencer'),
|
|
100
108
|
) {
|
|
101
109
|
this.metrics = new SequencerMetrics(telemetry, () => this.state, 'Sequencer');
|
|
110
|
+
this.l1Metrics = new L1Metrics(telemetry.getMeter('SequencerL1Metrics'), publisher.l1TxUtils.publicClient, [
|
|
111
|
+
publisher.getSenderAddress(),
|
|
112
|
+
]);
|
|
102
113
|
|
|
103
114
|
// Register the block builder with the validator client for re-execution
|
|
104
115
|
this.validatorClient?.registerBlockBuilder(this.buildBlock.bind(this));
|
|
@@ -187,6 +198,7 @@ export class Sequencer {
|
|
|
187
198
|
this.runningPromise = new RunningPromise(this.work.bind(this), this.log, this.pollingIntervalMs);
|
|
188
199
|
this.setState(SequencerState.IDLE, 0n, true /** force */);
|
|
189
200
|
this.runningPromise.start();
|
|
201
|
+
this.l1Metrics.start();
|
|
190
202
|
this.log.info(`Sequencer started with address ${this.publisher.getSenderAddress().toString()}`);
|
|
191
203
|
}
|
|
192
204
|
|
|
@@ -200,6 +212,7 @@ export class Sequencer {
|
|
|
200
212
|
this.slasherClient.stop();
|
|
201
213
|
this.publisher.interrupt();
|
|
202
214
|
this.setState(SequencerState.STOPPED, 0n, true /** force */);
|
|
215
|
+
this.l1Metrics.stop();
|
|
203
216
|
this.log.info('Stopped sequencer');
|
|
204
217
|
}
|
|
205
218
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
4
|
-
import {
|
|
4
|
+
import { getCallRequestsWithCalldataByPhase } from '@aztec/simulator/server';
|
|
5
5
|
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
6
6
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
7
|
import type { GasFees } from '@aztec/stdlib/gas';
|
|
@@ -68,26 +68,25 @@ export class GasTxValidator implements TxValidator<Tx> {
|
|
|
68
68
|
);
|
|
69
69
|
|
|
70
70
|
// If there is a claim in this tx that increases the fee payer balance in Fee Juice, add it to balance
|
|
71
|
-
const setupFns =
|
|
71
|
+
const setupFns = getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.SETUP);
|
|
72
72
|
const increasePublicBalanceSelector = await FunctionSelector.fromSignature(
|
|
73
73
|
'_increase_public_balance((Field),u128)',
|
|
74
74
|
);
|
|
75
|
+
|
|
76
|
+
// Arguments of the claim function call:
|
|
77
|
+
// - args[0]: Amount recipient.
|
|
78
|
+
// - args[1]: Amount being claimed.
|
|
75
79
|
const claimFunctionCall = setupFns.find(
|
|
76
80
|
fn =>
|
|
77
|
-
fn.
|
|
78
|
-
fn.
|
|
79
|
-
fn.
|
|
80
|
-
|
|
81
|
-
fn.args[0].equals(
|
|
82
|
-
fn.
|
|
83
|
-
!fn.callContext.isStaticCall,
|
|
81
|
+
fn.request.contractAddress.equals(this.#feeJuiceAddress) &&
|
|
82
|
+
fn.request.msgSender.equals(this.#feeJuiceAddress) &&
|
|
83
|
+
fn.calldata.length > 2 &&
|
|
84
|
+
fn.functionSelector.equals(increasePublicBalanceSelector) &&
|
|
85
|
+
fn.args[0].equals(feePayer.toField()) &&
|
|
86
|
+
!fn.request.isStaticCall,
|
|
84
87
|
);
|
|
85
88
|
|
|
86
|
-
|
|
87
|
-
// - Index 0: Target function selector (due to dispatch routing)
|
|
88
|
-
// - Index 1: Amount recipient
|
|
89
|
-
// - Index 2: Amount being claimed
|
|
90
|
-
const balance = claimFunctionCall ? initialBalance.add(claimFunctionCall.args[2]) : initialBalance;
|
|
89
|
+
const balance = claimFunctionCall ? initialBalance.add(claimFunctionCall.args[1]) : initialBalance;
|
|
91
90
|
if (balance.lt(feeLimit)) {
|
|
92
91
|
this.#log.warn(`Rejecting transaction due to not enough fee payer balance`, {
|
|
93
92
|
feePayer,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { PublicContractsDB,
|
|
2
|
+
import { PublicContractsDB, getCallRequestsWithCalldataByPhase } from '@aztec/simulator/server';
|
|
3
3
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
4
4
|
import type { AllowedElement } from '@aztec/stdlib/interfaces/server';
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
PublicCallRequestWithCalldata,
|
|
7
7
|
Tx,
|
|
8
8
|
TxExecutionPhase,
|
|
9
9
|
type TxValidationResult,
|
|
@@ -32,13 +32,13 @@ export class PhasesTxValidator implements TxValidator<Tx> {
|
|
|
32
32
|
return { result: 'valid' };
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const setupFns =
|
|
35
|
+
const setupFns = getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.SETUP);
|
|
36
36
|
for (const setupFn of setupFns) {
|
|
37
37
|
if (!(await this.isOnAllowList(setupFn, this.setupAllowList))) {
|
|
38
38
|
this.#log.warn(
|
|
39
39
|
`Rejecting tx ${await Tx.getHash(tx)} because it calls setup function not on allow list: ${
|
|
40
|
-
setupFn.
|
|
41
|
-
}:${setupFn.
|
|
40
|
+
setupFn.request.contractAddress
|
|
41
|
+
}:${setupFn.functionSelector}`,
|
|
42
42
|
{ allowList: this.setupAllowList },
|
|
43
43
|
);
|
|
44
44
|
|
|
@@ -52,12 +52,16 @@ export class PhasesTxValidator implements TxValidator<Tx> {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
async isOnAllowList(
|
|
55
|
+
private async isOnAllowList(
|
|
56
|
+
publicCall: PublicCallRequestWithCalldata,
|
|
57
|
+
allowList: AllowedElement[],
|
|
58
|
+
): Promise<boolean> {
|
|
56
59
|
if (publicCall.isEmpty()) {
|
|
57
60
|
return true;
|
|
58
61
|
}
|
|
59
62
|
|
|
60
|
-
const
|
|
63
|
+
const contractAddress = publicCall.request.contractAddress;
|
|
64
|
+
const functionSelector = publicCall.functionSelector;
|
|
61
65
|
|
|
62
66
|
// do these checks first since they don't require the contract class
|
|
63
67
|
for (const entry of allowList) {
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import {
|
|
5
|
-
import type { Tx } from '@aztec/stdlib/tx';
|
|
4
|
+
import { HashedValues, type Tx } from '@aztec/stdlib/tx';
|
|
6
5
|
|
|
7
6
|
export function patchNonRevertibleFn(
|
|
8
7
|
tx: Tx,
|
|
9
8
|
index: number,
|
|
10
9
|
overrides: { address?: AztecAddress; selector: FunctionSelector; args?: Fr[]; msgSender?: AztecAddress },
|
|
11
|
-
): Promise<
|
|
10
|
+
): Promise<AztecAddress> {
|
|
12
11
|
return patchFn('nonRevertibleAccumulatedData', tx, index, overrides);
|
|
13
12
|
}
|
|
14
13
|
|
|
@@ -16,7 +15,7 @@ export function patchRevertibleFn(
|
|
|
16
15
|
tx: Tx,
|
|
17
16
|
index: number,
|
|
18
17
|
overrides: { address?: AztecAddress; selector: FunctionSelector; args?: Fr[]; msgSender?: AztecAddress },
|
|
19
|
-
): Promise<
|
|
18
|
+
): Promise<AztecAddress> {
|
|
20
19
|
return patchFn('revertibleAccumulatedData', tx, index, overrides);
|
|
21
20
|
}
|
|
22
21
|
|
|
@@ -25,24 +24,20 @@ async function patchFn(
|
|
|
25
24
|
tx: Tx,
|
|
26
25
|
index: number,
|
|
27
26
|
overrides: { address?: AztecAddress; selector: FunctionSelector; args?: Fr[]; msgSender?: AztecAddress },
|
|
28
|
-
): Promise<
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
): Promise<AztecAddress> {
|
|
28
|
+
const calldataIndex =
|
|
29
|
+
where === 'nonRevertibleAccumulatedData'
|
|
30
|
+
? index
|
|
31
|
+
: index + tx.data.forPublic!.nonRevertibleAccumulatedData.publicCallRequests.length;
|
|
32
|
+
const calldata = [overrides.selector.toField(), ...(overrides.args ?? [])];
|
|
33
|
+
const hashedCalldata = await HashedValues.fromCalldata(calldata);
|
|
34
|
+
tx.publicFunctionCalldata[calldataIndex] = hashedCalldata;
|
|
35
35
|
|
|
36
36
|
const request = tx.data.forPublic![where].publicCallRequests[index];
|
|
37
|
-
request.contractAddress =
|
|
38
|
-
request.msgSender =
|
|
39
|
-
request.
|
|
40
|
-
request.isStaticCall = fn.callContext.isStaticCall;
|
|
41
|
-
request.argsHash = await computeVarArgsHash(fn.args);
|
|
37
|
+
request.contractAddress = overrides.address ?? request.contractAddress;
|
|
38
|
+
request.msgSender = overrides.msgSender ?? request.msgSender;
|
|
39
|
+
request.calldataHash = hashedCalldata.hash;
|
|
42
40
|
tx.data.forPublic![where].publicCallRequests[index] = request;
|
|
43
41
|
|
|
44
|
-
return
|
|
45
|
-
address: fn.callContext.contractAddress,
|
|
46
|
-
selector: fn.callContext.functionSelector,
|
|
47
|
-
};
|
|
42
|
+
return request.contractAddress;
|
|
48
43
|
}
|