@aztec/ethereum 0.0.1-commit.f2ce05ee → 0.0.1-commit.f5a9928
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.d.ts +27 -3
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +63 -8
- package/dest/config.d.ts +17 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +38 -10
- package/dest/contracts/chain_state_override.d.ts +78 -0
- package/dest/contracts/chain_state_override.d.ts.map +1 -0
- package/dest/contracts/chain_state_override.js +137 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts +105 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
- package/dest/contracts/fee_asset_price_oracle.js +656 -0
- package/dest/contracts/governance.d.ts +135 -35
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +229 -18
- package/dest/contracts/governance_proposer.d.ts +33 -2
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +54 -6
- package/dest/contracts/gse.d.ts +4 -2
- package/dest/contracts/gse.d.ts.map +1 -1
- package/dest/contracts/gse.js +2 -2
- package/dest/contracts/inbox.d.ts +3 -3
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +12 -7
- package/dest/contracts/index.d.ts +4 -3
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +3 -2
- package/dest/contracts/multicall.d.ts +127 -12
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +201 -94
- package/dest/contracts/outbox.d.ts +27 -4
- package/dest/contracts/outbox.d.ts.map +1 -1
- package/dest/contracts/outbox.js +34 -7
- package/dest/contracts/registry.d.ts +3 -1
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +30 -1
- package/dest/contracts/rollup.d.ts +5437 -34
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +448 -104
- package/dest/contracts/slashing_proposer.d.ts +171 -0
- package/dest/contracts/slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/slashing_proposer.js +753 -0
- package/dest/contracts/watch_event.d.ts +36 -0
- package/dest/contracts/watch_event.d.ts.map +1 -0
- package/dest/contracts/watch_event.js +66 -0
- package/dest/deploy_aztec_l1_contracts.d.ts +5 -9
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +48 -27
- package/dest/deploy_l1_contract.js +3 -3
- package/dest/foundry_binary.d.ts +13 -0
- package/dest/foundry_binary.d.ts.map +1 -0
- package/dest/foundry_binary.js +52 -0
- package/dest/generated/l1-contracts-defaults.d.ts +3 -3
- package/dest/generated/l1-contracts-defaults.js +3 -3
- package/dest/l1_artifacts.d.ts +15524 -15847
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_artifacts.js +9 -24
- package/dest/l1_contract_addresses.d.ts +61 -65
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +101 -82
- package/dest/l1_reader.d.ts +5 -5
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +9 -7
- package/dest/l1_tx_utils/config.d.ts +7 -1
- package/dest/l1_tx_utils/config.d.ts.map +1 -1
- package/dest/l1_tx_utils/config.js +17 -4
- package/dest/l1_tx_utils/factory.d.ts +18 -10
- package/dest/l1_tx_utils/factory.d.ts.map +1 -1
- package/dest/l1_tx_utils/factory.js +17 -7
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +1 -1
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +15 -15
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +9 -15
- package/dest/l1_tx_utils/index-blobs.d.ts +3 -3
- package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -1
- package/dest/l1_tx_utils/index-blobs.js +2 -2
- package/dest/l1_tx_utils/index.d.ts +2 -1
- package/dest/l1_tx_utils/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/index.js +1 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +26 -7
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +156 -79
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +57 -23
- package/dest/l1_tx_utils/tx_delayer.d.ts +58 -0
- package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
- package/dest/{test → l1_tx_utils}/tx_delayer.js +67 -37
- package/dest/publisher_manager.d.ts +34 -8
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +119 -8
- package/dest/queries.d.ts +13 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +62 -3
- package/dest/test/blob_kzg_warmup.d.ts +19 -0
- package/dest/test/blob_kzg_warmup.d.ts.map +1 -0
- package/dest/test/blob_kzg_warmup.js +64 -0
- package/dest/test/chain_monitor.d.ts +55 -4
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +104 -3
- package/dest/test/eth_cheat_codes.d.ts +31 -6
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +67 -44
- package/dest/test/index.d.ts +2 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +1 -2
- package/dest/test/recording_rpc_server.d.ts +18 -0
- package/dest/test/recording_rpc_server.d.ts.map +1 -0
- package/dest/test/recording_rpc_server.js +68 -0
- package/dest/test/rollup_cheat_codes.d.ts +60 -3
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +86 -7
- package/dest/test/start_anvil.d.ts +23 -3
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +182 -32
- package/dest/test/upgrade_utils.js +2 -2
- package/dest/utils.d.ts +9 -2
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +59 -24
- package/package.json +6 -8
- package/src/client.ts +72 -2
- package/src/config.ts +58 -14
- package/src/contracts/chain_state_override.ts +200 -0
- package/src/contracts/fee_asset_price_oracle.ts +285 -0
- package/src/contracts/governance.ts +313 -13
- package/src/contracts/governance_proposer.ts +58 -9
- package/src/contracts/gse.ts +7 -2
- package/src/contracts/inbox.ts +13 -5
- package/src/contracts/index.ts +3 -2
- package/src/contracts/multicall.ts +243 -105
- package/src/contracts/outbox.ts +42 -8
- package/src/contracts/registry.ts +31 -1
- package/src/contracts/rollup.ts +507 -109
- package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +119 -45
- package/src/contracts/watch_event.ts +110 -0
- package/src/deploy_aztec_l1_contracts.ts +75 -39
- package/src/deploy_l1_contract.ts +3 -3
- package/src/foundry_binary.ts +57 -0
- package/src/generated/l1-contracts-defaults.ts +3 -3
- package/src/l1_artifacts.ts +12 -35
- package/src/l1_contract_addresses.ts +120 -94
- package/src/l1_reader.ts +17 -10
- package/src/l1_tx_utils/config.ts +23 -3
- package/src/l1_tx_utils/factory.ts +31 -31
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +1 -1
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +1 -1
- package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +43 -54
- package/src/l1_tx_utils/index-blobs.ts +2 -2
- package/src/l1_tx_utils/index.ts +1 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +149 -64
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +57 -17
- package/src/{test → l1_tx_utils}/tx_delayer.ts +93 -56
- package/src/publisher_manager.ts +143 -12
- package/src/queries.ts +70 -4
- package/src/test/blob_kzg_warmup.ts +65 -0
- package/src/test/chain_monitor.ts +148 -3
- package/src/test/eth_cheat_codes.ts +63 -47
- package/src/test/index.ts +1 -2
- package/src/test/recording_rpc_server.ts +69 -0
- package/src/test/rollup_cheat_codes.ts +115 -6
- package/src/test/start_anvil.ts +212 -32
- package/src/test/upgrade_utils.ts +2 -2
- package/src/utils.ts +56 -29
- package/dest/contracts/empire_slashing_proposer.d.ts +0 -67
- package/dest/contracts/empire_slashing_proposer.d.ts.map +0 -1
- package/dest/contracts/empire_slashing_proposer.js +0 -207
- package/dest/contracts/tally_slashing_proposer.d.ts +0 -140
- package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
- package/dest/contracts/tally_slashing_proposer.js +0 -320
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +0 -26
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +0 -26
- package/dest/test/delayed_tx_utils.d.ts +0 -13
- package/dest/test/delayed_tx_utils.d.ts.map +0 -1
- package/dest/test/delayed_tx_utils.js +0 -28
- package/dest/test/tx_delayer.d.ts +0 -36
- package/dest/test/tx_delayer.d.ts.map +0 -1
- package/src/contracts/empire_slashing_proposer.ts +0 -259
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
- package/src/test/delayed_tx_utils.ts +0 -52
|
@@ -0,0 +1,753 @@
|
|
|
1
|
+
function applyDecs2203RFactory() {
|
|
2
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
3
|
+
return function addInitializer(initializer) {
|
|
4
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
5
|
+
assertCallable(initializer, "An initializer");
|
|
6
|
+
initializers.push(initializer);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
10
|
+
var kindStr;
|
|
11
|
+
switch(kind){
|
|
12
|
+
case 1:
|
|
13
|
+
kindStr = "accessor";
|
|
14
|
+
break;
|
|
15
|
+
case 2:
|
|
16
|
+
kindStr = "method";
|
|
17
|
+
break;
|
|
18
|
+
case 3:
|
|
19
|
+
kindStr = "getter";
|
|
20
|
+
break;
|
|
21
|
+
case 4:
|
|
22
|
+
kindStr = "setter";
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
kindStr = "field";
|
|
26
|
+
}
|
|
27
|
+
var ctx = {
|
|
28
|
+
kind: kindStr,
|
|
29
|
+
name: isPrivate ? "#" + name : name,
|
|
30
|
+
static: isStatic,
|
|
31
|
+
private: isPrivate,
|
|
32
|
+
metadata: metadata
|
|
33
|
+
};
|
|
34
|
+
var decoratorFinishedRef = {
|
|
35
|
+
v: false
|
|
36
|
+
};
|
|
37
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
38
|
+
var get, set;
|
|
39
|
+
if (kind === 0) {
|
|
40
|
+
if (isPrivate) {
|
|
41
|
+
get = desc.get;
|
|
42
|
+
set = desc.set;
|
|
43
|
+
} else {
|
|
44
|
+
get = function() {
|
|
45
|
+
return this[name];
|
|
46
|
+
};
|
|
47
|
+
set = function(v) {
|
|
48
|
+
this[name] = v;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
} else if (kind === 2) {
|
|
52
|
+
get = function() {
|
|
53
|
+
return desc.value;
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
if (kind === 1 || kind === 3) {
|
|
57
|
+
get = function() {
|
|
58
|
+
return desc.get.call(this);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (kind === 1 || kind === 4) {
|
|
62
|
+
set = function(v) {
|
|
63
|
+
desc.set.call(this, v);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
ctx.access = get && set ? {
|
|
68
|
+
get: get,
|
|
69
|
+
set: set
|
|
70
|
+
} : get ? {
|
|
71
|
+
get: get
|
|
72
|
+
} : {
|
|
73
|
+
set: set
|
|
74
|
+
};
|
|
75
|
+
try {
|
|
76
|
+
return dec(value, ctx);
|
|
77
|
+
} finally{
|
|
78
|
+
decoratorFinishedRef.v = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
82
|
+
if (decoratorFinishedRef.v) {
|
|
83
|
+
throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function assertCallable(fn, hint) {
|
|
87
|
+
if (typeof fn !== "function") {
|
|
88
|
+
throw new TypeError(hint + " must be a function");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function assertValidReturnValue(kind, value) {
|
|
92
|
+
var type = typeof value;
|
|
93
|
+
if (kind === 1) {
|
|
94
|
+
if (type !== "object" || value === null) {
|
|
95
|
+
throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
96
|
+
}
|
|
97
|
+
if (value.get !== undefined) {
|
|
98
|
+
assertCallable(value.get, "accessor.get");
|
|
99
|
+
}
|
|
100
|
+
if (value.set !== undefined) {
|
|
101
|
+
assertCallable(value.set, "accessor.set");
|
|
102
|
+
}
|
|
103
|
+
if (value.init !== undefined) {
|
|
104
|
+
assertCallable(value.init, "accessor.init");
|
|
105
|
+
}
|
|
106
|
+
} else if (type !== "function") {
|
|
107
|
+
var hint;
|
|
108
|
+
if (kind === 0) {
|
|
109
|
+
hint = "field";
|
|
110
|
+
} else if (kind === 10) {
|
|
111
|
+
hint = "class";
|
|
112
|
+
} else {
|
|
113
|
+
hint = "method";
|
|
114
|
+
}
|
|
115
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
119
|
+
var decs = decInfo[0];
|
|
120
|
+
var desc, init, value;
|
|
121
|
+
if (isPrivate) {
|
|
122
|
+
if (kind === 0 || kind === 1) {
|
|
123
|
+
desc = {
|
|
124
|
+
get: decInfo[3],
|
|
125
|
+
set: decInfo[4]
|
|
126
|
+
};
|
|
127
|
+
} else if (kind === 3) {
|
|
128
|
+
desc = {
|
|
129
|
+
get: decInfo[3]
|
|
130
|
+
};
|
|
131
|
+
} else if (kind === 4) {
|
|
132
|
+
desc = {
|
|
133
|
+
set: decInfo[3]
|
|
134
|
+
};
|
|
135
|
+
} else {
|
|
136
|
+
desc = {
|
|
137
|
+
value: decInfo[3]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
} else if (kind !== 0) {
|
|
141
|
+
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
142
|
+
}
|
|
143
|
+
if (kind === 1) {
|
|
144
|
+
value = {
|
|
145
|
+
get: desc.get,
|
|
146
|
+
set: desc.set
|
|
147
|
+
};
|
|
148
|
+
} else if (kind === 2) {
|
|
149
|
+
value = desc.value;
|
|
150
|
+
} else if (kind === 3) {
|
|
151
|
+
value = desc.get;
|
|
152
|
+
} else if (kind === 4) {
|
|
153
|
+
value = desc.set;
|
|
154
|
+
}
|
|
155
|
+
var newValue, get, set;
|
|
156
|
+
if (typeof decs === "function") {
|
|
157
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
158
|
+
if (newValue !== void 0) {
|
|
159
|
+
assertValidReturnValue(kind, newValue);
|
|
160
|
+
if (kind === 0) {
|
|
161
|
+
init = newValue;
|
|
162
|
+
} else if (kind === 1) {
|
|
163
|
+
init = newValue.init;
|
|
164
|
+
get = newValue.get || value.get;
|
|
165
|
+
set = newValue.set || value.set;
|
|
166
|
+
value = {
|
|
167
|
+
get: get,
|
|
168
|
+
set: set
|
|
169
|
+
};
|
|
170
|
+
} else {
|
|
171
|
+
value = newValue;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
for(var i = decs.length - 1; i >= 0; i--){
|
|
176
|
+
var dec = decs[i];
|
|
177
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
178
|
+
if (newValue !== void 0) {
|
|
179
|
+
assertValidReturnValue(kind, newValue);
|
|
180
|
+
var newInit;
|
|
181
|
+
if (kind === 0) {
|
|
182
|
+
newInit = newValue;
|
|
183
|
+
} else if (kind === 1) {
|
|
184
|
+
newInit = newValue.init;
|
|
185
|
+
get = newValue.get || value.get;
|
|
186
|
+
set = newValue.set || value.set;
|
|
187
|
+
value = {
|
|
188
|
+
get: get,
|
|
189
|
+
set: set
|
|
190
|
+
};
|
|
191
|
+
} else {
|
|
192
|
+
value = newValue;
|
|
193
|
+
}
|
|
194
|
+
if (newInit !== void 0) {
|
|
195
|
+
if (init === void 0) {
|
|
196
|
+
init = newInit;
|
|
197
|
+
} else if (typeof init === "function") {
|
|
198
|
+
init = [
|
|
199
|
+
init,
|
|
200
|
+
newInit
|
|
201
|
+
];
|
|
202
|
+
} else {
|
|
203
|
+
init.push(newInit);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (kind === 0 || kind === 1) {
|
|
210
|
+
if (init === void 0) {
|
|
211
|
+
init = function(instance, init) {
|
|
212
|
+
return init;
|
|
213
|
+
};
|
|
214
|
+
} else if (typeof init !== "function") {
|
|
215
|
+
var ownInitializers = init;
|
|
216
|
+
init = function(instance, init) {
|
|
217
|
+
var value = init;
|
|
218
|
+
for(var i = 0; i < ownInitializers.length; i++){
|
|
219
|
+
value = ownInitializers[i].call(instance, value);
|
|
220
|
+
}
|
|
221
|
+
return value;
|
|
222
|
+
};
|
|
223
|
+
} else {
|
|
224
|
+
var originalInitializer = init;
|
|
225
|
+
init = function(instance, init) {
|
|
226
|
+
return originalInitializer.call(instance, init);
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
ret.push(init);
|
|
230
|
+
}
|
|
231
|
+
if (kind !== 0) {
|
|
232
|
+
if (kind === 1) {
|
|
233
|
+
desc.get = value.get;
|
|
234
|
+
desc.set = value.set;
|
|
235
|
+
} else if (kind === 2) {
|
|
236
|
+
desc.value = value;
|
|
237
|
+
} else if (kind === 3) {
|
|
238
|
+
desc.get = value;
|
|
239
|
+
} else if (kind === 4) {
|
|
240
|
+
desc.set = value;
|
|
241
|
+
}
|
|
242
|
+
if (isPrivate) {
|
|
243
|
+
if (kind === 1) {
|
|
244
|
+
ret.push(function(instance, args) {
|
|
245
|
+
return value.get.call(instance, args);
|
|
246
|
+
});
|
|
247
|
+
ret.push(function(instance, args) {
|
|
248
|
+
return value.set.call(instance, args);
|
|
249
|
+
});
|
|
250
|
+
} else if (kind === 2) {
|
|
251
|
+
ret.push(value);
|
|
252
|
+
} else {
|
|
253
|
+
ret.push(function(instance, args) {
|
|
254
|
+
return value.call(instance, args);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
Object.defineProperty(base, name, desc);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
263
|
+
var ret = [];
|
|
264
|
+
var protoInitializers;
|
|
265
|
+
var staticInitializers;
|
|
266
|
+
var existingProtoNonFields = new Map();
|
|
267
|
+
var existingStaticNonFields = new Map();
|
|
268
|
+
for(var i = 0; i < decInfos.length; i++){
|
|
269
|
+
var decInfo = decInfos[i];
|
|
270
|
+
if (!Array.isArray(decInfo)) continue;
|
|
271
|
+
var kind = decInfo[1];
|
|
272
|
+
var name = decInfo[2];
|
|
273
|
+
var isPrivate = decInfo.length > 3;
|
|
274
|
+
var isStatic = kind >= 5;
|
|
275
|
+
var base;
|
|
276
|
+
var initializers;
|
|
277
|
+
if (isStatic) {
|
|
278
|
+
base = Class;
|
|
279
|
+
kind = kind - 5;
|
|
280
|
+
staticInitializers = staticInitializers || [];
|
|
281
|
+
initializers = staticInitializers;
|
|
282
|
+
} else {
|
|
283
|
+
base = Class.prototype;
|
|
284
|
+
protoInitializers = protoInitializers || [];
|
|
285
|
+
initializers = protoInitializers;
|
|
286
|
+
}
|
|
287
|
+
if (kind !== 0 && !isPrivate) {
|
|
288
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
289
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
290
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
|
|
291
|
+
throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
292
|
+
} else if (!existingKind && kind > 2) {
|
|
293
|
+
existingNonFields.set(name, kind);
|
|
294
|
+
} else {
|
|
295
|
+
existingNonFields.set(name, true);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
299
|
+
}
|
|
300
|
+
pushInitializers(ret, protoInitializers);
|
|
301
|
+
pushInitializers(ret, staticInitializers);
|
|
302
|
+
return ret;
|
|
303
|
+
}
|
|
304
|
+
function pushInitializers(ret, initializers) {
|
|
305
|
+
if (initializers) {
|
|
306
|
+
ret.push(function(instance) {
|
|
307
|
+
for(var i = 0; i < initializers.length; i++){
|
|
308
|
+
initializers[i].call(instance);
|
|
309
|
+
}
|
|
310
|
+
return instance;
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
315
|
+
if (classDecs.length > 0) {
|
|
316
|
+
var initializers = [];
|
|
317
|
+
var newClass = targetClass;
|
|
318
|
+
var name = targetClass.name;
|
|
319
|
+
for(var i = classDecs.length - 1; i >= 0; i--){
|
|
320
|
+
var decoratorFinishedRef = {
|
|
321
|
+
v: false
|
|
322
|
+
};
|
|
323
|
+
try {
|
|
324
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
325
|
+
kind: "class",
|
|
326
|
+
name: name,
|
|
327
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
328
|
+
metadata
|
|
329
|
+
});
|
|
330
|
+
} finally{
|
|
331
|
+
decoratorFinishedRef.v = true;
|
|
332
|
+
}
|
|
333
|
+
if (nextNewClass !== undefined) {
|
|
334
|
+
assertValidReturnValue(10, nextNewClass);
|
|
335
|
+
newClass = nextNewClass;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return [
|
|
339
|
+
defineMetadata(newClass, metadata),
|
|
340
|
+
function() {
|
|
341
|
+
for(var i = 0; i < initializers.length; i++){
|
|
342
|
+
initializers[i].call(newClass);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
];
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function defineMetadata(Class, metadata) {
|
|
349
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
350
|
+
configurable: true,
|
|
351
|
+
enumerable: true,
|
|
352
|
+
value: metadata
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
356
|
+
if (parentClass !== void 0) {
|
|
357
|
+
var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
358
|
+
}
|
|
359
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
360
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
361
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
362
|
+
return {
|
|
363
|
+
e: e,
|
|
364
|
+
get c () {
|
|
365
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
371
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
372
|
+
}
|
|
373
|
+
var _initProto;
|
|
374
|
+
import { mergeAbis, tryExtractEvent } from '@aztec/ethereum/utils';
|
|
375
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
376
|
+
import { memoize } from '@aztec/foundation/decorators';
|
|
377
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
378
|
+
import { Signature } from '@aztec/foundation/eth-signature';
|
|
379
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
380
|
+
import { hexToBuffer } from '@aztec/foundation/string';
|
|
381
|
+
import { SlasherAbi } from '@aztec/l1-artifacts/SlasherAbi';
|
|
382
|
+
import { SlashingProposerAbi } from '@aztec/l1-artifacts/SlashingProposerAbi';
|
|
383
|
+
import { encodeFunctionData, getContract } from 'viem';
|
|
384
|
+
import { watchContractEvent } from './watch_event.js';
|
|
385
|
+
/**
|
|
386
|
+
* Wrapper around the SlashingProposer contract that provides
|
|
387
|
+
* a TypeScript interface for interacting with the consensus-based slashing system.
|
|
388
|
+
*/ export class SlashingProposerContract {
|
|
389
|
+
client;
|
|
390
|
+
static{
|
|
391
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
392
|
+
[
|
|
393
|
+
memoize,
|
|
394
|
+
2,
|
|
395
|
+
"getSlashingAmounts"
|
|
396
|
+
]
|
|
397
|
+
], []));
|
|
398
|
+
}
|
|
399
|
+
contract;
|
|
400
|
+
logger;
|
|
401
|
+
/**
|
|
402
|
+
* Slash target validators of the last round asked for. Safe to cache because a round's targets are the committees
|
|
403
|
+
* of epochs that had already ended when the round opened (see SLASH_OFFSET_IN_ROUNDS), and those committees are
|
|
404
|
+
* sampled from validator set and randao snapshots taken before the epoch started, so they cannot change while the
|
|
405
|
+
* round is live. The promise is cached rather than the result, so concurrent callers share one in-flight read.
|
|
406
|
+
*/ slashTargetValidators;
|
|
407
|
+
constructor(client, address){
|
|
408
|
+
this.client = client;
|
|
409
|
+
this.logger = (_initProto(this), createLogger('ethereum:slashing_proposer'));
|
|
410
|
+
this.contract = getContract({
|
|
411
|
+
address: typeof address === 'string' ? address : address.toString(),
|
|
412
|
+
abi: SlashingProposerAbi,
|
|
413
|
+
client
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
get address() {
|
|
417
|
+
return EthAddress.fromString(this.contract.address);
|
|
418
|
+
}
|
|
419
|
+
getQuorumSize() {
|
|
420
|
+
return this.contract.read.QUORUM();
|
|
421
|
+
}
|
|
422
|
+
getRoundSize() {
|
|
423
|
+
return this.contract.read.ROUND_SIZE();
|
|
424
|
+
}
|
|
425
|
+
getCommitteeSize() {
|
|
426
|
+
return this.contract.read.COMMITTEE_SIZE();
|
|
427
|
+
}
|
|
428
|
+
getRoundSizeInEpochs() {
|
|
429
|
+
return this.contract.read.ROUND_SIZE_IN_EPOCHS();
|
|
430
|
+
}
|
|
431
|
+
getLifetimeInRounds() {
|
|
432
|
+
return this.contract.read.LIFETIME_IN_ROUNDS();
|
|
433
|
+
}
|
|
434
|
+
getExecutionDelayInRounds() {
|
|
435
|
+
return this.contract.read.EXECUTION_DELAY_IN_ROUNDS();
|
|
436
|
+
}
|
|
437
|
+
/** Returns the slash amounts for the three slash unit levels. Immutable on the contract, so memoized. */ getSlashingAmounts() {
|
|
438
|
+
return Promise.all([
|
|
439
|
+
this.contract.read.SLASH_AMOUNT_SMALL(),
|
|
440
|
+
this.contract.read.SLASH_AMOUNT_MEDIUM(),
|
|
441
|
+
this.contract.read.SLASH_AMOUNT_LARGE()
|
|
442
|
+
]);
|
|
443
|
+
}
|
|
444
|
+
getSlashOffsetInRounds() {
|
|
445
|
+
return this.contract.read.SLASH_OFFSET_IN_ROUNDS();
|
|
446
|
+
}
|
|
447
|
+
getCurrentRound() {
|
|
448
|
+
return this.contract.read.getCurrentRound();
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Get round information
|
|
452
|
+
* @param round - The round number to query
|
|
453
|
+
* @returns Round status information
|
|
454
|
+
*/ async getRound(round) {
|
|
455
|
+
const [isExecuted, voteCount] = await this.contract.read.getRound([
|
|
456
|
+
round
|
|
457
|
+
]);
|
|
458
|
+
return {
|
|
459
|
+
isExecuted,
|
|
460
|
+
voteCount
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Check if a round is ready to execute at a given slot
|
|
465
|
+
* @param round - The round number to check
|
|
466
|
+
* @param slot - The slot number to check at
|
|
467
|
+
* @returns Whether the round is ready to execute
|
|
468
|
+
*/ async isRoundReadyToExecute(round, slot) {
|
|
469
|
+
return await this.contract.read.isRoundReadyToExecute([
|
|
470
|
+
round,
|
|
471
|
+
BigInt(slot)
|
|
472
|
+
]);
|
|
473
|
+
}
|
|
474
|
+
/** Returns the slash actions and payload address for a given round (zero if no slash actions) */ async getPayload(round) {
|
|
475
|
+
const { result: committees } = await this.contract.simulate.getSlashTargetCommittees([
|
|
476
|
+
round
|
|
477
|
+
]);
|
|
478
|
+
const tally = await this.contract.read.getTally([
|
|
479
|
+
round,
|
|
480
|
+
committees
|
|
481
|
+
]);
|
|
482
|
+
const address = await this.contract.read.getPayloadAddress([
|
|
483
|
+
round,
|
|
484
|
+
tally
|
|
485
|
+
]);
|
|
486
|
+
const actions = this.mapSlashActions(tally);
|
|
487
|
+
return {
|
|
488
|
+
actions,
|
|
489
|
+
address: EthAddress.fromString(address)
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
/** Returns the slash actions to be executed for a given round based on votes */ async getTally(round) {
|
|
493
|
+
const { result: committees } = await this.contract.simulate.getSlashTargetCommittees([
|
|
494
|
+
round
|
|
495
|
+
]);
|
|
496
|
+
const tally = await this.contract.read.getTally([
|
|
497
|
+
round,
|
|
498
|
+
committees
|
|
499
|
+
]);
|
|
500
|
+
return {
|
|
501
|
+
actions: this.mapSlashActions(tally),
|
|
502
|
+
committees: committees.map((c)=>c.map(EthAddress.fromString))
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
mapSlashActions(actions) {
|
|
506
|
+
return actions.map(({ validator, slashAmount })=>({
|
|
507
|
+
validator: EthAddress.fromString(validator),
|
|
508
|
+
slashAmount
|
|
509
|
+
}));
|
|
510
|
+
}
|
|
511
|
+
/** Tries to extract a VoteCast event from the given logs. */ tryExtractVoteCastEvent(logs) {
|
|
512
|
+
return tryExtractEvent(logs, this.address.toString(), SlashingProposerAbi, 'VoteCast');
|
|
513
|
+
}
|
|
514
|
+
/** Tries to extract a RoundExecuted event from the given logs. */ tryExtractRoundExecutedEvent(logs) {
|
|
515
|
+
return tryExtractEvent(logs, this.address.toString(), SlashingProposerAbi, 'RoundExecuted');
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Create a transaction to vote for slashing offenses
|
|
519
|
+
* @param votes - The encoded votes for slashing
|
|
520
|
+
* @param slot - The slot number for the vote
|
|
521
|
+
* @param signer - The signer to produce the signature
|
|
522
|
+
* @returns L1 transaction request
|
|
523
|
+
*/ async buildVoteRequestFromSigner(votes, slot, signer) {
|
|
524
|
+
const typedData = this.buildVoteTypedData(votes, slot);
|
|
525
|
+
const signature = Signature.fromString(await signer(typedData));
|
|
526
|
+
return {
|
|
527
|
+
to: this.contract.address,
|
|
528
|
+
abi: SlashingProposerAbi,
|
|
529
|
+
data: encodeFunctionData({
|
|
530
|
+
abi: SlashingProposerAbi,
|
|
531
|
+
functionName: 'vote',
|
|
532
|
+
args: [
|
|
533
|
+
votes,
|
|
534
|
+
signature.toViemSignature()
|
|
535
|
+
]
|
|
536
|
+
})
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
/** Returns the typed data definition to EIP712-sign for voting */ buildVoteTypedData(votes, slot) {
|
|
540
|
+
const domain = {
|
|
541
|
+
name: 'SlashingProposer',
|
|
542
|
+
version: '1',
|
|
543
|
+
chainId: this.client.chain.id,
|
|
544
|
+
verifyingContract: this.contract.address
|
|
545
|
+
};
|
|
546
|
+
const types = {
|
|
547
|
+
EIP712Domain: [
|
|
548
|
+
{
|
|
549
|
+
name: 'name',
|
|
550
|
+
type: 'string'
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
name: 'version',
|
|
554
|
+
type: 'string'
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
name: 'chainId',
|
|
558
|
+
type: 'uint256'
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
name: 'verifyingContract',
|
|
562
|
+
type: 'address'
|
|
563
|
+
}
|
|
564
|
+
],
|
|
565
|
+
Vote: [
|
|
566
|
+
{
|
|
567
|
+
name: 'votes',
|
|
568
|
+
type: 'bytes'
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
name: 'slot',
|
|
572
|
+
type: 'uint256'
|
|
573
|
+
}
|
|
574
|
+
]
|
|
575
|
+
};
|
|
576
|
+
return {
|
|
577
|
+
domain,
|
|
578
|
+
types,
|
|
579
|
+
primaryType: 'Vote',
|
|
580
|
+
message: {
|
|
581
|
+
votes,
|
|
582
|
+
slot: BigInt(slot)
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
/** Gets the digest to sign for voting directly from the contract */ async getVoteDataDigest(votes, slot) {
|
|
587
|
+
return Buffer32.fromString(await this.contract.read.getVoteSignatureDigest([
|
|
588
|
+
votes,
|
|
589
|
+
BigInt(slot)
|
|
590
|
+
]));
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Create a transaction to vote for slashing offenses
|
|
594
|
+
* @param votes - The encoded votes for slashing
|
|
595
|
+
* @param signature - The signature from the current proposer
|
|
596
|
+
* @returns L1 transaction request
|
|
597
|
+
*/ buildVoteRequestWithSignature(votes, signature) {
|
|
598
|
+
return {
|
|
599
|
+
to: this.contract.address,
|
|
600
|
+
abi: SlashingProposerAbi,
|
|
601
|
+
data: encodeFunctionData({
|
|
602
|
+
abi: SlashingProposerAbi,
|
|
603
|
+
functionName: 'vote',
|
|
604
|
+
args: [
|
|
605
|
+
votes,
|
|
606
|
+
signature
|
|
607
|
+
]
|
|
608
|
+
})
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Create a transaction to execute a slashing round
|
|
613
|
+
* @param round - The round number to execute
|
|
614
|
+
* @param committees - The committees for each epoch in the round
|
|
615
|
+
* @returns L1 transaction request
|
|
616
|
+
*/ buildExecuteRoundRequest(round, committees) {
|
|
617
|
+
return {
|
|
618
|
+
to: this.contract.address,
|
|
619
|
+
abi: mergeAbis([
|
|
620
|
+
SlashingProposerAbi,
|
|
621
|
+
SlasherAbi
|
|
622
|
+
]),
|
|
623
|
+
data: encodeFunctionData({
|
|
624
|
+
abi: SlashingProposerAbi,
|
|
625
|
+
functionName: 'executeRound',
|
|
626
|
+
args: [
|
|
627
|
+
round,
|
|
628
|
+
committees.map((c)=>c.map((addr)=>addr.toString()))
|
|
629
|
+
]
|
|
630
|
+
})
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Returns the validators eligible to be voted against in a round, in the order votes encode them. Cached for the
|
|
635
|
+
* last round asked for: reading them runs a committee sampling simulation on L1, and every vote of a round decodes
|
|
636
|
+
* against the same list, so a caller walking a round's votes would otherwise repeat that call per vote. Only the
|
|
637
|
+
* last round is kept since callers move forward round by round.
|
|
638
|
+
*/ getSlashTargetValidators(round) {
|
|
639
|
+
const cached = this.slashTargetValidators;
|
|
640
|
+
if (cached?.round === round) {
|
|
641
|
+
return cached.validators;
|
|
642
|
+
}
|
|
643
|
+
const entry = {
|
|
644
|
+
round,
|
|
645
|
+
validators: this.fetchSlashTargetValidators(round)
|
|
646
|
+
};
|
|
647
|
+
this.slashTargetValidators = entry;
|
|
648
|
+
// A failed read must not stay cached, or every later vote of the round would replay the same rejection
|
|
649
|
+
entry.validators.catch(()=>{
|
|
650
|
+
if (this.slashTargetValidators === entry) {
|
|
651
|
+
this.slashTargetValidators = undefined;
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
return entry.validators;
|
|
655
|
+
}
|
|
656
|
+
async fetchSlashTargetValidators(round) {
|
|
657
|
+
const { result } = await this.contract.simulate.getSlashTargetCommittees([
|
|
658
|
+
round
|
|
659
|
+
]);
|
|
660
|
+
return result.flat().map((validator)=>EthAddress.fromString(validator));
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Returns the slash amount voted for each target validator by a single vote of a round.
|
|
664
|
+
* @param index - Position of the vote within the round, from 0 (inclusive) to the round's vote count (exclusive)
|
|
665
|
+
*/ async getVoteAt(round, index) {
|
|
666
|
+
const [validators, vote, slashAmounts] = await Promise.all([
|
|
667
|
+
this.getSlashTargetValidators(round),
|
|
668
|
+
this.contract.read.getVotes([
|
|
669
|
+
round,
|
|
670
|
+
index
|
|
671
|
+
]),
|
|
672
|
+
this.getSlashingAmounts()
|
|
673
|
+
]);
|
|
674
|
+
return decodeVote(vote, validators, slashAmounts);
|
|
675
|
+
}
|
|
676
|
+
/** Returns the last vote emitted for a given round */ async getLastVote(round) {
|
|
677
|
+
const { voteCount } = await this.getRound(round);
|
|
678
|
+
return await this.getVoteAt(round, voteCount - 1n);
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Listen for VoteCast events. Events are delivered by polling `eth_getLogs`: a reorg may re-emit them and
|
|
682
|
+
* removals are never reported, and events mined within roughly one polling interval of subscribing may be missed.
|
|
683
|
+
* @param callback - Callback function to handle vote cast events
|
|
684
|
+
* @returns Unwatch function
|
|
685
|
+
*/ listenToVoteCast(callback, options) {
|
|
686
|
+
return watchContractEvent(this.client, this.logger, {
|
|
687
|
+
address: this.contract.address,
|
|
688
|
+
abi: SlashingProposerAbi,
|
|
689
|
+
eventName: 'VoteCast',
|
|
690
|
+
onLog: (log)=>{
|
|
691
|
+
const { round, proposer } = log.args;
|
|
692
|
+
if (round !== undefined && proposer) {
|
|
693
|
+
return callback({
|
|
694
|
+
round,
|
|
695
|
+
proposer
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
}, options);
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Listen for RoundExecuted events. Events are delivered by polling `eth_getLogs`: a reorg may re-emit them and
|
|
703
|
+
* removals are never reported, and events mined within roughly one polling interval of subscribing may be missed.
|
|
704
|
+
* @param callback - Callback function to handle round executed events
|
|
705
|
+
* @returns Unwatch function
|
|
706
|
+
*/ listenToRoundExecuted(callback, options) {
|
|
707
|
+
return watchContractEvent(this.client, this.logger, {
|
|
708
|
+
address: this.contract.address,
|
|
709
|
+
abi: SlashingProposerAbi,
|
|
710
|
+
eventName: 'RoundExecuted',
|
|
711
|
+
onLog: (log)=>{
|
|
712
|
+
const { round, slashCount } = log.args;
|
|
713
|
+
if (round !== undefined && slashCount !== undefined) {
|
|
714
|
+
return callback({
|
|
715
|
+
round,
|
|
716
|
+
slashCount,
|
|
717
|
+
l1BlockHash: log.blockHash
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}, options);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
function decodeVote(vote, validators, slashAmounts) {
|
|
725
|
+
return decodeSlashConsensusVotes(hexToBuffer(vote)).map((units, position)=>({
|
|
726
|
+
validator: validators[position],
|
|
727
|
+
slashAmount: slashAmounts[units - 1] ?? 0n,
|
|
728
|
+
position
|
|
729
|
+
})).filter((v)=>v.slashAmount > 0n);
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Decodes a Buffer containing slash votes back into an array of numbers.
|
|
733
|
+
* Each vote is represented as a 2-bit value (0, 1, 2, or 3) representing slashing units.
|
|
734
|
+
* @dev This should live in stdlib next to encodeSlashConsensusVotes but is here since we
|
|
735
|
+
* do not have a dependency to stdlib from the ethereum package. We need a larger refactor to fix this.
|
|
736
|
+
* @param buffer - The Buffer containing encoded slash votes
|
|
737
|
+
* @returns An array of numbers representing the slash votes
|
|
738
|
+
*/ export function decodeSlashConsensusVotes(buffer) {
|
|
739
|
+
const votes = [];
|
|
740
|
+
for(let i = 0; i < buffer.length; i++){
|
|
741
|
+
const voteByte = buffer.readUInt8(i);
|
|
742
|
+
// Decode votes from Solidity's bit order (LSB to MSB)
|
|
743
|
+
// Bits 0-1: validator at index i*4
|
|
744
|
+
// Bits 2-3: validator at index i*4+1
|
|
745
|
+
// Bits 4-5: validator at index i*4+2
|
|
746
|
+
// Bits 6-7: validator at index i*4+3
|
|
747
|
+
votes.push(voteByte >> 0 & 0x03);
|
|
748
|
+
votes.push(voteByte >> 2 & 0x03);
|
|
749
|
+
votes.push(voteByte >> 4 & 0x03);
|
|
750
|
+
votes.push(voteByte >> 6 & 0x03);
|
|
751
|
+
}
|
|
752
|
+
return votes;
|
|
753
|
+
}
|