@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,17 +1,20 @@
|
|
|
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 {
|
|
11
10
|
log = createLogger('sequencer:global_variable_builder');
|
|
11
|
+
currentBaseFees = Promise.resolve(new GasFees(0, 0));
|
|
12
|
+
currentL1BlockNumber = undefined;
|
|
12
13
|
rollupContract;
|
|
13
14
|
publicClient;
|
|
14
15
|
ethereumSlotDuration;
|
|
16
|
+
chainId;
|
|
17
|
+
version;
|
|
15
18
|
constructor(config){
|
|
16
19
|
const { l1RpcUrls, l1ChainId: chainId, l1Contracts } = config;
|
|
17
20
|
const chain = createEthereumChain(l1RpcUrls, chainId);
|
|
@@ -21,31 +24,42 @@ import { createPublicClient, fallback, getAddress, getContract, http } from 'vie
|
|
|
21
24
|
transport: fallback(chain.rpcUrls.map((url)=>http(url))),
|
|
22
25
|
pollingInterval: config.viemPollingIntervalMS
|
|
23
26
|
});
|
|
24
|
-
this.rollupContract =
|
|
25
|
-
address: getAddress(l1Contracts.rollupAddress.toString()),
|
|
26
|
-
abi: RollupAbi,
|
|
27
|
-
client: this.publicClient
|
|
28
|
-
});
|
|
27
|
+
this.rollupContract = new RollupContract(this.publicClient, l1Contracts.rollupAddress);
|
|
29
28
|
}
|
|
30
29
|
/**
|
|
31
30
|
* Computes the "current" base fees, e.g., the price that you currently should pay to get include in the next block
|
|
32
|
-
* @returns Base fees for the
|
|
33
|
-
*/ async
|
|
31
|
+
* @returns Base fees for the next block
|
|
32
|
+
*/ async computeCurrentBaseFees() {
|
|
34
33
|
// Since this might be called in the middle of a slot where a block might have been published,
|
|
35
34
|
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
36
35
|
// 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
|
-
]);
|
|
36
|
+
const lastBlock = await this.rollupContract.getBlock(await this.rollupContract.getBlockNumber());
|
|
37
|
+
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(lastBlock.slotNumber + 1n);
|
|
43
38
|
const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
44
39
|
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
45
|
-
return new GasFees(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
return new GasFees(0, await this.rollupContract.getManaBaseFeeAt(timestamp, true));
|
|
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
|
+
}
|
|
52
|
+
async getGlobalConstantVariables() {
|
|
53
|
+
if (!this.chainId) {
|
|
54
|
+
this.chainId = new Fr(this.publicClient.chain.id);
|
|
55
|
+
}
|
|
56
|
+
if (!this.version) {
|
|
57
|
+
this.version = new Fr(await this.rollupContract.getVersion());
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
chainId: this.chainId,
|
|
61
|
+
version: this.version
|
|
62
|
+
};
|
|
49
63
|
}
|
|
50
64
|
/**
|
|
51
65
|
* Simple builder of global variables that use the minimum time possible.
|
|
@@ -55,25 +69,16 @@ import { createPublicClient, fallback, getAddress, getContract, http } from 'vie
|
|
|
55
69
|
* @param slotNumber - The slot number to use for the global variables, if undefined it will be calculated.
|
|
56
70
|
* @returns The global variables for the given block number.
|
|
57
71
|
*/ async buildGlobalVariables(blockNumber, coinbase, feeRecipient, slotNumber) {
|
|
58
|
-
const version =
|
|
59
|
-
const chainId = new Fr(this.publicClient.chain.id);
|
|
72
|
+
const { chainId, version } = await this.getGlobalConstantVariables();
|
|
60
73
|
if (slotNumber === undefined) {
|
|
61
74
|
const ts = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
62
|
-
slotNumber = await this.rollupContract.
|
|
63
|
-
ts
|
|
64
|
-
]);
|
|
75
|
+
slotNumber = await this.rollupContract.getSlotAt(ts);
|
|
65
76
|
}
|
|
66
|
-
const timestamp = await this.rollupContract.
|
|
67
|
-
slotNumber
|
|
68
|
-
]);
|
|
77
|
+
const timestamp = await this.rollupContract.getTimestampForSlot(slotNumber);
|
|
69
78
|
const slotFr = new Fr(slotNumber);
|
|
70
|
-
const timestampFr = new Fr(timestamp);
|
|
71
79
|
// 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(
|
|
73
|
-
|
|
74
|
-
true
|
|
75
|
-
])));
|
|
76
|
-
const globalVariables = new GlobalVariables(chainId, version, blockNumber, slotFr, timestampFr, coinbase, feeRecipient, gasFees);
|
|
80
|
+
const gasFees = new GasFees(0, await this.rollupContract.getManaBaseFeeAt(timestamp, true));
|
|
81
|
+
const globalVariables = new GlobalVariables(chainId, version, blockNumber, slotFr, timestamp, coinbase, feeRecipient, gasFees);
|
|
77
82
|
return globalVariables;
|
|
78
83
|
}
|
|
79
84
|
}
|
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, type SequencerEvents, } from './sequencer/index.js';
|
|
4
5
|
export * from './tx_validator/tx_validator_factory.js';
|
|
5
|
-
export * from './slasher/index.js';
|
|
6
|
-
export { Sequencer, SequencerState, getDefaultAllowedSetupFunctions } 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,EACL,oBAAoB,IAAI,YAAY,EACpC,SAAS,EACT,cAAc,EACd,KAAK,eAAe,GACrB,MAAM,sBAAsB,CAAC;AAC9B,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, getDefaultAllowedSetupFunctions } 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';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type BlobSinkConfig } from '@aztec/blob-sink/client';
|
|
2
2
|
import { type L1ReaderConfig, type L1TxUtilsConfig } from '@aztec/ethereum';
|
|
3
|
-
import { type ConfigMappingsType } from '@aztec/foundation/config';
|
|
3
|
+
import { type ConfigMappingsType, SecretValue } from '@aztec/foundation/config';
|
|
4
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
5
|
/**
|
|
6
6
|
* The configuration of the rollup transaction publisher.
|
|
@@ -9,20 +9,18 @@ export type TxSenderConfig = L1ReaderConfig & {
|
|
|
9
9
|
/**
|
|
10
10
|
* The private key to be used by the publisher.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
publisherPrivateKeys?: SecretValue<`0x${string}`>[];
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Publisher addresses to be used with a remote signer
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
publisherAddresses?: EthAddress[];
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
19
|
* Configuration of the L1Publisher.
|
|
20
20
|
*/
|
|
21
21
|
export type PublisherConfig = L1TxUtilsConfig & BlobSinkConfig & {
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
*/
|
|
25
|
-
l1PublishRetryIntervalMS: number;
|
|
22
|
+
/** True to use publishers in invalid states (timed out, cancelled, etc) if no other is available */
|
|
23
|
+
publisherAllowInvalidStates?: boolean;
|
|
26
24
|
};
|
|
27
25
|
export declare const getTxSenderConfigMappings: (scope: 'PROVER' | 'SEQ') => ConfigMappingsType<Omit<TxSenderConfig, 'l1Contracts'>>;
|
|
28
26
|
export declare function getTxSenderConfigFromEnv(scope: 'PROVER' | 'SEQ'): Omit<TxSenderConfig, 'l1Contracts'>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/publisher/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAyB,MAAM,yBAAyB,CAAC;AACrF,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/publisher/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAyB,MAAM,yBAAyB,CAAC;AACrF,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,eAAe,EAGrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,kBAAkB,EACvB,WAAW,EAGZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG;IAC5C;;OAEG;IACH,oBAAoB,CAAC,EAAE,WAAW,CAAC,KAAK,MAAM,EAAE,CAAC,EAAE,CAAC;IAEpD;;OAEG;IACH,kBAAkB,CAAC,EAAE,UAAU,EAAE,CAAC;CACnC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,eAAe,GAC3C,cAAc,GAAG;IACf,oGAAoG;IACpG,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC,CAAC;AAEJ,eAAO,MAAM,yBAAyB,EAAE,CACtC,KAAK,EAAE,QAAQ,GAAG,KAAK,KACpB,kBAAkB,CAAC,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,CAezD,CAAC;AAEH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,QAAQ,GAAG,KAAK,GAAG,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,CAErG;AAED,eAAO,MAAM,0BAA0B,EAAE,CACvC,KAAK,EAAE,QAAQ,GAAG,KAAK,KACpB,kBAAkB,CAAC,eAAe,GAAG,eAAe,CAQvD,CAAC;AAEH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,QAAQ,GAAG,KAAK,GAAG,eAAe,CAElF"}
|
package/dest/publisher/config.js
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
import { blobSinkConfigMapping } from '@aztec/blob-sink/client';
|
|
2
|
-
import {
|
|
3
|
-
import { getConfigFromMappings } from '@aztec/foundation/config';
|
|
2
|
+
import { l1ReaderConfigMappings, l1TxUtilsConfigMappings } from '@aztec/ethereum';
|
|
3
|
+
import { SecretValue, booleanConfigHelper, getConfigFromMappings } from '@aztec/foundation/config';
|
|
4
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
5
|
export const getTxSenderConfigMappings = (scope)=>({
|
|
6
6
|
...l1ReaderConfigMappings,
|
|
7
|
-
|
|
8
|
-
env: `
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
defaultValue:
|
|
7
|
+
publisherPrivateKeys: {
|
|
8
|
+
env: scope === 'PROVER' ? `PROVER_PUBLISHER_PRIVATE_KEYS` : `SEQ_PUBLISHER_PRIVATE_KEYS`,
|
|
9
|
+
description: 'The private keys to be used by the publisher.',
|
|
10
|
+
parseEnv: (val)=>val.split(',').map((key)=>new SecretValue(`0x${key.replace('0x', '')}`)),
|
|
11
|
+
defaultValue: [],
|
|
12
|
+
fallback: [
|
|
13
|
+
scope === 'PROVER' ? `PROVER_PUBLISHER_PRIVATE_KEY` : `SEQ_PUBLISHER_PRIVATE_KEY`
|
|
14
|
+
]
|
|
12
15
|
},
|
|
13
|
-
|
|
14
|
-
env: scope === 'PROVER' ? `
|
|
15
|
-
description: 'The
|
|
16
|
-
parseEnv: (val)=>val
|
|
17
|
-
defaultValue:
|
|
16
|
+
publisherAddresses: {
|
|
17
|
+
env: scope === 'PROVER' ? `PROVER_PUBLISHER_ADDRESSES` : `SEQ_PUBLISHER_ADDRESSES`,
|
|
18
|
+
description: 'The addresses of the publishers to use with remote signers',
|
|
19
|
+
parseEnv: (val)=>val.split(',').map((address)=>EthAddress.fromString(address)),
|
|
20
|
+
defaultValue: []
|
|
18
21
|
}
|
|
19
22
|
});
|
|
20
23
|
export function getTxSenderConfigFromEnv(scope) {
|
|
21
24
|
return getConfigFromMappings(getTxSenderConfigMappings(scope));
|
|
22
25
|
}
|
|
23
26
|
export const getPublisherConfigMappings = (scope)=>({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
description: 'The interval to wait between publish retries.'
|
|
27
|
+
publisherAllowInvalidStates: {
|
|
28
|
+
description: 'True to use publishers in invalid states (timed out, cancelled, etc) if no other is available',
|
|
29
|
+
env: scope === `PROVER` ? `PROVER_PUBLISHER_ALLOW_INVALID_STATES` : `SEQ_PUBLISHER_ALLOW_INVALID_STATES`,
|
|
30
|
+
...booleanConfigHelper(true)
|
|
29
31
|
},
|
|
30
32
|
...l1TxUtilsConfigMappings,
|
|
31
33
|
...blobSinkConfigMapping
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/publisher/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/publisher/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAG7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC"}
|
package/dest/publisher/index.js
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { type Logger } from '@aztec/aztec.js/log';
|
|
3
|
+
import type { BlobSinkClientInterface } from '@aztec/blob-sink/client';
|
|
4
|
+
import type { EpochCache } from '@aztec/epoch-cache';
|
|
5
|
+
import type { GovernanceProposerContract, PublisherManager, RollupContract } from '@aztec/ethereum';
|
|
6
|
+
import type { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
|
|
7
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
8
|
+
import type { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
9
|
+
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
10
|
+
import { NodeKeystoreAdapter } from '@aztec/validator-client';
|
|
11
|
+
import type { SequencerClientConfig } from '../config.js';
|
|
12
|
+
import { SequencerPublisher } from './sequencer-publisher.js';
|
|
13
|
+
export type AttestorPublisherPair = {
|
|
14
|
+
attestorAddress: EthAddress;
|
|
15
|
+
publisher: SequencerPublisher;
|
|
16
|
+
};
|
|
17
|
+
export declare class SequencerPublisherFactory {
|
|
18
|
+
private sequencerConfig;
|
|
19
|
+
private deps;
|
|
20
|
+
private publisherMetrics;
|
|
21
|
+
/** Stores the last slot in which every action was carried out by a publisher */
|
|
22
|
+
private lastActions;
|
|
23
|
+
private logger;
|
|
24
|
+
constructor(sequencerConfig: SequencerClientConfig, deps: {
|
|
25
|
+
telemetry: TelemetryClient;
|
|
26
|
+
publisherManager: PublisherManager<L1TxUtilsWithBlobs>;
|
|
27
|
+
blobSinkClient?: BlobSinkClientInterface;
|
|
28
|
+
dateProvider: DateProvider;
|
|
29
|
+
epochCache: EpochCache;
|
|
30
|
+
rollupContract: RollupContract;
|
|
31
|
+
governanceProposerContract: GovernanceProposerContract;
|
|
32
|
+
slashFactoryContract: SlashFactoryContract;
|
|
33
|
+
nodeKeyStore: NodeKeystoreAdapter;
|
|
34
|
+
logger?: Logger;
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new SequencerPublisher instance.
|
|
38
|
+
* @param _validatorAddress - The address of the validator that will be using the publisher.
|
|
39
|
+
* @returns A new SequencerPublisher instance.
|
|
40
|
+
*/
|
|
41
|
+
create(validatorAddress?: EthAddress): Promise<AttestorPublisherPair>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=sequencer-publisher-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequencer-publisher-factory.d.ts","sourceRoot":"","sources":["../../src/publisher/sequencer-publisher-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,0BAA0B,EAAmB,gBAAgB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACrH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAe,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE3E,MAAM,MAAM,qBAAqB,GAAG;IAClC,eAAe,EAAE,UAAU,CAAC;IAC5B,SAAS,EAAE,kBAAkB,CAAC;CAC/B,CAAC;AAEF,qBAAa,yBAAyB;IASlC,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,IAAI;IATd,OAAO,CAAC,gBAAgB,CAA4B;IAEpD,gFAAgF;IAChF,OAAO,CAAC,WAAW,CAAuC;IAE1D,OAAO,CAAC,MAAM,CAAS;gBAGb,eAAe,EAAE,qBAAqB,EACtC,IAAI,EAAE;QACZ,SAAS,EAAE,eAAe,CAAC;QAC3B,gBAAgB,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;QACvD,cAAc,CAAC,EAAE,uBAAuB,CAAC;QACzC,YAAY,EAAE,YAAY,CAAC;QAC3B,UAAU,EAAE,UAAU,CAAC;QACvB,cAAc,EAAE,cAAc,CAAC;QAC/B,0BAA0B,EAAE,0BAA0B,CAAC;QACvD,oBAAoB,EAAE,oBAAoB,CAAC;QAC3C,YAAY,EAAE,mBAAmB,CAAC;QAClC,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAKH;;;;OAIG;IACU,MAAM,CAAC,gBAAgB,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAsCnF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/aztec.js/log';
|
|
2
|
+
import { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
|
|
3
|
+
import { SequencerPublisher } from './sequencer-publisher.js';
|
|
4
|
+
export class SequencerPublisherFactory {
|
|
5
|
+
sequencerConfig;
|
|
6
|
+
deps;
|
|
7
|
+
publisherMetrics;
|
|
8
|
+
/** Stores the last slot in which every action was carried out by a publisher */ lastActions;
|
|
9
|
+
logger;
|
|
10
|
+
constructor(sequencerConfig, deps){
|
|
11
|
+
this.sequencerConfig = sequencerConfig;
|
|
12
|
+
this.deps = deps;
|
|
13
|
+
this.lastActions = {};
|
|
14
|
+
this.publisherMetrics = new SequencerPublisherMetrics(deps.telemetry, 'SequencerPublisher');
|
|
15
|
+
this.logger = deps.logger ?? createLogger('sequencer');
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new SequencerPublisher instance.
|
|
19
|
+
* @param _validatorAddress - The address of the validator that will be using the publisher.
|
|
20
|
+
* @returns A new SequencerPublisher instance.
|
|
21
|
+
*/ async create(validatorAddress) {
|
|
22
|
+
// If we have been given an attestor address we must only allow publishers permitted for that attestor
|
|
23
|
+
const allowedPublishers = !validatorAddress ? [] : this.deps.nodeKeyStore.getPublisherAddresses(validatorAddress);
|
|
24
|
+
const filter = !validatorAddress ? ()=>true : (utils)=>{
|
|
25
|
+
const publisherAddress = utils.getSenderAddress();
|
|
26
|
+
return allowedPublishers.some((allowedPublisher)=>allowedPublisher.equals(publisherAddress));
|
|
27
|
+
};
|
|
28
|
+
const l1Publisher = await this.deps.publisherManager.getAvailablePublisher(filter);
|
|
29
|
+
const attestorAddress = validatorAddress ?? this.deps.nodeKeyStore.getAttestorForPublisher(l1Publisher.getSenderAddress());
|
|
30
|
+
const rollup = this.deps.rollupContract;
|
|
31
|
+
const slashingProposerContract = await rollup.getSlashingProposer();
|
|
32
|
+
const publisher = new SequencerPublisher(this.sequencerConfig, {
|
|
33
|
+
l1TxUtils: l1Publisher,
|
|
34
|
+
telemetry: this.deps.telemetry,
|
|
35
|
+
blobSinkClient: this.deps.blobSinkClient,
|
|
36
|
+
rollupContract: this.deps.rollupContract,
|
|
37
|
+
epochCache: this.deps.epochCache,
|
|
38
|
+
governanceProposerContract: this.deps.governanceProposerContract,
|
|
39
|
+
slashingProposerContract,
|
|
40
|
+
slashFactoryContract: this.deps.slashFactoryContract,
|
|
41
|
+
dateProvider: this.deps.dateProvider,
|
|
42
|
+
metrics: this.publisherMetrics,
|
|
43
|
+
lastActions: this.lastActions,
|
|
44
|
+
log: this.logger.createChild('publisher')
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
attestorAddress,
|
|
48
|
+
publisher
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -11,12 +11,13 @@ export declare class SequencerPublisherMetrics {
|
|
|
11
11
|
private txCalldataGas;
|
|
12
12
|
private txBlobDataGasUsed;
|
|
13
13
|
private txBlobDataGasCost;
|
|
14
|
+
private txTotalFee;
|
|
14
15
|
private readonly blobCountHistogram;
|
|
15
16
|
private readonly blobInclusionBlocksHistogram;
|
|
16
17
|
private readonly blobTxSuccessCounter;
|
|
17
18
|
private readonly blobTxFailureCounter;
|
|
18
19
|
private senderBalance;
|
|
19
|
-
constructor(client: TelemetryClient, name?: string, logger?: import("@aztec/aztec.js").Logger);
|
|
20
|
+
constructor(client: TelemetryClient, name?: string, logger?: import("@aztec/aztec.js/log").Logger);
|
|
20
21
|
recordFailedTx(txType: L1TxType): void;
|
|
21
22
|
recordProcessBlockTx(durationMs: number, stats: L1PublishBlockStats): void;
|
|
22
23
|
recordSenderBalance(wei: bigint, senderAddress: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequencer-publisher-metrics.d.ts","sourceRoot":"","sources":["../../src/publisher/sequencer-publisher-metrics.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAkB,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAKL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAIjC,MAAM,MAAM,QAAQ,GAAG,SAAS,CAAC;AAEjC,qBAAa,yBAAyB;
|
|
1
|
+
{"version":3,"file":"sequencer-publisher-metrics.d.ts","sourceRoot":"","sources":["../../src/publisher/sequencer-publisher-metrics.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAkB,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAKL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAIjC,MAAM,MAAM,QAAQ,GAAG,SAAS,CAAC;AAEjC,qBAAa,yBAAyB;IAsBlC,OAAO,CAAC,MAAM;IArBhB,OAAO,CAAC,QAAQ,CAAY;IAE5B,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,KAAK,CAAY;IACzB,OAAO,CAAC,cAAc,CAAY;IAClC,OAAO,CAAC,aAAa,CAAY;IACjC,OAAO,CAAC,iBAAiB,CAAY;IACrC,OAAO,CAAC,iBAAiB,CAAY;IACrC,OAAO,CAAC,UAAU,CAAY;IAE9B,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAY;IAC/C,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAAY;IACzD,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAgB;IACrD,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAgB;IAErD,OAAO,CAAC,aAAa,CAAQ;gBAG3B,MAAM,EAAE,eAAe,EACvB,IAAI,SAAuB,EACnB,MAAM,uCAA8C;IAwF9D,cAAc,CAAC,MAAM,EAAE,QAAQ;IAW/B,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB;IAcnE,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;IAOtD,OAAO,CAAC,QAAQ;CAuCjB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/aztec.js';
|
|
1
|
+
import { createLogger } from '@aztec/aztec.js/log';
|
|
2
2
|
import { Attributes, Metrics, ValueType } from '@aztec/telemetry-client';
|
|
3
3
|
import { formatEther } from 'viem/utils';
|
|
4
4
|
export class SequencerPublisherMetrics {
|
|
@@ -11,6 +11,7 @@ export class SequencerPublisherMetrics {
|
|
|
11
11
|
txCalldataGas;
|
|
12
12
|
txBlobDataGasUsed;
|
|
13
13
|
txBlobDataGasCost;
|
|
14
|
+
txTotalFee;
|
|
14
15
|
blobCountHistogram;
|
|
15
16
|
blobInclusionBlocksHistogram;
|
|
16
17
|
blobTxSuccessCounter;
|
|
@@ -73,6 +74,32 @@ export class SequencerPublisherMetrics {
|
|
|
73
74
|
this.blobTxFailureCounter = meter.createUpDownCounter(Metrics.L1_PUBLISHER_BLOB_TX_FAILURE, {
|
|
74
75
|
description: 'Number of failed L1 transactions with blobs'
|
|
75
76
|
});
|
|
77
|
+
this.txTotalFee = meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE, {
|
|
78
|
+
description: 'How much L1 tx costs',
|
|
79
|
+
unit: 'eth',
|
|
80
|
+
valueType: ValueType.DOUBLE,
|
|
81
|
+
advice: {
|
|
82
|
+
explicitBucketBoundaries: [
|
|
83
|
+
0.001,
|
|
84
|
+
0.002,
|
|
85
|
+
0.004,
|
|
86
|
+
0.008,
|
|
87
|
+
0.01,
|
|
88
|
+
0.02,
|
|
89
|
+
0.04,
|
|
90
|
+
0.08,
|
|
91
|
+
0.1,
|
|
92
|
+
0.2,
|
|
93
|
+
0.4,
|
|
94
|
+
0.8,
|
|
95
|
+
1,
|
|
96
|
+
1.2,
|
|
97
|
+
1.4,
|
|
98
|
+
1.8,
|
|
99
|
+
2
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
});
|
|
76
103
|
this.senderBalance = meter.createGauge(Metrics.L1_PUBLISHER_BALANCE, {
|
|
77
104
|
unit: 'eth',
|
|
78
105
|
description: 'The balance of the sender address',
|
|
@@ -122,7 +149,15 @@ export class SequencerPublisherMetrics {
|
|
|
122
149
|
this.txBlobDataGasUsed.record(Number(stats.blobGasUsed), attributes);
|
|
123
150
|
try {
|
|
124
151
|
this.gasPrice.record(parseInt(formatEther(stats.gasPrice, 'gwei'), 10));
|
|
125
|
-
} catch
|
|
152
|
+
} catch {
|
|
153
|
+
// ignore
|
|
154
|
+
}
|
|
155
|
+
const executionFee = stats.gasUsed * stats.gasPrice;
|
|
156
|
+
const blobFee = stats.blobGasUsed * stats.blobDataGas;
|
|
157
|
+
const totalFee = executionFee + blobFee;
|
|
158
|
+
try {
|
|
159
|
+
this.txTotalFee.record(parseFloat(formatEther(totalFee)));
|
|
160
|
+
} catch {
|
|
126
161
|
// ignore
|
|
127
162
|
}
|
|
128
163
|
}
|