@aztec/aztec-node 0.0.1-commit.0dc957cde → 0.0.1-commit.0ec55a70b
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/aztec-node/block_response_helpers.d.ts +21 -0
- package/dest/aztec-node/block_response_helpers.d.ts.map +1 -0
- package/dest/aztec-node/block_response_helpers.js +88 -0
- package/dest/aztec-node/server.d.ts +21 -53
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +312 -117
- package/dest/sentinel/factory.d.ts +3 -2
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/sentinel.d.ts +6 -3
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +7 -1
- package/package.json +26 -26
- package/src/aztec-node/block_response_helpers.ts +131 -0
- package/src/aztec-node/server.ts +342 -146
- package/src/sentinel/factory.ts +2 -1
- package/src/sentinel/sentinel.ts +17 -5
|
@@ -37,6 +37,12 @@ export class Sentinel extends EventEmitter {
|
|
|
37
37
|
const interval = epochCache.getL1Constants().ethereumSlotDuration * 1000 / 4;
|
|
38
38
|
this.runningPromise = new RunningPromise(this.work.bind(this), logger, interval);
|
|
39
39
|
}
|
|
40
|
+
getSignatureContext() {
|
|
41
|
+
return {
|
|
42
|
+
chainId: this.config.l1ChainId,
|
|
43
|
+
rollupAddress: this.config.l1Contracts.rollupAddress
|
|
44
|
+
};
|
|
45
|
+
}
|
|
40
46
|
updateConfig(config) {
|
|
41
47
|
this.config = {
|
|
42
48
|
...this.config,
|
|
@@ -75,7 +81,7 @@ export class Sentinel extends EventEmitter {
|
|
|
75
81
|
this.slotNumberToCheckpoint.set(checkpoint.checkpoint.header.slotNumber, {
|
|
76
82
|
checkpointNumber: checkpoint.checkpoint.number,
|
|
77
83
|
archive: checkpoint.checkpoint.archive.root.toString(),
|
|
78
|
-
attestors: getAttestationInfoFromPublishedCheckpoint(checkpoint).filter((a)=>a.status === 'recovered-from-signature').map((a)=>a.address)
|
|
84
|
+
attestors: getAttestationInfoFromPublishedCheckpoint(checkpoint, this.getSignatureContext()).filter((a)=>a.status === 'recovered-from-signature').map((a)=>a.address)
|
|
79
85
|
});
|
|
80
86
|
// Prune the archive map to only keep at most N entries
|
|
81
87
|
const historyLength = this.store.getHistoryLength();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec-node",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.0ec55a70b",
|
|
4
4
|
"main": "dest/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -65,31 +65,31 @@
|
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
69
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
70
|
-
"@aztec/blob-client": "0.0.1-commit.
|
|
71
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
72
|
-
"@aztec/constants": "0.0.1-commit.
|
|
73
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
74
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
75
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
76
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
77
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
78
|
-
"@aztec/node-keystore": "0.0.1-commit.
|
|
79
|
-
"@aztec/node-lib": "0.0.1-commit.
|
|
80
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
81
|
-
"@aztec/p2p": "0.0.1-commit.
|
|
82
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
83
|
-
"@aztec/prover-client": "0.0.1-commit.
|
|
84
|
-
"@aztec/prover-node": "0.0.1-commit.
|
|
85
|
-
"@aztec/sequencer-client": "0.0.1-commit.
|
|
86
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
87
|
-
"@aztec/slasher": "0.0.1-commit.
|
|
88
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
89
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
90
|
-
"@aztec/validator-client": "0.0.1-commit.
|
|
91
|
-
"@aztec/validator-ha-signer": "0.0.1-commit.
|
|
92
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
68
|
+
"@aztec/archiver": "0.0.1-commit.0ec55a70b",
|
|
69
|
+
"@aztec/bb-prover": "0.0.1-commit.0ec55a70b",
|
|
70
|
+
"@aztec/blob-client": "0.0.1-commit.0ec55a70b",
|
|
71
|
+
"@aztec/blob-lib": "0.0.1-commit.0ec55a70b",
|
|
72
|
+
"@aztec/constants": "0.0.1-commit.0ec55a70b",
|
|
73
|
+
"@aztec/epoch-cache": "0.0.1-commit.0ec55a70b",
|
|
74
|
+
"@aztec/ethereum": "0.0.1-commit.0ec55a70b",
|
|
75
|
+
"@aztec/foundation": "0.0.1-commit.0ec55a70b",
|
|
76
|
+
"@aztec/kv-store": "0.0.1-commit.0ec55a70b",
|
|
77
|
+
"@aztec/l1-artifacts": "0.0.1-commit.0ec55a70b",
|
|
78
|
+
"@aztec/node-keystore": "0.0.1-commit.0ec55a70b",
|
|
79
|
+
"@aztec/node-lib": "0.0.1-commit.0ec55a70b",
|
|
80
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.0ec55a70b",
|
|
81
|
+
"@aztec/p2p": "0.0.1-commit.0ec55a70b",
|
|
82
|
+
"@aztec/protocol-contracts": "0.0.1-commit.0ec55a70b",
|
|
83
|
+
"@aztec/prover-client": "0.0.1-commit.0ec55a70b",
|
|
84
|
+
"@aztec/prover-node": "0.0.1-commit.0ec55a70b",
|
|
85
|
+
"@aztec/sequencer-client": "0.0.1-commit.0ec55a70b",
|
|
86
|
+
"@aztec/simulator": "0.0.1-commit.0ec55a70b",
|
|
87
|
+
"@aztec/slasher": "0.0.1-commit.0ec55a70b",
|
|
88
|
+
"@aztec/stdlib": "0.0.1-commit.0ec55a70b",
|
|
89
|
+
"@aztec/telemetry-client": "0.0.1-commit.0ec55a70b",
|
|
90
|
+
"@aztec/validator-client": "0.0.1-commit.0ec55a70b",
|
|
91
|
+
"@aztec/validator-ha-signer": "0.0.1-commit.0ec55a70b",
|
|
92
|
+
"@aztec/world-state": "0.0.1-commit.0ec55a70b",
|
|
93
93
|
"koa": "^2.16.1",
|
|
94
94
|
"koa-router": "^13.1.1",
|
|
95
95
|
"tslib": "^2.4.0",
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import {
|
|
3
|
+
type BlockData,
|
|
4
|
+
type BlockDataWithCheckpointContext,
|
|
5
|
+
type CheckpointedL2Block,
|
|
6
|
+
type CommitteeAttestation,
|
|
7
|
+
L2Block,
|
|
8
|
+
} from '@aztec/stdlib/block';
|
|
9
|
+
import type { CheckpointData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
10
|
+
import {
|
|
11
|
+
type BlockIncludeOptions,
|
|
12
|
+
type BlockResponse,
|
|
13
|
+
type CheckpointIncludeOptions,
|
|
14
|
+
type CheckpointResponse,
|
|
15
|
+
l1PublishInfoFromL1PublishedData,
|
|
16
|
+
} from '@aztec/stdlib/interfaces/client';
|
|
17
|
+
|
|
18
|
+
/** Projects a full {@link L2Block} into a {@link BlockResponse}, attaching L1 / attestation context when provided. */
|
|
19
|
+
export async function blockResponseFromL2Block(
|
|
20
|
+
block: L2Block,
|
|
21
|
+
options: BlockIncludeOptions,
|
|
22
|
+
context?: { l1?: BlockDataWithCheckpointContext['l1']; attestations?: CommitteeAttestation[] },
|
|
23
|
+
): Promise<BlockResponse> {
|
|
24
|
+
const response: BlockResponse = {
|
|
25
|
+
header: block.header,
|
|
26
|
+
archive: block.archive,
|
|
27
|
+
hash: await block.hash(),
|
|
28
|
+
checkpointNumber: block.checkpointNumber,
|
|
29
|
+
indexWithinCheckpoint: block.indexWithinCheckpoint,
|
|
30
|
+
number: block.number,
|
|
31
|
+
};
|
|
32
|
+
if (options.includeTransactions) {
|
|
33
|
+
(response as BlockResponse).body = block.body;
|
|
34
|
+
}
|
|
35
|
+
if (options.includeL1PublishInfo) {
|
|
36
|
+
(response as BlockResponse).l1 = l1PublishInfoFromL1PublishedData(context?.l1);
|
|
37
|
+
}
|
|
38
|
+
if (options.includeAttestations) {
|
|
39
|
+
(response as BlockResponse).attestations = context?.attestations ?? [];
|
|
40
|
+
}
|
|
41
|
+
return response;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Projects metadata-only {@link BlockData} into a {@link BlockResponse}. */
|
|
45
|
+
export function blockResponseFromBlockData(
|
|
46
|
+
data: BlockData,
|
|
47
|
+
blockNumber: BlockNumber,
|
|
48
|
+
options: BlockIncludeOptions,
|
|
49
|
+
context?: { l1?: BlockDataWithCheckpointContext['l1']; attestations?: CommitteeAttestation[] },
|
|
50
|
+
): BlockResponse {
|
|
51
|
+
const response: BlockResponse = {
|
|
52
|
+
header: data.header,
|
|
53
|
+
archive: data.archive,
|
|
54
|
+
hash: data.blockHash,
|
|
55
|
+
checkpointNumber: data.checkpointNumber,
|
|
56
|
+
indexWithinCheckpoint: data.indexWithinCheckpoint,
|
|
57
|
+
number: blockNumber,
|
|
58
|
+
};
|
|
59
|
+
if (options.includeL1PublishInfo) {
|
|
60
|
+
(response as BlockResponse).l1 = l1PublishInfoFromL1PublishedData(context?.l1);
|
|
61
|
+
}
|
|
62
|
+
if (options.includeAttestations) {
|
|
63
|
+
(response as BlockResponse).attestations = context?.attestations ?? [];
|
|
64
|
+
}
|
|
65
|
+
return response;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Projects a {@link CheckpointedL2Block} into a {@link BlockResponse}. */
|
|
69
|
+
export function blockResponseFromCheckpointedL2Block(
|
|
70
|
+
cp: CheckpointedL2Block,
|
|
71
|
+
options: BlockIncludeOptions,
|
|
72
|
+
): Promise<BlockResponse> {
|
|
73
|
+
return blockResponseFromL2Block(cp.block, options, { l1: cp.l1, attestations: cp.attestations });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Projects a {@link PublishedCheckpoint} into a {@link CheckpointResponse}. */
|
|
77
|
+
export async function checkpointResponseFromPublishedCheckpoint(
|
|
78
|
+
pc: PublishedCheckpoint,
|
|
79
|
+
options: CheckpointIncludeOptions,
|
|
80
|
+
): Promise<CheckpointResponse> {
|
|
81
|
+
const response: CheckpointResponse = {
|
|
82
|
+
number: pc.checkpoint.number,
|
|
83
|
+
header: pc.checkpoint.header,
|
|
84
|
+
archive: pc.checkpoint.archive,
|
|
85
|
+
checkpointOutHash: pc.checkpoint.getCheckpointOutHash(),
|
|
86
|
+
startBlock: pc.checkpoint.blocks[0]?.number ?? BlockNumber.ZERO,
|
|
87
|
+
blockCount: pc.checkpoint.blocks.length,
|
|
88
|
+
feeAssetPriceModifier: pc.checkpoint.feeAssetPriceModifier,
|
|
89
|
+
};
|
|
90
|
+
if (options.includeBlocks) {
|
|
91
|
+
(response as CheckpointResponse).blocks = await Promise.all(
|
|
92
|
+
pc.checkpoint.blocks.map(block =>
|
|
93
|
+
blockResponseFromL2Block(block, {
|
|
94
|
+
includeTransactions: options.includeTransactions,
|
|
95
|
+
includeL1PublishInfo: false,
|
|
96
|
+
includeAttestations: false,
|
|
97
|
+
}),
|
|
98
|
+
),
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
if (options.includeL1PublishInfo) {
|
|
102
|
+
(response as CheckpointResponse).l1 = l1PublishInfoFromL1PublishedData(pc.l1);
|
|
103
|
+
}
|
|
104
|
+
if (options.includeAttestations) {
|
|
105
|
+
(response as CheckpointResponse).attestations = pc.attestations;
|
|
106
|
+
}
|
|
107
|
+
return response;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Projects metadata-only {@link CheckpointData} into a {@link CheckpointResponse}. `includeBlocks` is ignored (no blocks loaded). */
|
|
111
|
+
export function checkpointResponseFromCheckpointData(
|
|
112
|
+
cd: CheckpointData,
|
|
113
|
+
options: CheckpointIncludeOptions,
|
|
114
|
+
): CheckpointResponse {
|
|
115
|
+
const response: CheckpointResponse = {
|
|
116
|
+
number: cd.checkpointNumber,
|
|
117
|
+
header: cd.header,
|
|
118
|
+
archive: cd.archive,
|
|
119
|
+
checkpointOutHash: cd.checkpointOutHash,
|
|
120
|
+
startBlock: cd.startBlock,
|
|
121
|
+
blockCount: cd.blockCount,
|
|
122
|
+
feeAssetPriceModifier: cd.feeAssetPriceModifier,
|
|
123
|
+
};
|
|
124
|
+
if (options.includeL1PublishInfo) {
|
|
125
|
+
(response as CheckpointResponse).l1 = l1PublishInfoFromL1PublishedData(cd.l1);
|
|
126
|
+
}
|
|
127
|
+
if (options.includeAttestations) {
|
|
128
|
+
(response as CheckpointResponse).attestations = cd.attestations;
|
|
129
|
+
}
|
|
130
|
+
return response;
|
|
131
|
+
}
|