@aztec/ethereum 0.0.1-commit.5daedc8 → 0.0.1-commit.6201a7b05

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.
Files changed (212) hide show
  1. package/dest/client.d.ts +16 -2
  2. package/dest/client.d.ts.map +1 -1
  3. package/dest/client.js +27 -3
  4. package/dest/config.d.ts +26 -73
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +64 -387
  7. package/dest/contracts/chain_state_override.d.ts +38 -0
  8. package/dest/contracts/chain_state_override.d.ts.map +1 -0
  9. package/dest/contracts/chain_state_override.js +100 -0
  10. package/dest/contracts/empire_base.d.ts +4 -1
  11. package/dest/contracts/empire_base.d.ts.map +1 -1
  12. package/dest/contracts/fee_asset_handler.d.ts +6 -5
  13. package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
  14. package/dest/contracts/fee_asset_handler.js +11 -9
  15. package/dest/contracts/fee_asset_price_oracle.d.ts +101 -0
  16. package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
  17. package/dest/contracts/fee_asset_price_oracle.js +651 -0
  18. package/dest/contracts/governance.d.ts +3 -1
  19. package/dest/contracts/governance.d.ts.map +1 -1
  20. package/dest/contracts/governance.js +14 -4
  21. package/dest/contracts/governance_proposer.d.ts +4 -1
  22. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  23. package/dest/contracts/governance_proposer.js +404 -9
  24. package/dest/contracts/inbox.d.ts +24 -3
  25. package/dest/contracts/inbox.d.ts.map +1 -1
  26. package/dest/contracts/inbox.js +41 -1
  27. package/dest/contracts/index.d.ts +6 -3
  28. package/dest/contracts/index.d.ts.map +1 -1
  29. package/dest/contracts/index.js +5 -2
  30. package/dest/contracts/log.d.ts +13 -0
  31. package/dest/contracts/log.d.ts.map +1 -0
  32. package/dest/contracts/log.js +1 -0
  33. package/dest/contracts/multicall.d.ts +51 -2
  34. package/dest/contracts/multicall.d.ts.map +1 -1
  35. package/dest/contracts/multicall.js +87 -1
  36. package/dest/contracts/outbox.d.ts +41 -0
  37. package/dest/contracts/outbox.d.ts.map +1 -0
  38. package/dest/contracts/outbox.js +86 -0
  39. package/dest/contracts/registry.d.ts +3 -1
  40. package/dest/contracts/registry.d.ts.map +1 -1
  41. package/dest/contracts/registry.js +30 -1
  42. package/dest/contracts/rollup.d.ts +5178 -108
  43. package/dest/contracts/rollup.d.ts.map +1 -1
  44. package/dest/contracts/rollup.js +1004 -188
  45. package/dest/contracts/{tally_slashing_proposer.d.ts → slashing_proposer.d.ts} +5 -5
  46. package/dest/contracts/slashing_proposer.d.ts.map +1 -0
  47. package/dest/contracts/{tally_slashing_proposer.js → slashing_proposer.js} +18 -13
  48. package/dest/deploy_aztec_l1_contracts.d.ts +256 -0
  49. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
  50. package/dest/deploy_aztec_l1_contracts.js +411 -0
  51. package/dest/deploy_l1_contract.d.ts +68 -0
  52. package/dest/deploy_l1_contract.d.ts.map +1 -0
  53. package/dest/deploy_l1_contract.js +312 -0
  54. package/dest/forwarder_proxy.d.ts +32 -0
  55. package/dest/forwarder_proxy.d.ts.map +1 -0
  56. package/dest/forwarder_proxy.js +93 -0
  57. package/dest/generated/l1-contracts-defaults.d.ts +30 -0
  58. package/dest/generated/l1-contracts-defaults.d.ts.map +1 -0
  59. package/dest/generated/l1-contracts-defaults.js +30 -0
  60. package/dest/l1_artifacts.d.ts +14161 -17158
  61. package/dest/l1_artifacts.d.ts.map +1 -1
  62. package/dest/l1_artifacts.js +9 -24
  63. package/dest/l1_contract_addresses.d.ts +1 -5
  64. package/dest/l1_contract_addresses.d.ts.map +1 -1
  65. package/dest/l1_contract_addresses.js +3 -9
  66. package/dest/l1_reader.d.ts +5 -1
  67. package/dest/l1_reader.d.ts.map +1 -1
  68. package/dest/l1_reader.js +13 -2
  69. package/dest/l1_tx_utils/config.d.ts +9 -3
  70. package/dest/l1_tx_utils/config.d.ts.map +1 -1
  71. package/dest/l1_tx_utils/config.js +31 -4
  72. package/dest/l1_tx_utils/constants.d.ts +8 -2
  73. package/dest/l1_tx_utils/constants.d.ts.map +1 -1
  74. package/dest/l1_tx_utils/constants.js +27 -2
  75. package/dest/l1_tx_utils/factory.d.ts +18 -10
  76. package/dest/l1_tx_utils/factory.d.ts.map +1 -1
  77. package/dest/l1_tx_utils/factory.js +17 -7
  78. package/dest/l1_tx_utils/fee-strategies/index.d.ts +10 -0
  79. package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
  80. package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
  81. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -0
  82. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
  83. package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +129 -0
  84. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -0
  85. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
  86. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +191 -0
  87. package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
  88. package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
  89. package/dest/l1_tx_utils/fee-strategies/types.js +3 -0
  90. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +41 -0
  91. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
  92. package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +42 -0
  93. package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
  94. package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
  95. package/dest/l1_tx_utils/index-blobs.js +2 -0
  96. package/dest/l1_tx_utils/index.d.ts +4 -1
  97. package/dest/l1_tx_utils/index.d.ts.map +1 -1
  98. package/dest/l1_tx_utils/index.js +3 -0
  99. package/dest/l1_tx_utils/interfaces.d.ts +2 -2
  100. package/dest/l1_tx_utils/interfaces.d.ts.map +1 -1
  101. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
  102. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
  103. package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
  104. package/dest/l1_tx_utils/l1_tx_utils.d.ts +20 -7
  105. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
  106. package/dest/l1_tx_utils/l1_tx_utils.js +98 -61
  107. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +4 -15
  108. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
  109. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +61 -164
  110. package/dest/l1_tx_utils/tx_delayer.d.ts +56 -0
  111. package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
  112. package/dest/{test → l1_tx_utils}/tx_delayer.js +65 -36
  113. package/dest/publisher_manager.d.ts +21 -6
  114. package/dest/publisher_manager.d.ts.map +1 -1
  115. package/dest/publisher_manager.js +81 -7
  116. package/dest/queries.d.ts +14 -3
  117. package/dest/queries.d.ts.map +1 -1
  118. package/dest/queries.js +74 -7
  119. package/dest/test/chain_monitor.d.ts +36 -14
  120. package/dest/test/chain_monitor.d.ts.map +1 -1
  121. package/dest/test/chain_monitor.js +45 -11
  122. package/dest/test/eth_cheat_codes.d.ts +18 -4
  123. package/dest/test/eth_cheat_codes.d.ts.map +1 -1
  124. package/dest/test/eth_cheat_codes.js +10 -6
  125. package/dest/test/index.d.ts +1 -3
  126. package/dest/test/index.d.ts.map +1 -1
  127. package/dest/test/index.js +0 -2
  128. package/dest/test/rollup_cheat_codes.d.ts +13 -6
  129. package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
  130. package/dest/test/rollup_cheat_codes.js +41 -7
  131. package/dest/test/start_anvil.d.ts +24 -2
  132. package/dest/test/start_anvil.d.ts.map +1 -1
  133. package/dest/test/start_anvil.js +143 -29
  134. package/dest/test/upgrade_utils.js +2 -2
  135. package/dest/types.d.ts +57 -2
  136. package/dest/types.d.ts.map +1 -1
  137. package/dest/utils.d.ts +16 -3
  138. package/dest/utils.d.ts.map +1 -1
  139. package/dest/utils.js +80 -12
  140. package/package.json +33 -16
  141. package/src/client.ts +28 -2
  142. package/src/config.ts +82 -468
  143. package/src/contracts/README.md +157 -0
  144. package/src/contracts/chain_state_override.ts +147 -0
  145. package/src/contracts/empire_base.ts +3 -1
  146. package/src/contracts/fee_asset_handler.ts +10 -7
  147. package/src/contracts/fee_asset_price_oracle.ts +280 -0
  148. package/src/contracts/governance.ts +13 -4
  149. package/src/contracts/governance_proposer.ts +16 -2
  150. package/src/contracts/inbox.ts +63 -3
  151. package/src/contracts/index.ts +5 -2
  152. package/src/contracts/log.ts +13 -0
  153. package/src/contracts/multicall.ts +70 -3
  154. package/src/contracts/outbox.ts +98 -0
  155. package/src/contracts/registry.ts +31 -1
  156. package/src/contracts/rollup.ts +701 -149
  157. package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +18 -14
  158. package/src/deploy_aztec_l1_contracts.ts +646 -0
  159. package/src/deploy_l1_contract.ts +362 -0
  160. package/src/forwarder_proxy.ts +108 -0
  161. package/src/generated/l1-contracts-defaults.ts +32 -0
  162. package/src/l1_artifacts.ts +12 -35
  163. package/src/l1_contract_addresses.ts +21 -26
  164. package/src/l1_reader.ts +22 -2
  165. package/src/l1_tx_utils/config.ts +44 -6
  166. package/src/l1_tx_utils/constants.ts +13 -2
  167. package/src/l1_tx_utils/factory.ts +31 -31
  168. package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
  169. package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +163 -0
  170. package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +245 -0
  171. package/src/l1_tx_utils/fee-strategies/types.ts +56 -0
  172. package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +108 -0
  173. package/src/l1_tx_utils/index-blobs.ts +2 -0
  174. package/src/l1_tx_utils/index.ts +3 -0
  175. package/src/l1_tx_utils/interfaces.ts +1 -1
  176. package/src/l1_tx_utils/l1_fee_analyzer.ts +803 -0
  177. package/src/l1_tx_utils/l1_tx_utils.ts +98 -40
  178. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +75 -210
  179. package/src/{test → l1_tx_utils}/tx_delayer.ts +82 -52
  180. package/src/publisher_manager.ts +107 -10
  181. package/src/queries.ts +81 -7
  182. package/src/test/chain_monitor.ts +82 -18
  183. package/src/test/eth_cheat_codes.ts +8 -6
  184. package/src/test/index.ts +0 -2
  185. package/src/test/rollup_cheat_codes.ts +43 -10
  186. package/src/test/start_anvil.ts +178 -28
  187. package/src/test/upgrade_utils.ts +2 -2
  188. package/src/types.ts +62 -0
  189. package/src/utils.ts +100 -15
  190. package/dest/contracts/empire_slashing_proposer.d.ts +0 -66
  191. package/dest/contracts/empire_slashing_proposer.d.ts.map +0 -1
  192. package/dest/contracts/empire_slashing_proposer.js +0 -200
  193. package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
  194. package/dest/deploy_l1_contracts.d.ts +0 -673
  195. package/dest/deploy_l1_contracts.d.ts.map +0 -1
  196. package/dest/deploy_l1_contracts.js +0 -1491
  197. package/dest/index.d.ts +0 -18
  198. package/dest/index.d.ts.map +0 -1
  199. package/dest/index.js +0 -17
  200. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +0 -26
  201. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +0 -1
  202. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +0 -26
  203. package/dest/test/delayed_tx_utils.d.ts +0 -13
  204. package/dest/test/delayed_tx_utils.d.ts.map +0 -1
  205. package/dest/test/delayed_tx_utils.js +0 -28
  206. package/dest/test/tx_delayer.d.ts +0 -36
  207. package/dest/test/tx_delayer.d.ts.map +0 -1
  208. package/src/contracts/empire_slashing_proposer.ts +0 -265
  209. package/src/deploy_l1_contracts.ts +0 -1869
  210. package/src/index.ts +0 -17
  211. package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
  212. package/src/test/delayed_tx_utils.ts +0 -52
@@ -1,33 +1,529 @@
1
- function _ts_decorate(decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
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
  }
7
- import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
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 { 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';
380
+ import { makeBackoff, retry } from '@aztec/foundation/retry';
381
+ import { EscapeHatchAbi } from '@aztec/l1-artifacts/EscapeHatchAbi';
10
382
  import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
11
383
  import { RollupStorage } from '@aztec/l1-artifacts/RollupStorage';
12
384
  import chunk from 'lodash.chunk';
13
- import { encodeFunctionData, getContract, hexToBigInt, keccak256 } from 'viem';
385
+ import { encodeAbiParameters, encodeFunctionData, getContract, hexToBigInt, keccak256 } from 'viem';
14
386
  import { getPublicClient } from '../client.js';
15
387
  import { formatViemError } from '../utils.js';
16
- import { EmpireSlashingProposerContract } from './empire_slashing_proposer.js';
17
388
  import { GSEContract } from './gse.js';
18
389
  import { SlasherContract } from './slasher_contract.js';
19
- import { TallySlashingProposerContract } from './tally_slashing_proposer.js';
390
+ import { SlashingProposerContract } from './slashing_proposer.js';
20
391
  import { checkBlockTag } from './utils.js';
21
- export var SlashingProposerType = /*#__PURE__*/ function(SlashingProposerType) {
22
- SlashingProposerType[SlashingProposerType["None"] = 0] = "None";
23
- SlashingProposerType[SlashingProposerType["Tally"] = 1] = "Tally";
24
- SlashingProposerType[SlashingProposerType["Empire"] = 2] = "Empire";
25
- return SlashingProposerType;
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;
26
411
  }({});
27
412
  export class RollupContract {
28
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
+ }
29
523
  rollup;
524
+ logger;
30
525
  static cachedStfStorageSlot;
526
+ cachedEscapeHatch;
31
527
  static get checkBlobStorageSlot() {
32
528
  const asString = RollupStorage.find((storage)=>storage.label === 'checkBlob')?.slot;
33
529
  if (asString === undefined) {
@@ -49,6 +545,7 @@ export class RollupContract {
49
545
  }
50
546
  constructor(client, address){
51
547
  this.client = client;
548
+ this.logger = (_initProto(this), createLogger('ethereum:rollup'));
52
549
  if (address instanceof EthAddress) {
53
550
  address = address.toString();
54
551
  }
@@ -58,8 +555,8 @@ export class RollupContract {
58
555
  client
59
556
  });
60
557
  }
61
- getGSE() {
62
- return this.rollup.read.getGSE();
558
+ async getGSE() {
559
+ return EthAddress.fromString(await this.rollup.read.getGSE());
63
560
  }
64
561
  get address() {
65
562
  return this.rollup.address;
@@ -73,34 +570,10 @@ export class RollupContract {
73
570
  return undefined;
74
571
  }
75
572
  const proposerAddress = await slasher.getProposer();
76
- const proposerAbi = [
77
- {
78
- type: 'function',
79
- name: 'SLASHING_PROPOSER_TYPE',
80
- inputs: [],
81
- outputs: [
82
- {
83
- name: '',
84
- type: 'uint8',
85
- internalType: 'enum SlasherFlavor'
86
- }
87
- ],
88
- stateMutability: 'view'
89
- }
90
- ];
91
- const proposer = getContract({
92
- address: proposerAddress.toString(),
93
- abi: proposerAbi,
94
- client: this.client
95
- });
96
- const proposerType = await proposer.read.SLASHING_PROPOSER_TYPE();
97
- if (proposerType === 1..valueOf()) {
98
- return new TallySlashingProposerContract(this.client, proposerAddress);
99
- } else if (proposerType === 2..valueOf()) {
100
- return new EmpireSlashingProposerContract(this.client, proposerAddress);
101
- } else {
102
- throw new Error(`Unknown slashing proposer type: ${proposerType}`);
573
+ if (proposerAddress.isZero()) {
574
+ return undefined;
103
575
  }
576
+ return new SlashingProposerContract(this.client, proposerAddress);
104
577
  }
105
578
  getL1StartBlock() {
106
579
  return this.rollup.read.L1_BLOCK_AT_GENESIS();
@@ -108,17 +581,17 @@ export class RollupContract {
108
581
  getL1GenesisTime() {
109
582
  return this.rollup.read.getGenesisTime();
110
583
  }
111
- getProofSubmissionEpochs() {
112
- return this.rollup.read.getProofSubmissionEpochs();
584
+ async getProofSubmissionEpochs() {
585
+ return Number(await this.rollup.read.getProofSubmissionEpochs());
113
586
  }
114
- getEpochDuration() {
115
- return this.rollup.read.getEpochDuration();
587
+ async getEpochDuration() {
588
+ return Number(await this.rollup.read.getEpochDuration());
116
589
  }
117
590
  async getSlotDuration() {
118
591
  return Number(await this.rollup.read.getSlotDuration());
119
592
  }
120
- getTargetCommitteeSize() {
121
- return this.rollup.read.getTargetCommitteeSize();
593
+ async getTargetCommitteeSize() {
594
+ return Number(await this.rollup.read.getTargetCommitteeSize());
122
595
  }
123
596
  getEjectionThreshold() {
124
597
  return this.rollup.read.getEjectionThreshold();
@@ -126,17 +599,17 @@ export class RollupContract {
126
599
  getLocalEjectionThreshold() {
127
600
  return this.rollup.read.getLocalEjectionThreshold();
128
601
  }
129
- getLagInEpochsForValidatorSet() {
130
- return this.rollup.read.getLagInEpochsForValidatorSet();
602
+ async getLagInEpochsForValidatorSet() {
603
+ return Number(await this.rollup.read.getLagInEpochsForValidatorSet());
131
604
  }
132
- getLagInEpochsForRandao() {
133
- return this.rollup.read.getLagInEpochsForRandao();
605
+ async getLagInEpochsForRandao() {
606
+ return Number(await this.rollup.read.getLagInEpochsForRandao());
134
607
  }
135
608
  getActivationThreshold() {
136
609
  return this.rollup.read.getActivationThreshold();
137
610
  }
138
- getExitDelay() {
139
- return this.rollup.read.getExitDelay();
611
+ async getExitDelay() {
612
+ return Number(await this.rollup.read.getExitDelay());
140
613
  }
141
614
  getManaTarget() {
142
615
  return this.rollup.read.getManaTarget();
@@ -154,47 +627,115 @@ export class RollupContract {
154
627
  return this.rollup.read.getVersion();
155
628
  }
156
629
  async getGenesisArchiveTreeRoot() {
157
- return await this.rollup.read.archiveAt([
630
+ return Fr.fromString(await this.rollup.read.archiveAt([
158
631
  0n
159
- ]);
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');
160
649
  }
161
650
  /**
162
651
  * Returns rollup constants used for epoch queries.
163
652
  * Return type is `L1RollupConstants` which is defined in stdlib,
164
653
  * so we cant reference it until we move this contract to that package.
165
654
  */ async getRollupConstants() {
166
- const [l1StartBlock, l1GenesisTime, slotDuration, epochDuration, proofSubmissionEpochs] = await Promise.all([
655
+ const [l1StartBlock, l1GenesisTime, slotDuration, epochDuration, proofSubmissionEpochs, targetCommitteeSize, rollupManaLimit] = await Promise.all([
167
656
  this.getL1StartBlock(),
168
657
  this.getL1GenesisTime(),
169
658
  this.getSlotDuration(),
170
659
  this.getEpochDuration(),
171
- this.getProofSubmissionEpochs()
660
+ this.getProofSubmissionEpochs(),
661
+ this.getTargetCommitteeSize(),
662
+ this.getManaLimit()
172
663
  ]);
173
664
  return {
174
665
  l1StartBlock,
175
666
  l1GenesisTime,
176
667
  slotDuration,
177
668
  epochDuration: Number(epochDuration),
178
- proofSubmissionEpochs: Number(proofSubmissionEpochs)
669
+ proofSubmissionEpochs: Number(proofSubmissionEpochs),
670
+ targetCommitteeSize,
671
+ rollupManaLimit: Number(rollupManaLimit)
179
672
  };
180
673
  }
181
- getSlasherAddress() {
182
- 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
+ }
183
724
  }
184
725
  /**
185
726
  * Returns a SlasherContract instance for interacting with the slasher contract.
186
727
  */ async getSlasherContract() {
187
- const slasherAddress = EthAddress.fromString(await this.getSlasherAddress());
728
+ const slasherAddress = await this.getSlasherAddress();
188
729
  if (slasherAddress.isZero()) {
189
730
  return undefined;
190
731
  }
191
732
  return new SlasherContract(this.client, slasherAddress);
192
733
  }
193
- getOwner() {
194
- return this.rollup.read.owner();
734
+ async getOwner() {
735
+ return EthAddress.fromString(await this.rollup.read.owner());
195
736
  }
196
- getActiveAttesterCount() {
197
- return this.rollup.read.getActiveAttesterCount();
737
+ async getActiveAttesterCount() {
738
+ return Number(await this.rollup.read.getActiveAttesterCount());
198
739
  }
199
740
  async getSlashingProposerAddress() {
200
741
  const slasher = await this.getSlasherContract();
@@ -206,22 +747,42 @@ export class RollupContract {
206
747
  getCheckpointReward() {
207
748
  return this.rollup.read.getCheckpointReward();
208
749
  }
209
- getCheckpointNumber() {
210
- return this.rollup.read.getPendingCheckpointNumber();
750
+ async getCheckpointNumber(options) {
751
+ await checkBlockTag(options?.blockNumber, this.client);
752
+ return CheckpointNumber.fromBigInt(await this.rollup.read.getPendingCheckpointNumber(options));
211
753
  }
212
- getProvenCheckpointNumber() {
213
- return this.rollup.read.getProvenCheckpointNumber();
754
+ async getProvenCheckpointNumber(options) {
755
+ await checkBlockTag(options?.blockNumber, this.client);
756
+ return CheckpointNumber.fromBigInt(await this.rollup.read.getProvenCheckpointNumber(options));
214
757
  }
215
- async getSlotNumber() {
216
- return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
758
+ async getSlotNumber(options) {
759
+ await checkBlockTag(options?.blockNumber, this.client);
760
+ return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot(options));
217
761
  }
218
- getL1FeesAt(timestamp) {
219
- return this.rollup.read.getL1FeesAt([
762
+ async getL1FeesAt(timestamp, options) {
763
+ await checkBlockTag(options?.blockNumber, this.client);
764
+ const result = await this.rollup.read.getL1FeesAt([
220
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
221
775
  ]);
776
+ return {
777
+ excessMana: result.excessMana,
778
+ manaUsed: result.manaUsed,
779
+ ethPerFeeAsset: result.ethPerFeeAsset,
780
+ congestionCost: result.congestionCost,
781
+ proverCost: result.proverCost
782
+ };
222
783
  }
223
- getFeeAssetPerEth() {
224
- return this.rollup.read.getFeeAssetPerEth();
784
+ getEthPerFeeAsset() {
785
+ return this.rollup.read.getEthPerFeeAsset();
225
786
  }
226
787
  async getCommitteeAt(timestamp) {
227
788
  const { result } = await this.client.simulateContract({
@@ -239,15 +800,15 @@ export class RollupContract {
239
800
  }
240
801
  throw e;
241
802
  });
242
- return result;
803
+ return result ? result.map((addr)=>EthAddress.fromString(addr)) : undefined;
243
804
  }
244
- getSampleSeedAt(timestamp) {
245
- return this.rollup.read.getSampleSeedAt([
805
+ async getSampleSeedAt(timestamp) {
806
+ return Buffer32.fromBigInt(await this.rollup.read.getSampleSeedAt([
246
807
  timestamp
247
- ]);
808
+ ]));
248
809
  }
249
- getCurrentSampleSeed() {
250
- return this.rollup.read.getCurrentSampleSeed();
810
+ async getCurrentSampleSeed() {
811
+ return Buffer32.fromBigInt(await this.rollup.read.getCurrentSampleSeed());
251
812
  }
252
813
  async getCurrentEpoch() {
253
814
  return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
@@ -266,7 +827,7 @@ export class RollupContract {
266
827
  }
267
828
  throw e;
268
829
  });
269
- return result;
830
+ return result ? result.map((addr)=>EthAddress.fromString(addr)) : undefined;
270
831
  }
271
832
  async getCurrentProposer() {
272
833
  const { result } = await this.client.simulateContract({
@@ -275,7 +836,7 @@ export class RollupContract {
275
836
  functionName: 'getCurrentProposer',
276
837
  args: []
277
838
  });
278
- return result;
839
+ return EthAddress.fromString(result);
279
840
  }
280
841
  async getProposerAt(timestamp) {
281
842
  const { result } = await this.client.simulateContract({
@@ -286,26 +847,81 @@ export class RollupContract {
286
847
  timestamp
287
848
  ]
288
849
  });
289
- return result;
850
+ return EthAddress.fromString(result);
290
851
  }
291
- getCheckpoint(checkpointNumber) {
292
- return this.rollup.read.getCheckpoint([
852
+ async getCheckpoint(checkpointNumber, options) {
853
+ await checkBlockTag(options?.blockNumber, this.client);
854
+ const result = await this.rollup.read.getCheckpoint([
293
855
  BigInt(checkpointNumber)
294
- ]);
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
+ };
295
872
  }
296
- getTips() {
297
- return this.rollup.read.getTips();
873
+ /** Returns the pending checkpoint from the rollup contract */ getPendingCheckpoint() {
874
+ // We retry because of race conditions during prunes: we may get a pending checkpoint number which is immediately
875
+ // reorged out due to a prune happening, causing the subsequent getCheckpoint call to fail. So we try again in that case.
876
+ return retry(async ()=>{
877
+ const pendingCheckpointNumber = await this.getCheckpointNumber();
878
+ const pendingCheckpoint = await this.getCheckpoint(pendingCheckpointNumber);
879
+ return pendingCheckpoint;
880
+ }, 'getting pending checkpoint', makeBackoff([
881
+ 0.5,
882
+ 0.5,
883
+ 0.5
884
+ ]));
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
+ }
908
+ async getTips() {
909
+ const { pending, proven } = await this.rollup.read.getTips();
910
+ return {
911
+ pending: CheckpointNumber.fromBigInt(pending),
912
+ proven: CheckpointNumber.fromBigInt(proven)
913
+ };
298
914
  }
299
915
  getTimestampForSlot(slot) {
300
916
  return this.rollup.read.getTimestampForSlot([
301
917
  BigInt(slot)
302
918
  ]);
303
919
  }
304
- getEntryQueueLength() {
305
- return this.rollup.read.getEntryQueueLength();
920
+ async getEntryQueueLength() {
921
+ return Number(await this.rollup.read.getEntryQueueLength());
306
922
  }
307
- getAvailableValidatorFlushes() {
308
- return this.rollup.read.getAvailableValidatorFlushes();
923
+ async getAvailableValidatorFlushes() {
924
+ return Number(await this.rollup.read.getAvailableValidatorFlushes());
309
925
  }
310
926
  async getNextFlushableEpoch() {
311
927
  return EpochNumber.fromBigInt(await this.rollup.read.getNextFlushableEpoch());
@@ -347,8 +963,9 @@ export class RollupContract {
347
963
  BigInt(slotNumber)
348
964
  ]));
349
965
  }
350
- getEpochProofPublicInputs(args) {
351
- return this.rollup.read.getEpochProofPublicInputs(args);
966
+ async getEpochProofPublicInputs(args) {
967
+ const result = await this.rollup.read.getEpochProofPublicInputs(args);
968
+ return result.map(Fr.fromString);
352
969
  }
353
970
  async validateHeader(args, account) {
354
971
  try {
@@ -372,9 +989,8 @@ export class RollupContract {
372
989
  * @return [slot, checkpointNumber, timeOfNextL1Slot] - If you can propose, the L2 slot number, checkpoint number and
373
990
  * timestamp of the next L1 block
374
991
  * @throws otherwise
375
- */ async canProposeAtNextEthBlock(archive, account, slotDuration, opts = {}) {
376
- const latestBlock = await this.client.getBlock();
377
- const timeOfNextL1Slot = latestBlock.timestamp + BigInt(slotDuration);
992
+ */ async canProposeAt(archive, account, timestamp, stateOverride = []) {
993
+ const timeOfNextL1Slot = timestamp;
378
994
  const who = typeof account === 'string' ? account : account.address;
379
995
  try {
380
996
  const { result: [slot, checkpointNumber] } = await this.client.simulateContract({
@@ -387,11 +1003,11 @@ export class RollupContract {
387
1003
  who
388
1004
  ],
389
1005
  account,
390
- stateOverride: await this.makePendingCheckpointNumberOverride(opts.forcePendingCheckpointNumber)
1006
+ stateOverride
391
1007
  });
392
1008
  return {
393
1009
  slot: SlotNumber.fromBigInt(slot),
394
- checkpointNumber,
1010
+ checkpointNumber: CheckpointNumber.fromBigInt(checkpointNumber),
395
1011
  timeOfNextL1Slot
396
1012
  };
397
1013
  } catch (err) {
@@ -425,9 +1041,143 @@ export class RollupContract {
425
1041
  }
426
1042
  ];
427
1043
  }
1044
+ /**
1045
+ * Returns a state override that sets tempCheckpointLogs[checkpointNumber].feeHeader to the compressed fee header.
1046
+ * Used when simulating a propose call where the parent checkpoint hasn't landed on L1 yet (pipelining).
1047
+ */ async makeFeeHeaderOverride(checkpointNumber, feeHeader) {
1048
+ const { epochDuration, proofSubmissionEpochs } = await this.getRollupConstants();
1049
+ const roundaboutSize = BigInt(epochDuration * (proofSubmissionEpochs + 1) + 1);
1050
+ const circularIndex = BigInt(checkpointNumber) % roundaboutSize;
1051
+ // tempCheckpointLogs is at offset 2 in RollupStore
1052
+ const tempCheckpointLogsMappingBase = hexToBigInt(RollupContract.stfStorageSlot) + 2n;
1053
+ // Solidity mapping slot: keccak256(abi.encode(key, baseSlot))
1054
+ const structBaseSlot = hexToBigInt(keccak256(encodeAbiParameters([
1055
+ {
1056
+ type: 'uint256'
1057
+ },
1058
+ {
1059
+ type: 'uint256'
1060
+ }
1061
+ ], [
1062
+ circularIndex,
1063
+ tempCheckpointLogsMappingBase
1064
+ ])));
1065
+ // feeHeader is the 7th field (offset 6) in CompressedTempCheckpointLog
1066
+ const feeHeaderSlot = structBaseSlot + 6n;
1067
+ const compressed = RollupContract.compressFeeHeader(feeHeader);
1068
+ return [
1069
+ {
1070
+ address: this.address,
1071
+ stateDiff: [
1072
+ {
1073
+ slot: `0x${feeHeaderSlot.toString(16).padStart(64, '0')}`,
1074
+ value: `0x${compressed.toString(16).padStart(64, '0')}`
1075
+ }
1076
+ ]
1077
+ }
1078
+ ];
1079
+ }
1080
+ /**
1081
+ * Returns a state override that sets archives[checkpointNumber] to the given archive value.
1082
+ * Used when simulating a canProposeAtTime call where the local archive differs from L1
1083
+ * (e.g. pipelining where the parent checkpoint hasn't landed on L1 yet).
1084
+ */ makeArchiveOverride(checkpointNumber, archive) {
1085
+ const archivesMappingBase = hexToBigInt(RollupContract.stfStorageSlot) + 1n;
1086
+ const archiveSlot = hexToBigInt(keccak256(encodeAbiParameters([
1087
+ {
1088
+ type: 'uint256'
1089
+ },
1090
+ {
1091
+ type: 'uint256'
1092
+ }
1093
+ ], [
1094
+ BigInt(checkpointNumber),
1095
+ archivesMappingBase
1096
+ ])));
1097
+ return [
1098
+ {
1099
+ address: this.address,
1100
+ stateDiff: [
1101
+ {
1102
+ slot: `0x${archiveSlot.toString(16).padStart(64, '0')}`,
1103
+ value: archive.toString()
1104
+ }
1105
+ ]
1106
+ }
1107
+ ];
1108
+ }
1109
+ /** Merges multiple StateOverride arrays, combining stateDiff entries for the same address. */ static mergeStateOverrides(...overrides) {
1110
+ const byAddress = new Map();
1111
+ for (const override of overrides){
1112
+ for (const entry of override){
1113
+ const key = entry.address.toLowerCase();
1114
+ const existing = byAddress.get(key);
1115
+ if (existing) {
1116
+ existing.stateDiff.push(...entry.stateDiff ?? []);
1117
+ if (entry.balance !== undefined) {
1118
+ existing.balance = entry.balance;
1119
+ }
1120
+ } else {
1121
+ byAddress.set(key, {
1122
+ address: entry.address,
1123
+ balance: entry.balance,
1124
+ stateDiff: [
1125
+ ...entry.stateDiff ?? []
1126
+ ]
1127
+ });
1128
+ }
1129
+ }
1130
+ }
1131
+ return [
1132
+ ...byAddress.values()
1133
+ ];
1134
+ }
1135
+ /** Compresses a FeeHeader into a uint256 matching FeeHeaderLib.compress() in FeeStructs.sol. */ static compressFeeHeader(feeHeader) {
1136
+ const MASK_48_BITS = (1n << 48n) - 1n;
1137
+ const MASK_64_BITS = (1n << 64n) - 1n;
1138
+ const MASK_63_BITS = (1n << 63n) - 1n;
1139
+ let value = BigInt(feeHeader.manaUsed) & (1n << 32n) - 1n; // bits [0:31]
1140
+ value |= (feeHeader.excessMana < MASK_48_BITS ? feeHeader.excessMana : MASK_48_BITS) << 32n; // bits [32:79]
1141
+ value |= (BigInt(feeHeader.ethPerFeeAsset) & MASK_48_BITS) << 80n; // bits [80:127]
1142
+ value |= (feeHeader.congestionCost < MASK_64_BITS ? feeHeader.congestionCost : MASK_64_BITS) << 128n; // bits [128:191]
1143
+ value |= (feeHeader.proverCost < MASK_63_BITS ? feeHeader.proverCost : MASK_63_BITS) << 192n; // bits [192:254]
1144
+ value |= 1n << 255n; // preheat flag
1145
+ return value;
1146
+ }
1147
+ /** Computes the fee header for a child checkpoint given parent fee header and child data.
1148
+ * Must stay in sync with Solidity FeeLib.sol (computeNewEthPerFeeAsset, clampedAdd). */ static computeChildFeeHeader(parentFeeHeader, childManaUsed, feeAssetPriceModifier, manaTarget) {
1149
+ const MIN_ETH_PER_FEE_ASSET = 100n;
1150
+ const MAX_ETH_PER_FEE_ASSET = 100_000_000_000_000n; // 1e14, matches FeeLib.sol
1151
+ // excessMana = clampedAdd(parent.excessMana + parent.manaUsed, -manaTarget)
1152
+ const sum = parentFeeHeader.excessMana + parentFeeHeader.manaUsed;
1153
+ const excessMana = sum > manaTarget ? sum - manaTarget : 0n;
1154
+ // ethPerFeeAsset = computeNewEthPerFeeAsset(max(parent.ethPerFeeAsset, MIN), modifier)
1155
+ const parentPrice = parentFeeHeader.ethPerFeeAsset > MIN_ETH_PER_FEE_ASSET ? parentFeeHeader.ethPerFeeAsset : MIN_ETH_PER_FEE_ASSET;
1156
+ let newPrice;
1157
+ if (feeAssetPriceModifier >= 0n) {
1158
+ newPrice = parentPrice * (10_000n + feeAssetPriceModifier) / 10_000n;
1159
+ } else {
1160
+ const absMod = -feeAssetPriceModifier;
1161
+ newPrice = parentPrice * (10_000n - absMod) / 10_000n;
1162
+ }
1163
+ if (newPrice < MIN_ETH_PER_FEE_ASSET) {
1164
+ newPrice = MIN_ETH_PER_FEE_ASSET;
1165
+ }
1166
+ if (newPrice > MAX_ETH_PER_FEE_ASSET) {
1167
+ newPrice = MAX_ETH_PER_FEE_ASSET;
1168
+ }
1169
+ return {
1170
+ excessMana,
1171
+ manaUsed: childManaUsed,
1172
+ ethPerFeeAsset: newPrice,
1173
+ congestionCost: 0n,
1174
+ proverCost: 0n
1175
+ };
1176
+ }
428
1177
  /** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */ buildInvalidateBadAttestationRequest(checkpointNumber, attestationsAndSigners, committee, invalidIndex) {
429
1178
  return {
430
1179
  to: this.address,
1180
+ abi: RollupAbi,
431
1181
  data: encodeFunctionData({
432
1182
  abi: RollupAbi,
433
1183
  functionName: 'invalidateBadAttestation',
@@ -443,6 +1193,7 @@ export class RollupContract {
443
1193
  /** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */ buildInvalidateInsufficientAttestationsRequest(checkpointNumber, attestationsAndSigners, committee) {
444
1194
  return {
445
1195
  to: this.address,
1196
+ abi: RollupAbi,
446
1197
  data: encodeFunctionData({
447
1198
  abi: RollupAbi,
448
1199
  functionName: 'invalidateInsufficientAttestations',
@@ -464,11 +1215,25 @@ export class RollupContract {
464
1215
  prover
465
1216
  ]);
466
1217
  }
467
- getManaBaseFeeAt(timestamp, inFeeAsset) {
468
- return this.rollup.read.getManaBaseFeeAt([
1218
+ getManaMinFeeAt(timestamp, inFeeAsset, stateOverride) {
1219
+ return this.rollup.read.getManaMinFeeAt([
1220
+ timestamp,
1221
+ inFeeAsset
1222
+ ], {
1223
+ stateOverride
1224
+ });
1225
+ }
1226
+ async getManaMinFeeComponentsAt(timestamp, inFeeAsset) {
1227
+ const result = await this.rollup.read.getManaMinFeeComponentsAt([
469
1228
  timestamp,
470
1229
  inFeeAsset
471
1230
  ]);
1231
+ return {
1232
+ sequencerCost: result.sequencerCost,
1233
+ proverCost: result.proverCost,
1234
+ congestionCost: result.congestionCost,
1235
+ congestionMultiplier: result.congestionMultiplier
1236
+ };
472
1237
  }
473
1238
  async getSlotAt(timestamp) {
474
1239
  return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([
@@ -477,9 +1242,16 @@ export class RollupContract {
477
1242
  }
478
1243
  async status(checkpointNumber, options) {
479
1244
  await checkBlockTag(options?.blockNumber, this.client);
480
- return this.rollup.read.status([
481
- checkpointNumber
1245
+ const result = await this.rollup.read.status([
1246
+ BigInt(checkpointNumber)
482
1247
  ], options);
1248
+ return {
1249
+ provenCheckpointNumber: CheckpointNumber.fromBigInt(result[0]),
1250
+ provenArchive: Fr.fromString(result[1]),
1251
+ pendingCheckpointNumber: CheckpointNumber.fromBigInt(result[2]),
1252
+ pendingArchive: Fr.fromString(result[3]),
1253
+ archiveOfMyCheckpoint: Fr.fromString(result[4])
1254
+ };
483
1255
  }
484
1256
  async canPruneAtTime(timestamp, options) {
485
1257
  await checkBlockTag(options?.blockNumber, this.client);
@@ -487,13 +1259,13 @@ export class RollupContract {
487
1259
  timestamp
488
1260
  ], options);
489
1261
  }
490
- archive() {
491
- return this.rollup.read.archive();
1262
+ async archive() {
1263
+ return Fr.fromString(await this.rollup.read.archive());
492
1264
  }
493
- archiveAt(checkpointNumber) {
494
- return this.rollup.read.archiveAt([
495
- checkpointNumber
496
- ]);
1265
+ async archiveAt(checkpointNumber) {
1266
+ return Fr.fromString(await this.rollup.read.archiveAt([
1267
+ BigInt(checkpointNumber)
1268
+ ]));
497
1269
  }
498
1270
  getSequencerRewards(address) {
499
1271
  if (address instanceof EthAddress) {
@@ -512,49 +1284,76 @@ export class RollupContract {
512
1284
  prover
513
1285
  ]);
514
1286
  }
515
- async getAttesters() {
1287
+ async getAttesters(timestamp) {
516
1288
  const attesterSize = await this.getActiveAttesterCount();
517
1289
  const gse = new GSEContract(this.client, await this.getGSE());
518
- const ts = (await this.client.getBlock()).timestamp;
1290
+ const ts = timestamp ?? (await this.client.getBlock()).timestamp;
519
1291
  const indices = Array.from({
520
- length: Number(attesterSize)
1292
+ length: attesterSize
521
1293
  }, (_, i)=>BigInt(i));
522
1294
  const chunks = chunk(indices, 1000);
523
- return (await Promise.all(chunks.map((chunk)=>gse.getAttestersFromIndicesAtTime(this.address, ts, chunk)))).flat();
1295
+ const results = await Promise.all(chunks.map((chunk)=>gse.getAttestersFromIndicesAtTime(this.address, ts, chunk)));
1296
+ return results.flat().map((addr)=>EthAddress.fromString(addr));
524
1297
  }
525
- getAttesterView(address) {
1298
+ async getAttesterView(address) {
526
1299
  if (address instanceof EthAddress) {
527
1300
  address = address.toString();
528
1301
  }
529
- return this.rollup.read.getAttesterView([
1302
+ const result = await this.rollup.read.getAttesterView([
530
1303
  address
531
1304
  ]);
1305
+ return {
1306
+ status: result.status,
1307
+ effectiveBalance: result.effectiveBalance,
1308
+ exit: {
1309
+ withdrawalId: result.exit.withdrawalId,
1310
+ amount: result.exit.amount,
1311
+ exitableAt: result.exit.exitableAt,
1312
+ recipientOrWithdrawer: EthAddress.fromString(result.exit.recipientOrWithdrawer),
1313
+ isRecipient: result.exit.isRecipient,
1314
+ exists: result.exit.exists
1315
+ },
1316
+ config: {
1317
+ publicKey: {
1318
+ x: result.config.publicKey.x,
1319
+ y: result.config.publicKey.y
1320
+ },
1321
+ withdrawer: EthAddress.fromString(result.config.withdrawer)
1322
+ }
1323
+ };
532
1324
  }
533
- getStatus(address) {
1325
+ async getStatus(address) {
534
1326
  if (address instanceof EthAddress) {
535
1327
  address = address.toString();
536
1328
  }
537
- return this.rollup.read.getStatus([
1329
+ return await this.rollup.read.getStatus([
538
1330
  address
539
1331
  ]);
540
1332
  }
541
- getBlobCommitmentsHash(checkpointNumber) {
542
- return this.rollup.read.getBlobCommitmentsHash([
543
- checkpointNumber
544
- ]);
1333
+ async getBlobCommitmentsHash(checkpointNumber) {
1334
+ return Buffer32.fromString(await this.rollup.read.getBlobCommitmentsHash([
1335
+ BigInt(checkpointNumber)
1336
+ ]));
545
1337
  }
546
- getCurrentBlobCommitmentsHash() {
547
- return this.rollup.read.getCurrentBlobCommitmentsHash();
1338
+ async getCurrentBlobCommitmentsHash() {
1339
+ return Buffer32.fromString(await this.rollup.read.getCurrentBlobCommitmentsHash());
548
1340
  }
549
- getStakingAsset() {
550
- return this.rollup.read.getStakingAsset();
1341
+ async getStakingAsset() {
1342
+ return EthAddress.fromString(await this.rollup.read.getStakingAsset());
551
1343
  }
552
- getRewardConfig() {
553
- return this.rollup.read.getRewardConfig();
1344
+ async getRewardConfig() {
1345
+ const result = await this.rollup.read.getRewardConfig();
1346
+ return {
1347
+ rewardDistributor: EthAddress.fromString(result.rewardDistributor),
1348
+ sequencerBps: BigInt(result.sequencerBps),
1349
+ booster: EthAddress.fromString(result.booster),
1350
+ checkpointReward: result.checkpointReward
1351
+ };
554
1352
  }
555
1353
  setupEpoch(l1TxUtils) {
556
1354
  return l1TxUtils.sendAndMonitorTransaction({
557
1355
  to: this.address,
1356
+ abi: RollupAbi,
558
1357
  data: encodeFunctionData({
559
1358
  abi: RollupAbi,
560
1359
  functionName: 'setupEpoch',
@@ -565,6 +1364,7 @@ export class RollupContract {
565
1364
  vote(l1TxUtils, proposalId) {
566
1365
  return l1TxUtils.sendAndMonitorTransaction({
567
1366
  to: this.address,
1367
+ abi: RollupAbi,
568
1368
  data: encodeFunctionData({
569
1369
  abi: RollupAbi,
570
1370
  functionName: 'vote',
@@ -593,7 +1393,8 @@ export class RollupContract {
593
1393
  const args = log.args;
594
1394
  if (args.checkpointNumber !== undefined) {
595
1395
  callback({
596
- checkpointNumber: args.checkpointNumber
1396
+ checkpointNumber: CheckpointNumber.fromBigInt(args.checkpointNumber),
1397
+ event: log
597
1398
  });
598
1399
  }
599
1400
  }
@@ -624,61 +1425,76 @@ export class RollupContract {
624
1425
  }
625
1426
  });
626
1427
  }
1428
+ /**
1429
+ * Fetches OwnershipTransferred events emitted on the L1 block this rollup was deployed on.
1430
+ * The Rollup inherits from Ownable and emits this event in its constructor, so the event
1431
+ * is guaranteed to exist on `l1StartBlock` for any correctly deployed rollup. Used as a
1432
+ * probe to detect RPC nodes that prune historical logs.
1433
+ */ async getOwnershipTransferredEventsAtDeploy() {
1434
+ const l1StartBlock = await this.getL1StartBlock();
1435
+ return await this.rollup.getEvents.OwnershipTransferred({}, {
1436
+ fromBlock: l1StartBlock,
1437
+ toBlock: l1StartBlock
1438
+ });
1439
+ }
1440
+ /** Fetches CheckpointProposed events within the given block range. */ async getCheckpointProposedEvents(fromBlock, toBlock) {
1441
+ const logs = await this.rollup.getEvents.CheckpointProposed({}, {
1442
+ fromBlock,
1443
+ toBlock
1444
+ });
1445
+ return logs.filter((log)=>log.blockNumber >= fromBlock && log.blockNumber <= toBlock).map((log)=>({
1446
+ l1BlockNumber: log.blockNumber,
1447
+ l1BlockHash: Buffer32.fromString(log.blockHash),
1448
+ l1TransactionHash: log.transactionHash,
1449
+ args: {
1450
+ checkpointNumber: CheckpointNumber.fromBigInt(log.args.checkpointNumber),
1451
+ archive: Fr.fromString(log.args.archive),
1452
+ versionedBlobHashes: log.args.versionedBlobHashes.map((h)=>Buffer.from(h.slice(2), 'hex')),
1453
+ attestationsHash: (()=>{
1454
+ if (!log.args.attestationsHash) {
1455
+ throw new Error(`CheckpointProposed event missing attestationsHash for checkpoint ${log.args.checkpointNumber}`);
1456
+ }
1457
+ return Buffer32.fromString(log.args.attestationsHash);
1458
+ })(),
1459
+ payloadDigest: (()=>{
1460
+ if (!log.args.payloadDigest) {
1461
+ throw new Error(`CheckpointProposed event missing payloadDigest for checkpoint ${log.args.checkpointNumber}`);
1462
+ }
1463
+ return Buffer32.fromString(log.args.payloadDigest);
1464
+ })()
1465
+ }
1466
+ }));
1467
+ }
1468
+ /** Packs pending and proven checkpoint numbers into the chain tips storage format. */ static packChainTips(pendingCheckpointNumber, provenCheckpointNumber) {
1469
+ return pendingCheckpointNumber << 128n | provenCheckpointNumber & (1n << 128n) - 1n;
1470
+ }
1471
+ /** Storage slot for the chain tips (offset 0 within the STF storage struct). */ static get chainTipsStorageSlot() {
1472
+ return BigInt(RollupContract.stfStorageSlot);
1473
+ }
1474
+ /**
1475
+ * Computes the storage slot for a field within a tempCheckpointLog entry.
1476
+ * @param checkpointNumber - The checkpoint number
1477
+ * @param field - The field within the CompressedTempCheckpointLog struct
1478
+ */ async getTempCheckpointLogStorageSlot(checkpointNumber, field) {
1479
+ const fieldOffset = BigInt(field);
1480
+ const [epochDuration, proofSubmissionEpochs] = await Promise.all([
1481
+ this.getEpochDuration(),
1482
+ this.getProofSubmissionEpochs()
1483
+ ]);
1484
+ const roundaboutSize = BigInt(epochDuration) * (BigInt(proofSubmissionEpochs) + 1n) + 1n;
1485
+ const tempCheckpointLogsBase = BigInt(RollupContract.stfStorageSlot) + 2n;
1486
+ const circularIndex = BigInt(checkpointNumber) % roundaboutSize;
1487
+ const entryBase = BigInt(keccak256(encodeAbiParameters([
1488
+ {
1489
+ type: 'uint256'
1490
+ },
1491
+ {
1492
+ type: 'uint256'
1493
+ }
1494
+ ], [
1495
+ circularIndex,
1496
+ tempCheckpointLogsBase
1497
+ ])));
1498
+ return entryBase + fieldOffset;
1499
+ }
627
1500
  }
628
- _ts_decorate([
629
- memoize
630
- ], RollupContract.prototype, "getL1StartBlock", null);
631
- _ts_decorate([
632
- memoize
633
- ], RollupContract.prototype, "getL1GenesisTime", null);
634
- _ts_decorate([
635
- memoize
636
- ], RollupContract.prototype, "getProofSubmissionEpochs", null);
637
- _ts_decorate([
638
- memoize
639
- ], RollupContract.prototype, "getEpochDuration", null);
640
- _ts_decorate([
641
- memoize
642
- ], RollupContract.prototype, "getSlotDuration", null);
643
- _ts_decorate([
644
- memoize
645
- ], RollupContract.prototype, "getTargetCommitteeSize", null);
646
- _ts_decorate([
647
- memoize
648
- ], RollupContract.prototype, "getEjectionThreshold", null);
649
- _ts_decorate([
650
- memoize
651
- ], RollupContract.prototype, "getLocalEjectionThreshold", null);
652
- _ts_decorate([
653
- memoize
654
- ], RollupContract.prototype, "getLagInEpochsForValidatorSet", null);
655
- _ts_decorate([
656
- memoize
657
- ], RollupContract.prototype, "getLagInEpochsForRandao", null);
658
- _ts_decorate([
659
- memoize
660
- ], RollupContract.prototype, "getActivationThreshold", null);
661
- _ts_decorate([
662
- memoize
663
- ], RollupContract.prototype, "getExitDelay", null);
664
- _ts_decorate([
665
- memoize
666
- ], RollupContract.prototype, "getManaTarget", null);
667
- _ts_decorate([
668
- memoize
669
- ], RollupContract.prototype, "getProvingCostPerMana", null);
670
- _ts_decorate([
671
- memoize
672
- ], RollupContract.prototype, "getProvingCostPerManaInFeeAsset", null);
673
- _ts_decorate([
674
- memoize
675
- ], RollupContract.prototype, "getManaLimit", null);
676
- _ts_decorate([
677
- memoize
678
- ], RollupContract.prototype, "getVersion", null);
679
- _ts_decorate([
680
- memoize
681
- ], RollupContract.prototype, "getGenesisArchiveTreeRoot", null);
682
- _ts_decorate([
683
- memoize
684
- ], RollupContract.prototype, "getRollupConstants", null);