@aztec/slasher 3.0.0-nightly.20250921 → 3.0.0-nightly.20250923
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.
|
@@ -26,6 +26,8 @@ export declare class EpochPruneWatcher extends EpochPruneWatcher_base implements
|
|
|
26
26
|
stop(): Promise<void>;
|
|
27
27
|
updateConfig(config: Partial<SlasherConfig>): void;
|
|
28
28
|
private handlePruneL2Blocks;
|
|
29
|
+
private emitSlashForEpoch;
|
|
30
|
+
private processPruneL2Blocks;
|
|
29
31
|
validateBlocks(blocks: L2Block[]): Promise<void>;
|
|
30
32
|
validateBlock(blockFromL1: L2Block, fork: MerkleTreeWriteOperations): Promise<void>;
|
|
31
33
|
private getValidatorsForEpoch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epoch_prune_watcher.d.ts","sourceRoot":"","sources":["../../src/watchers/epoch_prune_watcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"epoch_prune_watcher.d.ts","sourceRoot":"","sources":["../../src/watchers/epoch_prune_watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAEL,OAAO,EAEP,KAAK,yBAAyB,EAE/B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EACV,qBAAqB,EACrB,WAAW,EACX,yBAAyB,EACzB,aAAa,EACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAWnE,OAAO,EAA6C,KAAK,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAE7G,QAAA,MAAM,oCAAoC,+DAAgE,CAAC;AAE3G,KAAK,0BAA0B,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC,OAAO,oCAAoC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;sCAQrD,UAAU,cAAc;AANhF;;;;;GAKG;AACH,qBAAa,iBAAkB,SAAQ,sBAA2C,YAAW,OAAO;IAShG,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,mBAAmB;IAC3B,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,YAAY;IAZtB,OAAO,CAAC,GAAG,CAA+C;IAG1D,OAAO,CAAC,wBAAwB,CAAuC;IAEvE,OAAO,CAAC,SAAS,CAA6B;gBAGpC,aAAa,EAAE,yBAAyB,EACxC,mBAAmB,EAAE,mBAAmB,EACxC,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,iBAAiB,CAAC,EAChD,YAAY,EAAE,qBAAqB,EAC3C,SAAS,EAAE,0BAA0B;IAShC,KAAK;IAKL,IAAI;IAKJ,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI;IAKzD,OAAO,CAAC,mBAAmB;YAQb,iBAAiB;YAWjB,oBAAoB;IAwBrB,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAchD,aAAa,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;YAgClF,qBAAqB;IASnC,OAAO,CAAC,wBAAwB;CAgBjC"}
|
|
@@ -2,7 +2,7 @@ import { merge, pick } from '@aztec/foundation/collection';
|
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { L2BlockSourceEvents } from '@aztec/stdlib/block';
|
|
4
4
|
import { getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
|
|
5
|
-
import { OffenseType } from '@aztec/stdlib/slashing';
|
|
5
|
+
import { OffenseType, getOffenseTypeName } from '@aztec/stdlib/slashing';
|
|
6
6
|
import { ReExFailedTxsError, ReExStateMismatchError, TransactionsNotAvailableError, ValidatorError } from '@aztec/stdlib/validators';
|
|
7
7
|
import EventEmitter from 'node:events';
|
|
8
8
|
import { WANT_TO_SLASH_EVENT } from '../watcher.js';
|
|
@@ -44,48 +44,41 @@ const EpochPruneWatcherPenaltiesConfigKeys = [
|
|
|
44
44
|
}
|
|
45
45
|
handlePruneL2Blocks(event) {
|
|
46
46
|
const { blocks, epochNumber } = event;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
this.log.info(`Detected chain prune. Validating epoch ${epochNumber}`);
|
|
48
|
+
void this.processPruneL2Blocks(blocks, epochNumber).catch((err)=>this.log.error('Error processing pruned L2 blocks', err, {
|
|
49
|
+
epochNumber
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
async emitSlashForEpoch(offense, epochNumber) {
|
|
53
|
+
const validators = await this.getValidatorsForEpoch(epochNumber);
|
|
54
|
+
if (validators.length === 0) {
|
|
55
|
+
this.log.warn(`No validators found for epoch ${epochNumber} (cannot slash for ${getOffenseTypeName(offense)})`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const args = this.validatorsToSlashingArgs(validators, offense, BigInt(epochNumber));
|
|
59
|
+
this.log.verbose(`Created slash for ${getOffenseTypeName(offense)} at epoch ${epochNumber}`, args);
|
|
60
|
+
this.emit(WANT_TO_SLASH_EVENT, args);
|
|
61
|
+
}
|
|
62
|
+
async processPruneL2Blocks(blocks, epochNumber) {
|
|
63
|
+
try {
|
|
64
|
+
const l1Constants = this.epochCache.getL1Constants();
|
|
65
|
+
const epochBlocks = blocks.filter((b)=>getEpochAtSlot(b.slot, l1Constants) === epochNumber);
|
|
66
|
+
this.log.info(`Detected chain prune. Validating epoch ${epochNumber} with blocks ${epochBlocks[0]?.number} to ${epochBlocks[epochBlocks.length - 1]?.number}.`, {
|
|
67
|
+
blocks: epochBlocks.map((b)=>b.toBlockInfo())
|
|
68
|
+
});
|
|
69
|
+
await this.validateBlocks(epochBlocks);
|
|
53
70
|
this.log.info(`Pruned epoch ${epochNumber} was valid. Want to slash committee for not having it proven.`);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const result = {
|
|
57
|
-
validators,
|
|
58
|
-
offense: OffenseType.VALID_EPOCH_PRUNED
|
|
59
|
-
};
|
|
60
|
-
return result;
|
|
61
|
-
}).catch(async (error)=>{
|
|
71
|
+
await this.emitSlashForEpoch(OffenseType.VALID_EPOCH_PRUNED, epochNumber);
|
|
72
|
+
} catch (error) {
|
|
62
73
|
if (error instanceof TransactionsNotAvailableError) {
|
|
63
74
|
this.log.info(`Data for pruned epoch ${epochNumber} was not available. Will want to slash.`, {
|
|
64
75
|
message: error.message
|
|
65
76
|
});
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
validators,
|
|
69
|
-
offense: OffenseType.DATA_WITHHOLDING
|
|
70
|
-
};
|
|
77
|
+
await this.emitSlashForEpoch(OffenseType.DATA_WITHHOLDING, epochNumber);
|
|
71
78
|
} else {
|
|
72
79
|
this.log.error(`Error while validating pruned epoch ${epochNumber}. Will not want to slash.`, error);
|
|
73
|
-
return {
|
|
74
|
-
validators: [],
|
|
75
|
-
offense: undefined
|
|
76
|
-
};
|
|
77
80
|
}
|
|
78
|
-
}
|
|
79
|
-
if (validators.length === 0 || offense === undefined) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const args = this.validatorsToSlashingArgs(validators, offense, BigInt(epochNumber));
|
|
83
|
-
this.log.info(`Slash for epoch ${epochNumber} created`, args);
|
|
84
|
-
this.emit(WANT_TO_SLASH_EVENT, args);
|
|
85
|
-
}).catch((error)=>{
|
|
86
|
-
// This can happen if we fail to get the validators for the epoch.
|
|
87
|
-
this.log.error('Error while creating slash for epoch', error);
|
|
88
|
-
});
|
|
81
|
+
}
|
|
89
82
|
}
|
|
90
83
|
async validateBlocks(blocks) {
|
|
91
84
|
if (blocks.length === 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/slasher",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20250923",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -54,20 +54,20 @@
|
|
|
54
54
|
]
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@aztec/epoch-cache": "3.0.0-nightly.
|
|
58
|
-
"@aztec/ethereum": "3.0.0-nightly.
|
|
59
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
60
|
-
"@aztec/kv-store": "3.0.0-nightly.
|
|
61
|
-
"@aztec/l1-artifacts": "3.0.0-nightly.
|
|
62
|
-
"@aztec/stdlib": "3.0.0-nightly.
|
|
63
|
-
"@aztec/telemetry-client": "3.0.0-nightly.
|
|
57
|
+
"@aztec/epoch-cache": "3.0.0-nightly.20250923",
|
|
58
|
+
"@aztec/ethereum": "3.0.0-nightly.20250923",
|
|
59
|
+
"@aztec/foundation": "3.0.0-nightly.20250923",
|
|
60
|
+
"@aztec/kv-store": "3.0.0-nightly.20250923",
|
|
61
|
+
"@aztec/l1-artifacts": "3.0.0-nightly.20250923",
|
|
62
|
+
"@aztec/stdlib": "3.0.0-nightly.20250923",
|
|
63
|
+
"@aztec/telemetry-client": "3.0.0-nightly.20250923",
|
|
64
64
|
"source-map-support": "^0.5.21",
|
|
65
65
|
"tslib": "^2.4.0",
|
|
66
66
|
"viem": "2.23.7",
|
|
67
67
|
"zod": "^3.23.8"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@aztec/aztec.js": "3.0.0-nightly.
|
|
70
|
+
"@aztec/aztec.js": "3.0.0-nightly.20250923",
|
|
71
71
|
"@jest/globals": "^30.0.0",
|
|
72
72
|
"@types/jest": "^30.0.0",
|
|
73
73
|
"@types/node": "^22.15.17",
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Tx } from '@aztec/aztec.js';
|
|
2
1
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
3
2
|
import { merge, pick } from '@aztec/foundation/collection';
|
|
4
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
@@ -17,7 +16,7 @@ import type {
|
|
|
17
16
|
SlasherConfig,
|
|
18
17
|
} from '@aztec/stdlib/interfaces/server';
|
|
19
18
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
20
|
-
import { OffenseType } from '@aztec/stdlib/slashing';
|
|
19
|
+
import { OffenseType, getOffenseTypeName } from '@aztec/stdlib/slashing';
|
|
21
20
|
import {
|
|
22
21
|
ReExFailedTxsError,
|
|
23
22
|
ReExStateMismatchError,
|
|
@@ -79,54 +78,45 @@ export class EpochPruneWatcher extends (EventEmitter as new () => WatcherEmitter
|
|
|
79
78
|
|
|
80
79
|
private handlePruneL2Blocks(event: L2BlockPruneEvent): void {
|
|
81
80
|
const { blocks, epochNumber } = event;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
`Detected chain prune. Validating epoch ${epochNumber} with blocks ${epochBlocks[0]?.number} to ${epochBlocks[epochBlocks.length - 1]?.number}.`,
|
|
86
|
-
{ blocks: epochBlocks.map(b => b.toBlockInfo()) },
|
|
81
|
+
this.log.info(`Detected chain prune. Validating epoch ${epochNumber}`);
|
|
82
|
+
void this.processPruneL2Blocks(blocks, epochNumber).catch(err =>
|
|
83
|
+
this.log.error('Error processing pruned L2 blocks', err, { epochNumber }),
|
|
87
84
|
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private async emitSlashForEpoch(offense: OffenseType, epochNumber: bigint): Promise<void> {
|
|
88
|
+
const validators = await this.getValidatorsForEpoch(epochNumber);
|
|
89
|
+
if (validators.length === 0) {
|
|
90
|
+
this.log.warn(`No validators found for epoch ${epochNumber} (cannot slash for ${getOffenseTypeName(offense)})`);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const args = this.validatorsToSlashingArgs(validators, offense, BigInt(epochNumber));
|
|
94
|
+
this.log.verbose(`Created slash for ${getOffenseTypeName(offense)} at epoch ${epochNumber}`, args);
|
|
95
|
+
this.emit(WANT_TO_SLASH_EVENT, args);
|
|
96
|
+
}
|
|
88
97
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
})
|
|
100
|
-
.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
this.log.error(`Error while validating pruned epoch ${epochNumber}. Will not want to slash.`, error);
|
|
112
|
-
return {
|
|
113
|
-
validators: [],
|
|
114
|
-
offense: undefined,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
})
|
|
118
|
-
.then(({ validators, offense }) => {
|
|
119
|
-
if (validators.length === 0 || offense === undefined) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const args = this.validatorsToSlashingArgs(validators, offense, BigInt(epochNumber));
|
|
123
|
-
this.log.info(`Slash for epoch ${epochNumber} created`, args);
|
|
124
|
-
this.emit(WANT_TO_SLASH_EVENT, args);
|
|
125
|
-
})
|
|
126
|
-
.catch(error => {
|
|
127
|
-
// This can happen if we fail to get the validators for the epoch.
|
|
128
|
-
this.log.error('Error while creating slash for epoch', error);
|
|
129
|
-
});
|
|
98
|
+
private async processPruneL2Blocks(blocks: L2Block[], epochNumber: bigint): Promise<void> {
|
|
99
|
+
try {
|
|
100
|
+
const l1Constants = this.epochCache.getL1Constants();
|
|
101
|
+
const epochBlocks = blocks.filter(b => getEpochAtSlot(b.slot, l1Constants) === epochNumber);
|
|
102
|
+
this.log.info(
|
|
103
|
+
`Detected chain prune. Validating epoch ${epochNumber} with blocks ${epochBlocks[0]?.number} to ${epochBlocks[epochBlocks.length - 1]?.number}.`,
|
|
104
|
+
{ blocks: epochBlocks.map(b => b.toBlockInfo()) },
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
await this.validateBlocks(epochBlocks);
|
|
108
|
+
this.log.info(`Pruned epoch ${epochNumber} was valid. Want to slash committee for not having it proven.`);
|
|
109
|
+
await this.emitSlashForEpoch(OffenseType.VALID_EPOCH_PRUNED, epochNumber);
|
|
110
|
+
} catch (error) {
|
|
111
|
+
if (error instanceof TransactionsNotAvailableError) {
|
|
112
|
+
this.log.info(`Data for pruned epoch ${epochNumber} was not available. Will want to slash.`, {
|
|
113
|
+
message: error.message,
|
|
114
|
+
});
|
|
115
|
+
await this.emitSlashForEpoch(OffenseType.DATA_WITHHOLDING, epochNumber);
|
|
116
|
+
} else {
|
|
117
|
+
this.log.error(`Error while validating pruned epoch ${epochNumber}. Will not want to slash.`, error);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
130
120
|
}
|
|
131
121
|
|
|
132
122
|
public async validateBlocks(blocks: L2Block[]): Promise<void> {
|
|
@@ -157,7 +147,7 @@ export class EpochPruneWatcher extends (EventEmitter as new () => WatcherEmitter
|
|
|
157
147
|
|
|
158
148
|
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(blockFromL1.number);
|
|
159
149
|
const { block, failedTxs, numTxs } = await this.blockBuilder.buildBlock(
|
|
160
|
-
txs
|
|
150
|
+
txs,
|
|
161
151
|
l1ToL2Messages,
|
|
162
152
|
blockFromL1.header.globalVariables,
|
|
163
153
|
{},
|