@aztec/ethereum 3.0.0-nightly.20250905 → 3.0.0-nightly.20250908
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/config.d.ts.map +1 -1
- package/dest/config.js +40 -15
- package/dest/contracts/rollup.d.ts +12 -0
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +23 -0
- package/dest/contracts/tally_slashing_proposer.d.ts +15 -2
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/tally_slashing_proposer.js +43 -3
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +14 -25
- package/dest/l1_reader.js +8 -8
- package/dest/test/chain_monitor.d.ts +7 -0
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +24 -1
- package/package.json +5 -5
- package/src/config.ts +40 -15
- package/src/contracts/rollup.ts +29 -0
- package/src/contracts/tally_slashing_proposer.ts +42 -3
- package/src/l1_contract_addresses.ts +14 -25
- package/src/l1_reader.ts +8 -8
- package/src/test/chain_monitor.ts +25 -1
package/dest/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAOlB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAE,KAAK,eAAe,EAA2B,MAAM,kBAAkB,CAAC;AAEjF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,yFAAyF;IACzF,YAAY,EAAE,OAAO,CAAC;IACtB,yFAAyF;IACzF,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,yCAAyC;IACzC,oBAAoB,EAAE,MAAM,CAAC;IA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E;IAChE,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,sCAAsC;IACtC,2BAA2B,EAAE,MAAM,CAAC;IACpC,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gDAAgD;IAChD,gBAAgB,EAAE,MAAM,CAAC;CAC1B,GAAG,eAAe,CAAC;AAEpB,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;CAqBR,CAAC;AA8B9B,eAAO,MAAM,0BAA0B,GAAI,aAAa,YAAY;;;;;;;;;;;;CAUnE,CAAC;AAYF,eAAO,MAAM,mBAAmB,GAAI,aAAa,YAAY;;;CAU5D,CAAC;AAmBF,eAAO,MAAM,eAAe,GAAI,aAAa,YAAY;;;;;CAUxD,CAAC;AAkBF,eAAO,MAAM,oBAAoB,GAAI,aAAa,YAAY;;;;;;CAU7D,CAAC;AAmBF,eAAO,MAAM,mBAAmB,GAAI,aAAa,YAAY;;;;;;CAU5D,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,kBAAkB,CAAC,iBAAiB,CAkH3E,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,kBAAkB,CAAC,kBAAkB,CAW7E,CAAC;AAEF,wBAAgB,2BAA2B,IAAI,iBAAiB,CAE/D;AAED,wBAAgB,4BAA4B,IAAI,kBAAkB,CAEjE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,eAAe,CAAC,GAAG,IAAI,CAmH3F"}
|
package/dest/config.js
CHANGED
|
@@ -50,10 +50,15 @@ const TestnetGovernanceConfiguration = {
|
|
|
50
50
|
minimumVotes: DefaultL1ContractsConfig.ejectionThreshold * 200n
|
|
51
51
|
};
|
|
52
52
|
export const getGovernanceConfiguration = (networkName)=>{
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
switch(networkName){
|
|
54
|
+
case 'alpha-testnet':
|
|
55
|
+
case 'testnet':
|
|
56
|
+
return TestnetGovernanceConfiguration;
|
|
57
|
+
case 'local':
|
|
58
|
+
return LocalGovernanceConfiguration;
|
|
59
|
+
default:
|
|
60
|
+
throw new Error('Unrecognized network name: ' + networkName);
|
|
55
61
|
}
|
|
56
|
-
return LocalGovernanceConfiguration;
|
|
57
62
|
};
|
|
58
63
|
const TestnetGSEConfiguration = {
|
|
59
64
|
activationThreshold: BigInt(100e18),
|
|
@@ -64,10 +69,15 @@ const LocalGSEConfiguration = {
|
|
|
64
69
|
ejectionThreshold: BigInt(50e18)
|
|
65
70
|
};
|
|
66
71
|
export const getGSEConfiguration = (networkName)=>{
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
switch(networkName){
|
|
73
|
+
case 'alpha-testnet':
|
|
74
|
+
case 'testnet':
|
|
75
|
+
return TestnetGSEConfiguration;
|
|
76
|
+
case 'local':
|
|
77
|
+
return LocalGSEConfiguration;
|
|
78
|
+
default:
|
|
79
|
+
throw new Error('Unrecognized network name: ' + networkName);
|
|
69
80
|
}
|
|
70
|
-
return LocalGSEConfiguration;
|
|
71
81
|
};
|
|
72
82
|
// Making a default config here as we are only using it thought the deployment
|
|
73
83
|
// and do not expect to be using different setups, so having environment variables
|
|
@@ -85,10 +95,15 @@ const TestnetRewardConfig = {
|
|
|
85
95
|
blockReward: BigInt(50e18)
|
|
86
96
|
};
|
|
87
97
|
export const getRewardConfig = (networkName)=>{
|
|
88
|
-
|
|
89
|
-
|
|
98
|
+
switch(networkName){
|
|
99
|
+
case 'alpha-testnet':
|
|
100
|
+
case 'testnet':
|
|
101
|
+
return TestnetRewardConfig;
|
|
102
|
+
case 'local':
|
|
103
|
+
return LocalRewardConfig;
|
|
104
|
+
default:
|
|
105
|
+
throw new Error('Unrecognized network name: ' + networkName);
|
|
90
106
|
}
|
|
91
|
-
return LocalRewardConfig;
|
|
92
107
|
};
|
|
93
108
|
const LocalRewardBoostConfig = {
|
|
94
109
|
increment: 200000,
|
|
@@ -105,10 +120,15 @@ const TestnetRewardBoostConfig = {
|
|
|
105
120
|
minimum: 100000
|
|
106
121
|
};
|
|
107
122
|
export const getRewardBoostConfig = (networkName)=>{
|
|
108
|
-
|
|
109
|
-
|
|
123
|
+
switch(networkName){
|
|
124
|
+
case 'alpha-testnet':
|
|
125
|
+
case 'testnet':
|
|
126
|
+
return TestnetRewardBoostConfig;
|
|
127
|
+
case 'local':
|
|
128
|
+
return LocalRewardBoostConfig;
|
|
129
|
+
default:
|
|
130
|
+
throw new Error('Unrecognized network name: ' + networkName);
|
|
110
131
|
}
|
|
111
|
-
return LocalRewardBoostConfig;
|
|
112
132
|
};
|
|
113
133
|
// Similar to the above, no need for environment variables for this.
|
|
114
134
|
const LocalEntryQueueConfig = {
|
|
@@ -126,10 +146,15 @@ const TestnetEntryQueueConfig = {
|
|
|
126
146
|
maxQueueFlushSize: 32n
|
|
127
147
|
};
|
|
128
148
|
export const getEntryQueueConfig = (networkName)=>{
|
|
129
|
-
|
|
130
|
-
|
|
149
|
+
switch(networkName){
|
|
150
|
+
case 'alpha-testnet':
|
|
151
|
+
case 'testnet':
|
|
152
|
+
return TestnetEntryQueueConfig;
|
|
153
|
+
case 'local':
|
|
154
|
+
return LocalEntryQueueConfig;
|
|
155
|
+
default:
|
|
156
|
+
throw new Error('Unrecognized network name: ' + networkName);
|
|
131
157
|
}
|
|
132
|
-
return LocalEntryQueueConfig;
|
|
133
158
|
};
|
|
134
159
|
export const l1ContractsConfigMappings = {
|
|
135
160
|
ethereumSlotDuration: {
|
|
@@ -89,6 +89,18 @@ export declare class RollupContract {
|
|
|
89
89
|
getManaLimit(): Promise<bigint>;
|
|
90
90
|
getVersion(): Promise<bigint>;
|
|
91
91
|
getGenesisArchiveTreeRoot(): Promise<`0x${string}`>;
|
|
92
|
+
/**
|
|
93
|
+
* Returns rollup constants used for epoch queries.
|
|
94
|
+
* Return type is `L1RollupConstants` which is defined in stdlib,
|
|
95
|
+
* so we cant reference it until we move this contract to that package.
|
|
96
|
+
*/
|
|
97
|
+
getRollupConstants(): Promise<{
|
|
98
|
+
l1StartBlock: bigint;
|
|
99
|
+
l1GenesisTime: bigint;
|
|
100
|
+
slotDuration: number;
|
|
101
|
+
epochDuration: number;
|
|
102
|
+
proofSubmissionEpochs: number;
|
|
103
|
+
}>;
|
|
92
104
|
getSlasher(): Promise<`0x${string}`>;
|
|
93
105
|
/**
|
|
94
106
|
* Returns a SlasherContract instance for interacting with the slasher contract.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../../src/contracts/rollup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAK1D,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,qBAAqB,EAC1B,KAAK,GAAG,EACR,KAAK,aAAa,EAMnB,MAAM,MAAM,CAAC;AAGd,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAE/E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAG7E,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,KAAK,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,aAAa,CAAC;CAC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,EAAE,CAAC,IAAI,EAAE;QAAE,UAAU,EAAE,KAAK,MAAM,EAAE,CAAC;QAAC,UAAU,EAAE,KAAK,MAAM,EAAE,CAAA;KAAE,KAAK,OAAO;IAgBtG,cAAc,CAAC,WAAW,EAAE,GAAG,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,UAAU,CAAA;KAAE,EAAE,CAAC;IAQ3F,aAAa,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,UAAU,CAAA;KAAE,KAAK,OAAO;CAc3F"}
|
package/dest/contracts/rollup.js
CHANGED
|
@@ -155,6 +155,26 @@ export class RollupContract {
|
|
|
155
155
|
]);
|
|
156
156
|
return block.archive;
|
|
157
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Returns rollup constants used for epoch queries.
|
|
160
|
+
* Return type is `L1RollupConstants` which is defined in stdlib,
|
|
161
|
+
* so we cant reference it until we move this contract to that package.
|
|
162
|
+
*/ async getRollupConstants() {
|
|
163
|
+
const [l1StartBlock, l1GenesisTime, slotDuration, epochDuration, proofSubmissionEpochs] = await Promise.all([
|
|
164
|
+
this.getL1StartBlock(),
|
|
165
|
+
this.getL1GenesisTime(),
|
|
166
|
+
this.getSlotDuration(),
|
|
167
|
+
this.getEpochDuration(),
|
|
168
|
+
this.getProofSubmissionEpochs()
|
|
169
|
+
]);
|
|
170
|
+
return {
|
|
171
|
+
l1StartBlock,
|
|
172
|
+
l1GenesisTime,
|
|
173
|
+
slotDuration: Number(slotDuration),
|
|
174
|
+
epochDuration: Number(epochDuration),
|
|
175
|
+
proofSubmissionEpochs: Number(proofSubmissionEpochs)
|
|
176
|
+
};
|
|
177
|
+
}
|
|
158
178
|
getSlasher() {
|
|
159
179
|
return this.rollup.read.getSlasher();
|
|
160
180
|
}
|
|
@@ -681,3 +701,6 @@ _ts_decorate([
|
|
|
681
701
|
_ts_decorate([
|
|
682
702
|
memoize
|
|
683
703
|
], RollupContract.prototype, "getGenesisArchiveTreeRoot", null);
|
|
704
|
+
_ts_decorate([
|
|
705
|
+
memoize
|
|
706
|
+
], RollupContract.prototype, "getRollupConstants", null);
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { type L1TxRequest, type ViemClient } from '@aztec/ethereum';
|
|
2
2
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
-
import EventEmitter from 'events';
|
|
5
4
|
import { type Hex, type Log, type TypedDataDefinition } from 'viem';
|
|
6
5
|
/**
|
|
7
6
|
* Wrapper around the TallySlashingProposer contract that provides
|
|
8
7
|
* a TypeScript interface for interacting with the consensus-based slashing system.
|
|
9
8
|
*/
|
|
10
|
-
export declare class TallySlashingProposerContract
|
|
9
|
+
export declare class TallySlashingProposerContract {
|
|
11
10
|
readonly client: ViemClient;
|
|
12
11
|
private readonly contract;
|
|
13
12
|
readonly type: "tally";
|
|
@@ -96,6 +95,11 @@ export declare class TallySlashingProposerContract extends EventEmitter {
|
|
|
96
95
|
* @returns L1 transaction request
|
|
97
96
|
*/
|
|
98
97
|
buildExecuteRoundRequest(round: bigint, committees: EthAddress[][]): L1TxRequest;
|
|
98
|
+
/** Returns the last vote emitted for a given round */
|
|
99
|
+
getLastVote(round: bigint): Promise<{
|
|
100
|
+
validator: EthAddress;
|
|
101
|
+
slashAmount: bigint;
|
|
102
|
+
}[]>;
|
|
99
103
|
/**
|
|
100
104
|
* Listen for VoteCast events
|
|
101
105
|
* @param callback - Callback function to handle vote cast events
|
|
@@ -116,4 +120,13 @@ export declare class TallySlashingProposerContract extends EventEmitter {
|
|
|
116
120
|
l1BlockHash: Hex;
|
|
117
121
|
}) => void): () => void;
|
|
118
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Decodes a Buffer containing slash votes back into an array of numbers.
|
|
125
|
+
* Each vote is represented as a 2-bit value (0, 1, 2, or 3) representing slashing units.
|
|
126
|
+
* @dev This should live in stdlib next to encodeSlashConsensusVotes but is here since we
|
|
127
|
+
* do not have a dependency to stdlib from the ethereum package. We need a larger refactor to fix this.
|
|
128
|
+
* @param buffer - The Buffer containing encoded slash votes
|
|
129
|
+
* @returns An array of numbers representing the slash votes
|
|
130
|
+
*/
|
|
131
|
+
export declare function decodeSlashConsensusVotes(buffer: Buffer): number[];
|
|
119
132
|
//# sourceMappingURL=tally_slashing_proposer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tally_slashing_proposer.d.ts","sourceRoot":"","sources":["../../src/contracts/tally_slashing_proposer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAmB,MAAM,iBAAiB,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"tally_slashing_proposer.d.ts","sourceRoot":"","sources":["../../src/contracts/tally_slashing_proposer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAmB,MAAM,iBAAiB,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAK3D,OAAO,EAEL,KAAK,GAAG,EACR,KAAK,GAAG,EACR,KAAK,mBAAmB,EAGzB,MAAM,MAAM,CAAC;AAEd;;;GAGG;AACH,qBAAa,6BAA6B;aAMtB,MAAM,EAAE,UAAU;IALpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqE;IAE9F,SAAgB,IAAI,EAAG,OAAO,CAAU;gBAGtB,MAAM,EAAE,UAAU,EAClC,OAAO,EAAE,GAAG,GAAG,UAAU;IAS3B,IAAW,OAAO,eAEjB;IAEM,aAAa,IAAI,OAAO,CAA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
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
5
|
+
import { hexToBuffer } from '@aztec/foundation/string';
|
|
5
6
|
import { TallySlashingProposerAbi } from '@aztec/l1-artifacts/TallySlashingProposerAbi';
|
|
6
|
-
import EventEmitter from 'events';
|
|
7
7
|
import { encodeFunctionData, getContract } from 'viem';
|
|
8
8
|
/**
|
|
9
9
|
* Wrapper around the TallySlashingProposer contract that provides
|
|
10
10
|
* a TypeScript interface for interacting with the consensus-based slashing system.
|
|
11
|
-
*/ export class TallySlashingProposerContract
|
|
11
|
+
*/ export class TallySlashingProposerContract {
|
|
12
12
|
client;
|
|
13
13
|
contract;
|
|
14
14
|
type;
|
|
15
15
|
constructor(client, address){
|
|
16
|
-
|
|
16
|
+
this.client = client;
|
|
17
|
+
this.type = 'tally';
|
|
17
18
|
this.contract = getContract({
|
|
18
19
|
address: typeof address === 'string' ? address : address.toString(),
|
|
19
20
|
abi: TallySlashingProposerAbi,
|
|
@@ -221,6 +222,22 @@ import { encodeFunctionData, getContract } from 'viem';
|
|
|
221
222
|
})
|
|
222
223
|
};
|
|
223
224
|
}
|
|
225
|
+
/** Returns the last vote emitted for a given round */ async getLastVote(round) {
|
|
226
|
+
const { voteCount } = await this.getRound(round);
|
|
227
|
+
const validators = (await this.contract.simulate.getSlashTargetCommittees([
|
|
228
|
+
round
|
|
229
|
+
])).result.flat();
|
|
230
|
+
const vote = await this.contract.read.getVotes([
|
|
231
|
+
round,
|
|
232
|
+
voteCount - 1n
|
|
233
|
+
]);
|
|
234
|
+
const decoded = decodeSlashConsensusVotes(hexToBuffer(vote));
|
|
235
|
+
const slashAmounts = await this.getSlashingAmounts();
|
|
236
|
+
return decoded.map((units, i)=>({
|
|
237
|
+
validator: EthAddress.fromString(validators[i]),
|
|
238
|
+
slashAmount: slashAmounts[units - 1] ?? 0n
|
|
239
|
+
})).filter((v)=>v.slashAmount > 0n);
|
|
240
|
+
}
|
|
224
241
|
/**
|
|
225
242
|
* Listen for VoteCast events
|
|
226
243
|
* @param callback - Callback function to handle vote cast events
|
|
@@ -261,3 +278,26 @@ import { encodeFunctionData, getContract } from 'viem';
|
|
|
261
278
|
});
|
|
262
279
|
}
|
|
263
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* Decodes a Buffer containing slash votes back into an array of numbers.
|
|
283
|
+
* Each vote is represented as a 2-bit value (0, 1, 2, or 3) representing slashing units.
|
|
284
|
+
* @dev This should live in stdlib next to encodeSlashConsensusVotes but is here since we
|
|
285
|
+
* do not have a dependency to stdlib from the ethereum package. We need a larger refactor to fix this.
|
|
286
|
+
* @param buffer - The Buffer containing encoded slash votes
|
|
287
|
+
* @returns An array of numbers representing the slash votes
|
|
288
|
+
*/ export function decodeSlashConsensusVotes(buffer) {
|
|
289
|
+
const votes = [];
|
|
290
|
+
for(let i = 0; i < buffer.length; i++){
|
|
291
|
+
const voteByte = buffer.readUInt8(i);
|
|
292
|
+
// Decode votes from Solidity's bit order (LSB to MSB)
|
|
293
|
+
// Bits 0-1: validator at index i*4
|
|
294
|
+
// Bits 2-3: validator at index i*4+1
|
|
295
|
+
// Bits 4-5: validator at index i*4+2
|
|
296
|
+
// Bits 6-7: validator at index i*4+3
|
|
297
|
+
votes.push(voteByte >> 0 & 0x03);
|
|
298
|
+
votes.push(voteByte >> 2 & 0x03);
|
|
299
|
+
votes.push(voteByte >> 4 & 0x03);
|
|
300
|
+
votes.push(voteByte >> 6 & 0x03);
|
|
301
|
+
}
|
|
302
|
+
return votes;
|
|
303
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"l1_contract_addresses.d.ts","sourceRoot":"","sources":["../src/l1_contract_addresses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D,OAAO,EAAE,CAAC,EAAE,MAAM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EAAE,UAAU,GAAG,SAAS,CAAC;IACpD,yBAAyB,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACnD,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CACrC,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBE,CAAC;AAIzC,eAAO,MAAM,0BAA0B,EAAE,kBAAkB,CACzD,IAAI,CAAC,mBAAmB,EAAE,YAAY,GAAG,2BAA2B,CAAC,CA6DtE,CAAC"}
|
|
@@ -38,73 +38,62 @@ export const L1ContractAddressesSchema = z.object({
|
|
|
38
38
|
});
|
|
39
39
|
const parseEnv = (val)=>EthAddress.fromString(val);
|
|
40
40
|
export const l1ContractAddressesMapping = {
|
|
41
|
-
rollupAddress: {
|
|
42
|
-
env: 'ROLLUP_CONTRACT_ADDRESS',
|
|
43
|
-
description: 'The deployed L1 rollup contract address.',
|
|
44
|
-
parseEnv
|
|
45
|
-
},
|
|
46
41
|
registryAddress: {
|
|
47
42
|
env: 'REGISTRY_CONTRACT_ADDRESS',
|
|
48
43
|
description: 'The deployed L1 registry contract address.',
|
|
49
44
|
parseEnv
|
|
50
45
|
},
|
|
46
|
+
slashFactoryAddress: {
|
|
47
|
+
env: 'SLASH_FACTORY_CONTRACT_ADDRESS',
|
|
48
|
+
description: 'The deployed L1 slashFactory contract address',
|
|
49
|
+
parseEnv
|
|
50
|
+
},
|
|
51
|
+
feeAssetHandlerAddress: {
|
|
52
|
+
env: 'FEE_ASSET_HANDLER_CONTRACT_ADDRESS',
|
|
53
|
+
description: 'The deployed L1 feeAssetHandler contract address',
|
|
54
|
+
parseEnv
|
|
55
|
+
},
|
|
56
|
+
rollupAddress: {
|
|
57
|
+
description: 'The deployed L1 rollup contract address.',
|
|
58
|
+
parseEnv
|
|
59
|
+
},
|
|
51
60
|
inboxAddress: {
|
|
52
|
-
env: 'INBOX_CONTRACT_ADDRESS',
|
|
53
61
|
description: 'The deployed L1 inbox contract address.',
|
|
54
62
|
parseEnv
|
|
55
63
|
},
|
|
56
64
|
outboxAddress: {
|
|
57
|
-
env: 'OUTBOX_CONTRACT_ADDRESS',
|
|
58
65
|
description: 'The deployed L1 outbox contract address.',
|
|
59
66
|
parseEnv
|
|
60
67
|
},
|
|
61
68
|
feeJuiceAddress: {
|
|
62
|
-
env: 'FEE_JUICE_CONTRACT_ADDRESS',
|
|
63
69
|
description: 'The deployed L1 Fee Juice contract address.',
|
|
64
70
|
parseEnv
|
|
65
71
|
},
|
|
66
72
|
stakingAssetAddress: {
|
|
67
|
-
env: 'STAKING_ASSET_CONTRACT_ADDRESS',
|
|
68
73
|
description: 'The deployed L1 staking asset contract address.',
|
|
69
74
|
parseEnv
|
|
70
75
|
},
|
|
71
76
|
feeJuicePortalAddress: {
|
|
72
|
-
env: 'FEE_JUICE_PORTAL_CONTRACT_ADDRESS',
|
|
73
77
|
description: 'The deployed L1 Fee Juice portal contract address.',
|
|
74
78
|
parseEnv
|
|
75
79
|
},
|
|
76
80
|
coinIssuerAddress: {
|
|
77
|
-
env: 'COIN_ISSUER_CONTRACT_ADDRESS',
|
|
78
81
|
description: 'The deployed L1 coinIssuer contract address',
|
|
79
82
|
parseEnv
|
|
80
83
|
},
|
|
81
84
|
rewardDistributorAddress: {
|
|
82
|
-
env: 'REWARD_DISTRIBUTOR_CONTRACT_ADDRESS',
|
|
83
85
|
description: 'The deployed L1 rewardDistributor contract address',
|
|
84
86
|
parseEnv
|
|
85
87
|
},
|
|
86
88
|
governanceProposerAddress: {
|
|
87
|
-
env: 'GOVERNANCE_PROPOSER_CONTRACT_ADDRESS',
|
|
88
89
|
description: 'The deployed L1 governanceProposer contract address',
|
|
89
90
|
parseEnv
|
|
90
91
|
},
|
|
91
92
|
governanceAddress: {
|
|
92
|
-
env: 'GOVERNANCE_CONTRACT_ADDRESS',
|
|
93
93
|
description: 'The deployed L1 governance contract address',
|
|
94
94
|
parseEnv
|
|
95
95
|
},
|
|
96
|
-
slashFactoryAddress: {
|
|
97
|
-
env: 'SLASH_FACTORY_CONTRACT_ADDRESS',
|
|
98
|
-
description: 'The deployed L1 slashFactory contract address',
|
|
99
|
-
parseEnv
|
|
100
|
-
},
|
|
101
|
-
feeAssetHandlerAddress: {
|
|
102
|
-
env: 'FEE_ASSET_HANDLER_CONTRACT_ADDRESS',
|
|
103
|
-
description: 'The deployed L1 feeAssetHandler contract address',
|
|
104
|
-
parseEnv
|
|
105
|
-
},
|
|
106
96
|
stakingAssetHandlerAddress: {
|
|
107
|
-
env: 'STAKING_ASSET_HANDLER_CONTRACT_ADDRESS',
|
|
108
97
|
description: 'The deployed L1 stakingAssetHandler contract address',
|
|
109
98
|
parseEnv
|
|
110
99
|
}
|
package/dest/l1_reader.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
|
|
2
2
|
import { l1ContractAddressesMapping } from './l1_contract_addresses.js';
|
|
3
3
|
export const l1ReaderConfigMappings = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
parseEnv: (val)=>val.split(',').map((url)=>url.trim())
|
|
4
|
+
l1Contracts: {
|
|
5
|
+
description: 'The deployed L1 contract addresses',
|
|
6
|
+
nested: l1ContractAddressesMapping
|
|
8
7
|
},
|
|
9
8
|
l1ChainId: {
|
|
10
9
|
env: 'L1_CHAIN_ID',
|
|
11
10
|
parseEnv: (val)=>+val,
|
|
12
|
-
defaultValue: 31337,
|
|
13
11
|
description: 'The chain ID of the ethereum host.'
|
|
14
12
|
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
l1RpcUrls: {
|
|
14
|
+
env: 'ETHEREUM_HOSTS',
|
|
15
|
+
description: 'The RPC Url of the ethereum host.',
|
|
16
|
+
parseEnv: (val)=>val.split(',').map((url)=>url.trim()),
|
|
17
|
+
defaultValue: []
|
|
18
18
|
},
|
|
19
19
|
viemPollingIntervalMS: {
|
|
20
20
|
env: 'L1_READER_VIEM_POLLING_INTERVAL_MS',
|
|
@@ -26,6 +26,10 @@ export type ChainMonitorEventMap = {
|
|
|
26
26
|
timestamp: bigint;
|
|
27
27
|
committee: EthAddress[] | undefined;
|
|
28
28
|
}];
|
|
29
|
+
'l2-slot': [{
|
|
30
|
+
l2SlotNumber: number;
|
|
31
|
+
timestamp: bigint;
|
|
32
|
+
}];
|
|
29
33
|
};
|
|
30
34
|
/** Utility class that polls the chain on quick intervals and logs new L1 blocks, L2 blocks, and L2 proofs. */
|
|
31
35
|
export declare class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
@@ -51,11 +55,14 @@ export declare class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
51
55
|
totalL2Messages: number;
|
|
52
56
|
/** Current L2 epoch number */
|
|
53
57
|
l2EpochNumber: bigint;
|
|
58
|
+
/** Current L2 slot number */
|
|
59
|
+
l2SlotNumber: bigint;
|
|
54
60
|
constructor(rollup: RollupContract, dateProvider?: DateProvider, logger?: import("@aztec/foundation/log").Logger, intervalMs?: number);
|
|
55
61
|
start(): this;
|
|
56
62
|
stop(): Promise<void>;
|
|
57
63
|
private getInbox;
|
|
58
64
|
protected safeRun(): void;
|
|
59
65
|
run(force?: boolean): Promise<this>;
|
|
66
|
+
waitUntilL2Slot(slot: number | bigint): Promise<void>;
|
|
60
67
|
}
|
|
61
68
|
//# sourceMappingURL=chain_monitor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain_monitor.d.ts","sourceRoot":"","sources":["../../src/test/chain_monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,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AM,CAAC;gBAGV,MAAM,EAAE,cAAc,EACtB,YAAY,GAAE,YAAiC,EAC/C,MAAM,yCAA8C,EACpD,UAAU,SAAM;IAMnC,KAAK;IAQC,IAAI;YAaI,QAAQ;IAQtB,SAAS,CAAC,OAAO;IAcX,GAAG,CAAC,KAAK,UAAQ;IA0EhB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAe7D"}
|
|
@@ -21,6 +21,7 @@ import { EventEmitter } from 'events';
|
|
|
21
21
|
/** L1 timestamp for the proven L2 block */ l2ProvenBlockTimestamp;
|
|
22
22
|
/** Total number of L2 messages pushed into the Inbox */ totalL2Messages;
|
|
23
23
|
/** Current L2 epoch number */ l2EpochNumber;
|
|
24
|
+
/** Current L2 slot number */ l2SlotNumber;
|
|
24
25
|
constructor(rollup, dateProvider = new DateProvider(), logger = createLogger('aztecjs:utils:chain_monitor'), intervalMs = 200){
|
|
25
26
|
super(), this.rollup = rollup, this.dateProvider = dateProvider, this.logger = logger, this.intervalMs = intervalMs, this.running = new Set(), this.totalL2Messages = 0;
|
|
26
27
|
this.l1Client = rollup.client;
|
|
@@ -129,7 +130,14 @@ import { EventEmitter } from 'events';
|
|
|
129
130
|
timestamp,
|
|
130
131
|
committee
|
|
131
132
|
});
|
|
132
|
-
msg += ` starting new epoch ${this.l2EpochNumber}
|
|
133
|
+
msg += ` starting new epoch ${this.l2EpochNumber} `;
|
|
134
|
+
}
|
|
135
|
+
if (l2SlotNumber !== this.l2SlotNumber) {
|
|
136
|
+
this.l2SlotNumber = l2SlotNumber;
|
|
137
|
+
this.emit('l2-slot', {
|
|
138
|
+
l2SlotNumber: Number(l2SlotNumber),
|
|
139
|
+
timestamp
|
|
140
|
+
});
|
|
133
141
|
}
|
|
134
142
|
this.logger.info(msg, {
|
|
135
143
|
currentTimestamp: this.dateProvider.nowInSeconds(),
|
|
@@ -144,4 +152,19 @@ import { EventEmitter } from 'events';
|
|
|
144
152
|
});
|
|
145
153
|
return this;
|
|
146
154
|
}
|
|
155
|
+
waitUntilL2Slot(slot) {
|
|
156
|
+
const targetSlot = typeof slot === 'bigint' ? slot.valueOf() : slot;
|
|
157
|
+
if (this.l2SlotNumber >= targetSlot) {
|
|
158
|
+
return Promise.resolve();
|
|
159
|
+
}
|
|
160
|
+
return new Promise((resolve)=>{
|
|
161
|
+
const listener = (data)=>{
|
|
162
|
+
if (data.l2SlotNumber >= targetSlot) {
|
|
163
|
+
this.off('l2-slot', listener);
|
|
164
|
+
resolve();
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
this.on('l2-slot', listener);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
147
170
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/ethereum",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20250908",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"../package.common.json"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@aztec/blob-lib": "3.0.0-nightly.
|
|
35
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
36
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
37
|
-
"@aztec/l1-artifacts": "3.0.0-nightly.
|
|
34
|
+
"@aztec/blob-lib": "3.0.0-nightly.20250908",
|
|
35
|
+
"@aztec/constants": "3.0.0-nightly.20250908",
|
|
36
|
+
"@aztec/foundation": "3.0.0-nightly.20250908",
|
|
37
|
+
"@aztec/l1-artifacts": "3.0.0-nightly.20250908",
|
|
38
38
|
"@viem/anvil": "^0.0.10",
|
|
39
39
|
"dotenv": "^16.0.3",
|
|
40
40
|
"lodash.chunk": "^4.2.0",
|
package/src/config.ts
CHANGED
|
@@ -118,10 +118,15 @@ const TestnetGovernanceConfiguration = {
|
|
|
118
118
|
};
|
|
119
119
|
|
|
120
120
|
export const getGovernanceConfiguration = (networkName: NetworkNames) => {
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
switch (networkName) {
|
|
122
|
+
case 'alpha-testnet':
|
|
123
|
+
case 'testnet':
|
|
124
|
+
return TestnetGovernanceConfiguration;
|
|
125
|
+
case 'local':
|
|
126
|
+
return LocalGovernanceConfiguration;
|
|
127
|
+
default:
|
|
128
|
+
throw new Error('Unrecognized network name: ' + networkName);
|
|
123
129
|
}
|
|
124
|
-
return LocalGovernanceConfiguration;
|
|
125
130
|
};
|
|
126
131
|
|
|
127
132
|
const TestnetGSEConfiguration = {
|
|
@@ -135,10 +140,15 @@ const LocalGSEConfiguration = {
|
|
|
135
140
|
};
|
|
136
141
|
|
|
137
142
|
export const getGSEConfiguration = (networkName: NetworkNames) => {
|
|
138
|
-
|
|
139
|
-
|
|
143
|
+
switch (networkName) {
|
|
144
|
+
case 'alpha-testnet':
|
|
145
|
+
case 'testnet':
|
|
146
|
+
return TestnetGSEConfiguration;
|
|
147
|
+
case 'local':
|
|
148
|
+
return LocalGSEConfiguration;
|
|
149
|
+
default:
|
|
150
|
+
throw new Error('Unrecognized network name: ' + networkName);
|
|
140
151
|
}
|
|
141
|
-
return LocalGSEConfiguration;
|
|
142
152
|
};
|
|
143
153
|
|
|
144
154
|
// Making a default config here as we are only using it thought the deployment
|
|
@@ -159,10 +169,15 @@ const TestnetRewardConfig = {
|
|
|
159
169
|
};
|
|
160
170
|
|
|
161
171
|
export const getRewardConfig = (networkName: NetworkNames) => {
|
|
162
|
-
|
|
163
|
-
|
|
172
|
+
switch (networkName) {
|
|
173
|
+
case 'alpha-testnet':
|
|
174
|
+
case 'testnet':
|
|
175
|
+
return TestnetRewardConfig;
|
|
176
|
+
case 'local':
|
|
177
|
+
return LocalRewardConfig;
|
|
178
|
+
default:
|
|
179
|
+
throw new Error('Unrecognized network name: ' + networkName);
|
|
164
180
|
}
|
|
165
|
-
return LocalRewardConfig;
|
|
166
181
|
};
|
|
167
182
|
|
|
168
183
|
const LocalRewardBoostConfig = {
|
|
@@ -182,10 +197,15 @@ const TestnetRewardBoostConfig = {
|
|
|
182
197
|
};
|
|
183
198
|
|
|
184
199
|
export const getRewardBoostConfig = (networkName: NetworkNames) => {
|
|
185
|
-
|
|
186
|
-
|
|
200
|
+
switch (networkName) {
|
|
201
|
+
case 'alpha-testnet':
|
|
202
|
+
case 'testnet':
|
|
203
|
+
return TestnetRewardBoostConfig;
|
|
204
|
+
case 'local':
|
|
205
|
+
return LocalRewardBoostConfig;
|
|
206
|
+
default:
|
|
207
|
+
throw new Error('Unrecognized network name: ' + networkName);
|
|
187
208
|
}
|
|
188
|
-
return LocalRewardBoostConfig;
|
|
189
209
|
};
|
|
190
210
|
|
|
191
211
|
// Similar to the above, no need for environment variables for this.
|
|
@@ -206,10 +226,15 @@ const TestnetEntryQueueConfig = {
|
|
|
206
226
|
};
|
|
207
227
|
|
|
208
228
|
export const getEntryQueueConfig = (networkName: NetworkNames) => {
|
|
209
|
-
|
|
210
|
-
|
|
229
|
+
switch (networkName) {
|
|
230
|
+
case 'alpha-testnet':
|
|
231
|
+
case 'testnet':
|
|
232
|
+
return TestnetEntryQueueConfig;
|
|
233
|
+
case 'local':
|
|
234
|
+
return LocalEntryQueueConfig;
|
|
235
|
+
default:
|
|
236
|
+
throw new Error('Unrecognized network name: ' + networkName);
|
|
211
237
|
}
|
|
212
|
-
return LocalEntryQueueConfig;
|
|
213
238
|
};
|
|
214
239
|
|
|
215
240
|
export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> = {
|
package/src/contracts/rollup.ts
CHANGED
|
@@ -264,6 +264,35 @@ export class RollupContract {
|
|
|
264
264
|
return block.archive;
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
+
/**
|
|
268
|
+
* Returns rollup constants used for epoch queries.
|
|
269
|
+
* Return type is `L1RollupConstants` which is defined in stdlib,
|
|
270
|
+
* so we cant reference it until we move this contract to that package.
|
|
271
|
+
*/
|
|
272
|
+
@memoize
|
|
273
|
+
public async getRollupConstants(): Promise<{
|
|
274
|
+
l1StartBlock: bigint;
|
|
275
|
+
l1GenesisTime: bigint;
|
|
276
|
+
slotDuration: number;
|
|
277
|
+
epochDuration: number;
|
|
278
|
+
proofSubmissionEpochs: number;
|
|
279
|
+
}> {
|
|
280
|
+
const [l1StartBlock, l1GenesisTime, slotDuration, epochDuration, proofSubmissionEpochs] = await Promise.all([
|
|
281
|
+
this.getL1StartBlock(),
|
|
282
|
+
this.getL1GenesisTime(),
|
|
283
|
+
this.getSlotDuration(),
|
|
284
|
+
this.getEpochDuration(),
|
|
285
|
+
this.getProofSubmissionEpochs(),
|
|
286
|
+
]);
|
|
287
|
+
return {
|
|
288
|
+
l1StartBlock,
|
|
289
|
+
l1GenesisTime,
|
|
290
|
+
slotDuration: Number(slotDuration),
|
|
291
|
+
epochDuration: Number(epochDuration),
|
|
292
|
+
proofSubmissionEpochs: Number(proofSubmissionEpochs),
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
267
296
|
getSlasher() {
|
|
268
297
|
return this.rollup.read.getSlasher();
|
|
269
298
|
}
|
|
@@ -2,9 +2,9 @@ import { type L1TxRequest, type ViemClient, tryExtractEvent } from '@aztec/ether
|
|
|
2
2
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
5
|
+
import { hexToBuffer } from '@aztec/foundation/string';
|
|
5
6
|
import { TallySlashingProposerAbi } from '@aztec/l1-artifacts/TallySlashingProposerAbi';
|
|
6
7
|
|
|
7
|
-
import EventEmitter from 'events';
|
|
8
8
|
import {
|
|
9
9
|
type GetContractReturnType,
|
|
10
10
|
type Hex,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
* Wrapper around the TallySlashingProposer contract that provides
|
|
19
19
|
* a TypeScript interface for interacting with the consensus-based slashing system.
|
|
20
20
|
*/
|
|
21
|
-
export class TallySlashingProposerContract
|
|
21
|
+
export class TallySlashingProposerContract {
|
|
22
22
|
private readonly contract: GetContractReturnType<typeof TallySlashingProposerAbi, ViemClient>;
|
|
23
23
|
|
|
24
24
|
public readonly type = 'tally' as const;
|
|
@@ -27,7 +27,6 @@ export class TallySlashingProposerContract extends EventEmitter {
|
|
|
27
27
|
public readonly client: ViemClient,
|
|
28
28
|
address: Hex | EthAddress,
|
|
29
29
|
) {
|
|
30
|
-
super();
|
|
31
30
|
this.contract = getContract({
|
|
32
31
|
address: typeof address === 'string' ? address : address.toString(),
|
|
33
32
|
abi: TallySlashingProposerAbi,
|
|
@@ -221,6 +220,21 @@ export class TallySlashingProposerContract extends EventEmitter {
|
|
|
221
220
|
};
|
|
222
221
|
}
|
|
223
222
|
|
|
223
|
+
/** Returns the last vote emitted for a given round */
|
|
224
|
+
public async getLastVote(round: bigint) {
|
|
225
|
+
const { voteCount } = await this.getRound(round);
|
|
226
|
+
const validators = (await this.contract.simulate.getSlashTargetCommittees([round])).result.flat();
|
|
227
|
+
const vote = await this.contract.read.getVotes([round, voteCount - 1n]);
|
|
228
|
+
const decoded = decodeSlashConsensusVotes(hexToBuffer(vote));
|
|
229
|
+
const slashAmounts = await this.getSlashingAmounts();
|
|
230
|
+
return decoded
|
|
231
|
+
.map((units, i) => ({
|
|
232
|
+
validator: EthAddress.fromString(validators[i]),
|
|
233
|
+
slashAmount: slashAmounts[units - 1] ?? 0n,
|
|
234
|
+
}))
|
|
235
|
+
.filter(v => v.slashAmount > 0n);
|
|
236
|
+
}
|
|
237
|
+
|
|
224
238
|
/**
|
|
225
239
|
* Listen for VoteCast events
|
|
226
240
|
* @param callback - Callback function to handle vote cast events
|
|
@@ -265,3 +279,28 @@ export class TallySlashingProposerContract extends EventEmitter {
|
|
|
265
279
|
);
|
|
266
280
|
}
|
|
267
281
|
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Decodes a Buffer containing slash votes back into an array of numbers.
|
|
285
|
+
* Each vote is represented as a 2-bit value (0, 1, 2, or 3) representing slashing units.
|
|
286
|
+
* @dev This should live in stdlib next to encodeSlashConsensusVotes but is here since we
|
|
287
|
+
* do not have a dependency to stdlib from the ethereum package. We need a larger refactor to fix this.
|
|
288
|
+
* @param buffer - The Buffer containing encoded slash votes
|
|
289
|
+
* @returns An array of numbers representing the slash votes
|
|
290
|
+
*/
|
|
291
|
+
export function decodeSlashConsensusVotes(buffer: Buffer): number[] {
|
|
292
|
+
const votes: number[] = [];
|
|
293
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
294
|
+
const voteByte = buffer.readUInt8(i);
|
|
295
|
+
// Decode votes from Solidity's bit order (LSB to MSB)
|
|
296
|
+
// Bits 0-1: validator at index i*4
|
|
297
|
+
// Bits 2-3: validator at index i*4+1
|
|
298
|
+
// Bits 4-5: validator at index i*4+2
|
|
299
|
+
// Bits 6-7: validator at index i*4+3
|
|
300
|
+
votes.push((voteByte >> 0) & 0x03);
|
|
301
|
+
votes.push((voteByte >> 2) & 0x03);
|
|
302
|
+
votes.push((voteByte >> 4) & 0x03);
|
|
303
|
+
votes.push((voteByte >> 6) & 0x03);
|
|
304
|
+
}
|
|
305
|
+
return votes;
|
|
306
|
+
}
|
|
@@ -58,73 +58,62 @@ const parseEnv = (val: string) => EthAddress.fromString(val);
|
|
|
58
58
|
export const l1ContractAddressesMapping: ConfigMappingsType<
|
|
59
59
|
Omit<L1ContractAddresses, 'gseAddress' | 'zkPassportVerifierAddress'>
|
|
60
60
|
> = {
|
|
61
|
-
rollupAddress: {
|
|
62
|
-
env: 'ROLLUP_CONTRACT_ADDRESS',
|
|
63
|
-
description: 'The deployed L1 rollup contract address.',
|
|
64
|
-
parseEnv,
|
|
65
|
-
},
|
|
66
61
|
registryAddress: {
|
|
67
62
|
env: 'REGISTRY_CONTRACT_ADDRESS',
|
|
68
63
|
description: 'The deployed L1 registry contract address.',
|
|
69
64
|
parseEnv,
|
|
70
65
|
},
|
|
66
|
+
slashFactoryAddress: {
|
|
67
|
+
env: 'SLASH_FACTORY_CONTRACT_ADDRESS',
|
|
68
|
+
description: 'The deployed L1 slashFactory contract address',
|
|
69
|
+
parseEnv,
|
|
70
|
+
},
|
|
71
|
+
feeAssetHandlerAddress: {
|
|
72
|
+
env: 'FEE_ASSET_HANDLER_CONTRACT_ADDRESS',
|
|
73
|
+
description: 'The deployed L1 feeAssetHandler contract address',
|
|
74
|
+
parseEnv,
|
|
75
|
+
},
|
|
76
|
+
rollupAddress: {
|
|
77
|
+
description: 'The deployed L1 rollup contract address.',
|
|
78
|
+
parseEnv,
|
|
79
|
+
},
|
|
71
80
|
inboxAddress: {
|
|
72
|
-
env: 'INBOX_CONTRACT_ADDRESS',
|
|
73
81
|
description: 'The deployed L1 inbox contract address.',
|
|
74
82
|
parseEnv,
|
|
75
83
|
},
|
|
76
84
|
outboxAddress: {
|
|
77
|
-
env: 'OUTBOX_CONTRACT_ADDRESS',
|
|
78
85
|
description: 'The deployed L1 outbox contract address.',
|
|
79
86
|
parseEnv,
|
|
80
87
|
},
|
|
81
88
|
feeJuiceAddress: {
|
|
82
|
-
env: 'FEE_JUICE_CONTRACT_ADDRESS',
|
|
83
89
|
description: 'The deployed L1 Fee Juice contract address.',
|
|
84
90
|
parseEnv,
|
|
85
91
|
},
|
|
86
92
|
stakingAssetAddress: {
|
|
87
|
-
env: 'STAKING_ASSET_CONTRACT_ADDRESS',
|
|
88
93
|
description: 'The deployed L1 staking asset contract address.',
|
|
89
94
|
parseEnv,
|
|
90
95
|
},
|
|
91
96
|
feeJuicePortalAddress: {
|
|
92
|
-
env: 'FEE_JUICE_PORTAL_CONTRACT_ADDRESS',
|
|
93
97
|
description: 'The deployed L1 Fee Juice portal contract address.',
|
|
94
98
|
parseEnv,
|
|
95
99
|
},
|
|
96
100
|
coinIssuerAddress: {
|
|
97
|
-
env: 'COIN_ISSUER_CONTRACT_ADDRESS',
|
|
98
101
|
description: 'The deployed L1 coinIssuer contract address',
|
|
99
102
|
parseEnv,
|
|
100
103
|
},
|
|
101
104
|
rewardDistributorAddress: {
|
|
102
|
-
env: 'REWARD_DISTRIBUTOR_CONTRACT_ADDRESS',
|
|
103
105
|
description: 'The deployed L1 rewardDistributor contract address',
|
|
104
106
|
parseEnv,
|
|
105
107
|
},
|
|
106
108
|
governanceProposerAddress: {
|
|
107
|
-
env: 'GOVERNANCE_PROPOSER_CONTRACT_ADDRESS',
|
|
108
109
|
description: 'The deployed L1 governanceProposer contract address',
|
|
109
110
|
parseEnv,
|
|
110
111
|
},
|
|
111
112
|
governanceAddress: {
|
|
112
|
-
env: 'GOVERNANCE_CONTRACT_ADDRESS',
|
|
113
113
|
description: 'The deployed L1 governance contract address',
|
|
114
114
|
parseEnv,
|
|
115
115
|
},
|
|
116
|
-
slashFactoryAddress: {
|
|
117
|
-
env: 'SLASH_FACTORY_CONTRACT_ADDRESS',
|
|
118
|
-
description: 'The deployed L1 slashFactory contract address',
|
|
119
|
-
parseEnv,
|
|
120
|
-
},
|
|
121
|
-
feeAssetHandlerAddress: {
|
|
122
|
-
env: 'FEE_ASSET_HANDLER_CONTRACT_ADDRESS',
|
|
123
|
-
description: 'The deployed L1 feeAssetHandler contract address',
|
|
124
|
-
parseEnv,
|
|
125
|
-
},
|
|
126
116
|
stakingAssetHandlerAddress: {
|
|
127
|
-
env: 'STAKING_ASSET_HANDLER_CONTRACT_ADDRESS',
|
|
128
117
|
description: 'The deployed L1 stakingAssetHandler contract address',
|
|
129
118
|
parseEnv,
|
|
130
119
|
},
|
package/src/l1_reader.ts
CHANGED
|
@@ -15,20 +15,20 @@ export interface L1ReaderConfig {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export const l1ReaderConfigMappings: ConfigMappingsType<L1ReaderConfig> = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
parseEnv: (val: string) => val.split(',').map(url => url.trim()),
|
|
18
|
+
l1Contracts: {
|
|
19
|
+
description: 'The deployed L1 contract addresses',
|
|
20
|
+
nested: l1ContractAddressesMapping,
|
|
22
21
|
},
|
|
23
22
|
l1ChainId: {
|
|
24
23
|
env: 'L1_CHAIN_ID',
|
|
25
24
|
parseEnv: (val: string) => +val,
|
|
26
|
-
defaultValue: 31337,
|
|
27
25
|
description: 'The chain ID of the ethereum host.',
|
|
28
26
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
l1RpcUrls: {
|
|
28
|
+
env: 'ETHEREUM_HOSTS',
|
|
29
|
+
description: 'The RPC Url of the ethereum host.',
|
|
30
|
+
parseEnv: (val: string) => val.split(',').map(url => url.trim()),
|
|
31
|
+
defaultValue: [],
|
|
32
32
|
},
|
|
33
33
|
viemPollingIntervalMS: {
|
|
34
34
|
env: 'L1_READER_VIEM_POLLING_INTERVAL_MS',
|
|
@@ -14,6 +14,7 @@ export type ChainMonitorEventMap = {
|
|
|
14
14
|
'l2-block-proven': [{ l2ProvenBlockNumber: number; l1BlockNumber: number; timestamp: bigint }];
|
|
15
15
|
'l2-messages': [{ totalL2Messages: number; l1BlockNumber: number }];
|
|
16
16
|
'l2-epoch': [{ l2EpochNumber: number; timestamp: bigint; committee: EthAddress[] | undefined }];
|
|
17
|
+
'l2-slot': [{ l2SlotNumber: number; timestamp: bigint }];
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
/** Utility class that polls the chain on quick intervals and logs new L1 blocks, L2 blocks, and L2 proofs. */
|
|
@@ -38,6 +39,8 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
38
39
|
public totalL2Messages: number = 0;
|
|
39
40
|
/** Current L2 epoch number */
|
|
40
41
|
public l2EpochNumber!: bigint;
|
|
42
|
+
/** Current L2 slot number */
|
|
43
|
+
public l2SlotNumber!: bigint;
|
|
41
44
|
|
|
42
45
|
constructor(
|
|
43
46
|
private readonly rollup: RollupContract,
|
|
@@ -143,7 +146,12 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
143
146
|
this.l2EpochNumber = l2Epoch;
|
|
144
147
|
committee = (await this.rollup.getCurrentEpochCommittee())?.map(addr => EthAddress.fromString(addr));
|
|
145
148
|
this.emit('l2-epoch', { l2EpochNumber: Number(l2Epoch), timestamp, committee });
|
|
146
|
-
msg += ` starting new epoch ${this.l2EpochNumber}
|
|
149
|
+
msg += ` starting new epoch ${this.l2EpochNumber} `;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (l2SlotNumber !== this.l2SlotNumber) {
|
|
153
|
+
this.l2SlotNumber = l2SlotNumber;
|
|
154
|
+
this.emit('l2-slot', { l2SlotNumber: Number(l2SlotNumber), timestamp });
|
|
147
155
|
}
|
|
148
156
|
|
|
149
157
|
this.logger.info(msg, {
|
|
@@ -160,4 +168,20 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
160
168
|
|
|
161
169
|
return this;
|
|
162
170
|
}
|
|
171
|
+
|
|
172
|
+
public waitUntilL2Slot(slot: number | bigint): Promise<void> {
|
|
173
|
+
const targetSlot = typeof slot === 'bigint' ? slot.valueOf() : slot;
|
|
174
|
+
if (this.l2SlotNumber >= targetSlot) {
|
|
175
|
+
return Promise.resolve();
|
|
176
|
+
}
|
|
177
|
+
return new Promise(resolve => {
|
|
178
|
+
const listener = (data: { l2SlotNumber: number; timestamp: bigint }) => {
|
|
179
|
+
if (data.l2SlotNumber >= targetSlot) {
|
|
180
|
+
this.off('l2-slot', listener);
|
|
181
|
+
resolve();
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
this.on('l2-slot', listener);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
163
187
|
}
|