@aztec/ethereum 0.0.1-commit.03f7ef2 → 0.0.1-commit.04d373f
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 +16 -2
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +27 -7
- package/dest/config.d.ts +24 -32
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +63 -62
- 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_handler.d.ts +6 -5
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.js +11 -9
- 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 +110 -33
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +207 -16
- package/dest/contracts/governance_proposer.d.ts +33 -1
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +438 -10
- package/dest/contracts/inbox.d.ts +22 -1
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +42 -2
- package/dest/contracts/index.d.ts +6 -3
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +5 -2
- package/dest/contracts/log.d.ts +13 -0
- package/dest/contracts/log.d.ts.map +1 -0
- package/dest/contracts/log.js +1 -0
- package/dest/contracts/multicall.d.ts +127 -12
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +201 -93
- package/dest/contracts/outbox.d.ts +58 -0
- package/dest/contracts/outbox.d.ts.map +1 -0
- package/dest/contracts/outbox.js +109 -0
- 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 +5409 -115
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +1027 -189
- package/dest/contracts/{tally_slashing_proposer.d.ts → slashing_proposer.d.ts} +3 -4
- package/dest/contracts/slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/{tally_slashing_proposer.js → slashing_proposer.js} +18 -13
- package/dest/deploy_aztec_l1_contracts.d.ts +20 -9
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +113 -37
- package/dest/deploy_l1_contract.js +3 -3
- package/dest/generated/l1-contracts-defaults.d.ts +30 -0
- package/dest/generated/l1-contracts-defaults.d.ts.map +1 -0
- package/dest/generated/l1-contracts-defaults.js +30 -0
- package/dest/l1_artifacts.d.ts +18360 -16454
- 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 +14 -1
- package/dest/l1_tx_utils/constants.d.ts +1 -1
- package/dest/l1_tx_utils/constants.js +2 -2
- 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/index.d.ts +3 -2
- package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/index.js +2 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +2 -12
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +36 -18
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +2 -11
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +37 -19
- package/dest/l1_tx_utils/fee-strategies/types.d.ts +14 -27
- package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/types.js +0 -21
- 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_fee_analyzer.d.ts +2 -2
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_fee_analyzer.js +3 -3
- 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 +101 -66
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -5
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +25 -58
- 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 +21 -6
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +81 -7
- package/dest/queries.d.ts +14 -3
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +74 -7
- package/dest/test/chain_monitor.d.ts +23 -3
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +39 -4
- package/dest/test/eth_cheat_codes.d.ts +24 -4
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +17 -4
- package/dest/test/index.d.ts +1 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +0 -2
- package/dest/test/rollup_cheat_codes.d.ts +34 -3
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +75 -6
- 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 +143 -29
- package/dest/test/upgrade_utils.js +2 -2
- package/dest/utils.d.ts +9 -1
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +81 -12
- package/package.json +9 -10
- package/src/client.ts +28 -2
- package/src/config.ts +81 -63
- package/src/contracts/README.md +157 -0
- package/src/contracts/chain_state_override.ts +200 -0
- package/src/contracts/fee_asset_handler.ts +10 -7
- package/src/contracts/fee_asset_price_oracle.ts +285 -0
- package/src/contracts/governance.ts +279 -13
- package/src/contracts/governance_proposer.ts +58 -2
- package/src/contracts/inbox.ts +62 -2
- package/src/contracts/index.ts +5 -2
- package/src/contracts/log.ts +13 -0
- package/src/contracts/multicall.ts +243 -102
- package/src/contracts/outbox.ts +128 -0
- package/src/contracts/registry.ts +31 -1
- package/src/contracts/rollup.ts +728 -148
- package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +16 -14
- package/src/deploy_aztec_l1_contracts.ts +137 -47
- package/src/deploy_l1_contract.ts +3 -3
- package/src/generated/l1-contracts-defaults.ts +32 -0
- 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 +20 -0
- package/src/l1_tx_utils/constants.ts +2 -2
- package/src/l1_tx_utils/factory.ts +31 -31
- package/src/l1_tx_utils/fee-strategies/index.ts +1 -1
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +46 -42
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +49 -45
- package/src/l1_tx_utils/fee-strategies/types.ts +14 -46
- 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_fee_analyzer.ts +2 -3
- package/src/l1_tx_utils/l1_tx_utils.ts +99 -48
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +31 -66
- package/src/{test → l1_tx_utils}/tx_delayer.ts +93 -56
- package/src/publisher_manager.ts +107 -10
- package/src/queries.ts +81 -7
- package/src/test/chain_monitor.ts +66 -4
- package/src/test/eth_cheat_codes.ts +16 -4
- package/src/test/index.ts +0 -2
- package/src/test/rollup_cheat_codes.ts +82 -6
- package/src/test/start_anvil.ts +177 -29
- package/src/test/upgrade_utils.ts +2 -2
- package/src/utils.ts +88 -14
- 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 -209
- package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
- 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 -270
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
- package/src/test/delayed_tx_utils.ts +0 -52
package/dest/contracts/rollup.js
CHANGED
|
@@ -1,34 +1,529 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
};
|
|
6
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;
|
|
7
374
|
import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
375
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
376
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
377
|
import { memoize } from '@aztec/foundation/decorators';
|
|
9
378
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
379
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
10
380
|
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
381
|
+
import { EscapeHatchAbi } from '@aztec/l1-artifacts/EscapeHatchAbi';
|
|
11
382
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
12
383
|
import { RollupStorage } from '@aztec/l1-artifacts/RollupStorage';
|
|
13
384
|
import chunk from 'lodash.chunk';
|
|
14
|
-
import { encodeFunctionData, getContract, hexToBigInt, keccak256 } from 'viem';
|
|
385
|
+
import { encodeAbiParameters, encodeFunctionData, getContract, hexToBigInt, keccak256 } from 'viem';
|
|
15
386
|
import { getPublicClient } from '../client.js';
|
|
16
387
|
import { formatViemError } from '../utils.js';
|
|
17
|
-
import { EmpireSlashingProposerContract } from './empire_slashing_proposer.js';
|
|
18
388
|
import { GSEContract } from './gse.js';
|
|
19
389
|
import { SlasherContract } from './slasher_contract.js';
|
|
20
|
-
import {
|
|
390
|
+
import { SlashingProposerContract } from './slashing_proposer.js';
|
|
21
391
|
import { checkBlockTag } from './utils.js';
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
392
|
+
/**
|
|
393
|
+
* Status of a validator/attester in the staking system.
|
|
394
|
+
* Matches the Status enum in StakingLib.sol
|
|
395
|
+
*/ export var AttesterStatus = /*#__PURE__*/ function(AttesterStatus) {
|
|
396
|
+
AttesterStatus[AttesterStatus["NONE"] = 0] = "NONE";
|
|
397
|
+
AttesterStatus[AttesterStatus["VALIDATING"] = 1] = "VALIDATING";
|
|
398
|
+
AttesterStatus[AttesterStatus["ZOMBIE"] = 2] = "ZOMBIE";
|
|
399
|
+
AttesterStatus[AttesterStatus["EXITING"] = 3] = "EXITING";
|
|
400
|
+
return AttesterStatus;
|
|
401
|
+
}({});
|
|
402
|
+
/** Field offsets within the CompressedTempCheckpointLog struct in Solidity storage. */ export var TempCheckpointLogField = /*#__PURE__*/ function(TempCheckpointLogField) {
|
|
403
|
+
TempCheckpointLogField[TempCheckpointLogField["HeaderHash"] = 0] = "HeaderHash";
|
|
404
|
+
TempCheckpointLogField[TempCheckpointLogField["BlobCommitmentsHash"] = 1] = "BlobCommitmentsHash";
|
|
405
|
+
TempCheckpointLogField[TempCheckpointLogField["OutHash"] = 2] = "OutHash";
|
|
406
|
+
TempCheckpointLogField[TempCheckpointLogField["AttestationsHash"] = 3] = "AttestationsHash";
|
|
407
|
+
TempCheckpointLogField[TempCheckpointLogField["PayloadDigest"] = 4] = "PayloadDigest";
|
|
408
|
+
TempCheckpointLogField[TempCheckpointLogField["SlotNumber"] = 5] = "SlotNumber";
|
|
409
|
+
TempCheckpointLogField[TempCheckpointLogField["FeeHeader"] = 6] = "FeeHeader";
|
|
410
|
+
return TempCheckpointLogField;
|
|
27
411
|
}({});
|
|
28
412
|
export class RollupContract {
|
|
29
413
|
client;
|
|
414
|
+
static{
|
|
415
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
416
|
+
[
|
|
417
|
+
memoize,
|
|
418
|
+
2,
|
|
419
|
+
"getL1StartBlock"
|
|
420
|
+
],
|
|
421
|
+
[
|
|
422
|
+
memoize,
|
|
423
|
+
2,
|
|
424
|
+
"getL1GenesisTime"
|
|
425
|
+
],
|
|
426
|
+
[
|
|
427
|
+
memoize,
|
|
428
|
+
2,
|
|
429
|
+
"getProofSubmissionEpochs"
|
|
430
|
+
],
|
|
431
|
+
[
|
|
432
|
+
memoize,
|
|
433
|
+
2,
|
|
434
|
+
"getEpochDuration"
|
|
435
|
+
],
|
|
436
|
+
[
|
|
437
|
+
memoize,
|
|
438
|
+
2,
|
|
439
|
+
"getSlotDuration"
|
|
440
|
+
],
|
|
441
|
+
[
|
|
442
|
+
memoize,
|
|
443
|
+
2,
|
|
444
|
+
"getTargetCommitteeSize"
|
|
445
|
+
],
|
|
446
|
+
[
|
|
447
|
+
memoize,
|
|
448
|
+
2,
|
|
449
|
+
"getEjectionThreshold"
|
|
450
|
+
],
|
|
451
|
+
[
|
|
452
|
+
memoize,
|
|
453
|
+
2,
|
|
454
|
+
"getLocalEjectionThreshold"
|
|
455
|
+
],
|
|
456
|
+
[
|
|
457
|
+
memoize,
|
|
458
|
+
2,
|
|
459
|
+
"getLagInEpochsForValidatorSet"
|
|
460
|
+
],
|
|
461
|
+
[
|
|
462
|
+
memoize,
|
|
463
|
+
2,
|
|
464
|
+
"getLagInEpochsForRandao"
|
|
465
|
+
],
|
|
466
|
+
[
|
|
467
|
+
memoize,
|
|
468
|
+
2,
|
|
469
|
+
"getActivationThreshold"
|
|
470
|
+
],
|
|
471
|
+
[
|
|
472
|
+
memoize,
|
|
473
|
+
2,
|
|
474
|
+
"getExitDelay"
|
|
475
|
+
],
|
|
476
|
+
[
|
|
477
|
+
memoize,
|
|
478
|
+
2,
|
|
479
|
+
"getManaTarget"
|
|
480
|
+
],
|
|
481
|
+
[
|
|
482
|
+
memoize,
|
|
483
|
+
2,
|
|
484
|
+
"getProvingCostPerMana"
|
|
485
|
+
],
|
|
486
|
+
[
|
|
487
|
+
memoize,
|
|
488
|
+
2,
|
|
489
|
+
"getProvingCostPerManaInFeeAsset"
|
|
490
|
+
],
|
|
491
|
+
[
|
|
492
|
+
memoize,
|
|
493
|
+
2,
|
|
494
|
+
"getManaLimit"
|
|
495
|
+
],
|
|
496
|
+
[
|
|
497
|
+
memoize,
|
|
498
|
+
2,
|
|
499
|
+
"getVersion"
|
|
500
|
+
],
|
|
501
|
+
[
|
|
502
|
+
memoize,
|
|
503
|
+
2,
|
|
504
|
+
"getGenesisArchiveTreeRoot"
|
|
505
|
+
],
|
|
506
|
+
[
|
|
507
|
+
memoize,
|
|
508
|
+
2,
|
|
509
|
+
"getVkTreeRoot"
|
|
510
|
+
],
|
|
511
|
+
[
|
|
512
|
+
memoize,
|
|
513
|
+
2,
|
|
514
|
+
"getProtocolContractsHash"
|
|
515
|
+
],
|
|
516
|
+
[
|
|
517
|
+
memoize,
|
|
518
|
+
2,
|
|
519
|
+
"getRollupConstants"
|
|
520
|
+
]
|
|
521
|
+
], []));
|
|
522
|
+
}
|
|
30
523
|
rollup;
|
|
524
|
+
logger;
|
|
31
525
|
static cachedStfStorageSlot;
|
|
526
|
+
cachedEscapeHatch;
|
|
32
527
|
static get checkBlobStorageSlot() {
|
|
33
528
|
const asString = RollupStorage.find((storage)=>storage.label === 'checkBlob')?.slot;
|
|
34
529
|
if (asString === undefined) {
|
|
@@ -45,11 +540,12 @@ export class RollupContract {
|
|
|
45
540
|
}
|
|
46
541
|
static getFromConfig(config) {
|
|
47
542
|
const client = getPublicClient(config);
|
|
48
|
-
const address = config.
|
|
543
|
+
const address = config.rollupAddress.toString();
|
|
49
544
|
return new RollupContract(client, address);
|
|
50
545
|
}
|
|
51
546
|
constructor(client, address){
|
|
52
547
|
this.client = client;
|
|
548
|
+
this.logger = (_initProto(this), createLogger('ethereum:rollup'));
|
|
53
549
|
if (address instanceof EthAddress) {
|
|
54
550
|
address = address.toString();
|
|
55
551
|
}
|
|
@@ -59,8 +555,8 @@ export class RollupContract {
|
|
|
59
555
|
client
|
|
60
556
|
});
|
|
61
557
|
}
|
|
62
|
-
getGSE() {
|
|
63
|
-
return this.rollup.read.getGSE();
|
|
558
|
+
async getGSE() {
|
|
559
|
+
return EthAddress.fromString(await this.rollup.read.getGSE());
|
|
64
560
|
}
|
|
65
561
|
get address() {
|
|
66
562
|
return this.rollup.address;
|
|
@@ -74,34 +570,10 @@ export class RollupContract {
|
|
|
74
570
|
return undefined;
|
|
75
571
|
}
|
|
76
572
|
const proposerAddress = await slasher.getProposer();
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
type: 'function',
|
|
80
|
-
name: 'SLASHING_PROPOSER_TYPE',
|
|
81
|
-
inputs: [],
|
|
82
|
-
outputs: [
|
|
83
|
-
{
|
|
84
|
-
name: '',
|
|
85
|
-
type: 'uint8',
|
|
86
|
-
internalType: 'enum SlasherFlavor'
|
|
87
|
-
}
|
|
88
|
-
],
|
|
89
|
-
stateMutability: 'view'
|
|
90
|
-
}
|
|
91
|
-
];
|
|
92
|
-
const proposer = getContract({
|
|
93
|
-
address: proposerAddress.toString(),
|
|
94
|
-
abi: proposerAbi,
|
|
95
|
-
client: this.client
|
|
96
|
-
});
|
|
97
|
-
const proposerType = await proposer.read.SLASHING_PROPOSER_TYPE();
|
|
98
|
-
if (proposerType === 1..valueOf()) {
|
|
99
|
-
return new TallySlashingProposerContract(this.client, proposerAddress);
|
|
100
|
-
} else if (proposerType === 2..valueOf()) {
|
|
101
|
-
return new EmpireSlashingProposerContract(this.client, proposerAddress);
|
|
102
|
-
} else {
|
|
103
|
-
throw new Error(`Unknown slashing proposer type: ${proposerType}`);
|
|
573
|
+
if (proposerAddress.isZero()) {
|
|
574
|
+
return undefined;
|
|
104
575
|
}
|
|
576
|
+
return new SlashingProposerContract(this.client, proposerAddress);
|
|
105
577
|
}
|
|
106
578
|
getL1StartBlock() {
|
|
107
579
|
return this.rollup.read.L1_BLOCK_AT_GENESIS();
|
|
@@ -109,17 +581,17 @@ export class RollupContract {
|
|
|
109
581
|
getL1GenesisTime() {
|
|
110
582
|
return this.rollup.read.getGenesisTime();
|
|
111
583
|
}
|
|
112
|
-
getProofSubmissionEpochs() {
|
|
113
|
-
return this.rollup.read.getProofSubmissionEpochs();
|
|
584
|
+
async getProofSubmissionEpochs() {
|
|
585
|
+
return Number(await this.rollup.read.getProofSubmissionEpochs());
|
|
114
586
|
}
|
|
115
|
-
getEpochDuration() {
|
|
116
|
-
return this.rollup.read.getEpochDuration();
|
|
587
|
+
async getEpochDuration() {
|
|
588
|
+
return Number(await this.rollup.read.getEpochDuration());
|
|
117
589
|
}
|
|
118
590
|
async getSlotDuration() {
|
|
119
591
|
return Number(await this.rollup.read.getSlotDuration());
|
|
120
592
|
}
|
|
121
|
-
getTargetCommitteeSize() {
|
|
122
|
-
return this.rollup.read.getTargetCommitteeSize();
|
|
593
|
+
async getTargetCommitteeSize() {
|
|
594
|
+
return Number(await this.rollup.read.getTargetCommitteeSize());
|
|
123
595
|
}
|
|
124
596
|
getEjectionThreshold() {
|
|
125
597
|
return this.rollup.read.getEjectionThreshold();
|
|
@@ -127,17 +599,17 @@ export class RollupContract {
|
|
|
127
599
|
getLocalEjectionThreshold() {
|
|
128
600
|
return this.rollup.read.getLocalEjectionThreshold();
|
|
129
601
|
}
|
|
130
|
-
getLagInEpochsForValidatorSet() {
|
|
131
|
-
return this.rollup.read.getLagInEpochsForValidatorSet();
|
|
602
|
+
async getLagInEpochsForValidatorSet() {
|
|
603
|
+
return Number(await this.rollup.read.getLagInEpochsForValidatorSet());
|
|
132
604
|
}
|
|
133
|
-
getLagInEpochsForRandao() {
|
|
134
|
-
return this.rollup.read.getLagInEpochsForRandao();
|
|
605
|
+
async getLagInEpochsForRandao() {
|
|
606
|
+
return Number(await this.rollup.read.getLagInEpochsForRandao());
|
|
135
607
|
}
|
|
136
608
|
getActivationThreshold() {
|
|
137
609
|
return this.rollup.read.getActivationThreshold();
|
|
138
610
|
}
|
|
139
|
-
getExitDelay() {
|
|
140
|
-
return this.rollup.read.getExitDelay();
|
|
611
|
+
async getExitDelay() {
|
|
612
|
+
return Number(await this.rollup.read.getExitDelay());
|
|
141
613
|
}
|
|
142
614
|
getManaTarget() {
|
|
143
615
|
return this.rollup.read.getManaTarget();
|
|
@@ -155,47 +627,115 @@ export class RollupContract {
|
|
|
155
627
|
return this.rollup.read.getVersion();
|
|
156
628
|
}
|
|
157
629
|
async getGenesisArchiveTreeRoot() {
|
|
158
|
-
return await this.rollup.read.archiveAt([
|
|
630
|
+
return Fr.fromString(await this.rollup.read.archiveAt([
|
|
159
631
|
0n
|
|
160
|
-
]);
|
|
632
|
+
]));
|
|
633
|
+
}
|
|
634
|
+
async getVkTreeRoot() {
|
|
635
|
+
const slot = BigInt(RollupContract.stfStorageSlot) + 3n;
|
|
636
|
+
const value = await this.client.getStorageAt({
|
|
637
|
+
address: this.address,
|
|
638
|
+
slot: `0x${slot.toString(16)}`
|
|
639
|
+
});
|
|
640
|
+
return Fr.fromString(value ?? '0x0');
|
|
641
|
+
}
|
|
642
|
+
async getProtocolContractsHash() {
|
|
643
|
+
const slot = BigInt(RollupContract.stfStorageSlot) + 4n;
|
|
644
|
+
const value = await this.client.getStorageAt({
|
|
645
|
+
address: this.address,
|
|
646
|
+
slot: `0x${slot.toString(16)}`
|
|
647
|
+
});
|
|
648
|
+
return Fr.fromString(value ?? '0x0');
|
|
161
649
|
}
|
|
162
650
|
/**
|
|
163
651
|
* Returns rollup constants used for epoch queries.
|
|
164
652
|
* Return type is `L1RollupConstants` which is defined in stdlib,
|
|
165
653
|
* so we cant reference it until we move this contract to that package.
|
|
166
654
|
*/ async getRollupConstants() {
|
|
167
|
-
const [l1StartBlock, l1GenesisTime, slotDuration, epochDuration, proofSubmissionEpochs] = await Promise.all([
|
|
655
|
+
const [l1StartBlock, l1GenesisTime, slotDuration, epochDuration, proofSubmissionEpochs, targetCommitteeSize, rollupManaLimit] = await Promise.all([
|
|
168
656
|
this.getL1StartBlock(),
|
|
169
657
|
this.getL1GenesisTime(),
|
|
170
658
|
this.getSlotDuration(),
|
|
171
659
|
this.getEpochDuration(),
|
|
172
|
-
this.getProofSubmissionEpochs()
|
|
660
|
+
this.getProofSubmissionEpochs(),
|
|
661
|
+
this.getTargetCommitteeSize(),
|
|
662
|
+
this.getManaLimit()
|
|
173
663
|
]);
|
|
174
664
|
return {
|
|
175
665
|
l1StartBlock,
|
|
176
666
|
l1GenesisTime,
|
|
177
667
|
slotDuration,
|
|
178
668
|
epochDuration: Number(epochDuration),
|
|
179
|
-
proofSubmissionEpochs: Number(proofSubmissionEpochs)
|
|
669
|
+
proofSubmissionEpochs: Number(proofSubmissionEpochs),
|
|
670
|
+
targetCommitteeSize,
|
|
671
|
+
rollupManaLimit: Number(rollupManaLimit)
|
|
180
672
|
};
|
|
181
673
|
}
|
|
182
|
-
getSlasherAddress() {
|
|
183
|
-
return this.rollup.read.getSlasher();
|
|
674
|
+
async getSlasherAddress() {
|
|
675
|
+
return EthAddress.fromString(await this.rollup.read.getSlasher());
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Returns the configured escape hatch contract address, or zero if disabled.
|
|
679
|
+
*/ async getEscapeHatchAddress() {
|
|
680
|
+
return EthAddress.fromString(await this.rollup.read.getEscapeHatch());
|
|
681
|
+
}
|
|
682
|
+
async getEscapeHatchContract() {
|
|
683
|
+
const escapeHatchAddress = await this.getEscapeHatchAddress();
|
|
684
|
+
if (escapeHatchAddress.isZero()) {
|
|
685
|
+
return undefined;
|
|
686
|
+
}
|
|
687
|
+
// Cache the viem contract wrapper since it will be used frequently.
|
|
688
|
+
if (!this.cachedEscapeHatch || !this.cachedEscapeHatch.address.equals(escapeHatchAddress)) {
|
|
689
|
+
this.cachedEscapeHatch = {
|
|
690
|
+
address: escapeHatchAddress,
|
|
691
|
+
contract: getContract({
|
|
692
|
+
address: escapeHatchAddress.toString(),
|
|
693
|
+
abi: EscapeHatchAbi,
|
|
694
|
+
client: this.client
|
|
695
|
+
})
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
return this.cachedEscapeHatch.contract;
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Returns whether the escape hatch is open for the given epoch.
|
|
702
|
+
* If escape hatch is not configured, returns false.
|
|
703
|
+
*
|
|
704
|
+
* This function is intentionally defensive: any failure to query the escape hatch
|
|
705
|
+
* (RPC issues, transient errors, etc.) is treated as "closed" to avoid callers
|
|
706
|
+
* needing to sprinkle try/catch everywhere.
|
|
707
|
+
*/ async isEscapeHatchOpen(epoch) {
|
|
708
|
+
try {
|
|
709
|
+
const escapeHatch = await this.getEscapeHatchContract();
|
|
710
|
+
if (!escapeHatch) {
|
|
711
|
+
return false;
|
|
712
|
+
}
|
|
713
|
+
const [isOpen] = await escapeHatch.read.isHatchOpen([
|
|
714
|
+
BigInt(epoch)
|
|
715
|
+
]);
|
|
716
|
+
return isOpen;
|
|
717
|
+
} catch (err) {
|
|
718
|
+
this.logger.warn('isEscapeHatchOpen failed (treating as closed); RPC or contract error may cause liveness risk', {
|
|
719
|
+
epoch: Number(epoch),
|
|
720
|
+
error: err
|
|
721
|
+
});
|
|
722
|
+
return false;
|
|
723
|
+
}
|
|
184
724
|
}
|
|
185
725
|
/**
|
|
186
726
|
* Returns a SlasherContract instance for interacting with the slasher contract.
|
|
187
727
|
*/ async getSlasherContract() {
|
|
188
|
-
const slasherAddress =
|
|
728
|
+
const slasherAddress = await this.getSlasherAddress();
|
|
189
729
|
if (slasherAddress.isZero()) {
|
|
190
730
|
return undefined;
|
|
191
731
|
}
|
|
192
732
|
return new SlasherContract(this.client, slasherAddress);
|
|
193
733
|
}
|
|
194
|
-
getOwner() {
|
|
195
|
-
return this.rollup.read.owner();
|
|
734
|
+
async getOwner() {
|
|
735
|
+
return EthAddress.fromString(await this.rollup.read.owner());
|
|
196
736
|
}
|
|
197
|
-
getActiveAttesterCount() {
|
|
198
|
-
return this.rollup.read.getActiveAttesterCount();
|
|
737
|
+
async getActiveAttesterCount() {
|
|
738
|
+
return Number(await this.rollup.read.getActiveAttesterCount());
|
|
199
739
|
}
|
|
200
740
|
async getSlashingProposerAddress() {
|
|
201
741
|
const slasher = await this.getSlasherContract();
|
|
@@ -207,22 +747,42 @@ export class RollupContract {
|
|
|
207
747
|
getCheckpointReward() {
|
|
208
748
|
return this.rollup.read.getCheckpointReward();
|
|
209
749
|
}
|
|
210
|
-
async getCheckpointNumber() {
|
|
211
|
-
|
|
750
|
+
async getCheckpointNumber(options) {
|
|
751
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
752
|
+
return CheckpointNumber.fromBigInt(await this.rollup.read.getPendingCheckpointNumber(options));
|
|
212
753
|
}
|
|
213
|
-
async getProvenCheckpointNumber() {
|
|
214
|
-
|
|
754
|
+
async getProvenCheckpointNumber(options) {
|
|
755
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
756
|
+
return CheckpointNumber.fromBigInt(await this.rollup.read.getProvenCheckpointNumber(options));
|
|
215
757
|
}
|
|
216
|
-
async getSlotNumber() {
|
|
217
|
-
|
|
758
|
+
async getSlotNumber(options) {
|
|
759
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
760
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot(options));
|
|
218
761
|
}
|
|
219
|
-
getL1FeesAt(timestamp) {
|
|
220
|
-
|
|
762
|
+
async getL1FeesAt(timestamp, options) {
|
|
763
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
764
|
+
const result = await this.rollup.read.getL1FeesAt([
|
|
221
765
|
timestamp
|
|
766
|
+
], options);
|
|
767
|
+
return {
|
|
768
|
+
baseFee: result.baseFee,
|
|
769
|
+
blobFee: result.blobFee
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
async getFeeHeader(checkpointNumber) {
|
|
773
|
+
const result = await this.rollup.read.getFeeHeader([
|
|
774
|
+
checkpointNumber
|
|
222
775
|
]);
|
|
776
|
+
return {
|
|
777
|
+
excessMana: result.excessMana,
|
|
778
|
+
manaUsed: result.manaUsed,
|
|
779
|
+
ethPerFeeAsset: result.ethPerFeeAsset,
|
|
780
|
+
congestionCost: result.congestionCost,
|
|
781
|
+
proverCost: result.proverCost
|
|
782
|
+
};
|
|
223
783
|
}
|
|
224
|
-
|
|
225
|
-
return this.rollup.read.
|
|
784
|
+
getEthPerFeeAsset() {
|
|
785
|
+
return this.rollup.read.getEthPerFeeAsset();
|
|
226
786
|
}
|
|
227
787
|
async getCommitteeAt(timestamp) {
|
|
228
788
|
const { result } = await this.client.simulateContract({
|
|
@@ -240,15 +800,15 @@ export class RollupContract {
|
|
|
240
800
|
}
|
|
241
801
|
throw e;
|
|
242
802
|
});
|
|
243
|
-
return result;
|
|
803
|
+
return result ? result.map((addr)=>EthAddress.fromString(addr)) : undefined;
|
|
244
804
|
}
|
|
245
|
-
getSampleSeedAt(timestamp) {
|
|
246
|
-
return this.rollup.read.getSampleSeedAt([
|
|
805
|
+
async getSampleSeedAt(timestamp) {
|
|
806
|
+
return Buffer32.fromBigInt(await this.rollup.read.getSampleSeedAt([
|
|
247
807
|
timestamp
|
|
248
|
-
]);
|
|
808
|
+
]));
|
|
249
809
|
}
|
|
250
|
-
getCurrentSampleSeed() {
|
|
251
|
-
return this.rollup.read.getCurrentSampleSeed();
|
|
810
|
+
async getCurrentSampleSeed() {
|
|
811
|
+
return Buffer32.fromBigInt(await this.rollup.read.getCurrentSampleSeed());
|
|
252
812
|
}
|
|
253
813
|
async getCurrentEpoch() {
|
|
254
814
|
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
@@ -267,7 +827,7 @@ export class RollupContract {
|
|
|
267
827
|
}
|
|
268
828
|
throw e;
|
|
269
829
|
});
|
|
270
|
-
return result;
|
|
830
|
+
return result ? result.map((addr)=>EthAddress.fromString(addr)) : undefined;
|
|
271
831
|
}
|
|
272
832
|
async getCurrentProposer() {
|
|
273
833
|
const { result } = await this.client.simulateContract({
|
|
@@ -276,7 +836,7 @@ export class RollupContract {
|
|
|
276
836
|
functionName: 'getCurrentProposer',
|
|
277
837
|
args: []
|
|
278
838
|
});
|
|
279
|
-
return result;
|
|
839
|
+
return EthAddress.fromString(result);
|
|
280
840
|
}
|
|
281
841
|
async getProposerAt(timestamp) {
|
|
282
842
|
const { result } = await this.client.simulateContract({
|
|
@@ -287,12 +847,28 @@ export class RollupContract {
|
|
|
287
847
|
timestamp
|
|
288
848
|
]
|
|
289
849
|
});
|
|
290
|
-
return result;
|
|
850
|
+
return EthAddress.fromString(result);
|
|
291
851
|
}
|
|
292
|
-
getCheckpoint(checkpointNumber) {
|
|
293
|
-
|
|
852
|
+
async getCheckpoint(checkpointNumber, options) {
|
|
853
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
854
|
+
const result = await this.rollup.read.getCheckpoint([
|
|
294
855
|
BigInt(checkpointNumber)
|
|
295
|
-
]);
|
|
856
|
+
], options);
|
|
857
|
+
return {
|
|
858
|
+
archive: Fr.fromString(result.archive),
|
|
859
|
+
headerHash: Buffer32.fromString(result.headerHash),
|
|
860
|
+
blobCommitmentsHash: Buffer32.fromString(result.blobCommitmentsHash),
|
|
861
|
+
attestationsHash: Buffer32.fromString(result.attestationsHash),
|
|
862
|
+
payloadDigest: Buffer32.fromString(result.payloadDigest),
|
|
863
|
+
slotNumber: SlotNumber.fromBigInt(result.slotNumber),
|
|
864
|
+
feeHeader: {
|
|
865
|
+
excessMana: result.feeHeader.excessMana,
|
|
866
|
+
manaUsed: result.feeHeader.manaUsed,
|
|
867
|
+
ethPerFeeAsset: result.feeHeader.ethPerFeeAsset,
|
|
868
|
+
congestionCost: result.feeHeader.congestionCost,
|
|
869
|
+
proverCost: result.feeHeader.proverCost
|
|
870
|
+
}
|
|
871
|
+
};
|
|
296
872
|
}
|
|
297
873
|
/** Returns the pending checkpoint from the rollup contract */ getPendingCheckpoint() {
|
|
298
874
|
// We retry because of race conditions during prunes: we may get a pending checkpoint number which is immediately
|
|
@@ -307,6 +883,28 @@ export class RollupContract {
|
|
|
307
883
|
0.5
|
|
308
884
|
]));
|
|
309
885
|
}
|
|
886
|
+
/**
|
|
887
|
+
* Returns the effective pending checkpoint, accounting for potential prunes.
|
|
888
|
+
* When a prune can happen, the L1 contract uses the proven checkpoint instead of the pending one.
|
|
889
|
+
* This mirrors the behavior of getEffectivePendingCheckpointNumber in STFLib.sol.
|
|
890
|
+
* @param atTimestamp - The timestamp to evaluate pruneability at. Defaults to the current L1 block timestamp.
|
|
891
|
+
* @param options - Optional L1 block number to pin the queries to.
|
|
892
|
+
*/ getEffectivePendingCheckpoint(atTimestamp, options) {
|
|
893
|
+
return retry(async ()=>{
|
|
894
|
+
const timestamp = atTimestamp ?? (await this.client.getBlock()).timestamp;
|
|
895
|
+
const canPrune = await this.canPruneAtTime(timestamp, options);
|
|
896
|
+
if (canPrune) {
|
|
897
|
+
const provenCheckpointNumber = await this.getProvenCheckpointNumber(options);
|
|
898
|
+
return await this.getCheckpoint(provenCheckpointNumber, options);
|
|
899
|
+
}
|
|
900
|
+
const pendingCheckpointNumber = await this.getCheckpointNumber(options);
|
|
901
|
+
return await this.getCheckpoint(pendingCheckpointNumber, options);
|
|
902
|
+
}, 'getting effective pending checkpoint', makeBackoff([
|
|
903
|
+
0.5,
|
|
904
|
+
0.5,
|
|
905
|
+
0.5
|
|
906
|
+
]));
|
|
907
|
+
}
|
|
310
908
|
async getTips() {
|
|
311
909
|
const { pending, proven } = await this.rollup.read.getTips();
|
|
312
910
|
return {
|
|
@@ -319,11 +917,11 @@ export class RollupContract {
|
|
|
319
917
|
BigInt(slot)
|
|
320
918
|
]);
|
|
321
919
|
}
|
|
322
|
-
getEntryQueueLength() {
|
|
323
|
-
return this.rollup.read.getEntryQueueLength();
|
|
920
|
+
async getEntryQueueLength() {
|
|
921
|
+
return Number(await this.rollup.read.getEntryQueueLength());
|
|
324
922
|
}
|
|
325
|
-
getAvailableValidatorFlushes() {
|
|
326
|
-
return this.rollup.read.getAvailableValidatorFlushes();
|
|
923
|
+
async getAvailableValidatorFlushes() {
|
|
924
|
+
return Number(await this.rollup.read.getAvailableValidatorFlushes());
|
|
327
925
|
}
|
|
328
926
|
async getNextFlushableEpoch() {
|
|
329
927
|
return EpochNumber.fromBigInt(await this.rollup.read.getNextFlushableEpoch());
|
|
@@ -365,8 +963,9 @@ export class RollupContract {
|
|
|
365
963
|
BigInt(slotNumber)
|
|
366
964
|
]));
|
|
367
965
|
}
|
|
368
|
-
getEpochProofPublicInputs(args) {
|
|
369
|
-
|
|
966
|
+
async getEpochProofPublicInputs(args) {
|
|
967
|
+
const result = await this.rollup.read.getEpochProofPublicInputs(args);
|
|
968
|
+
return result.map(Fr.fromString);
|
|
370
969
|
}
|
|
371
970
|
async validateHeader(args, account) {
|
|
372
971
|
try {
|
|
@@ -390,9 +989,8 @@ export class RollupContract {
|
|
|
390
989
|
* @return [slot, checkpointNumber, timeOfNextL1Slot] - If you can propose, the L2 slot number, checkpoint number and
|
|
391
990
|
* timestamp of the next L1 block
|
|
392
991
|
* @throws otherwise
|
|
393
|
-
*/ async
|
|
394
|
-
const
|
|
395
|
-
const timeOfNextL1Slot = latestBlock.timestamp + BigInt(slotDuration);
|
|
992
|
+
*/ async canProposeAt(archive, account, timestamp, stateOverride = []) {
|
|
993
|
+
const timeOfNextL1Slot = timestamp;
|
|
396
994
|
const who = typeof account === 'string' ? account : account.address;
|
|
397
995
|
try {
|
|
398
996
|
const { result: [slot, checkpointNumber] } = await this.client.simulateContract({
|
|
@@ -405,7 +1003,7 @@ export class RollupContract {
|
|
|
405
1003
|
who
|
|
406
1004
|
],
|
|
407
1005
|
account,
|
|
408
|
-
stateOverride
|
|
1006
|
+
stateOverride
|
|
409
1007
|
});
|
|
410
1008
|
return {
|
|
411
1009
|
slot: SlotNumber.fromBigInt(slot),
|
|
@@ -417,11 +1015,15 @@ export class RollupContract {
|
|
|
417
1015
|
}
|
|
418
1016
|
}
|
|
419
1017
|
/**
|
|
420
|
-
* Returns a state override that sets the pending
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
|
|
424
|
-
|
|
1018
|
+
* Returns a state override that sets the pending and/or proven checkpoint numbers. Useful for simulations.
|
|
1019
|
+
* Both values share a single storage slot (pending in the upper 128 bits, proven in the lower 128 bits), so
|
|
1020
|
+
* a single combined override is emitted to avoid the second state-diff clobbering the first. The current live
|
|
1021
|
+
* value is read once to preserve any half not being overridden. Returns an empty override if neither is set.
|
|
1022
|
+
*
|
|
1023
|
+
* Throws if the resulting `proven > pending`, which would crash the simulation: `STFLib.canPruneAtTime` calls
|
|
1024
|
+
* `getEpochForCheckpoint(proven + 1)` whenever `pending != proven`, and that asserts `_n <= tips.pending`.
|
|
1025
|
+
*/ async makeChainTipsOverride(override) {
|
|
1026
|
+
if (override.pending === undefined && override.proven === undefined) {
|
|
425
1027
|
return [];
|
|
426
1028
|
}
|
|
427
1029
|
const slot = RollupContract.stfStorageSlot;
|
|
@@ -429,8 +1031,15 @@ export class RollupContract {
|
|
|
429
1031
|
address: this.address,
|
|
430
1032
|
slot
|
|
431
1033
|
});
|
|
432
|
-
const
|
|
433
|
-
const
|
|
1034
|
+
const currentRaw = currentValue ? hexToBigInt(currentValue) : 0n;
|
|
1035
|
+
const currentPending = currentRaw >> 128n;
|
|
1036
|
+
const currentProven = currentRaw & (1n << 128n) - 1n;
|
|
1037
|
+
const newPending = override.pending !== undefined ? BigInt(override.pending) : currentPending;
|
|
1038
|
+
const newProven = override.proven !== undefined ? BigInt(override.proven) : currentProven;
|
|
1039
|
+
if (newProven > newPending) {
|
|
1040
|
+
throw new Error(`Invalid chain tips override: proven (${newProven}) > pending (${newPending})`);
|
|
1041
|
+
}
|
|
1042
|
+
const newValue = newPending << 128n | newProven;
|
|
434
1043
|
return [
|
|
435
1044
|
{
|
|
436
1045
|
address: this.address,
|
|
@@ -443,9 +1052,165 @@ export class RollupContract {
|
|
|
443
1052
|
}
|
|
444
1053
|
];
|
|
445
1054
|
}
|
|
1055
|
+
/**
|
|
1056
|
+
* Returns a state override that patches `tempCheckpointLogs[checkpointNumber]` with every field that
|
|
1057
|
+
* the L1 contract reads during `propose()` for the checkpoint that builds on top of it (proposer
|
|
1058
|
+
* pipelining simulation). Mirrors the writes done by `ProposeLib.addTempCheckpointLog`.
|
|
1059
|
+
*
|
|
1060
|
+
* `blobCommitmentsHash` and `attestationsHash` are intentionally not exposed here — the propose path
|
|
1061
|
+
* never asserts against them, so leaving them at storage zero is harmless.
|
|
1062
|
+
*/ async makeTempCheckpointLogOverride(checkpointNumber, fields) {
|
|
1063
|
+
const constants = await this.getRollupConstants();
|
|
1064
|
+
const slotAt = (field)=>`0x${this.computeTempCheckpointLogStorageSlot(checkpointNumber, field, constants).toString(16).padStart(64, '0')}`;
|
|
1065
|
+
const word = (v)=>`0x${v.toString(16).padStart(64, '0')}`;
|
|
1066
|
+
const stateDiff = [];
|
|
1067
|
+
if (fields.headerHash) {
|
|
1068
|
+
stateDiff.push({
|
|
1069
|
+
slot: slotAt(0),
|
|
1070
|
+
value: fields.headerHash.toString()
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
if (fields.outHash) {
|
|
1074
|
+
stateDiff.push({
|
|
1075
|
+
slot: slotAt(2),
|
|
1076
|
+
value: fields.outHash.toString()
|
|
1077
|
+
});
|
|
1078
|
+
}
|
|
1079
|
+
if (fields.payloadDigest) {
|
|
1080
|
+
stateDiff.push({
|
|
1081
|
+
slot: slotAt(4),
|
|
1082
|
+
value: fields.payloadDigest.toString()
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
if (fields.slotNumber !== undefined) {
|
|
1086
|
+
// CompressedSlot is uint32 on L1 (SafeCast.toUint32 reverts on overflow). Match that behavior here
|
|
1087
|
+
// so a malformed override surfaces immediately rather than silently truncating into a wrong slot.
|
|
1088
|
+
const slotNumber = BigInt(fields.slotNumber);
|
|
1089
|
+
if (slotNumber < 0n || slotNumber > 0xffffffffn) {
|
|
1090
|
+
throw new Error(`slotNumber ${slotNumber} does not fit in uint32`);
|
|
1091
|
+
}
|
|
1092
|
+
stateDiff.push({
|
|
1093
|
+
slot: slotAt(5),
|
|
1094
|
+
value: word(slotNumber)
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
if (fields.feeHeader) {
|
|
1098
|
+
stateDiff.push({
|
|
1099
|
+
slot: slotAt(6),
|
|
1100
|
+
value: word(RollupContract.compressFeeHeader(fields.feeHeader))
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
if (stateDiff.length === 0) {
|
|
1104
|
+
return [];
|
|
1105
|
+
}
|
|
1106
|
+
return [
|
|
1107
|
+
{
|
|
1108
|
+
address: this.address,
|
|
1109
|
+
stateDiff
|
|
1110
|
+
}
|
|
1111
|
+
];
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Returns a state override that sets archives[checkpointNumber] to the given archive value.
|
|
1115
|
+
* Used when simulating a canProposeAtTime call where the local archive differs from L1
|
|
1116
|
+
* (e.g. pipelining where the parent checkpoint hasn't landed on L1 yet).
|
|
1117
|
+
*/ makeArchiveOverride(checkpointNumber, archive) {
|
|
1118
|
+
const archivesMappingBase = hexToBigInt(RollupContract.stfStorageSlot) + 1n;
|
|
1119
|
+
const archiveSlot = hexToBigInt(keccak256(encodeAbiParameters([
|
|
1120
|
+
{
|
|
1121
|
+
type: 'uint256'
|
|
1122
|
+
},
|
|
1123
|
+
{
|
|
1124
|
+
type: 'uint256'
|
|
1125
|
+
}
|
|
1126
|
+
], [
|
|
1127
|
+
BigInt(checkpointNumber),
|
|
1128
|
+
archivesMappingBase
|
|
1129
|
+
])));
|
|
1130
|
+
return [
|
|
1131
|
+
{
|
|
1132
|
+
address: this.address,
|
|
1133
|
+
stateDiff: [
|
|
1134
|
+
{
|
|
1135
|
+
slot: `0x${archiveSlot.toString(16).padStart(64, '0')}`,
|
|
1136
|
+
value: archive.toString()
|
|
1137
|
+
}
|
|
1138
|
+
]
|
|
1139
|
+
}
|
|
1140
|
+
];
|
|
1141
|
+
}
|
|
1142
|
+
/** Merges multiple StateOverride arrays, combining stateDiff entries for the same address. */ static mergeStateOverrides(...overrides) {
|
|
1143
|
+
const byAddress = new Map();
|
|
1144
|
+
for (const override of overrides){
|
|
1145
|
+
for (const entry of override){
|
|
1146
|
+
const key = entry.address.toLowerCase();
|
|
1147
|
+
const existing = byAddress.get(key);
|
|
1148
|
+
if (existing) {
|
|
1149
|
+
existing.stateDiff.push(...entry.stateDiff ?? []);
|
|
1150
|
+
if (entry.balance !== undefined) {
|
|
1151
|
+
existing.balance = entry.balance;
|
|
1152
|
+
}
|
|
1153
|
+
} else {
|
|
1154
|
+
byAddress.set(key, {
|
|
1155
|
+
address: entry.address,
|
|
1156
|
+
balance: entry.balance,
|
|
1157
|
+
stateDiff: [
|
|
1158
|
+
...entry.stateDiff ?? []
|
|
1159
|
+
]
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
return [
|
|
1165
|
+
...byAddress.values()
|
|
1166
|
+
];
|
|
1167
|
+
}
|
|
1168
|
+
/** Compresses a FeeHeader into a uint256 matching FeeHeaderLib.compress() in FeeStructs.sol. */ static compressFeeHeader(feeHeader) {
|
|
1169
|
+
const MASK_48_BITS = (1n << 48n) - 1n;
|
|
1170
|
+
const MASK_64_BITS = (1n << 64n) - 1n;
|
|
1171
|
+
const MASK_63_BITS = (1n << 63n) - 1n;
|
|
1172
|
+
let value = BigInt(feeHeader.manaUsed) & (1n << 32n) - 1n; // bits [0:31]
|
|
1173
|
+
value |= (feeHeader.excessMana < MASK_48_BITS ? feeHeader.excessMana : MASK_48_BITS) << 32n; // bits [32:79]
|
|
1174
|
+
value |= (BigInt(feeHeader.ethPerFeeAsset) & MASK_48_BITS) << 80n; // bits [80:127]
|
|
1175
|
+
value |= (feeHeader.congestionCost < MASK_64_BITS ? feeHeader.congestionCost : MASK_64_BITS) << 128n; // bits [128:191]
|
|
1176
|
+
value |= (feeHeader.proverCost < MASK_63_BITS ? feeHeader.proverCost : MASK_63_BITS) << 192n; // bits [192:254]
|
|
1177
|
+
value |= 1n << 255n; // preheat flag
|
|
1178
|
+
return value;
|
|
1179
|
+
}
|
|
1180
|
+
/** Computes the fee header for a child checkpoint given parent fee header and child data.
|
|
1181
|
+
* Must stay in sync with Solidity FeeLib.sol (computeNewEthPerFeeAsset, clampedAdd). */ static computeChildFeeHeader(parentFeeHeader, childManaUsed, feeAssetPriceModifier, manaTarget) {
|
|
1182
|
+
const MIN_ETH_PER_FEE_ASSET = 100n;
|
|
1183
|
+
const MAX_ETH_PER_FEE_ASSET = 100_000_000_000_000n; // 1e14, matches FeeLib.sol
|
|
1184
|
+
// excessMana = clampedAdd(parent.excessMana + parent.manaUsed, -manaTarget)
|
|
1185
|
+
const sum = parentFeeHeader.excessMana + parentFeeHeader.manaUsed;
|
|
1186
|
+
const excessMana = sum > manaTarget ? sum - manaTarget : 0n;
|
|
1187
|
+
// ethPerFeeAsset = computeNewEthPerFeeAsset(max(parent.ethPerFeeAsset, MIN), modifier)
|
|
1188
|
+
const parentPrice = parentFeeHeader.ethPerFeeAsset > MIN_ETH_PER_FEE_ASSET ? parentFeeHeader.ethPerFeeAsset : MIN_ETH_PER_FEE_ASSET;
|
|
1189
|
+
let newPrice;
|
|
1190
|
+
if (feeAssetPriceModifier >= 0n) {
|
|
1191
|
+
newPrice = parentPrice * (10_000n + feeAssetPriceModifier) / 10_000n;
|
|
1192
|
+
} else {
|
|
1193
|
+
const absMod = -feeAssetPriceModifier;
|
|
1194
|
+
newPrice = parentPrice * (10_000n - absMod) / 10_000n;
|
|
1195
|
+
}
|
|
1196
|
+
if (newPrice < MIN_ETH_PER_FEE_ASSET) {
|
|
1197
|
+
newPrice = MIN_ETH_PER_FEE_ASSET;
|
|
1198
|
+
}
|
|
1199
|
+
if (newPrice > MAX_ETH_PER_FEE_ASSET) {
|
|
1200
|
+
newPrice = MAX_ETH_PER_FEE_ASSET;
|
|
1201
|
+
}
|
|
1202
|
+
return {
|
|
1203
|
+
excessMana,
|
|
1204
|
+
manaUsed: childManaUsed,
|
|
1205
|
+
ethPerFeeAsset: newPrice,
|
|
1206
|
+
congestionCost: 0n,
|
|
1207
|
+
proverCost: 0n
|
|
1208
|
+
};
|
|
1209
|
+
}
|
|
446
1210
|
/** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */ buildInvalidateBadAttestationRequest(checkpointNumber, attestationsAndSigners, committee, invalidIndex) {
|
|
447
1211
|
return {
|
|
448
1212
|
to: this.address,
|
|
1213
|
+
abi: RollupAbi,
|
|
449
1214
|
data: encodeFunctionData({
|
|
450
1215
|
abi: RollupAbi,
|
|
451
1216
|
functionName: 'invalidateBadAttestation',
|
|
@@ -461,6 +1226,7 @@ export class RollupContract {
|
|
|
461
1226
|
/** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */ buildInvalidateInsufficientAttestationsRequest(checkpointNumber, attestationsAndSigners, committee) {
|
|
462
1227
|
return {
|
|
463
1228
|
to: this.address,
|
|
1229
|
+
abi: RollupAbi,
|
|
464
1230
|
data: encodeFunctionData({
|
|
465
1231
|
abi: RollupAbi,
|
|
466
1232
|
functionName: 'invalidateInsufficientAttestations',
|
|
@@ -482,11 +1248,25 @@ export class RollupContract {
|
|
|
482
1248
|
prover
|
|
483
1249
|
]);
|
|
484
1250
|
}
|
|
485
|
-
|
|
486
|
-
return this.rollup.read.
|
|
1251
|
+
getManaMinFeeAt(timestamp, inFeeAsset, stateOverride) {
|
|
1252
|
+
return this.rollup.read.getManaMinFeeAt([
|
|
1253
|
+
timestamp,
|
|
1254
|
+
inFeeAsset
|
|
1255
|
+
], {
|
|
1256
|
+
stateOverride
|
|
1257
|
+
});
|
|
1258
|
+
}
|
|
1259
|
+
async getManaMinFeeComponentsAt(timestamp, inFeeAsset) {
|
|
1260
|
+
const result = await this.rollup.read.getManaMinFeeComponentsAt([
|
|
487
1261
|
timestamp,
|
|
488
1262
|
inFeeAsset
|
|
489
1263
|
]);
|
|
1264
|
+
return {
|
|
1265
|
+
sequencerCost: result.sequencerCost,
|
|
1266
|
+
proverCost: result.proverCost,
|
|
1267
|
+
congestionCost: result.congestionCost,
|
|
1268
|
+
congestionMultiplier: result.congestionMultiplier
|
|
1269
|
+
};
|
|
490
1270
|
}
|
|
491
1271
|
async getSlotAt(timestamp) {
|
|
492
1272
|
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([
|
|
@@ -495,9 +1275,16 @@ export class RollupContract {
|
|
|
495
1275
|
}
|
|
496
1276
|
async status(checkpointNumber, options) {
|
|
497
1277
|
await checkBlockTag(options?.blockNumber, this.client);
|
|
498
|
-
|
|
1278
|
+
const result = await this.rollup.read.status([
|
|
499
1279
|
BigInt(checkpointNumber)
|
|
500
1280
|
], options);
|
|
1281
|
+
return {
|
|
1282
|
+
provenCheckpointNumber: CheckpointNumber.fromBigInt(result[0]),
|
|
1283
|
+
provenArchive: Fr.fromString(result[1]),
|
|
1284
|
+
pendingCheckpointNumber: CheckpointNumber.fromBigInt(result[2]),
|
|
1285
|
+
pendingArchive: Fr.fromString(result[3]),
|
|
1286
|
+
archiveOfMyCheckpoint: Fr.fromString(result[4])
|
|
1287
|
+
};
|
|
501
1288
|
}
|
|
502
1289
|
async canPruneAtTime(timestamp, options) {
|
|
503
1290
|
await checkBlockTag(options?.blockNumber, this.client);
|
|
@@ -505,13 +1292,13 @@ export class RollupContract {
|
|
|
505
1292
|
timestamp
|
|
506
1293
|
], options);
|
|
507
1294
|
}
|
|
508
|
-
archive() {
|
|
509
|
-
return this.rollup.read.archive();
|
|
1295
|
+
async archive() {
|
|
1296
|
+
return Fr.fromString(await this.rollup.read.archive());
|
|
510
1297
|
}
|
|
511
|
-
archiveAt(checkpointNumber) {
|
|
512
|
-
return this.rollup.read.archiveAt([
|
|
1298
|
+
async archiveAt(checkpointNumber) {
|
|
1299
|
+
return Fr.fromString(await this.rollup.read.archiveAt([
|
|
513
1300
|
BigInt(checkpointNumber)
|
|
514
|
-
]);
|
|
1301
|
+
]));
|
|
515
1302
|
}
|
|
516
1303
|
getSequencerRewards(address) {
|
|
517
1304
|
if (address instanceof EthAddress) {
|
|
@@ -530,49 +1317,76 @@ export class RollupContract {
|
|
|
530
1317
|
prover
|
|
531
1318
|
]);
|
|
532
1319
|
}
|
|
533
|
-
async getAttesters() {
|
|
1320
|
+
async getAttesters(timestamp) {
|
|
534
1321
|
const attesterSize = await this.getActiveAttesterCount();
|
|
535
1322
|
const gse = new GSEContract(this.client, await this.getGSE());
|
|
536
|
-
const ts = (await this.client.getBlock()).timestamp;
|
|
1323
|
+
const ts = timestamp ?? (await this.client.getBlock()).timestamp;
|
|
537
1324
|
const indices = Array.from({
|
|
538
|
-
length:
|
|
1325
|
+
length: attesterSize
|
|
539
1326
|
}, (_, i)=>BigInt(i));
|
|
540
1327
|
const chunks = chunk(indices, 1000);
|
|
541
|
-
|
|
1328
|
+
const results = await Promise.all(chunks.map((chunk)=>gse.getAttestersFromIndicesAtTime(this.address, ts, chunk)));
|
|
1329
|
+
return results.flat().map((addr)=>EthAddress.fromString(addr));
|
|
542
1330
|
}
|
|
543
|
-
getAttesterView(address) {
|
|
1331
|
+
async getAttesterView(address) {
|
|
544
1332
|
if (address instanceof EthAddress) {
|
|
545
1333
|
address = address.toString();
|
|
546
1334
|
}
|
|
547
|
-
|
|
1335
|
+
const result = await this.rollup.read.getAttesterView([
|
|
548
1336
|
address
|
|
549
1337
|
]);
|
|
1338
|
+
return {
|
|
1339
|
+
status: result.status,
|
|
1340
|
+
effectiveBalance: result.effectiveBalance,
|
|
1341
|
+
exit: {
|
|
1342
|
+
withdrawalId: result.exit.withdrawalId,
|
|
1343
|
+
amount: result.exit.amount,
|
|
1344
|
+
exitableAt: result.exit.exitableAt,
|
|
1345
|
+
recipientOrWithdrawer: EthAddress.fromString(result.exit.recipientOrWithdrawer),
|
|
1346
|
+
isRecipient: result.exit.isRecipient,
|
|
1347
|
+
exists: result.exit.exists
|
|
1348
|
+
},
|
|
1349
|
+
config: {
|
|
1350
|
+
publicKey: {
|
|
1351
|
+
x: result.config.publicKey.x,
|
|
1352
|
+
y: result.config.publicKey.y
|
|
1353
|
+
},
|
|
1354
|
+
withdrawer: EthAddress.fromString(result.config.withdrawer)
|
|
1355
|
+
}
|
|
1356
|
+
};
|
|
550
1357
|
}
|
|
551
|
-
getStatus(address) {
|
|
1358
|
+
async getStatus(address) {
|
|
552
1359
|
if (address instanceof EthAddress) {
|
|
553
1360
|
address = address.toString();
|
|
554
1361
|
}
|
|
555
|
-
return this.rollup.read.getStatus([
|
|
1362
|
+
return await this.rollup.read.getStatus([
|
|
556
1363
|
address
|
|
557
1364
|
]);
|
|
558
1365
|
}
|
|
559
|
-
getBlobCommitmentsHash(checkpointNumber) {
|
|
560
|
-
return this.rollup.read.getBlobCommitmentsHash([
|
|
1366
|
+
async getBlobCommitmentsHash(checkpointNumber) {
|
|
1367
|
+
return Buffer32.fromString(await this.rollup.read.getBlobCommitmentsHash([
|
|
561
1368
|
BigInt(checkpointNumber)
|
|
562
|
-
]);
|
|
1369
|
+
]));
|
|
563
1370
|
}
|
|
564
|
-
getCurrentBlobCommitmentsHash() {
|
|
565
|
-
return this.rollup.read.getCurrentBlobCommitmentsHash();
|
|
1371
|
+
async getCurrentBlobCommitmentsHash() {
|
|
1372
|
+
return Buffer32.fromString(await this.rollup.read.getCurrentBlobCommitmentsHash());
|
|
566
1373
|
}
|
|
567
|
-
getStakingAsset() {
|
|
568
|
-
return this.rollup.read.getStakingAsset();
|
|
1374
|
+
async getStakingAsset() {
|
|
1375
|
+
return EthAddress.fromString(await this.rollup.read.getStakingAsset());
|
|
569
1376
|
}
|
|
570
|
-
getRewardConfig() {
|
|
571
|
-
|
|
1377
|
+
async getRewardConfig() {
|
|
1378
|
+
const result = await this.rollup.read.getRewardConfig();
|
|
1379
|
+
return {
|
|
1380
|
+
rewardDistributor: EthAddress.fromString(result.rewardDistributor),
|
|
1381
|
+
sequencerBps: BigInt(result.sequencerBps),
|
|
1382
|
+
booster: EthAddress.fromString(result.booster),
|
|
1383
|
+
checkpointReward: result.checkpointReward
|
|
1384
|
+
};
|
|
572
1385
|
}
|
|
573
1386
|
setupEpoch(l1TxUtils) {
|
|
574
1387
|
return l1TxUtils.sendAndMonitorTransaction({
|
|
575
1388
|
to: this.address,
|
|
1389
|
+
abi: RollupAbi,
|
|
576
1390
|
data: encodeFunctionData({
|
|
577
1391
|
abi: RollupAbi,
|
|
578
1392
|
functionName: 'setupEpoch',
|
|
@@ -583,6 +1397,7 @@ export class RollupContract {
|
|
|
583
1397
|
vote(l1TxUtils, proposalId) {
|
|
584
1398
|
return l1TxUtils.sendAndMonitorTransaction({
|
|
585
1399
|
to: this.address,
|
|
1400
|
+
abi: RollupAbi,
|
|
586
1401
|
data: encodeFunctionData({
|
|
587
1402
|
abi: RollupAbi,
|
|
588
1403
|
functionName: 'vote',
|
|
@@ -611,7 +1426,8 @@ export class RollupContract {
|
|
|
611
1426
|
const args = log.args;
|
|
612
1427
|
if (args.checkpointNumber !== undefined) {
|
|
613
1428
|
callback({
|
|
614
|
-
checkpointNumber: CheckpointNumber.fromBigInt(args.checkpointNumber)
|
|
1429
|
+
checkpointNumber: CheckpointNumber.fromBigInt(args.checkpointNumber),
|
|
1430
|
+
event: log
|
|
615
1431
|
});
|
|
616
1432
|
}
|
|
617
1433
|
}
|
|
@@ -642,61 +1458,83 @@ export class RollupContract {
|
|
|
642
1458
|
}
|
|
643
1459
|
});
|
|
644
1460
|
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Fetches OwnershipTransferred events emitted on the L1 block this rollup was deployed on.
|
|
1463
|
+
* The Rollup inherits from Ownable and emits this event in its constructor, so the event
|
|
1464
|
+
* is guaranteed to exist on `l1StartBlock` for any correctly deployed rollup. Used as a
|
|
1465
|
+
* probe to detect RPC nodes that prune historical logs.
|
|
1466
|
+
*/ async getOwnershipTransferredEventsAtDeploy() {
|
|
1467
|
+
const l1StartBlock = await this.getL1StartBlock();
|
|
1468
|
+
return await this.rollup.getEvents.OwnershipTransferred({}, {
|
|
1469
|
+
fromBlock: l1StartBlock,
|
|
1470
|
+
toBlock: l1StartBlock
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
/** Fetches CheckpointProposed events within the given block range. */ async getCheckpointProposedEvents(fromBlock, toBlock) {
|
|
1474
|
+
const logs = await this.rollup.getEvents.CheckpointProposed({}, {
|
|
1475
|
+
fromBlock,
|
|
1476
|
+
toBlock
|
|
1477
|
+
});
|
|
1478
|
+
return logs.filter((log)=>log.blockNumber >= fromBlock && log.blockNumber <= toBlock).map((log)=>({
|
|
1479
|
+
l1BlockNumber: log.blockNumber,
|
|
1480
|
+
l1BlockHash: Buffer32.fromString(log.blockHash),
|
|
1481
|
+
l1TransactionHash: log.transactionHash,
|
|
1482
|
+
args: {
|
|
1483
|
+
checkpointNumber: CheckpointNumber.fromBigInt(log.args.checkpointNumber),
|
|
1484
|
+
archive: Fr.fromString(log.args.archive),
|
|
1485
|
+
versionedBlobHashes: log.args.versionedBlobHashes.map((h)=>Buffer.from(h.slice(2), 'hex')),
|
|
1486
|
+
attestationsHash: (()=>{
|
|
1487
|
+
if (!log.args.attestationsHash) {
|
|
1488
|
+
throw new Error(`CheckpointProposed event missing attestationsHash for checkpoint ${log.args.checkpointNumber}`);
|
|
1489
|
+
}
|
|
1490
|
+
return Buffer32.fromString(log.args.attestationsHash);
|
|
1491
|
+
})(),
|
|
1492
|
+
payloadDigest: (()=>{
|
|
1493
|
+
if (!log.args.payloadDigest) {
|
|
1494
|
+
throw new Error(`CheckpointProposed event missing payloadDigest for checkpoint ${log.args.checkpointNumber}`);
|
|
1495
|
+
}
|
|
1496
|
+
return Buffer32.fromString(log.args.payloadDigest);
|
|
1497
|
+
})()
|
|
1498
|
+
}
|
|
1499
|
+
}));
|
|
1500
|
+
}
|
|
1501
|
+
/** Packs pending and proven checkpoint numbers into the chain tips storage format. */ static packChainTips(pendingCheckpointNumber, provenCheckpointNumber) {
|
|
1502
|
+
return pendingCheckpointNumber << 128n | provenCheckpointNumber & (1n << 128n) - 1n;
|
|
1503
|
+
}
|
|
1504
|
+
/** Storage slot for the chain tips (offset 0 within the STF storage struct). */ static get chainTipsStorageSlot() {
|
|
1505
|
+
return BigInt(RollupContract.stfStorageSlot);
|
|
1506
|
+
}
|
|
1507
|
+
/**
|
|
1508
|
+
* Computes the storage slot for a field within a tempCheckpointLog entry.
|
|
1509
|
+
* @param checkpointNumber - The checkpoint number
|
|
1510
|
+
* @param field - The field within the CompressedTempCheckpointLog struct
|
|
1511
|
+
*/ async getTempCheckpointLogStorageSlot(checkpointNumber, field) {
|
|
1512
|
+
const [epochDuration, proofSubmissionEpochs] = await Promise.all([
|
|
1513
|
+
this.getEpochDuration(),
|
|
1514
|
+
this.getProofSubmissionEpochs()
|
|
1515
|
+
]);
|
|
1516
|
+
return this.computeTempCheckpointLogStorageSlot(checkpointNumber, field, {
|
|
1517
|
+
epochDuration,
|
|
1518
|
+
proofSubmissionEpochs
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
computeTempCheckpointLogStorageSlot(checkpointNumber, field, constants) {
|
|
1522
|
+
const fieldOffset = BigInt(field);
|
|
1523
|
+
const { epochDuration, proofSubmissionEpochs } = constants;
|
|
1524
|
+
const roundaboutSize = BigInt(epochDuration) * (BigInt(proofSubmissionEpochs) + 1n) + 1n;
|
|
1525
|
+
const tempCheckpointLogsBase = BigInt(RollupContract.stfStorageSlot) + 2n;
|
|
1526
|
+
const circularIndex = BigInt(checkpointNumber) % roundaboutSize;
|
|
1527
|
+
const entryBase = BigInt(keccak256(encodeAbiParameters([
|
|
1528
|
+
{
|
|
1529
|
+
type: 'uint256'
|
|
1530
|
+
},
|
|
1531
|
+
{
|
|
1532
|
+
type: 'uint256'
|
|
1533
|
+
}
|
|
1534
|
+
], [
|
|
1535
|
+
circularIndex,
|
|
1536
|
+
tempCheckpointLogsBase
|
|
1537
|
+
])));
|
|
1538
|
+
return entryBase + fieldOffset;
|
|
1539
|
+
}
|
|
645
1540
|
}
|
|
646
|
-
_ts_decorate([
|
|
647
|
-
memoize
|
|
648
|
-
], RollupContract.prototype, "getL1StartBlock", null);
|
|
649
|
-
_ts_decorate([
|
|
650
|
-
memoize
|
|
651
|
-
], RollupContract.prototype, "getL1GenesisTime", null);
|
|
652
|
-
_ts_decorate([
|
|
653
|
-
memoize
|
|
654
|
-
], RollupContract.prototype, "getProofSubmissionEpochs", null);
|
|
655
|
-
_ts_decorate([
|
|
656
|
-
memoize
|
|
657
|
-
], RollupContract.prototype, "getEpochDuration", null);
|
|
658
|
-
_ts_decorate([
|
|
659
|
-
memoize
|
|
660
|
-
], RollupContract.prototype, "getSlotDuration", null);
|
|
661
|
-
_ts_decorate([
|
|
662
|
-
memoize
|
|
663
|
-
], RollupContract.prototype, "getTargetCommitteeSize", null);
|
|
664
|
-
_ts_decorate([
|
|
665
|
-
memoize
|
|
666
|
-
], RollupContract.prototype, "getEjectionThreshold", null);
|
|
667
|
-
_ts_decorate([
|
|
668
|
-
memoize
|
|
669
|
-
], RollupContract.prototype, "getLocalEjectionThreshold", null);
|
|
670
|
-
_ts_decorate([
|
|
671
|
-
memoize
|
|
672
|
-
], RollupContract.prototype, "getLagInEpochsForValidatorSet", null);
|
|
673
|
-
_ts_decorate([
|
|
674
|
-
memoize
|
|
675
|
-
], RollupContract.prototype, "getLagInEpochsForRandao", null);
|
|
676
|
-
_ts_decorate([
|
|
677
|
-
memoize
|
|
678
|
-
], RollupContract.prototype, "getActivationThreshold", null);
|
|
679
|
-
_ts_decorate([
|
|
680
|
-
memoize
|
|
681
|
-
], RollupContract.prototype, "getExitDelay", null);
|
|
682
|
-
_ts_decorate([
|
|
683
|
-
memoize
|
|
684
|
-
], RollupContract.prototype, "getManaTarget", null);
|
|
685
|
-
_ts_decorate([
|
|
686
|
-
memoize
|
|
687
|
-
], RollupContract.prototype, "getProvingCostPerMana", null);
|
|
688
|
-
_ts_decorate([
|
|
689
|
-
memoize
|
|
690
|
-
], RollupContract.prototype, "getProvingCostPerManaInFeeAsset", null);
|
|
691
|
-
_ts_decorate([
|
|
692
|
-
memoize
|
|
693
|
-
], RollupContract.prototype, "getManaLimit", null);
|
|
694
|
-
_ts_decorate([
|
|
695
|
-
memoize
|
|
696
|
-
], RollupContract.prototype, "getVersion", null);
|
|
697
|
-
_ts_decorate([
|
|
698
|
-
memoize
|
|
699
|
-
], RollupContract.prototype, "getGenesisArchiveTreeRoot", null);
|
|
700
|
-
_ts_decorate([
|
|
701
|
-
memoize
|
|
702
|
-
], RollupContract.prototype, "getRollupConstants", null);
|