@aztec/ethereum 0.0.0-test.1 → 0.0.1-commit.1142ef1

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 (276) hide show
  1. package/dest/account.d.ts +2 -0
  2. package/dest/account.d.ts.map +1 -0
  3. package/dest/account.js +4 -0
  4. package/dest/chain.d.ts +1 -1
  5. package/dest/client.d.ts +6 -4
  6. package/dest/client.d.ts.map +1 -1
  7. package/dest/client.js +21 -3
  8. package/dest/config.d.ts +74 -16
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +144 -22
  11. package/dest/constants.d.ts +1 -1
  12. package/dest/contracts/empire_base.d.ts +25 -8
  13. package/dest/contracts/empire_base.d.ts.map +1 -1
  14. package/dest/contracts/empire_base.js +75 -2
  15. package/dest/contracts/empire_slashing_proposer.d.ts +67 -0
  16. package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -0
  17. package/dest/contracts/empire_slashing_proposer.js +209 -0
  18. package/dest/contracts/errors.d.ts +7 -0
  19. package/dest/contracts/errors.d.ts.map +1 -0
  20. package/dest/contracts/errors.js +12 -0
  21. package/dest/contracts/fee_asset_handler.d.ts +20 -0
  22. package/dest/contracts/fee_asset_handler.d.ts.map +1 -0
  23. package/dest/contracts/fee_asset_handler.js +57 -0
  24. package/dest/contracts/fee_juice.d.ts +6 -7
  25. package/dest/contracts/fee_juice.d.ts.map +1 -1
  26. package/dest/contracts/fee_juice.js +27 -20
  27. package/dest/contracts/governance.d.ts +43 -32
  28. package/dest/contracts/governance.d.ts.map +1 -1
  29. package/dest/contracts/governance.js +87 -84
  30. package/dest/contracts/governance_proposer.d.ts +17 -13
  31. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  32. package/dest/contracts/governance_proposer.js +428 -25
  33. package/dest/contracts/gse.d.ts +32 -0
  34. package/dest/contracts/gse.d.ts.map +1 -0
  35. package/dest/contracts/gse.js +72 -0
  36. package/dest/contracts/inbox.d.ts +30 -0
  37. package/dest/contracts/inbox.d.ts.map +1 -0
  38. package/dest/contracts/inbox.js +49 -0
  39. package/dest/contracts/index.d.ts +10 -3
  40. package/dest/contracts/index.d.ts.map +1 -1
  41. package/dest/contracts/index.js +9 -2
  42. package/dest/contracts/multicall.d.ts +21 -0
  43. package/dest/contracts/multicall.d.ts.map +1 -0
  44. package/dest/contracts/multicall.js +156 -0
  45. package/dest/contracts/outbox.d.ts +41 -0
  46. package/dest/contracts/outbox.d.ts.map +1 -0
  47. package/dest/contracts/outbox.js +86 -0
  48. package/dest/contracts/registry.d.ts +10 -5
  49. package/dest/contracts/registry.d.ts.map +1 -1
  50. package/dest/contracts/registry.js +44 -16
  51. package/dest/contracts/rollup.d.ts +266 -53
  52. package/dest/contracts/rollup.d.ts.map +1 -1
  53. package/dest/contracts/rollup.js +1059 -116
  54. package/dest/contracts/slasher_contract.d.ts +44 -0
  55. package/dest/contracts/slasher_contract.d.ts.map +1 -0
  56. package/dest/contracts/slasher_contract.js +75 -0
  57. package/dest/contracts/tally_slashing_proposer.d.ts +140 -0
  58. package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -0
  59. package/dest/contracts/tally_slashing_proposer.js +313 -0
  60. package/dest/contracts/utils.d.ts +3 -0
  61. package/dest/contracts/utils.d.ts.map +1 -0
  62. package/dest/contracts/utils.js +11 -0
  63. package/dest/deploy_aztec_l1_contracts.d.ts +255 -0
  64. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
  65. package/dest/deploy_aztec_l1_contracts.js +385 -0
  66. package/dest/deploy_l1_contract.d.ts +68 -0
  67. package/dest/deploy_l1_contract.d.ts.map +1 -0
  68. package/dest/deploy_l1_contract.js +312 -0
  69. package/dest/eth-signer/eth-signer.d.ts +21 -0
  70. package/dest/eth-signer/eth-signer.d.ts.map +1 -0
  71. package/dest/eth-signer/eth-signer.js +5 -0
  72. package/dest/eth-signer/index.d.ts +2 -0
  73. package/dest/eth-signer/index.d.ts.map +1 -0
  74. package/dest/eth-signer/index.js +1 -0
  75. package/dest/forwarder_proxy.d.ts +32 -0
  76. package/dest/forwarder_proxy.d.ts.map +1 -0
  77. package/dest/forwarder_proxy.js +93 -0
  78. package/dest/l1_artifacts.d.ts +79812 -0
  79. package/dest/l1_artifacts.d.ts.map +1 -0
  80. package/dest/l1_artifacts.js +166 -0
  81. package/dest/l1_contract_addresses.d.ts +24 -4
  82. package/dest/l1_contract_addresses.d.ts.map +1 -1
  83. package/dest/l1_contract_addresses.js +25 -21
  84. package/dest/l1_reader.d.ts +4 -2
  85. package/dest/l1_reader.d.ts.map +1 -1
  86. package/dest/l1_reader.js +14 -8
  87. package/dest/l1_tx_utils/config.d.ts +59 -0
  88. package/dest/l1_tx_utils/config.d.ts.map +1 -0
  89. package/dest/l1_tx_utils/config.js +96 -0
  90. package/dest/l1_tx_utils/constants.d.ts +12 -0
  91. package/dest/l1_tx_utils/constants.d.ts.map +1 -0
  92. package/dest/l1_tx_utils/constants.js +39 -0
  93. package/dest/l1_tx_utils/factory.d.ts +24 -0
  94. package/dest/l1_tx_utils/factory.d.ts.map +1 -0
  95. package/dest/l1_tx_utils/factory.js +12 -0
  96. package/dest/l1_tx_utils/fee-strategies/index.d.ts +10 -0
  97. package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
  98. package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
  99. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -0
  100. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
  101. package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +129 -0
  102. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -0
  103. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
  104. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +191 -0
  105. package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
  106. package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
  107. package/dest/l1_tx_utils/fee-strategies/types.js +3 -0
  108. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +41 -0
  109. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
  110. package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +48 -0
  111. package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
  112. package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
  113. package/dest/l1_tx_utils/index-blobs.js +2 -0
  114. package/dest/l1_tx_utils/index.d.ts +12 -0
  115. package/dest/l1_tx_utils/index.d.ts.map +1 -0
  116. package/dest/l1_tx_utils/index.js +12 -0
  117. package/dest/l1_tx_utils/interfaces.d.ts +76 -0
  118. package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
  119. package/dest/l1_tx_utils/interfaces.js +4 -0
  120. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
  121. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
  122. package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
  123. package/dest/l1_tx_utils/l1_tx_utils.d.ts +94 -0
  124. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
  125. package/dest/l1_tx_utils/l1_tx_utils.js +623 -0
  126. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +26 -0
  127. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +1 -0
  128. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +26 -0
  129. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +83 -0
  130. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -0
  131. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +323 -0
  132. package/dest/l1_tx_utils/signer.d.ts +4 -0
  133. package/dest/l1_tx_utils/signer.d.ts.map +1 -0
  134. package/dest/l1_tx_utils/signer.js +16 -0
  135. package/dest/l1_tx_utils/types.d.ts +67 -0
  136. package/dest/l1_tx_utils/types.d.ts.map +1 -0
  137. package/dest/l1_tx_utils/types.js +26 -0
  138. package/dest/l1_tx_utils/utils.d.ts +4 -0
  139. package/dest/l1_tx_utils/utils.d.ts.map +1 -0
  140. package/dest/l1_tx_utils/utils.js +14 -0
  141. package/dest/l1_types.d.ts +6 -0
  142. package/dest/l1_types.d.ts.map +1 -0
  143. package/dest/l1_types.js +1 -0
  144. package/dest/publisher_manager.d.ts +15 -0
  145. package/dest/publisher_manager.d.ts.map +1 -0
  146. package/dest/publisher_manager.js +88 -0
  147. package/dest/queries.d.ts +4 -2
  148. package/dest/queries.d.ts.map +1 -1
  149. package/dest/queries.js +58 -12
  150. package/dest/test/chain_monitor.d.ts +75 -0
  151. package/dest/test/chain_monitor.d.ts.map +1 -0
  152. package/dest/test/chain_monitor.js +213 -0
  153. package/dest/test/delayed_tx_utils.d.ts +8 -3
  154. package/dest/test/delayed_tx_utils.d.ts.map +1 -1
  155. package/dest/test/delayed_tx_utils.js +13 -6
  156. package/dest/test/eth_cheat_codes.d.ts +217 -0
  157. package/dest/test/eth_cheat_codes.d.ts.map +1 -0
  158. package/dest/test/eth_cheat_codes.js +560 -0
  159. package/dest/test/eth_cheat_codes_with_state.d.ts +2 -2
  160. package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
  161. package/dest/test/eth_cheat_codes_with_state.js +1 -1
  162. package/dest/test/index.d.ts +4 -1
  163. package/dest/test/index.d.ts.map +1 -1
  164. package/dest/test/index.js +3 -0
  165. package/dest/test/rollup_cheat_codes.d.ts +88 -0
  166. package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
  167. package/dest/test/rollup_cheat_codes.js +283 -0
  168. package/dest/test/start_anvil.d.ts +9 -1
  169. package/dest/test/start_anvil.d.ts.map +1 -1
  170. package/dest/test/start_anvil.js +16 -7
  171. package/dest/test/tx_delayer.d.ts +18 -7
  172. package/dest/test/tx_delayer.d.ts.map +1 -1
  173. package/dest/test/tx_delayer.js +97 -20
  174. package/dest/test/upgrade_utils.d.ts +6 -5
  175. package/dest/test/upgrade_utils.d.ts.map +1 -1
  176. package/dest/test/upgrade_utils.js +23 -16
  177. package/dest/types.d.ts +62 -8
  178. package/dest/types.d.ts.map +1 -1
  179. package/dest/types.js +3 -1
  180. package/dest/utils.d.ts +16 -3
  181. package/dest/utils.d.ts.map +1 -1
  182. package/dest/utils.js +61 -88
  183. package/dest/zkPassportVerifierAddress.d.ts +15 -0
  184. package/dest/zkPassportVerifierAddress.d.ts.map +1 -0
  185. package/dest/zkPassportVerifierAddress.js +11 -0
  186. package/package.json +50 -23
  187. package/src/account.ts +5 -0
  188. package/src/client.ts +43 -5
  189. package/src/config.ts +196 -31
  190. package/src/contracts/empire_base.ts +77 -7
  191. package/src/contracts/empire_slashing_proposer.ts +270 -0
  192. package/src/contracts/errors.ts +13 -0
  193. package/src/contracts/fee_asset_handler.ts +64 -0
  194. package/src/contracts/fee_juice.ts +29 -15
  195. package/src/contracts/governance.ts +80 -77
  196. package/src/contracts/governance_proposer.ts +71 -24
  197. package/src/contracts/gse.ts +88 -0
  198. package/src/contracts/inbox.ts +68 -0
  199. package/src/contracts/index.ts +9 -2
  200. package/src/contracts/multicall.ts +155 -0
  201. package/src/contracts/outbox.ts +98 -0
  202. package/src/contracts/registry.ts +51 -26
  203. package/src/contracts/rollup.ts +784 -90
  204. package/src/contracts/slasher_contract.ts +89 -0
  205. package/src/contracts/tally_slashing_proposer.ts +318 -0
  206. package/src/contracts/utils.ts +14 -0
  207. package/src/deploy_aztec_l1_contracts.ts +605 -0
  208. package/src/deploy_l1_contract.ts +362 -0
  209. package/src/eth-signer/eth-signer.ts +25 -0
  210. package/src/eth-signer/index.ts +1 -0
  211. package/src/forwarder_proxy.ts +108 -0
  212. package/src/l1_artifacts.ts +254 -0
  213. package/src/l1_contract_addresses.ts +49 -34
  214. package/src/l1_reader.ts +17 -9
  215. package/src/l1_tx_utils/README.md +177 -0
  216. package/src/l1_tx_utils/config.ts +161 -0
  217. package/src/l1_tx_utils/constants.ts +29 -0
  218. package/src/l1_tx_utils/factory.ts +64 -0
  219. package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
  220. package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +163 -0
  221. package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +245 -0
  222. package/src/l1_tx_utils/fee-strategies/types.ts +56 -0
  223. package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +119 -0
  224. package/src/l1_tx_utils/index-blobs.ts +2 -0
  225. package/src/l1_tx_utils/index.ts +14 -0
  226. package/src/l1_tx_utils/interfaces.ts +86 -0
  227. package/src/l1_tx_utils/l1_fee_analyzer.ts +803 -0
  228. package/src/l1_tx_utils/l1_tx_utils.ts +738 -0
  229. package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +77 -0
  230. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +419 -0
  231. package/src/l1_tx_utils/signer.ts +28 -0
  232. package/src/l1_tx_utils/types.ts +85 -0
  233. package/src/l1_tx_utils/utils.ts +16 -0
  234. package/src/l1_types.ts +6 -0
  235. package/src/publisher_manager.ts +106 -0
  236. package/src/queries.ts +79 -15
  237. package/src/test/chain_monitor.ts +245 -0
  238. package/src/test/delayed_tx_utils.ts +34 -6
  239. package/src/test/eth_cheat_codes.ts +588 -0
  240. package/src/test/eth_cheat_codes_with_state.ts +1 -1
  241. package/src/test/index.ts +3 -0
  242. package/src/test/rollup_cheat_codes.ts +321 -0
  243. package/src/test/start_anvil.ts +24 -5
  244. package/src/test/tx_delayer.ts +130 -27
  245. package/src/test/upgrade_utils.ts +30 -21
  246. package/src/types.ts +71 -7
  247. package/src/utils.ts +79 -91
  248. package/src/zkPassportVerifierAddress.ts +15 -0
  249. package/dest/contracts/forwarder.d.ts +0 -24
  250. package/dest/contracts/forwarder.d.ts.map +0 -1
  251. package/dest/contracts/forwarder.js +0 -101
  252. package/dest/contracts/slashing_proposer.d.ts +0 -21
  253. package/dest/contracts/slashing_proposer.d.ts.map +0 -1
  254. package/dest/contracts/slashing_proposer.js +0 -47
  255. package/dest/deploy_l1_contracts.d.ts +0 -21210
  256. package/dest/deploy_l1_contracts.d.ts.map +0 -1
  257. package/dest/deploy_l1_contracts.js +0 -687
  258. package/dest/eth_cheat_codes.d.ts +0 -147
  259. package/dest/eth_cheat_codes.d.ts.map +0 -1
  260. package/dest/eth_cheat_codes.js +0 -303
  261. package/dest/index.d.ts +0 -14
  262. package/dest/index.d.ts.map +0 -1
  263. package/dest/index.js +0 -13
  264. package/dest/l1_tx_utils.d.ts +0 -192
  265. package/dest/l1_tx_utils.d.ts.map +0 -1
  266. package/dest/l1_tx_utils.js +0 -641
  267. package/dest/l1_tx_utils_with_blobs.d.ts +0 -12
  268. package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
  269. package/dest/l1_tx_utils_with_blobs.js +0 -64
  270. package/src/contracts/forwarder.ts +0 -132
  271. package/src/contracts/slashing_proposer.ts +0 -51
  272. package/src/deploy_l1_contracts.ts +0 -948
  273. package/src/eth_cheat_codes.ts +0 -314
  274. package/src/index.ts +0 -13
  275. package/src/l1_tx_utils.ts +0 -847
  276. package/src/l1_tx_utils_with_blobs.ts +0 -86
@@ -1,19 +1,512 @@
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
  }
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';
7
377
  import { memoize } from '@aztec/foundation/decorators';
8
378
  import { EthAddress } from '@aztec/foundation/eth-address';
9
- import { RollupAbi, RollupStorage, SlasherAbi } from '@aztec/l1-artifacts';
10
- import { getAddress, getContract } from 'viem';
379
+ import { makeBackoff, retry } from '@aztec/foundation/retry';
380
+ import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
381
+ import { RollupStorage } from '@aztec/l1-artifacts/RollupStorage';
382
+ import chunk from 'lodash.chunk';
383
+ import { encodeFunctionData, getContract, hexToBigInt, keccak256 } from 'viem';
11
384
  import { getPublicClient } from '../client.js';
12
385
  import { formatViemError } from '../utils.js';
13
- import { SlashingProposerContract } from './slashing_proposer.js';
386
+ import { EmpireSlashingProposerContract } from './empire_slashing_proposer.js';
387
+ import { GSEContract } from './gse.js';
388
+ import { SlasherContract } from './slasher_contract.js';
389
+ import { TallySlashingProposerContract } from './tally_slashing_proposer.js';
390
+ import { checkBlockTag } from './utils.js';
391
+ export var SlashingProposerType = /*#__PURE__*/ function(SlashingProposerType) {
392
+ SlashingProposerType[SlashingProposerType["None"] = 0] = "None";
393
+ SlashingProposerType[SlashingProposerType["Tally"] = 1] = "Tally";
394
+ SlashingProposerType[SlashingProposerType["Empire"] = 2] = "Empire";
395
+ return SlashingProposerType;
396
+ }({});
397
+ /**
398
+ * Status of a validator/attester in the staking system.
399
+ * Matches the Status enum in StakingLib.sol
400
+ */ export var AttesterStatus = /*#__PURE__*/ function(AttesterStatus) {
401
+ AttesterStatus[AttesterStatus["NONE"] = 0] = "NONE";
402
+ AttesterStatus[AttesterStatus["VALIDATING"] = 1] = "VALIDATING";
403
+ AttesterStatus[AttesterStatus["ZOMBIE"] = 2] = "ZOMBIE";
404
+ AttesterStatus[AttesterStatus["EXITING"] = 3] = "EXITING";
405
+ return AttesterStatus;
406
+ }({});
14
407
  export class RollupContract {
15
408
  client;
409
+ static{
410
+ ({ e: [_initProto] } = _apply_decs_2203_r(this, [
411
+ [
412
+ memoize,
413
+ 2,
414
+ "getL1StartBlock"
415
+ ],
416
+ [
417
+ memoize,
418
+ 2,
419
+ "getL1GenesisTime"
420
+ ],
421
+ [
422
+ memoize,
423
+ 2,
424
+ "getProofSubmissionEpochs"
425
+ ],
426
+ [
427
+ memoize,
428
+ 2,
429
+ "getEpochDuration"
430
+ ],
431
+ [
432
+ memoize,
433
+ 2,
434
+ "getSlotDuration"
435
+ ],
436
+ [
437
+ memoize,
438
+ 2,
439
+ "getTargetCommitteeSize"
440
+ ],
441
+ [
442
+ memoize,
443
+ 2,
444
+ "getEjectionThreshold"
445
+ ],
446
+ [
447
+ memoize,
448
+ 2,
449
+ "getLocalEjectionThreshold"
450
+ ],
451
+ [
452
+ memoize,
453
+ 2,
454
+ "getLagInEpochsForValidatorSet"
455
+ ],
456
+ [
457
+ memoize,
458
+ 2,
459
+ "getLagInEpochsForRandao"
460
+ ],
461
+ [
462
+ memoize,
463
+ 2,
464
+ "getActivationThreshold"
465
+ ],
466
+ [
467
+ memoize,
468
+ 2,
469
+ "getExitDelay"
470
+ ],
471
+ [
472
+ memoize,
473
+ 2,
474
+ "getManaTarget"
475
+ ],
476
+ [
477
+ memoize,
478
+ 2,
479
+ "getProvingCostPerMana"
480
+ ],
481
+ [
482
+ memoize,
483
+ 2,
484
+ "getProvingCostPerManaInFeeAsset"
485
+ ],
486
+ [
487
+ memoize,
488
+ 2,
489
+ "getManaLimit"
490
+ ],
491
+ [
492
+ memoize,
493
+ 2,
494
+ "getVersion"
495
+ ],
496
+ [
497
+ memoize,
498
+ 2,
499
+ "getGenesisArchiveTreeRoot"
500
+ ],
501
+ [
502
+ memoize,
503
+ 2,
504
+ "getRollupConstants"
505
+ ]
506
+ ], []));
507
+ }
16
508
  rollup;
509
+ static cachedStfStorageSlot;
17
510
  static get checkBlobStorageSlot() {
18
511
  const asString = RollupStorage.find((storage)=>storage.label === 'checkBlob')?.slot;
19
512
  if (asString === undefined) {
@@ -21,9 +514,12 @@ export class RollupContract {
21
514
  }
22
515
  return BigInt(asString);
23
516
  }
517
+ static get stfStorageSlot() {
518
+ return RollupContract.cachedStfStorageSlot ??= keccak256(Buffer.from('aztec.stf.storage', 'utf-8'));
519
+ }
24
520
  static getFromL1ContractsValues(deployL1ContractsValues) {
25
- const { publicClient, l1ContractAddresses: { rollupAddress } } = deployL1ContractsValues;
26
- return new RollupContract(publicClient, rollupAddress.toString());
521
+ const { l1Client, l1ContractAddresses: { rollupAddress } } = deployL1ContractsValues;
522
+ return new RollupContract(l1Client, rollupAddress.toString());
27
523
  }
28
524
  static getFromConfig(config) {
29
525
  const client = getPublicClient(config);
@@ -32,6 +528,7 @@ export class RollupContract {
32
528
  }
33
529
  constructor(client, address){
34
530
  this.client = client;
531
+ _initProto(this);
35
532
  if (address instanceof EthAddress) {
36
533
  address = address.toString();
37
534
  }
@@ -41,18 +538,49 @@ export class RollupContract {
41
538
  client
42
539
  });
43
540
  }
541
+ async getGSE() {
542
+ return EthAddress.fromString(await this.rollup.read.getGSE());
543
+ }
44
544
  get address() {
45
545
  return this.rollup.address;
46
546
  }
547
+ getContract() {
548
+ return this.rollup;
549
+ }
47
550
  async getSlashingProposer() {
48
- const slasherAddress = await this.rollup.read.getSlasher();
49
- const slasher = getContract({
50
- address: slasherAddress,
51
- abi: SlasherAbi,
551
+ const slasher = await this.getSlasherContract();
552
+ if (!slasher) {
553
+ return undefined;
554
+ }
555
+ const proposerAddress = await slasher.getProposer();
556
+ const proposerAbi = [
557
+ {
558
+ type: 'function',
559
+ name: 'SLASHING_PROPOSER_TYPE',
560
+ inputs: [],
561
+ outputs: [
562
+ {
563
+ name: '',
564
+ type: 'uint8',
565
+ internalType: 'enum SlasherFlavor'
566
+ }
567
+ ],
568
+ stateMutability: 'view'
569
+ }
570
+ ];
571
+ const proposer = getContract({
572
+ address: proposerAddress.toString(),
573
+ abi: proposerAbi,
52
574
  client: this.client
53
575
  });
54
- const proposerAddress = await slasher.read.PROPOSER();
55
- return new SlashingProposerContract(this.client, proposerAddress);
576
+ const proposerType = await proposer.read.SLASHING_PROPOSER_TYPE();
577
+ if (proposerType === 1..valueOf()) {
578
+ return new TallySlashingProposerContract(this.client, proposerAddress);
579
+ } else if (proposerType === 2..valueOf()) {
580
+ return new EmpireSlashingProposerContract(this.client, proposerAddress);
581
+ } else {
582
+ throw new Error(`Unknown slashing proposer type: ${proposerType}`);
583
+ }
56
584
  }
57
585
  getL1StartBlock() {
58
586
  return this.rollup.read.L1_BLOCK_AT_GENESIS();
@@ -60,90 +588,261 @@ export class RollupContract {
60
588
  getL1GenesisTime() {
61
589
  return this.rollup.read.getGenesisTime();
62
590
  }
63
- getProofSubmissionWindow() {
64
- return this.rollup.read.getProofSubmissionWindow();
591
+ async getProofSubmissionEpochs() {
592
+ return Number(await this.rollup.read.getProofSubmissionEpochs());
593
+ }
594
+ async getEpochDuration() {
595
+ return Number(await this.rollup.read.getEpochDuration());
596
+ }
597
+ async getSlotDuration() {
598
+ return Number(await this.rollup.read.getSlotDuration());
599
+ }
600
+ async getTargetCommitteeSize() {
601
+ return Number(await this.rollup.read.getTargetCommitteeSize());
602
+ }
603
+ getEjectionThreshold() {
604
+ return this.rollup.read.getEjectionThreshold();
605
+ }
606
+ getLocalEjectionThreshold() {
607
+ return this.rollup.read.getLocalEjectionThreshold();
608
+ }
609
+ async getLagInEpochsForValidatorSet() {
610
+ return Number(await this.rollup.read.getLagInEpochsForValidatorSet());
611
+ }
612
+ async getLagInEpochsForRandao() {
613
+ return Number(await this.rollup.read.getLagInEpochsForRandao());
614
+ }
615
+ getActivationThreshold() {
616
+ return this.rollup.read.getActivationThreshold();
617
+ }
618
+ async getExitDelay() {
619
+ return Number(await this.rollup.read.getExitDelay());
65
620
  }
66
- getEpochDuration() {
67
- return this.rollup.read.getEpochDuration();
621
+ getManaTarget() {
622
+ return this.rollup.read.getManaTarget();
68
623
  }
69
- getSlotDuration() {
70
- return this.rollup.read.getSlotDuration();
624
+ getProvingCostPerMana() {
625
+ return this.rollup.read.getProvingCostPerManaInEth();
71
626
  }
72
- getTargetCommitteeSize() {
73
- return this.rollup.read.getTargetCommitteeSize();
627
+ getProvingCostPerManaInFeeAsset() {
628
+ return this.rollup.read.getProvingCostPerManaInFeeAsset();
74
629
  }
75
- getMinimumStake() {
76
- return this.rollup.read.getMinimumStake();
630
+ getManaLimit() {
631
+ return this.rollup.read.getManaLimit();
632
+ }
633
+ getVersion() {
634
+ return this.rollup.read.getVersion();
635
+ }
636
+ async getGenesisArchiveTreeRoot() {
637
+ return Fr.fromString(await this.rollup.read.archiveAt([
638
+ 0n
639
+ ]));
640
+ }
641
+ /**
642
+ * Returns rollup constants used for epoch queries.
643
+ * Return type is `L1RollupConstants` which is defined in stdlib,
644
+ * so we cant reference it until we move this contract to that package.
645
+ */ async getRollupConstants() {
646
+ const [l1StartBlock, l1GenesisTime, slotDuration, epochDuration, proofSubmissionEpochs] = await Promise.all([
647
+ this.getL1StartBlock(),
648
+ this.getL1GenesisTime(),
649
+ this.getSlotDuration(),
650
+ this.getEpochDuration(),
651
+ this.getProofSubmissionEpochs()
652
+ ]);
653
+ return {
654
+ l1StartBlock,
655
+ l1GenesisTime,
656
+ slotDuration,
657
+ epochDuration: Number(epochDuration),
658
+ proofSubmissionEpochs: Number(proofSubmissionEpochs)
659
+ };
660
+ }
661
+ async getSlasherAddress() {
662
+ return EthAddress.fromString(await this.rollup.read.getSlasher());
663
+ }
664
+ /**
665
+ * Returns a SlasherContract instance for interacting with the slasher contract.
666
+ */ async getSlasherContract() {
667
+ const slasherAddress = await this.getSlasherAddress();
668
+ if (slasherAddress.isZero()) {
669
+ return undefined;
670
+ }
671
+ return new SlasherContract(this.client, slasherAddress);
672
+ }
673
+ async getOwner() {
674
+ return EthAddress.fromString(await this.rollup.read.owner());
675
+ }
676
+ async getActiveAttesterCount() {
677
+ return Number(await this.rollup.read.getActiveAttesterCount());
77
678
  }
78
679
  async getSlashingProposerAddress() {
79
- const slasherAddress = await this.rollup.read.getSlasher();
80
- const slasher = getContract({
81
- address: getAddress(slasherAddress.toString()),
82
- abi: SlasherAbi,
83
- client: this.client
84
- });
85
- return EthAddress.fromString(await slasher.read.PROPOSER());
680
+ const slasher = await this.getSlasherContract();
681
+ if (!slasher) {
682
+ return EthAddress.ZERO;
683
+ }
684
+ return await slasher.getProposer();
685
+ }
686
+ getCheckpointReward() {
687
+ return this.rollup.read.getCheckpointReward();
86
688
  }
87
- getBlockNumber() {
88
- return this.rollup.read.getPendingBlockNumber();
689
+ async getCheckpointNumber() {
690
+ return CheckpointNumber.fromBigInt(await this.rollup.read.getPendingCheckpointNumber());
89
691
  }
90
- getProvenBlockNumber() {
91
- return this.rollup.read.getProvenBlockNumber();
692
+ async getProvenCheckpointNumber() {
693
+ return CheckpointNumber.fromBigInt(await this.rollup.read.getProvenCheckpointNumber());
92
694
  }
93
- getSlotNumber() {
94
- return this.rollup.read.getCurrentSlot();
695
+ async getSlotNumber() {
696
+ return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
95
697
  }
96
- getCommitteeAt(timestamp) {
97
- return this.rollup.read.getCommitteeAt([
698
+ async getL1FeesAt(timestamp) {
699
+ const result = await this.rollup.read.getL1FeesAt([
98
700
  timestamp
99
701
  ]);
702
+ return {
703
+ baseFee: result.baseFee,
704
+ blobFee: result.blobFee
705
+ };
706
+ }
707
+ getFeeAssetPerEth() {
708
+ return this.rollup.read.getFeeAssetPerEth();
100
709
  }
101
- getSampleSeedAt(timestamp) {
102
- return this.rollup.read.getSampleSeedAt([
710
+ async getCommitteeAt(timestamp) {
711
+ const { result } = await this.client.simulateContract({
712
+ address: this.address,
713
+ abi: RollupAbi,
714
+ functionName: 'getCommitteeAt',
715
+ args: [
716
+ timestamp
717
+ ]
718
+ }).catch((e)=>{
719
+ if (e instanceof Error && e.message.includes('ValidatorSelection__InsufficientValidatorSetSize')) {
720
+ return {
721
+ result: undefined
722
+ };
723
+ }
724
+ throw e;
725
+ });
726
+ return result ? result.map((addr)=>EthAddress.fromString(addr)) : undefined;
727
+ }
728
+ async getSampleSeedAt(timestamp) {
729
+ return Buffer32.fromBigInt(await this.rollup.read.getSampleSeedAt([
103
730
  timestamp
104
- ]);
731
+ ]));
105
732
  }
106
- getCurrentSampleSeed() {
107
- return this.rollup.read.getCurrentSampleSeed();
733
+ async getCurrentSampleSeed() {
734
+ return Buffer32.fromBigInt(await this.rollup.read.getCurrentSampleSeed());
108
735
  }
109
- getCurrentEpochCommittee() {
110
- return this.rollup.read.getCurrentEpochCommittee();
736
+ async getCurrentEpoch() {
737
+ return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
111
738
  }
112
- getCurrentProposer() {
113
- return this.rollup.read.getCurrentProposer();
739
+ async getCurrentEpochCommittee() {
740
+ const { result } = await this.client.simulateContract({
741
+ address: this.address,
742
+ abi: RollupAbi,
743
+ functionName: 'getCurrentEpochCommittee',
744
+ args: []
745
+ }).catch((e)=>{
746
+ if (e instanceof Error && e.message.includes('ValidatorSelection__InsufficientValidatorSetSize')) {
747
+ return {
748
+ result: undefined
749
+ };
750
+ }
751
+ throw e;
752
+ });
753
+ return result ? result.map((addr)=>EthAddress.fromString(addr)) : undefined;
114
754
  }
115
- getProposerAt(timestamp) {
116
- return this.rollup.read.getProposerAt([
117
- timestamp
118
- ]);
755
+ async getCurrentProposer() {
756
+ const { result } = await this.client.simulateContract({
757
+ address: this.address,
758
+ abi: RollupAbi,
759
+ functionName: 'getCurrentProposer',
760
+ args: []
761
+ });
762
+ return EthAddress.fromString(result);
119
763
  }
120
- getBlock(blockNumber) {
121
- return this.rollup.read.getBlock([
122
- blockNumber
764
+ async getProposerAt(timestamp) {
765
+ const { result } = await this.client.simulateContract({
766
+ address: this.address,
767
+ abi: RollupAbi,
768
+ functionName: 'getProposerAt',
769
+ args: [
770
+ timestamp
771
+ ]
772
+ });
773
+ return EthAddress.fromString(result);
774
+ }
775
+ async getCheckpoint(checkpointNumber) {
776
+ const result = await this.rollup.read.getCheckpoint([
777
+ BigInt(checkpointNumber)
123
778
  ]);
779
+ return {
780
+ archive: Fr.fromString(result.archive),
781
+ headerHash: Buffer32.fromString(result.headerHash),
782
+ blobCommitmentsHash: Buffer32.fromString(result.blobCommitmentsHash),
783
+ attestationsHash: Buffer32.fromString(result.attestationsHash),
784
+ payloadDigest: Buffer32.fromString(result.payloadDigest),
785
+ slotNumber: SlotNumber.fromBigInt(result.slotNumber),
786
+ feeHeader: {
787
+ excessMana: result.feeHeader.excessMana,
788
+ manaUsed: result.feeHeader.manaUsed,
789
+ feeAssetPriceNumerator: result.feeHeader.feeAssetPriceNumerator,
790
+ congestionCost: result.feeHeader.congestionCost,
791
+ proverCost: result.feeHeader.proverCost
792
+ }
793
+ };
124
794
  }
125
- getTips() {
126
- return this.rollup.read.getTips();
795
+ /** Returns the pending checkpoint from the rollup contract */ getPendingCheckpoint() {
796
+ // We retry because of race conditions during prunes: we may get a pending checkpoint number which is immediately
797
+ // reorged out due to a prune happening, causing the subsequent getCheckpoint call to fail. So we try again in that case.
798
+ return retry(async ()=>{
799
+ const pendingCheckpointNumber = await this.getCheckpointNumber();
800
+ const pendingCheckpoint = await this.getCheckpoint(pendingCheckpointNumber);
801
+ return pendingCheckpoint;
802
+ }, 'getting pending checkpoint', makeBackoff([
803
+ 0.5,
804
+ 0.5,
805
+ 0.5
806
+ ]));
807
+ }
808
+ async getTips() {
809
+ const { pending, proven } = await this.rollup.read.getTips();
810
+ return {
811
+ pending: CheckpointNumber.fromBigInt(pending),
812
+ proven: CheckpointNumber.fromBigInt(proven)
813
+ };
127
814
  }
128
815
  getTimestampForSlot(slot) {
129
816
  return this.rollup.read.getTimestampForSlot([
130
- slot
817
+ BigInt(slot)
131
818
  ]);
132
819
  }
133
- async getEpochNumber(blockNumber) {
134
- blockNumber ??= await this.getBlockNumber();
135
- return this.rollup.read.getEpochForBlock([
136
- BigInt(blockNumber)
137
- ]);
820
+ async getEntryQueueLength() {
821
+ return Number(await this.rollup.read.getEntryQueueLength());
822
+ }
823
+ async getAvailableValidatorFlushes() {
824
+ return Number(await this.rollup.read.getAvailableValidatorFlushes());
825
+ }
826
+ async getNextFlushableEpoch() {
827
+ return EpochNumber.fromBigInt(await this.rollup.read.getNextFlushableEpoch());
828
+ }
829
+ async getCurrentEpochNumber() {
830
+ return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
831
+ }
832
+ async getEpochNumberForCheckpoint(checkpointNumber) {
833
+ return EpochNumber.fromBigInt(await this.rollup.read.getEpochForCheckpoint([
834
+ BigInt(checkpointNumber)
835
+ ]));
138
836
  }
139
837
  async getRollupAddresses() {
140
- const [inboxAddress, outboxAddress, feeJuicePortalAddress, rewardDistributorAddress, feeJuiceAddress, stakingAssetAddress] = (await Promise.all([
838
+ const [inboxAddress, outboxAddress, feeJuicePortalAddress, rewardDistributorAddress, feeJuiceAddress, stakingAssetAddress, gseAddress] = (await Promise.all([
141
839
  this.rollup.read.getInbox(),
142
840
  this.rollup.read.getOutbox(),
143
841
  this.rollup.read.getFeeAssetPortal(),
144
842
  this.rollup.read.getRewardDistributor(),
145
843
  this.rollup.read.getFeeAsset(),
146
- this.rollup.read.getStakingAsset()
844
+ this.rollup.read.getStakingAsset(),
845
+ this.rollup.read.getGSE()
147
846
  ])).map(EthAddress.fromString);
148
847
  return {
149
848
  rollupAddress: EthAddress.fromString(this.address),
@@ -152,20 +851,29 @@ export class RollupContract {
152
851
  feeJuicePortalAddress,
153
852
  feeJuiceAddress,
154
853
  stakingAssetAddress,
155
- rewardDistributorAddress
854
+ rewardDistributorAddress,
855
+ gseAddress
156
856
  };
157
857
  }
858
+ async getFeeJuicePortal() {
859
+ return EthAddress.fromString(await this.rollup.read.getFeeAssetPortal());
860
+ }
158
861
  async getEpochNumberForSlotNumber(slotNumber) {
159
- return await this.rollup.read.getEpochAtSlot([
160
- slotNumber
161
- ]);
862
+ return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([
863
+ BigInt(slotNumber)
864
+ ]));
162
865
  }
163
- getEpochProofPublicInputs(args) {
164
- return this.rollup.read.getEpochProofPublicInputs(args);
866
+ async getEpochProofPublicInputs(args) {
867
+ const result = await this.rollup.read.getEpochProofPublicInputs(args);
868
+ return result.map(Fr.fromString);
165
869
  }
166
870
  async validateHeader(args, account) {
167
871
  try {
168
- await this.rollup.read.validateHeader(args, {
872
+ await this.client.simulateContract({
873
+ address: this.address,
874
+ abi: RollupAbi,
875
+ functionName: 'validateHeaderWithAttestations',
876
+ args,
169
877
  account
170
878
  });
171
879
  } catch (error) {
@@ -178,57 +886,292 @@ export class RollupContract {
178
886
  * @dev Throws if unable to propose
179
887
  *
180
888
  * @param archive - The archive that we expect to be current state
181
- * @return [slot, blockNumber] - If you can propose, the L2 slot number and L2 block number of the next Ethereum block,
889
+ * @return [slot, checkpointNumber, timeOfNextL1Slot] - If you can propose, the L2 slot number, checkpoint number and
890
+ * timestamp of the next L1 block
182
891
  * @throws otherwise
183
- */ async canProposeAtNextEthBlock(archive, account, slotDuration) {
184
- if (typeof slotDuration === 'number') {
185
- slotDuration = BigInt(slotDuration);
186
- }
187
- const timeOfNextL1Slot = (await this.client.getBlock()).timestamp + slotDuration;
892
+ */ async canProposeAtNextEthBlock(archive, account, slotDuration, opts = {}) {
893
+ const latestBlock = await this.client.getBlock();
894
+ const timeOfNextL1Slot = latestBlock.timestamp + BigInt(slotDuration);
895
+ const who = typeof account === 'string' ? account : account.address;
188
896
  try {
189
- const [slot, blockNumber] = await this.rollup.read.canProposeAtTime([
190
- timeOfNextL1Slot,
191
- `0x${archive.toString('hex')}`
192
- ], {
193
- account
897
+ const { result: [slot, checkpointNumber] } = await this.client.simulateContract({
898
+ address: this.address,
899
+ abi: RollupAbi,
900
+ functionName: 'canProposeAtTime',
901
+ args: [
902
+ timeOfNextL1Slot,
903
+ `0x${archive.toString('hex')}`,
904
+ who
905
+ ],
906
+ account,
907
+ stateOverride: await this.makePendingCheckpointNumberOverride(opts.forcePendingCheckpointNumber)
194
908
  });
195
- return [
196
- slot,
197
- blockNumber
198
- ];
909
+ return {
910
+ slot: SlotNumber.fromBigInt(slot),
911
+ checkpointNumber: CheckpointNumber.fromBigInt(checkpointNumber),
912
+ timeOfNextL1Slot
913
+ };
199
914
  } catch (err) {
200
915
  throw formatViemError(err);
201
916
  }
202
917
  }
203
- /** Calls getHasSubmitted directly. Returns whether the given prover has submitted a proof with the given length for the given epoch. */ getHasSubmittedProof(epochNumber, numberOfBlocksInEpoch, prover) {
918
+ /**
919
+ * Returns a state override that sets the pending checkpoint number to the specified value. Useful for simulations.
920
+ * Requires querying the current state of the contract to get the current proven checkpoint number, as they are both
921
+ * stored in the same slot. If the argument is undefined, it returns an empty override.
922
+ */ async makePendingCheckpointNumberOverride(forcePendingCheckpointNumber) {
923
+ if (forcePendingCheckpointNumber === undefined) {
924
+ return [];
925
+ }
926
+ const slot = RollupContract.stfStorageSlot;
927
+ const currentValue = await this.client.getStorageAt({
928
+ address: this.address,
929
+ slot
930
+ });
931
+ const currentProvenCheckpointNumber = currentValue ? hexToBigInt(currentValue) & (1n << 128n) - 1n : 0n;
932
+ const newValue = BigInt(forcePendingCheckpointNumber) << 128n | currentProvenCheckpointNumber;
933
+ return [
934
+ {
935
+ address: this.address,
936
+ stateDiff: [
937
+ {
938
+ slot,
939
+ value: `0x${newValue.toString(16).padStart(64, '0')}`
940
+ }
941
+ ]
942
+ }
943
+ ];
944
+ }
945
+ /** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */ buildInvalidateBadAttestationRequest(checkpointNumber, attestationsAndSigners, committee, invalidIndex) {
946
+ return {
947
+ to: this.address,
948
+ data: encodeFunctionData({
949
+ abi: RollupAbi,
950
+ functionName: 'invalidateBadAttestation',
951
+ args: [
952
+ BigInt(checkpointNumber),
953
+ attestationsAndSigners,
954
+ committee.map((addr)=>addr.toString()),
955
+ BigInt(invalidIndex)
956
+ ]
957
+ })
958
+ };
959
+ }
960
+ /** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */ buildInvalidateInsufficientAttestationsRequest(checkpointNumber, attestationsAndSigners, committee) {
961
+ return {
962
+ to: this.address,
963
+ data: encodeFunctionData({
964
+ abi: RollupAbi,
965
+ functionName: 'invalidateInsufficientAttestations',
966
+ args: [
967
+ BigInt(checkpointNumber),
968
+ attestationsAndSigners,
969
+ committee.map((addr)=>addr.toString())
970
+ ]
971
+ })
972
+ };
973
+ }
974
+ /** Calls getHasSubmitted directly. Returns whether the given prover has submitted a proof with the given length for the given epoch. */ getHasSubmittedProof(epochNumber, numberOfCheckpointsInEpoch, prover) {
975
+ if (prover instanceof EthAddress) {
976
+ prover = prover.toString();
977
+ }
204
978
  return this.rollup.read.getHasSubmitted([
205
979
  BigInt(epochNumber),
206
- BigInt(numberOfBlocksInEpoch),
207
- prover.toString()
980
+ BigInt(numberOfCheckpointsInEpoch),
981
+ prover
982
+ ]);
983
+ }
984
+ getManaMinFeeAt(timestamp, inFeeAsset) {
985
+ return this.rollup.read.getManaMinFeeAt([
986
+ timestamp,
987
+ inFeeAsset
988
+ ]);
989
+ }
990
+ async getSlotAt(timestamp) {
991
+ return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([
992
+ timestamp
993
+ ]));
994
+ }
995
+ async status(checkpointNumber, options) {
996
+ await checkBlockTag(options?.blockNumber, this.client);
997
+ const result = await this.rollup.read.status([
998
+ BigInt(checkpointNumber)
999
+ ], options);
1000
+ return {
1001
+ provenCheckpointNumber: CheckpointNumber.fromBigInt(result[0]),
1002
+ provenArchive: Fr.fromString(result[1]),
1003
+ pendingCheckpointNumber: CheckpointNumber.fromBigInt(result[2]),
1004
+ pendingArchive: Fr.fromString(result[3]),
1005
+ archiveOfMyCheckpoint: Fr.fromString(result[4])
1006
+ };
1007
+ }
1008
+ async canPruneAtTime(timestamp, options) {
1009
+ await checkBlockTag(options?.blockNumber, this.client);
1010
+ return this.rollup.read.canPruneAtTime([
1011
+ timestamp
1012
+ ], options);
1013
+ }
1014
+ async archive() {
1015
+ return Fr.fromString(await this.rollup.read.archive());
1016
+ }
1017
+ async archiveAt(checkpointNumber) {
1018
+ return Fr.fromString(await this.rollup.read.archiveAt([
1019
+ BigInt(checkpointNumber)
1020
+ ]));
1021
+ }
1022
+ getSequencerRewards(address) {
1023
+ if (address instanceof EthAddress) {
1024
+ address = address.toString();
1025
+ }
1026
+ return this.rollup.read.getSequencerRewards([
1027
+ address
208
1028
  ]);
209
1029
  }
1030
+ getSpecificProverRewardsForEpoch(epoch, prover) {
1031
+ if (prover instanceof EthAddress) {
1032
+ prover = prover.toString();
1033
+ }
1034
+ return this.rollup.read.getSpecificProverRewardsForEpoch([
1035
+ epoch,
1036
+ prover
1037
+ ]);
1038
+ }
1039
+ async getAttesters() {
1040
+ const attesterSize = await this.getActiveAttesterCount();
1041
+ const gse = new GSEContract(this.client, await this.getGSE());
1042
+ const ts = (await this.client.getBlock()).timestamp;
1043
+ const indices = Array.from({
1044
+ length: attesterSize
1045
+ }, (_, i)=>BigInt(i));
1046
+ const chunks = chunk(indices, 1000);
1047
+ const results = await Promise.all(chunks.map((chunk)=>gse.getAttestersFromIndicesAtTime(this.address, ts, chunk)));
1048
+ return results.flat().map((addr)=>EthAddress.fromString(addr));
1049
+ }
1050
+ async getAttesterView(address) {
1051
+ if (address instanceof EthAddress) {
1052
+ address = address.toString();
1053
+ }
1054
+ const result = await this.rollup.read.getAttesterView([
1055
+ address
1056
+ ]);
1057
+ return {
1058
+ status: result.status,
1059
+ effectiveBalance: result.effectiveBalance,
1060
+ exit: {
1061
+ withdrawalId: result.exit.withdrawalId,
1062
+ amount: result.exit.amount,
1063
+ exitableAt: result.exit.exitableAt,
1064
+ recipientOrWithdrawer: EthAddress.fromString(result.exit.recipientOrWithdrawer),
1065
+ isRecipient: result.exit.isRecipient,
1066
+ exists: result.exit.exists
1067
+ },
1068
+ config: {
1069
+ publicKey: {
1070
+ x: result.config.publicKey.x,
1071
+ y: result.config.publicKey.y
1072
+ },
1073
+ withdrawer: EthAddress.fromString(result.config.withdrawer)
1074
+ }
1075
+ };
1076
+ }
1077
+ async getStatus(address) {
1078
+ if (address instanceof EthAddress) {
1079
+ address = address.toString();
1080
+ }
1081
+ return await this.rollup.read.getStatus([
1082
+ address
1083
+ ]);
1084
+ }
1085
+ async getBlobCommitmentsHash(checkpointNumber) {
1086
+ return Buffer32.fromString(await this.rollup.read.getBlobCommitmentsHash([
1087
+ BigInt(checkpointNumber)
1088
+ ]));
1089
+ }
1090
+ async getCurrentBlobCommitmentsHash() {
1091
+ return Buffer32.fromString(await this.rollup.read.getCurrentBlobCommitmentsHash());
1092
+ }
1093
+ async getStakingAsset() {
1094
+ return EthAddress.fromString(await this.rollup.read.getStakingAsset());
1095
+ }
1096
+ async getRewardConfig() {
1097
+ const result = await this.rollup.read.getRewardConfig();
1098
+ return {
1099
+ rewardDistributor: EthAddress.fromString(result.rewardDistributor),
1100
+ sequencerBps: BigInt(result.sequencerBps),
1101
+ booster: EthAddress.fromString(result.booster),
1102
+ checkpointReward: result.checkpointReward
1103
+ };
1104
+ }
1105
+ setupEpoch(l1TxUtils) {
1106
+ return l1TxUtils.sendAndMonitorTransaction({
1107
+ to: this.address,
1108
+ data: encodeFunctionData({
1109
+ abi: RollupAbi,
1110
+ functionName: 'setupEpoch',
1111
+ args: []
1112
+ })
1113
+ });
1114
+ }
1115
+ vote(l1TxUtils, proposalId) {
1116
+ return l1TxUtils.sendAndMonitorTransaction({
1117
+ to: this.address,
1118
+ data: encodeFunctionData({
1119
+ abi: RollupAbi,
1120
+ functionName: 'vote',
1121
+ args: [
1122
+ proposalId
1123
+ ]
1124
+ })
1125
+ });
1126
+ }
1127
+ listenToSlasherChanged(callback) {
1128
+ return this.rollup.watchEvent.SlasherUpdated({}, {
1129
+ onLogs: (logs)=>{
1130
+ for (const log of logs){
1131
+ const args = log.args;
1132
+ if (args.oldSlasher && args.newSlasher) {
1133
+ callback(args);
1134
+ }
1135
+ }
1136
+ }
1137
+ });
1138
+ }
1139
+ listenToCheckpointInvalidated(callback) {
1140
+ return this.rollup.watchEvent.CheckpointInvalidated({}, {
1141
+ onLogs: (logs)=>{
1142
+ for (const log of logs){
1143
+ const args = log.args;
1144
+ if (args.checkpointNumber !== undefined) {
1145
+ callback({
1146
+ checkpointNumber: CheckpointNumber.fromBigInt(args.checkpointNumber)
1147
+ });
1148
+ }
1149
+ }
1150
+ }
1151
+ });
1152
+ }
1153
+ async getSlashEvents(l1BlockHash) {
1154
+ const events = await this.rollup.getEvents.Slashed({}, {
1155
+ blockHash: l1BlockHash,
1156
+ strict: true
1157
+ });
1158
+ return events.map((event)=>({
1159
+ amount: event.args.amount,
1160
+ attester: EthAddress.fromString(event.args.attester)
1161
+ }));
1162
+ }
1163
+ listenToSlash(callback) {
1164
+ return this.rollup.watchEvent.Slashed({}, {
1165
+ strict: true,
1166
+ onLogs: (logs)=>{
1167
+ for (const log of logs){
1168
+ const args = log.args;
1169
+ callback({
1170
+ amount: args.amount,
1171
+ attester: EthAddress.fromString(args.attester)
1172
+ });
1173
+ }
1174
+ }
1175
+ });
1176
+ }
210
1177
  }
211
- _ts_decorate([
212
- memoize
213
- ], RollupContract.prototype, "getSlashingProposer", null);
214
- _ts_decorate([
215
- memoize
216
- ], RollupContract.prototype, "getL1StartBlock", null);
217
- _ts_decorate([
218
- memoize
219
- ], RollupContract.prototype, "getL1GenesisTime", null);
220
- _ts_decorate([
221
- memoize
222
- ], RollupContract.prototype, "getProofSubmissionWindow", null);
223
- _ts_decorate([
224
- memoize
225
- ], RollupContract.prototype, "getEpochDuration", null);
226
- _ts_decorate([
227
- memoize
228
- ], RollupContract.prototype, "getSlotDuration", null);
229
- _ts_decorate([
230
- memoize
231
- ], RollupContract.prototype, "getTargetCommitteeSize", null);
232
- _ts_decorate([
233
- memoize
234
- ], RollupContract.prototype, "getMinimumStake", null);