@aztec/aztec-node 0.0.1-commit.b655e406 → 0.0.1-commit.d3ec352c
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/config.d.ts +1 -1
- package/dest/aztec-node/node_metrics.d.ts +1 -1
- package/dest/aztec-node/node_metrics.d.ts.map +1 -1
- package/dest/aztec-node/server.d.ts +28 -27
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +32 -20
- package/dest/bin/index.d.ts +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/sentinel/config.d.ts +1 -1
- package/dest/sentinel/factory.d.ts +1 -1
- package/dest/sentinel/index.d.ts +1 -1
- package/dest/sentinel/sentinel.d.ts +20 -19
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +23 -16
- package/dest/sentinel/store.d.ts +6 -5
- package/dest/sentinel/store.d.ts.map +1 -1
- package/dest/sentinel/store.js +3 -2
- package/dest/test/index.d.ts +1 -1
- package/package.json +28 -27
- package/src/aztec-node/server.ts +69 -54
- package/src/sentinel/sentinel.ts +47 -35
- package/src/sentinel/store.ts +11 -10
package/src/sentinel/store.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
3
|
import { BufferReader, numToUInt8, numToUInt32BE, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
4
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
@@ -33,7 +34,7 @@ export class SentinelStore {
|
|
|
33
34
|
return this.config.historicProvenPerformanceLength;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
public async updateProvenPerformance(epoch:
|
|
37
|
+
public async updateProvenPerformance(epoch: EpochNumber, performance: ValidatorsEpochPerformance) {
|
|
37
38
|
await this.store.transactionAsync(async () => {
|
|
38
39
|
for (const [who, { missed, total }] of Object.entries(performance)) {
|
|
39
40
|
await this.pushValidatorProvenPerformanceForEpoch({ who: EthAddress.fromString(who), missed, total, epoch });
|
|
@@ -41,7 +42,7 @@ export class SentinelStore {
|
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
public async getProvenPerformance(who: EthAddress): Promise<{ missed: number; total: number; epoch:
|
|
45
|
+
public async getProvenPerformance(who: EthAddress): Promise<{ missed: number; total: number; epoch: EpochNumber }[]> {
|
|
45
46
|
const currentPerformanceBuffer = await this.provenMap.getAsync(who.toString());
|
|
46
47
|
return currentPerformanceBuffer ? this.deserializePerformance(currentPerformanceBuffer) : [];
|
|
47
48
|
}
|
|
@@ -55,7 +56,7 @@ export class SentinelStore {
|
|
|
55
56
|
who: EthAddress;
|
|
56
57
|
missed: number;
|
|
57
58
|
total: number;
|
|
58
|
-
epoch:
|
|
59
|
+
epoch: EpochNumber;
|
|
59
60
|
}) {
|
|
60
61
|
const currentPerformance = await this.getProvenPerformance(who);
|
|
61
62
|
const existingIndex = currentPerformance.findIndex(p => p.epoch === epoch);
|
|
@@ -75,7 +76,7 @@ export class SentinelStore {
|
|
|
75
76
|
await this.provenMap.set(who.toString(), this.serializePerformance(performanceToKeep));
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
public async updateValidators(slot:
|
|
79
|
+
public async updateValidators(slot: SlotNumber, statuses: Record<`0x${string}`, ValidatorStatusInSlot | undefined>) {
|
|
79
80
|
await this.store.transactionAsync(async () => {
|
|
80
81
|
for (const [who, status] of Object.entries(statuses)) {
|
|
81
82
|
if (status) {
|
|
@@ -87,7 +88,7 @@ export class SentinelStore {
|
|
|
87
88
|
|
|
88
89
|
private async pushValidatorStatusForSlot(
|
|
89
90
|
who: EthAddress,
|
|
90
|
-
slot:
|
|
91
|
+
slot: SlotNumber,
|
|
91
92
|
status: 'block-mined' | 'block-proposed' | 'block-missed' | 'attestation-sent' | 'attestation-missed',
|
|
92
93
|
) {
|
|
93
94
|
await this.store.transactionAsync(async () => {
|
|
@@ -110,18 +111,18 @@ export class SentinelStore {
|
|
|
110
111
|
return data && this.deserializeHistory(data);
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
private serializePerformance(performance: { missed: number; total: number; epoch:
|
|
114
|
+
private serializePerformance(performance: { missed: number; total: number; epoch: EpochNumber }[]): Buffer {
|
|
114
115
|
return serializeToBuffer(
|
|
115
116
|
performance.map(p => [numToUInt32BE(Number(p.epoch)), numToUInt32BE(p.missed), numToUInt32BE(p.total)]),
|
|
116
117
|
);
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
private deserializePerformance(buffer: Buffer): { missed: number; total: number; epoch:
|
|
120
|
+
private deserializePerformance(buffer: Buffer): { missed: number; total: number; epoch: EpochNumber }[] {
|
|
120
121
|
const reader = new BufferReader(buffer);
|
|
121
|
-
const performance: { missed: number; total: number; epoch:
|
|
122
|
+
const performance: { missed: number; total: number; epoch: EpochNumber }[] = [];
|
|
122
123
|
while (!reader.isEmpty()) {
|
|
123
124
|
performance.push({
|
|
124
|
-
epoch:
|
|
125
|
+
epoch: EpochNumber(reader.readNumber()),
|
|
125
126
|
missed: reader.readNumber(),
|
|
126
127
|
total: reader.readNumber(),
|
|
127
128
|
});
|
|
@@ -139,7 +140,7 @@ export class SentinelStore {
|
|
|
139
140
|
const reader = new BufferReader(buffer);
|
|
140
141
|
const history: ValidatorStatusHistory = [];
|
|
141
142
|
while (!reader.isEmpty()) {
|
|
142
|
-
const slot =
|
|
143
|
+
const slot = SlotNumber(reader.readNumber());
|
|
143
144
|
const status = this.statusFromNumber(reader.readUInt8());
|
|
144
145
|
history.push({ slot, status });
|
|
145
146
|
}
|