@aztec/ethereum 0.0.0-test.1 → 0.0.1-commit.017a351
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/account.d.ts +2 -0
- package/dest/account.d.ts.map +1 -0
- package/dest/account.js +4 -0
- package/dest/chain.d.ts +1 -1
- package/dest/client.d.ts +28 -4
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +73 -3
- package/dest/config.d.ts +70 -23
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +151 -34
- package/dest/constants.d.ts +1 -1
- package/dest/contracts/chain_state_override.d.ts +78 -0
- package/dest/contracts/chain_state_override.d.ts.map +1 -0
- package/dest/contracts/chain_state_override.js +137 -0
- package/dest/contracts/empire_base.d.ts +25 -8
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_base.js +75 -2
- package/dest/contracts/errors.d.ts +7 -0
- package/dest/contracts/errors.d.ts.map +1 -0
- package/dest/contracts/errors.js +12 -0
- package/dest/contracts/fee_asset_handler.d.ts +20 -0
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -0
- package/dest/contracts/fee_asset_handler.js +59 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts +105 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
- package/dest/contracts/fee_asset_price_oracle.js +656 -0
- package/dest/contracts/fee_juice.d.ts +6 -7
- package/dest/contracts/fee_juice.d.ts.map +1 -1
- package/dest/contracts/fee_juice.js +27 -20
- package/dest/contracts/governance.d.ts +131 -43
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +281 -87
- package/dest/contracts/governance_proposer.d.ts +49 -13
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +483 -26
- package/dest/contracts/gse.d.ts +32 -0
- package/dest/contracts/gse.d.ts.map +1 -0
- package/dest/contracts/gse.js +72 -0
- package/dest/contracts/inbox.d.ts +47 -0
- package/dest/contracts/inbox.d.ts.map +1 -0
- package/dest/contracts/inbox.js +85 -0
- package/dest/contracts/index.d.ts +11 -2
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +10 -1
- package/dest/contracts/log.d.ts +13 -0
- package/dest/contracts/log.d.ts.map +1 -0
- package/dest/contracts/log.js +1 -0
- package/dest/contracts/multicall.d.ts +136 -0
- package/dest/contracts/multicall.d.ts.map +1 -0
- package/dest/contracts/multicall.js +264 -0
- package/dest/contracts/outbox.d.ts +64 -0
- package/dest/contracts/outbox.d.ts.map +1 -0
- package/dest/contracts/outbox.js +113 -0
- package/dest/contracts/registry.d.ts +12 -5
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +74 -17
- package/dest/contracts/rollup.d.ts +5526 -52
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +1446 -118
- package/dest/contracts/slasher_contract.d.ts +44 -0
- package/dest/contracts/slasher_contract.d.ts.map +1 -0
- package/dest/contracts/slasher_contract.js +75 -0
- package/dest/contracts/slashing_proposer.d.ts +133 -15
- package/dest/contracts/slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/slashing_proposer.js +293 -22
- package/dest/contracts/utils.d.ts +3 -0
- package/dest/contracts/utils.d.ts.map +1 -0
- package/dest/contracts/utils.js +11 -0
- package/dest/deploy_aztec_l1_contracts.d.ts +256 -0
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
- package/dest/deploy_aztec_l1_contracts.js +411 -0
- package/dest/deploy_l1_contract.d.ts +68 -0
- package/dest/deploy_l1_contract.d.ts.map +1 -0
- package/dest/deploy_l1_contract.js +312 -0
- package/dest/eth-signer/eth-signer.d.ts +21 -0
- package/dest/eth-signer/eth-signer.d.ts.map +1 -0
- package/dest/eth-signer/eth-signer.js +5 -0
- package/dest/eth-signer/index.d.ts +2 -0
- package/dest/eth-signer/index.d.ts.map +1 -0
- package/dest/eth-signer/index.js +1 -0
- package/dest/forwarder_proxy.d.ts +32 -0
- package/dest/forwarder_proxy.d.ts.map +1 -0
- package/dest/forwarder_proxy.js +93 -0
- package/dest/generated/l1-contracts-defaults.d.ts +30 -0
- package/dest/generated/l1-contracts-defaults.d.ts.map +1 -0
- package/dest/generated/l1-contracts-defaults.js +30 -0
- package/dest/l1_artifacts.d.ts +79270 -0
- package/dest/l1_artifacts.d.ts.map +1 -0
- package/dest/l1_artifacts.js +151 -0
- package/dest/l1_contract_addresses.d.ts +61 -45
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +99 -76
- package/dest/l1_reader.d.ts +8 -6
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +20 -12
- package/dest/l1_tx_utils/config.d.ts +65 -0
- package/dest/l1_tx_utils/config.d.ts.map +1 -0
- package/dest/l1_tx_utils/config.js +109 -0
- package/dest/l1_tx_utils/constants.d.ts +12 -0
- package/dest/l1_tx_utils/constants.d.ts.map +1 -0
- package/dest/l1_tx_utils/constants.js +39 -0
- package/dest/l1_tx_utils/factory.d.ts +32 -0
- package/dest/l1_tx_utils/factory.d.ts.map +1 -0
- package/dest/l1_tx_utils/factory.js +22 -0
- package/dest/l1_tx_utils/fee-strategies/index.d.ts +10 -0
- package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +129 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +191 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/types.js +3 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +41 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +42 -0
- package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
- package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
- package/dest/l1_tx_utils/index-blobs.js +2 -0
- package/dest/l1_tx_utils/index.d.ts +13 -0
- package/dest/l1_tx_utils/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/index.js +13 -0
- package/dest/l1_tx_utils/interfaces.d.ts +76 -0
- package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
- package/dest/l1_tx_utils/interfaces.js +4 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +113 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_tx_utils.js +658 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +83 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +328 -0
- package/dest/l1_tx_utils/signer.d.ts +4 -0
- package/dest/l1_tx_utils/signer.d.ts.map +1 -0
- package/dest/l1_tx_utils/signer.js +16 -0
- package/dest/l1_tx_utils/tx_delayer.d.ts +58 -0
- package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
- package/dest/l1_tx_utils/tx_delayer.js +223 -0
- package/dest/l1_tx_utils/types.d.ts +67 -0
- package/dest/l1_tx_utils/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/types.js +26 -0
- package/dest/l1_tx_utils/utils.d.ts +4 -0
- package/dest/l1_tx_utils/utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/utils.js +14 -0
- package/dest/l1_types.d.ts +6 -0
- package/dest/l1_types.d.ts.map +1 -0
- package/dest/l1_types.js +1 -0
- package/dest/publisher_manager.d.ts +30 -0
- package/dest/publisher_manager.d.ts.map +1 -0
- package/dest/publisher_manager.js +162 -0
- package/dest/queries.d.ts +17 -4
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +120 -12
- package/dest/test/chain_monitor.d.ts +95 -0
- package/dest/test/chain_monitor.d.ts.map +1 -0
- package/dest/test/chain_monitor.js +249 -0
- package/dest/test/eth_cheat_codes.d.ts +237 -0
- package/dest/test/eth_cheat_codes.d.ts.map +1 -0
- package/dest/test/eth_cheat_codes.js +573 -0
- package/dest/test/eth_cheat_codes_with_state.d.ts +2 -2
- package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes_with_state.js +1 -1
- package/dest/test/index.d.ts +4 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +3 -2
- package/dest/test/rollup_cheat_codes.d.ts +118 -0
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
- package/dest/test/rollup_cheat_codes.js +344 -0
- package/dest/test/start_anvil.d.ts +30 -2
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +147 -24
- package/dest/test/upgrade_utils.d.ts +6 -5
- package/dest/test/upgrade_utils.d.ts.map +1 -1
- package/dest/test/upgrade_utils.js +23 -16
- package/dest/types.d.ts +62 -8
- package/dest/types.d.ts.map +1 -1
- package/dest/types.js +3 -1
- package/dest/utils.d.ts +25 -4
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +142 -91
- package/dest/zkPassportVerifierAddress.d.ts +15 -0
- package/dest/zkPassportVerifierAddress.d.ts.map +1 -0
- package/dest/zkPassportVerifierAddress.js +11 -0
- package/package.json +52 -26
- package/src/account.ts +5 -0
- package/src/client.ts +107 -5
- package/src/config.ts +218 -43
- package/src/contracts/README.md +157 -0
- package/src/contracts/chain_state_override.ts +200 -0
- package/src/contracts/empire_base.ts +77 -7
- package/src/contracts/errors.ts +13 -0
- package/src/contracts/fee_asset_handler.ts +66 -0
- package/src/contracts/fee_asset_price_oracle.ts +285 -0
- package/src/contracts/fee_juice.ts +29 -15
- package/src/contracts/governance.ts +343 -74
- package/src/contracts/governance_proposer.ts +128 -25
- package/src/contracts/gse.ts +88 -0
- package/src/contracts/inbox.ts +123 -0
- package/src/contracts/index.ts +10 -1
- package/src/contracts/log.ts +13 -0
- package/src/contracts/multicall.ts +296 -0
- package/src/contracts/outbox.ts +132 -0
- package/src/contracts/registry.ts +81 -26
- package/src/contracts/rollup.ts +1246 -90
- package/src/contracts/slasher_contract.ts +89 -0
- package/src/contracts/slashing_proposer.ts +296 -27
- package/src/contracts/utils.ts +14 -0
- package/src/deploy_aztec_l1_contracts.ts +646 -0
- package/src/deploy_l1_contract.ts +362 -0
- package/src/eth-signer/eth-signer.ts +25 -0
- package/src/eth-signer/index.ts +1 -0
- package/src/forwarder_proxy.ts +108 -0
- package/src/generated/l1-contracts-defaults.ts +32 -0
- package/src/l1_artifacts.ts +231 -0
- package/src/l1_contract_addresses.ts +121 -80
- package/src/l1_reader.ts +31 -16
- package/src/l1_tx_utils/README.md +177 -0
- package/src/l1_tx_utils/config.ts +181 -0
- package/src/l1_tx_utils/constants.ts +29 -0
- package/src/l1_tx_utils/factory.ts +64 -0
- package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +163 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +245 -0
- package/src/l1_tx_utils/fee-strategies/types.ts +56 -0
- package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +108 -0
- package/src/l1_tx_utils/index-blobs.ts +2 -0
- package/src/l1_tx_utils/index.ts +15 -0
- package/src/l1_tx_utils/interfaces.ts +86 -0
- package/src/l1_tx_utils/l1_fee_analyzer.ts +803 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +789 -0
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +424 -0
- package/src/l1_tx_utils/signer.ts +28 -0
- package/src/l1_tx_utils/tx_delayer.ts +303 -0
- package/src/l1_tx_utils/types.ts +85 -0
- package/src/l1_tx_utils/utils.ts +16 -0
- package/src/l1_types.ts +6 -0
- package/src/publisher_manager.ts +203 -0
- package/src/queries.ts +149 -17
- package/src/test/chain_monitor.ts +307 -0
- package/src/test/eth_cheat_codes.ts +600 -0
- package/src/test/eth_cheat_codes_with_state.ts +1 -1
- package/src/test/index.ts +3 -2
- package/src/test/rollup_cheat_codes.ts +388 -0
- package/src/test/start_anvil.ts +189 -22
- package/src/test/upgrade_utils.ts +30 -21
- package/src/types.ts +71 -7
- package/src/utils.ts +164 -96
- package/src/zkPassportVerifierAddress.ts +15 -0
- package/dest/contracts/forwarder.d.ts +0 -24
- package/dest/contracts/forwarder.d.ts.map +0 -1
- package/dest/contracts/forwarder.js +0 -101
- package/dest/deploy_l1_contracts.d.ts +0 -21210
- package/dest/deploy_l1_contracts.d.ts.map +0 -1
- package/dest/deploy_l1_contracts.js +0 -687
- package/dest/eth_cheat_codes.d.ts +0 -147
- package/dest/eth_cheat_codes.d.ts.map +0 -1
- package/dest/eth_cheat_codes.js +0 -303
- package/dest/index.d.ts +0 -14
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -13
- package/dest/l1_tx_utils.d.ts +0 -192
- package/dest/l1_tx_utils.d.ts.map +0 -1
- package/dest/l1_tx_utils.js +0 -641
- package/dest/l1_tx_utils_with_blobs.d.ts +0 -12
- package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils_with_blobs.js +0 -64
- package/dest/test/delayed_tx_utils.d.ts +0 -8
- package/dest/test/delayed_tx_utils.d.ts.map +0 -1
- package/dest/test/delayed_tx_utils.js +0 -21
- package/dest/test/tx_delayer.d.ts +0 -25
- package/dest/test/tx_delayer.d.ts.map +0 -1
- package/dest/test/tx_delayer.js +0 -116
- package/src/contracts/forwarder.ts +0 -132
- package/src/deploy_l1_contracts.ts +0 -948
- package/src/eth_cheat_codes.ts +0 -314
- package/src/index.ts +0 -13
- package/src/l1_tx_utils.ts +0 -847
- package/src/l1_tx_utils_with_blobs.ts +0 -86
- package/src/test/delayed_tx_utils.ts +0 -24
- package/src/test/tx_delayer.ts +0 -163
package/dest/contracts/rollup.js
CHANGED
|
@@ -1,19 +1,551 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
function applyDecs2203RFactory() {
|
|
2
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
3
|
+
return function addInitializer(initializer) {
|
|
4
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
5
|
+
assertCallable(initializer, "An initializer");
|
|
6
|
+
initializers.push(initializer);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
10
|
+
var kindStr;
|
|
11
|
+
switch(kind){
|
|
12
|
+
case 1:
|
|
13
|
+
kindStr = "accessor";
|
|
14
|
+
break;
|
|
15
|
+
case 2:
|
|
16
|
+
kindStr = "method";
|
|
17
|
+
break;
|
|
18
|
+
case 3:
|
|
19
|
+
kindStr = "getter";
|
|
20
|
+
break;
|
|
21
|
+
case 4:
|
|
22
|
+
kindStr = "setter";
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
kindStr = "field";
|
|
26
|
+
}
|
|
27
|
+
var ctx = {
|
|
28
|
+
kind: kindStr,
|
|
29
|
+
name: isPrivate ? "#" + name : name,
|
|
30
|
+
static: isStatic,
|
|
31
|
+
private: isPrivate,
|
|
32
|
+
metadata: metadata
|
|
33
|
+
};
|
|
34
|
+
var decoratorFinishedRef = {
|
|
35
|
+
v: false
|
|
36
|
+
};
|
|
37
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
38
|
+
var get, set;
|
|
39
|
+
if (kind === 0) {
|
|
40
|
+
if (isPrivate) {
|
|
41
|
+
get = desc.get;
|
|
42
|
+
set = desc.set;
|
|
43
|
+
} else {
|
|
44
|
+
get = function() {
|
|
45
|
+
return this[name];
|
|
46
|
+
};
|
|
47
|
+
set = function(v) {
|
|
48
|
+
this[name] = v;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
} else if (kind === 2) {
|
|
52
|
+
get = function() {
|
|
53
|
+
return desc.value;
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
if (kind === 1 || kind === 3) {
|
|
57
|
+
get = function() {
|
|
58
|
+
return desc.get.call(this);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (kind === 1 || kind === 4) {
|
|
62
|
+
set = function(v) {
|
|
63
|
+
desc.set.call(this, v);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
ctx.access = get && set ? {
|
|
68
|
+
get: get,
|
|
69
|
+
set: set
|
|
70
|
+
} : get ? {
|
|
71
|
+
get: get
|
|
72
|
+
} : {
|
|
73
|
+
set: set
|
|
74
|
+
};
|
|
75
|
+
try {
|
|
76
|
+
return dec(value, ctx);
|
|
77
|
+
} finally{
|
|
78
|
+
decoratorFinishedRef.v = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
82
|
+
if (decoratorFinishedRef.v) {
|
|
83
|
+
throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function assertCallable(fn, hint) {
|
|
87
|
+
if (typeof fn !== "function") {
|
|
88
|
+
throw new TypeError(hint + " must be a function");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function assertValidReturnValue(kind, value) {
|
|
92
|
+
var type = typeof value;
|
|
93
|
+
if (kind === 1) {
|
|
94
|
+
if (type !== "object" || value === null) {
|
|
95
|
+
throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
96
|
+
}
|
|
97
|
+
if (value.get !== undefined) {
|
|
98
|
+
assertCallable(value.get, "accessor.get");
|
|
99
|
+
}
|
|
100
|
+
if (value.set !== undefined) {
|
|
101
|
+
assertCallable(value.set, "accessor.set");
|
|
102
|
+
}
|
|
103
|
+
if (value.init !== undefined) {
|
|
104
|
+
assertCallable(value.init, "accessor.init");
|
|
105
|
+
}
|
|
106
|
+
} else if (type !== "function") {
|
|
107
|
+
var hint;
|
|
108
|
+
if (kind === 0) {
|
|
109
|
+
hint = "field";
|
|
110
|
+
} else if (kind === 10) {
|
|
111
|
+
hint = "class";
|
|
112
|
+
} else {
|
|
113
|
+
hint = "method";
|
|
114
|
+
}
|
|
115
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
119
|
+
var decs = decInfo[0];
|
|
120
|
+
var desc, init, value;
|
|
121
|
+
if (isPrivate) {
|
|
122
|
+
if (kind === 0 || kind === 1) {
|
|
123
|
+
desc = {
|
|
124
|
+
get: decInfo[3],
|
|
125
|
+
set: decInfo[4]
|
|
126
|
+
};
|
|
127
|
+
} else if (kind === 3) {
|
|
128
|
+
desc = {
|
|
129
|
+
get: decInfo[3]
|
|
130
|
+
};
|
|
131
|
+
} else if (kind === 4) {
|
|
132
|
+
desc = {
|
|
133
|
+
set: decInfo[3]
|
|
134
|
+
};
|
|
135
|
+
} else {
|
|
136
|
+
desc = {
|
|
137
|
+
value: decInfo[3]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
} else if (kind !== 0) {
|
|
141
|
+
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
142
|
+
}
|
|
143
|
+
if (kind === 1) {
|
|
144
|
+
value = {
|
|
145
|
+
get: desc.get,
|
|
146
|
+
set: desc.set
|
|
147
|
+
};
|
|
148
|
+
} else if (kind === 2) {
|
|
149
|
+
value = desc.value;
|
|
150
|
+
} else if (kind === 3) {
|
|
151
|
+
value = desc.get;
|
|
152
|
+
} else if (kind === 4) {
|
|
153
|
+
value = desc.set;
|
|
154
|
+
}
|
|
155
|
+
var newValue, get, set;
|
|
156
|
+
if (typeof decs === "function") {
|
|
157
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
158
|
+
if (newValue !== void 0) {
|
|
159
|
+
assertValidReturnValue(kind, newValue);
|
|
160
|
+
if (kind === 0) {
|
|
161
|
+
init = newValue;
|
|
162
|
+
} else if (kind === 1) {
|
|
163
|
+
init = newValue.init;
|
|
164
|
+
get = newValue.get || value.get;
|
|
165
|
+
set = newValue.set || value.set;
|
|
166
|
+
value = {
|
|
167
|
+
get: get,
|
|
168
|
+
set: set
|
|
169
|
+
};
|
|
170
|
+
} else {
|
|
171
|
+
value = newValue;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
for(var i = decs.length - 1; i >= 0; i--){
|
|
176
|
+
var dec = decs[i];
|
|
177
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
178
|
+
if (newValue !== void 0) {
|
|
179
|
+
assertValidReturnValue(kind, newValue);
|
|
180
|
+
var newInit;
|
|
181
|
+
if (kind === 0) {
|
|
182
|
+
newInit = newValue;
|
|
183
|
+
} else if (kind === 1) {
|
|
184
|
+
newInit = newValue.init;
|
|
185
|
+
get = newValue.get || value.get;
|
|
186
|
+
set = newValue.set || value.set;
|
|
187
|
+
value = {
|
|
188
|
+
get: get,
|
|
189
|
+
set: set
|
|
190
|
+
};
|
|
191
|
+
} else {
|
|
192
|
+
value = newValue;
|
|
193
|
+
}
|
|
194
|
+
if (newInit !== void 0) {
|
|
195
|
+
if (init === void 0) {
|
|
196
|
+
init = newInit;
|
|
197
|
+
} else if (typeof init === "function") {
|
|
198
|
+
init = [
|
|
199
|
+
init,
|
|
200
|
+
newInit
|
|
201
|
+
];
|
|
202
|
+
} else {
|
|
203
|
+
init.push(newInit);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (kind === 0 || kind === 1) {
|
|
210
|
+
if (init === void 0) {
|
|
211
|
+
init = function(instance, init) {
|
|
212
|
+
return init;
|
|
213
|
+
};
|
|
214
|
+
} else if (typeof init !== "function") {
|
|
215
|
+
var ownInitializers = init;
|
|
216
|
+
init = function(instance, init) {
|
|
217
|
+
var value = init;
|
|
218
|
+
for(var i = 0; i < ownInitializers.length; i++){
|
|
219
|
+
value = ownInitializers[i].call(instance, value);
|
|
220
|
+
}
|
|
221
|
+
return value;
|
|
222
|
+
};
|
|
223
|
+
} else {
|
|
224
|
+
var originalInitializer = init;
|
|
225
|
+
init = function(instance, init) {
|
|
226
|
+
return originalInitializer.call(instance, init);
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
ret.push(init);
|
|
230
|
+
}
|
|
231
|
+
if (kind !== 0) {
|
|
232
|
+
if (kind === 1) {
|
|
233
|
+
desc.get = value.get;
|
|
234
|
+
desc.set = value.set;
|
|
235
|
+
} else if (kind === 2) {
|
|
236
|
+
desc.value = value;
|
|
237
|
+
} else if (kind === 3) {
|
|
238
|
+
desc.get = value;
|
|
239
|
+
} else if (kind === 4) {
|
|
240
|
+
desc.set = value;
|
|
241
|
+
}
|
|
242
|
+
if (isPrivate) {
|
|
243
|
+
if (kind === 1) {
|
|
244
|
+
ret.push(function(instance, args) {
|
|
245
|
+
return value.get.call(instance, args);
|
|
246
|
+
});
|
|
247
|
+
ret.push(function(instance, args) {
|
|
248
|
+
return value.set.call(instance, args);
|
|
249
|
+
});
|
|
250
|
+
} else if (kind === 2) {
|
|
251
|
+
ret.push(value);
|
|
252
|
+
} else {
|
|
253
|
+
ret.push(function(instance, args) {
|
|
254
|
+
return value.call(instance, args);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
Object.defineProperty(base, name, desc);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
263
|
+
var ret = [];
|
|
264
|
+
var protoInitializers;
|
|
265
|
+
var staticInitializers;
|
|
266
|
+
var existingProtoNonFields = new Map();
|
|
267
|
+
var existingStaticNonFields = new Map();
|
|
268
|
+
for(var i = 0; i < decInfos.length; i++){
|
|
269
|
+
var decInfo = decInfos[i];
|
|
270
|
+
if (!Array.isArray(decInfo)) continue;
|
|
271
|
+
var kind = decInfo[1];
|
|
272
|
+
var name = decInfo[2];
|
|
273
|
+
var isPrivate = decInfo.length > 3;
|
|
274
|
+
var isStatic = kind >= 5;
|
|
275
|
+
var base;
|
|
276
|
+
var initializers;
|
|
277
|
+
if (isStatic) {
|
|
278
|
+
base = Class;
|
|
279
|
+
kind = kind - 5;
|
|
280
|
+
staticInitializers = staticInitializers || [];
|
|
281
|
+
initializers = staticInitializers;
|
|
282
|
+
} else {
|
|
283
|
+
base = Class.prototype;
|
|
284
|
+
protoInitializers = protoInitializers || [];
|
|
285
|
+
initializers = protoInitializers;
|
|
286
|
+
}
|
|
287
|
+
if (kind !== 0 && !isPrivate) {
|
|
288
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
289
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
290
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
|
|
291
|
+
throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
292
|
+
} else if (!existingKind && kind > 2) {
|
|
293
|
+
existingNonFields.set(name, kind);
|
|
294
|
+
} else {
|
|
295
|
+
existingNonFields.set(name, true);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
299
|
+
}
|
|
300
|
+
pushInitializers(ret, protoInitializers);
|
|
301
|
+
pushInitializers(ret, staticInitializers);
|
|
302
|
+
return ret;
|
|
303
|
+
}
|
|
304
|
+
function pushInitializers(ret, initializers) {
|
|
305
|
+
if (initializers) {
|
|
306
|
+
ret.push(function(instance) {
|
|
307
|
+
for(var i = 0; i < initializers.length; i++){
|
|
308
|
+
initializers[i].call(instance);
|
|
309
|
+
}
|
|
310
|
+
return instance;
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
315
|
+
if (classDecs.length > 0) {
|
|
316
|
+
var initializers = [];
|
|
317
|
+
var newClass = targetClass;
|
|
318
|
+
var name = targetClass.name;
|
|
319
|
+
for(var i = classDecs.length - 1; i >= 0; i--){
|
|
320
|
+
var decoratorFinishedRef = {
|
|
321
|
+
v: false
|
|
322
|
+
};
|
|
323
|
+
try {
|
|
324
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
325
|
+
kind: "class",
|
|
326
|
+
name: name,
|
|
327
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
328
|
+
metadata
|
|
329
|
+
});
|
|
330
|
+
} finally{
|
|
331
|
+
decoratorFinishedRef.v = true;
|
|
332
|
+
}
|
|
333
|
+
if (nextNewClass !== undefined) {
|
|
334
|
+
assertValidReturnValue(10, nextNewClass);
|
|
335
|
+
newClass = nextNewClass;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return [
|
|
339
|
+
defineMetadata(newClass, metadata),
|
|
340
|
+
function() {
|
|
341
|
+
for(var i = 0; i < initializers.length; i++){
|
|
342
|
+
initializers[i].call(newClass);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
];
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function defineMetadata(Class, metadata) {
|
|
349
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
350
|
+
configurable: true,
|
|
351
|
+
enumerable: true,
|
|
352
|
+
value: metadata
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
356
|
+
if (parentClass !== void 0) {
|
|
357
|
+
var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
358
|
+
}
|
|
359
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
360
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
361
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
362
|
+
return {
|
|
363
|
+
e: e,
|
|
364
|
+
get c () {
|
|
365
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
};
|
|
6
369
|
}
|
|
370
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
371
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
372
|
+
}
|
|
373
|
+
var _initProto;
|
|
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 {
|
|
10
|
-
import {
|
|
379
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
380
|
+
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
381
|
+
import { getErrorCause } from '@aztec/foundation/types';
|
|
382
|
+
import { EscapeHatchAbi } from '@aztec/l1-artifacts/EscapeHatchAbi';
|
|
383
|
+
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
384
|
+
import { RollupStorage } from '@aztec/l1-artifacts/RollupStorage';
|
|
385
|
+
import chunk from 'lodash.chunk';
|
|
386
|
+
import { ContractFunctionRevertedError, RpcRequestError, decodeErrorResult, encodeAbiParameters, encodeFunctionData, getContract, hexToBigInt, keccak256 } from 'viem';
|
|
11
387
|
import { getPublicClient } from '../client.js';
|
|
12
388
|
import { formatViemError } from '../utils.js';
|
|
389
|
+
import { GSEContract } from './gse.js';
|
|
390
|
+
import { SlasherContract } from './slasher_contract.js';
|
|
13
391
|
import { SlashingProposerContract } from './slashing_proposer.js';
|
|
392
|
+
import { checkBlockTag } from './utils.js';
|
|
393
|
+
/**
|
|
394
|
+
* Status of a validator/attester in the staking system.
|
|
395
|
+
* Matches the Status enum in StakingLib.sol
|
|
396
|
+
*/ export var AttesterStatus = /*#__PURE__*/ function(AttesterStatus) {
|
|
397
|
+
AttesterStatus[AttesterStatus["NONE"] = 0] = "NONE";
|
|
398
|
+
AttesterStatus[AttesterStatus["VALIDATING"] = 1] = "VALIDATING";
|
|
399
|
+
AttesterStatus[AttesterStatus["ZOMBIE"] = 2] = "ZOMBIE";
|
|
400
|
+
AttesterStatus[AttesterStatus["EXITING"] = 3] = "EXITING";
|
|
401
|
+
return AttesterStatus;
|
|
402
|
+
}({});
|
|
403
|
+
/** Field offsets within the CompressedTempCheckpointLog struct in Solidity storage. */ export var TempCheckpointLogField = /*#__PURE__*/ function(TempCheckpointLogField) {
|
|
404
|
+
TempCheckpointLogField[TempCheckpointLogField["HeaderHash"] = 0] = "HeaderHash";
|
|
405
|
+
TempCheckpointLogField[TempCheckpointLogField["BlobCommitmentsHash"] = 1] = "BlobCommitmentsHash";
|
|
406
|
+
TempCheckpointLogField[TempCheckpointLogField["OutHash"] = 2] = "OutHash";
|
|
407
|
+
TempCheckpointLogField[TempCheckpointLogField["AttestationsHash"] = 3] = "AttestationsHash";
|
|
408
|
+
TempCheckpointLogField[TempCheckpointLogField["PayloadDigest"] = 4] = "PayloadDigest";
|
|
409
|
+
TempCheckpointLogField[TempCheckpointLogField["SlotNumber"] = 5] = "SlotNumber";
|
|
410
|
+
TempCheckpointLogField[TempCheckpointLogField["FeeHeader"] = 6] = "FeeHeader";
|
|
411
|
+
return TempCheckpointLogField;
|
|
412
|
+
}({});
|
|
413
|
+
const INSUFFICIENT_VALIDATOR_SET_SIZE_ERROR = 'ValidatorSelection__InsufficientValidatorSetSize';
|
|
414
|
+
function isValidatorSelectionError(err, errorName) {
|
|
415
|
+
return getErrorCause(err, ContractFunctionRevertedError)?.data?.errorName === errorName || decodeRpcRequestErrorName(err) === errorName;
|
|
416
|
+
}
|
|
417
|
+
function decodeRpcRequestErrorName(err) {
|
|
418
|
+
const data = getErrorCause(err, RpcRequestError)?.data;
|
|
419
|
+
if (!isHexString(data)) {
|
|
420
|
+
return undefined;
|
|
421
|
+
}
|
|
422
|
+
try {
|
|
423
|
+
return decodeErrorResult({
|
|
424
|
+
abi: RollupAbi,
|
|
425
|
+
data
|
|
426
|
+
}).errorName;
|
|
427
|
+
} catch {
|
|
428
|
+
return undefined;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
function isHexString(value) {
|
|
432
|
+
return typeof value === 'string' && value.startsWith('0x');
|
|
433
|
+
}
|
|
14
434
|
export class RollupContract {
|
|
15
435
|
client;
|
|
436
|
+
static{
|
|
437
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
438
|
+
[
|
|
439
|
+
memoize,
|
|
440
|
+
2,
|
|
441
|
+
"getL1StartBlock"
|
|
442
|
+
],
|
|
443
|
+
[
|
|
444
|
+
memoize,
|
|
445
|
+
2,
|
|
446
|
+
"getL1GenesisTime"
|
|
447
|
+
],
|
|
448
|
+
[
|
|
449
|
+
memoize,
|
|
450
|
+
2,
|
|
451
|
+
"getProofSubmissionEpochs"
|
|
452
|
+
],
|
|
453
|
+
[
|
|
454
|
+
memoize,
|
|
455
|
+
2,
|
|
456
|
+
"getEpochDuration"
|
|
457
|
+
],
|
|
458
|
+
[
|
|
459
|
+
memoize,
|
|
460
|
+
2,
|
|
461
|
+
"getSlotDuration"
|
|
462
|
+
],
|
|
463
|
+
[
|
|
464
|
+
memoize,
|
|
465
|
+
2,
|
|
466
|
+
"getTargetCommitteeSize"
|
|
467
|
+
],
|
|
468
|
+
[
|
|
469
|
+
memoize,
|
|
470
|
+
2,
|
|
471
|
+
"getEjectionThreshold"
|
|
472
|
+
],
|
|
473
|
+
[
|
|
474
|
+
memoize,
|
|
475
|
+
2,
|
|
476
|
+
"getLocalEjectionThreshold"
|
|
477
|
+
],
|
|
478
|
+
[
|
|
479
|
+
memoize,
|
|
480
|
+
2,
|
|
481
|
+
"getLagInEpochsForValidatorSet"
|
|
482
|
+
],
|
|
483
|
+
[
|
|
484
|
+
memoize,
|
|
485
|
+
2,
|
|
486
|
+
"getLagInEpochsForRandao"
|
|
487
|
+
],
|
|
488
|
+
[
|
|
489
|
+
memoize,
|
|
490
|
+
2,
|
|
491
|
+
"getActivationThreshold"
|
|
492
|
+
],
|
|
493
|
+
[
|
|
494
|
+
memoize,
|
|
495
|
+
2,
|
|
496
|
+
"getExitDelay"
|
|
497
|
+
],
|
|
498
|
+
[
|
|
499
|
+
memoize,
|
|
500
|
+
2,
|
|
501
|
+
"getManaTarget"
|
|
502
|
+
],
|
|
503
|
+
[
|
|
504
|
+
memoize,
|
|
505
|
+
2,
|
|
506
|
+
"getProvingCostPerMana"
|
|
507
|
+
],
|
|
508
|
+
[
|
|
509
|
+
memoize,
|
|
510
|
+
2,
|
|
511
|
+
"getProvingCostPerManaInFeeAsset"
|
|
512
|
+
],
|
|
513
|
+
[
|
|
514
|
+
memoize,
|
|
515
|
+
2,
|
|
516
|
+
"getManaLimit"
|
|
517
|
+
],
|
|
518
|
+
[
|
|
519
|
+
memoize,
|
|
520
|
+
2,
|
|
521
|
+
"getVersion"
|
|
522
|
+
],
|
|
523
|
+
[
|
|
524
|
+
memoize,
|
|
525
|
+
2,
|
|
526
|
+
"getGenesisArchiveTreeRoot"
|
|
527
|
+
],
|
|
528
|
+
[
|
|
529
|
+
memoize,
|
|
530
|
+
2,
|
|
531
|
+
"getVkTreeRoot"
|
|
532
|
+
],
|
|
533
|
+
[
|
|
534
|
+
memoize,
|
|
535
|
+
2,
|
|
536
|
+
"getProtocolContractsHash"
|
|
537
|
+
],
|
|
538
|
+
[
|
|
539
|
+
memoize,
|
|
540
|
+
2,
|
|
541
|
+
"getRollupConstants"
|
|
542
|
+
]
|
|
543
|
+
], []));
|
|
544
|
+
}
|
|
16
545
|
rollup;
|
|
546
|
+
logger;
|
|
547
|
+
static cachedStfStorageSlot;
|
|
548
|
+
cachedEscapeHatch;
|
|
17
549
|
static get checkBlobStorageSlot() {
|
|
18
550
|
const asString = RollupStorage.find((storage)=>storage.label === 'checkBlob')?.slot;
|
|
19
551
|
if (asString === undefined) {
|
|
@@ -21,17 +553,21 @@ export class RollupContract {
|
|
|
21
553
|
}
|
|
22
554
|
return BigInt(asString);
|
|
23
555
|
}
|
|
556
|
+
static get stfStorageSlot() {
|
|
557
|
+
return RollupContract.cachedStfStorageSlot ??= keccak256(Buffer.from('aztec.stf.storage', 'utf-8'));
|
|
558
|
+
}
|
|
24
559
|
static getFromL1ContractsValues(deployL1ContractsValues) {
|
|
25
|
-
const {
|
|
26
|
-
return new RollupContract(
|
|
560
|
+
const { l1Client, l1ContractAddresses: { rollupAddress } } = deployL1ContractsValues;
|
|
561
|
+
return new RollupContract(l1Client, rollupAddress.toString());
|
|
27
562
|
}
|
|
28
563
|
static getFromConfig(config) {
|
|
29
564
|
const client = getPublicClient(config);
|
|
30
|
-
const address = config.
|
|
565
|
+
const address = config.rollupAddress.toString();
|
|
31
566
|
return new RollupContract(client, address);
|
|
32
567
|
}
|
|
33
568
|
constructor(client, address){
|
|
34
569
|
this.client = client;
|
|
570
|
+
this.logger = (_initProto(this), createLogger('ethereum:rollup'));
|
|
35
571
|
if (address instanceof EthAddress) {
|
|
36
572
|
address = address.toString();
|
|
37
573
|
}
|
|
@@ -41,17 +577,24 @@ export class RollupContract {
|
|
|
41
577
|
client
|
|
42
578
|
});
|
|
43
579
|
}
|
|
580
|
+
async getGSE() {
|
|
581
|
+
return EthAddress.fromString(await this.rollup.read.getGSE());
|
|
582
|
+
}
|
|
44
583
|
get address() {
|
|
45
584
|
return this.rollup.address;
|
|
46
585
|
}
|
|
586
|
+
getContract() {
|
|
587
|
+
return this.rollup;
|
|
588
|
+
}
|
|
47
589
|
async getSlashingProposer() {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
590
|
+
const slasher = await this.getSlasherContract();
|
|
591
|
+
if (!slasher) {
|
|
592
|
+
return undefined;
|
|
593
|
+
}
|
|
594
|
+
const proposerAddress = await slasher.getProposer();
|
|
595
|
+
if (proposerAddress.isZero()) {
|
|
596
|
+
return undefined;
|
|
597
|
+
}
|
|
55
598
|
return new SlashingProposerContract(this.client, proposerAddress);
|
|
56
599
|
}
|
|
57
600
|
getL1StartBlock() {
|
|
@@ -60,90 +603,368 @@ export class RollupContract {
|
|
|
60
603
|
getL1GenesisTime() {
|
|
61
604
|
return this.rollup.read.getGenesisTime();
|
|
62
605
|
}
|
|
63
|
-
|
|
64
|
-
return this.rollup.read.
|
|
606
|
+
async getProofSubmissionEpochs() {
|
|
607
|
+
return Number(await this.rollup.read.getProofSubmissionEpochs());
|
|
65
608
|
}
|
|
66
|
-
getEpochDuration() {
|
|
67
|
-
return this.rollup.read.getEpochDuration();
|
|
609
|
+
async getEpochDuration() {
|
|
610
|
+
return Number(await this.rollup.read.getEpochDuration());
|
|
68
611
|
}
|
|
69
|
-
getSlotDuration() {
|
|
70
|
-
return this.rollup.read.getSlotDuration();
|
|
612
|
+
async getSlotDuration() {
|
|
613
|
+
return Number(await this.rollup.read.getSlotDuration());
|
|
71
614
|
}
|
|
72
|
-
getTargetCommitteeSize() {
|
|
73
|
-
return this.rollup.read.getTargetCommitteeSize();
|
|
615
|
+
async getTargetCommitteeSize() {
|
|
616
|
+
return Number(await this.rollup.read.getTargetCommitteeSize());
|
|
74
617
|
}
|
|
75
|
-
|
|
76
|
-
return this.rollup.read.
|
|
618
|
+
getEjectionThreshold() {
|
|
619
|
+
return this.rollup.read.getEjectionThreshold();
|
|
77
620
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
621
|
+
getLocalEjectionThreshold() {
|
|
622
|
+
return this.rollup.read.getLocalEjectionThreshold();
|
|
623
|
+
}
|
|
624
|
+
async getLagInEpochsForValidatorSet() {
|
|
625
|
+
return Number(await this.rollup.read.getLagInEpochsForValidatorSet());
|
|
626
|
+
}
|
|
627
|
+
async getLagInEpochsForRandao() {
|
|
628
|
+
return Number(await this.rollup.read.getLagInEpochsForRandao());
|
|
629
|
+
}
|
|
630
|
+
getActivationThreshold() {
|
|
631
|
+
return this.rollup.read.getActivationThreshold();
|
|
632
|
+
}
|
|
633
|
+
async getExitDelay() {
|
|
634
|
+
return Number(await this.rollup.read.getExitDelay());
|
|
635
|
+
}
|
|
636
|
+
getManaTarget() {
|
|
637
|
+
return this.rollup.read.getManaTarget();
|
|
638
|
+
}
|
|
639
|
+
getProvingCostPerMana() {
|
|
640
|
+
return this.rollup.read.getProvingCostPerManaInEth();
|
|
641
|
+
}
|
|
642
|
+
getProvingCostPerManaInFeeAsset() {
|
|
643
|
+
return this.rollup.read.getProvingCostPerManaInFeeAsset();
|
|
644
|
+
}
|
|
645
|
+
getManaLimit() {
|
|
646
|
+
return this.rollup.read.getManaLimit();
|
|
647
|
+
}
|
|
648
|
+
getVersion() {
|
|
649
|
+
return this.rollup.read.getVersion();
|
|
650
|
+
}
|
|
651
|
+
async getGenesisArchiveTreeRoot() {
|
|
652
|
+
return Fr.fromString(await this.rollup.read.archiveAt([
|
|
653
|
+
0n
|
|
654
|
+
]));
|
|
655
|
+
}
|
|
656
|
+
async getVkTreeRoot() {
|
|
657
|
+
const slot = BigInt(RollupContract.stfStorageSlot) + 3n;
|
|
658
|
+
const value = await this.client.getStorageAt({
|
|
659
|
+
address: this.address,
|
|
660
|
+
slot: `0x${slot.toString(16)}`
|
|
661
|
+
});
|
|
662
|
+
return Fr.fromString(value ?? '0x0');
|
|
663
|
+
}
|
|
664
|
+
async getProtocolContractsHash() {
|
|
665
|
+
const slot = BigInt(RollupContract.stfStorageSlot) + 4n;
|
|
666
|
+
const value = await this.client.getStorageAt({
|
|
667
|
+
address: this.address,
|
|
668
|
+
slot: `0x${slot.toString(16)}`
|
|
84
669
|
});
|
|
85
|
-
return
|
|
670
|
+
return Fr.fromString(value ?? '0x0');
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Returns rollup constants used for epoch queries.
|
|
674
|
+
* Return type is `L1RollupConstants` which is defined in stdlib,
|
|
675
|
+
* so we cant reference it until we move this contract to that package.
|
|
676
|
+
*/ async getRollupConstants() {
|
|
677
|
+
const [l1StartBlock, l1GenesisTime, slotDuration, epochDuration, proofSubmissionEpochs, targetCommitteeSize, rollupManaLimit] = await Promise.all([
|
|
678
|
+
this.getL1StartBlock(),
|
|
679
|
+
this.getL1GenesisTime(),
|
|
680
|
+
this.getSlotDuration(),
|
|
681
|
+
this.getEpochDuration(),
|
|
682
|
+
this.getProofSubmissionEpochs(),
|
|
683
|
+
this.getTargetCommitteeSize(),
|
|
684
|
+
this.getManaLimit()
|
|
685
|
+
]);
|
|
686
|
+
return {
|
|
687
|
+
l1StartBlock,
|
|
688
|
+
l1GenesisTime,
|
|
689
|
+
slotDuration,
|
|
690
|
+
epochDuration: Number(epochDuration),
|
|
691
|
+
proofSubmissionEpochs: Number(proofSubmissionEpochs),
|
|
692
|
+
targetCommitteeSize,
|
|
693
|
+
rollupManaLimit: Number(rollupManaLimit)
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
async getSlasherAddress() {
|
|
697
|
+
return EthAddress.fromString(await this.rollup.read.getSlasher());
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Returns the configured escape hatch contract address, or zero if disabled.
|
|
701
|
+
*/ async getEscapeHatchAddress() {
|
|
702
|
+
return EthAddress.fromString(await this.rollup.read.getEscapeHatch());
|
|
703
|
+
}
|
|
704
|
+
async getEscapeHatchContract() {
|
|
705
|
+
const escapeHatchAddress = await this.getEscapeHatchAddress();
|
|
706
|
+
if (escapeHatchAddress.isZero()) {
|
|
707
|
+
return undefined;
|
|
708
|
+
}
|
|
709
|
+
// Cache the viem contract wrapper since it will be used frequently.
|
|
710
|
+
if (!this.cachedEscapeHatch || !this.cachedEscapeHatch.address.equals(escapeHatchAddress)) {
|
|
711
|
+
this.cachedEscapeHatch = {
|
|
712
|
+
address: escapeHatchAddress,
|
|
713
|
+
contract: getContract({
|
|
714
|
+
address: escapeHatchAddress.toString(),
|
|
715
|
+
abi: EscapeHatchAbi,
|
|
716
|
+
client: this.client
|
|
717
|
+
})
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
return this.cachedEscapeHatch.contract;
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Returns whether the escape hatch is open for the given epoch.
|
|
724
|
+
* If escape hatch is not configured, returns false.
|
|
725
|
+
*
|
|
726
|
+
* This function is intentionally defensive: any failure to query the escape hatch
|
|
727
|
+
* (RPC issues, transient errors, etc.) is treated as "closed" to avoid callers
|
|
728
|
+
* needing to sprinkle try/catch everywhere.
|
|
729
|
+
*/ async isEscapeHatchOpen(epoch) {
|
|
730
|
+
try {
|
|
731
|
+
const escapeHatch = await this.getEscapeHatchContract();
|
|
732
|
+
if (!escapeHatch) {
|
|
733
|
+
return false;
|
|
734
|
+
}
|
|
735
|
+
const [isOpen] = await escapeHatch.read.isHatchOpen([
|
|
736
|
+
BigInt(epoch)
|
|
737
|
+
]);
|
|
738
|
+
return isOpen;
|
|
739
|
+
} catch (err) {
|
|
740
|
+
this.logger.warn('isEscapeHatchOpen failed (treating as closed); RPC or contract error may cause liveness risk', {
|
|
741
|
+
epoch: Number(epoch),
|
|
742
|
+
error: err
|
|
743
|
+
});
|
|
744
|
+
return false;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Returns a SlasherContract instance for interacting with the slasher contract.
|
|
749
|
+
*/ async getSlasherContract() {
|
|
750
|
+
const slasherAddress = await this.getSlasherAddress();
|
|
751
|
+
if (slasherAddress.isZero()) {
|
|
752
|
+
return undefined;
|
|
753
|
+
}
|
|
754
|
+
return new SlasherContract(this.client, slasherAddress);
|
|
755
|
+
}
|
|
756
|
+
async getOwner() {
|
|
757
|
+
return EthAddress.fromString(await this.rollup.read.owner());
|
|
758
|
+
}
|
|
759
|
+
async getActiveAttesterCount() {
|
|
760
|
+
return Number(await this.rollup.read.getActiveAttesterCount());
|
|
761
|
+
}
|
|
762
|
+
async getSlashingProposerAddress() {
|
|
763
|
+
const slasher = await this.getSlasherContract();
|
|
764
|
+
if (!slasher) {
|
|
765
|
+
return EthAddress.ZERO;
|
|
766
|
+
}
|
|
767
|
+
return await slasher.getProposer();
|
|
86
768
|
}
|
|
87
|
-
|
|
88
|
-
return this.rollup.read.
|
|
769
|
+
getCheckpointReward() {
|
|
770
|
+
return this.rollup.read.getCheckpointReward();
|
|
89
771
|
}
|
|
90
|
-
|
|
91
|
-
|
|
772
|
+
async getCheckpointNumber(options) {
|
|
773
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
774
|
+
return CheckpointNumber.fromBigInt(await this.rollup.read.getPendingCheckpointNumber(options));
|
|
92
775
|
}
|
|
93
|
-
|
|
94
|
-
|
|
776
|
+
async getProvenCheckpointNumber(options) {
|
|
777
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
778
|
+
return CheckpointNumber.fromBigInt(await this.rollup.read.getProvenCheckpointNumber(options));
|
|
95
779
|
}
|
|
96
|
-
|
|
97
|
-
|
|
780
|
+
async getSlotNumber(options) {
|
|
781
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
782
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot(options));
|
|
783
|
+
}
|
|
784
|
+
async getL1FeesAt(timestamp, options) {
|
|
785
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
786
|
+
const result = await this.rollup.read.getL1FeesAt([
|
|
98
787
|
timestamp
|
|
788
|
+
], options);
|
|
789
|
+
return {
|
|
790
|
+
baseFee: result.baseFee,
|
|
791
|
+
blobFee: result.blobFee
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
async getFeeHeader(checkpointNumber) {
|
|
795
|
+
const result = await this.rollup.read.getFeeHeader([
|
|
796
|
+
checkpointNumber
|
|
99
797
|
]);
|
|
798
|
+
return {
|
|
799
|
+
excessMana: result.excessMana,
|
|
800
|
+
manaUsed: result.manaUsed,
|
|
801
|
+
ethPerFeeAsset: result.ethPerFeeAsset,
|
|
802
|
+
congestionCost: result.congestionCost,
|
|
803
|
+
proverCost: result.proverCost
|
|
804
|
+
};
|
|
100
805
|
}
|
|
101
|
-
|
|
102
|
-
return this.rollup.read.
|
|
806
|
+
getEthPerFeeAsset() {
|
|
807
|
+
return this.rollup.read.getEthPerFeeAsset();
|
|
808
|
+
}
|
|
809
|
+
async getCommitteeAt(timestamp) {
|
|
810
|
+
const { result } = await this.client.simulateContract({
|
|
811
|
+
address: this.address,
|
|
812
|
+
abi: RollupAbi,
|
|
813
|
+
functionName: 'getCommitteeAt',
|
|
814
|
+
args: [
|
|
815
|
+
timestamp
|
|
816
|
+
]
|
|
817
|
+
}).catch((e)=>{
|
|
818
|
+
if (isValidatorSelectionError(e, INSUFFICIENT_VALIDATOR_SET_SIZE_ERROR)) {
|
|
819
|
+
return {
|
|
820
|
+
result: undefined
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
throw e;
|
|
824
|
+
});
|
|
825
|
+
return result ? result.map((addr)=>EthAddress.fromString(addr)) : undefined;
|
|
826
|
+
}
|
|
827
|
+
async getSampleSeedAt(timestamp) {
|
|
828
|
+
return Buffer32.fromBigInt(await this.rollup.read.getSampleSeedAt([
|
|
103
829
|
timestamp
|
|
104
|
-
]);
|
|
830
|
+
]));
|
|
105
831
|
}
|
|
106
|
-
getCurrentSampleSeed() {
|
|
107
|
-
return this.rollup.read.getCurrentSampleSeed();
|
|
832
|
+
async getCurrentSampleSeed() {
|
|
833
|
+
return Buffer32.fromBigInt(await this.rollup.read.getCurrentSampleSeed());
|
|
108
834
|
}
|
|
109
|
-
|
|
110
|
-
return this.rollup.read.
|
|
835
|
+
async getCurrentEpoch() {
|
|
836
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
111
837
|
}
|
|
112
|
-
|
|
113
|
-
|
|
838
|
+
async getCurrentEpochCommittee() {
|
|
839
|
+
const { result } = await this.client.simulateContract({
|
|
840
|
+
address: this.address,
|
|
841
|
+
abi: RollupAbi,
|
|
842
|
+
functionName: 'getCurrentEpochCommittee',
|
|
843
|
+
args: []
|
|
844
|
+
}).catch((e)=>{
|
|
845
|
+
if (isValidatorSelectionError(e, INSUFFICIENT_VALIDATOR_SET_SIZE_ERROR)) {
|
|
846
|
+
return {
|
|
847
|
+
result: undefined
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
throw e;
|
|
851
|
+
});
|
|
852
|
+
return result ? result.map((addr)=>EthAddress.fromString(addr)) : undefined;
|
|
114
853
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
854
|
+
async getCurrentProposer() {
|
|
855
|
+
const { result } = await this.client.simulateContract({
|
|
856
|
+
address: this.address,
|
|
857
|
+
abi: RollupAbi,
|
|
858
|
+
functionName: 'getCurrentProposer',
|
|
859
|
+
args: []
|
|
860
|
+
});
|
|
861
|
+
return EthAddress.fromString(result);
|
|
119
862
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
863
|
+
async getProposerAt(timestamp) {
|
|
864
|
+
const { result } = await this.client.simulateContract({
|
|
865
|
+
address: this.address,
|
|
866
|
+
abi: RollupAbi,
|
|
867
|
+
functionName: 'getProposerAt',
|
|
868
|
+
args: [
|
|
869
|
+
timestamp
|
|
870
|
+
]
|
|
871
|
+
});
|
|
872
|
+
return EthAddress.fromString(result);
|
|
873
|
+
}
|
|
874
|
+
async getCheckpoint(checkpointNumber, options) {
|
|
875
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
876
|
+
const result = await this.rollup.read.getCheckpoint([
|
|
877
|
+
BigInt(checkpointNumber)
|
|
878
|
+
], options);
|
|
879
|
+
return {
|
|
880
|
+
archive: Fr.fromString(result.archive),
|
|
881
|
+
headerHash: Buffer32.fromString(result.headerHash),
|
|
882
|
+
blobCommitmentsHash: Buffer32.fromString(result.blobCommitmentsHash),
|
|
883
|
+
attestationsHash: Buffer32.fromString(result.attestationsHash),
|
|
884
|
+
payloadDigest: Buffer32.fromString(result.payloadDigest),
|
|
885
|
+
slotNumber: SlotNumber.fromBigInt(result.slotNumber),
|
|
886
|
+
feeHeader: {
|
|
887
|
+
excessMana: result.feeHeader.excessMana,
|
|
888
|
+
manaUsed: result.feeHeader.manaUsed,
|
|
889
|
+
ethPerFeeAsset: result.feeHeader.ethPerFeeAsset,
|
|
890
|
+
congestionCost: result.feeHeader.congestionCost,
|
|
891
|
+
proverCost: result.feeHeader.proverCost
|
|
892
|
+
}
|
|
893
|
+
};
|
|
124
894
|
}
|
|
125
|
-
|
|
126
|
-
|
|
895
|
+
/** Returns the pending checkpoint from the rollup contract */ getPendingCheckpoint() {
|
|
896
|
+
// We retry because of race conditions during prunes: we may get a pending checkpoint number which is immediately
|
|
897
|
+
// reorged out due to a prune happening, causing the subsequent getCheckpoint call to fail. So we try again in that case.
|
|
898
|
+
return retry(async ()=>{
|
|
899
|
+
const pendingCheckpointNumber = await this.getCheckpointNumber();
|
|
900
|
+
const pendingCheckpoint = await this.getCheckpoint(pendingCheckpointNumber);
|
|
901
|
+
return pendingCheckpoint;
|
|
902
|
+
}, 'getting pending checkpoint', makeBackoff([
|
|
903
|
+
0.5,
|
|
904
|
+
0.5,
|
|
905
|
+
0.5
|
|
906
|
+
]));
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Returns the effective pending checkpoint, accounting for potential prunes.
|
|
910
|
+
* When a prune can happen, the L1 contract uses the proven checkpoint instead of the pending one.
|
|
911
|
+
* This mirrors the behavior of getEffectivePendingCheckpointNumber in STFLib.sol.
|
|
912
|
+
* @param atTimestamp - The timestamp to evaluate pruneability at. Defaults to the current L1 block timestamp.
|
|
913
|
+
* @param options - Optional L1 block number to pin the queries to.
|
|
914
|
+
*/ getEffectivePendingCheckpoint(atTimestamp, options) {
|
|
915
|
+
return retry(async ()=>{
|
|
916
|
+
const timestamp = atTimestamp ?? (await this.client.getBlock()).timestamp;
|
|
917
|
+
const canPrune = await this.canPruneAtTime(timestamp, options);
|
|
918
|
+
if (canPrune) {
|
|
919
|
+
const provenCheckpointNumber = await this.getProvenCheckpointNumber(options);
|
|
920
|
+
return await this.getCheckpoint(provenCheckpointNumber, options);
|
|
921
|
+
}
|
|
922
|
+
const pendingCheckpointNumber = await this.getCheckpointNumber(options);
|
|
923
|
+
return await this.getCheckpoint(pendingCheckpointNumber, options);
|
|
924
|
+
}, 'getting effective pending checkpoint', makeBackoff([
|
|
925
|
+
0.5,
|
|
926
|
+
0.5,
|
|
927
|
+
0.5
|
|
928
|
+
]));
|
|
929
|
+
}
|
|
930
|
+
async getTips() {
|
|
931
|
+
const { pending, proven } = await this.rollup.read.getTips();
|
|
932
|
+
return {
|
|
933
|
+
pending: CheckpointNumber.fromBigInt(pending),
|
|
934
|
+
proven: CheckpointNumber.fromBigInt(proven)
|
|
935
|
+
};
|
|
127
936
|
}
|
|
128
937
|
getTimestampForSlot(slot) {
|
|
129
938
|
return this.rollup.read.getTimestampForSlot([
|
|
130
|
-
slot
|
|
939
|
+
BigInt(slot)
|
|
131
940
|
]);
|
|
132
941
|
}
|
|
133
|
-
async
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
942
|
+
async getEntryQueueLength() {
|
|
943
|
+
return Number(await this.rollup.read.getEntryQueueLength());
|
|
944
|
+
}
|
|
945
|
+
async getAvailableValidatorFlushes() {
|
|
946
|
+
return Number(await this.rollup.read.getAvailableValidatorFlushes());
|
|
947
|
+
}
|
|
948
|
+
async getNextFlushableEpoch() {
|
|
949
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getNextFlushableEpoch());
|
|
950
|
+
}
|
|
951
|
+
async getCurrentEpochNumber() {
|
|
952
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
953
|
+
}
|
|
954
|
+
async getEpochNumberForCheckpoint(checkpointNumber) {
|
|
955
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochForCheckpoint([
|
|
956
|
+
BigInt(checkpointNumber)
|
|
957
|
+
]));
|
|
138
958
|
}
|
|
139
959
|
async getRollupAddresses() {
|
|
140
|
-
const [inboxAddress, outboxAddress, feeJuicePortalAddress, rewardDistributorAddress, feeJuiceAddress, stakingAssetAddress] = (await Promise.all([
|
|
960
|
+
const [inboxAddress, outboxAddress, feeJuicePortalAddress, rewardDistributorAddress, feeJuiceAddress, stakingAssetAddress, gseAddress] = (await Promise.all([
|
|
141
961
|
this.rollup.read.getInbox(),
|
|
142
962
|
this.rollup.read.getOutbox(),
|
|
143
963
|
this.rollup.read.getFeeAssetPortal(),
|
|
144
964
|
this.rollup.read.getRewardDistributor(),
|
|
145
965
|
this.rollup.read.getFeeAsset(),
|
|
146
|
-
this.rollup.read.getStakingAsset()
|
|
966
|
+
this.rollup.read.getStakingAsset(),
|
|
967
|
+
this.rollup.read.getGSE()
|
|
147
968
|
])).map(EthAddress.fromString);
|
|
148
969
|
return {
|
|
149
970
|
rollupAddress: EthAddress.fromString(this.address),
|
|
@@ -152,20 +973,29 @@ export class RollupContract {
|
|
|
152
973
|
feeJuicePortalAddress,
|
|
153
974
|
feeJuiceAddress,
|
|
154
975
|
stakingAssetAddress,
|
|
155
|
-
rewardDistributorAddress
|
|
976
|
+
rewardDistributorAddress,
|
|
977
|
+
gseAddress
|
|
156
978
|
};
|
|
157
979
|
}
|
|
980
|
+
async getFeeJuicePortal() {
|
|
981
|
+
return EthAddress.fromString(await this.rollup.read.getFeeAssetPortal());
|
|
982
|
+
}
|
|
158
983
|
async getEpochNumberForSlotNumber(slotNumber) {
|
|
159
|
-
return await this.rollup.read.getEpochAtSlot([
|
|
160
|
-
slotNumber
|
|
161
|
-
]);
|
|
984
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([
|
|
985
|
+
BigInt(slotNumber)
|
|
986
|
+
]));
|
|
162
987
|
}
|
|
163
|
-
getEpochProofPublicInputs(args) {
|
|
164
|
-
|
|
988
|
+
async getEpochProofPublicInputs(args) {
|
|
989
|
+
const result = await this.rollup.read.getEpochProofPublicInputs(args);
|
|
990
|
+
return result.map(Fr.fromString);
|
|
165
991
|
}
|
|
166
992
|
async validateHeader(args, account) {
|
|
167
993
|
try {
|
|
168
|
-
await this.
|
|
994
|
+
await this.client.simulateContract({
|
|
995
|
+
address: this.address,
|
|
996
|
+
abi: RollupAbi,
|
|
997
|
+
functionName: 'validateHeaderWithAttestations',
|
|
998
|
+
args,
|
|
169
999
|
account
|
|
170
1000
|
});
|
|
171
1001
|
} catch (error) {
|
|
@@ -178,57 +1008,555 @@ export class RollupContract {
|
|
|
178
1008
|
* @dev Throws if unable to propose
|
|
179
1009
|
*
|
|
180
1010
|
* @param archive - The archive that we expect to be current state
|
|
181
|
-
* @return [slot,
|
|
1011
|
+
* @return [slot, checkpointNumber, timeOfNextL1Slot] - If you can propose, the L2 slot number, checkpoint number and
|
|
1012
|
+
* timestamp of the next L1 block
|
|
182
1013
|
* @throws otherwise
|
|
183
|
-
*/ async
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
const timeOfNextL1Slot = (await this.client.getBlock()).timestamp + slotDuration;
|
|
1014
|
+
*/ async canProposeAt(archive, account, timestamp, stateOverride = []) {
|
|
1015
|
+
const timeOfNextL1Slot = timestamp;
|
|
1016
|
+
const who = typeof account === 'string' ? account : account.address;
|
|
188
1017
|
try {
|
|
189
|
-
const [slot,
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
1018
|
+
const { result: [slot, checkpointNumber] } = await this.client.simulateContract({
|
|
1019
|
+
address: this.address,
|
|
1020
|
+
abi: RollupAbi,
|
|
1021
|
+
functionName: 'canProposeAtTime',
|
|
1022
|
+
args: [
|
|
1023
|
+
timeOfNextL1Slot,
|
|
1024
|
+
`0x${archive.toString('hex')}`,
|
|
1025
|
+
who
|
|
1026
|
+
],
|
|
1027
|
+
account,
|
|
1028
|
+
stateOverride
|
|
194
1029
|
});
|
|
195
|
-
return
|
|
196
|
-
slot,
|
|
197
|
-
|
|
198
|
-
|
|
1030
|
+
return {
|
|
1031
|
+
slot: SlotNumber.fromBigInt(slot),
|
|
1032
|
+
checkpointNumber: CheckpointNumber.fromBigInt(checkpointNumber),
|
|
1033
|
+
timeOfNextL1Slot
|
|
1034
|
+
};
|
|
199
1035
|
} catch (err) {
|
|
200
1036
|
throw formatViemError(err);
|
|
201
1037
|
}
|
|
202
1038
|
}
|
|
203
|
-
/**
|
|
1039
|
+
/**
|
|
1040
|
+
* Returns a state override that sets the pending and/or proven checkpoint numbers. Useful for simulations.
|
|
1041
|
+
* Both values share a single storage slot (pending in the upper 128 bits, proven in the lower 128 bits), so
|
|
1042
|
+
* a single combined override is emitted to avoid the second state-diff clobbering the first. The current live
|
|
1043
|
+
* value is read once to preserve any half not being overridden. Returns an empty override if neither is set.
|
|
1044
|
+
*
|
|
1045
|
+
* Throws if the resulting `proven > pending`, which would crash the simulation: `STFLib.canPruneAtTime` calls
|
|
1046
|
+
* `getEpochForCheckpoint(proven + 1)` whenever `pending != proven`, and that asserts `_n <= tips.pending`.
|
|
1047
|
+
*/ async makeChainTipsOverride(override) {
|
|
1048
|
+
if (override.pending === undefined && override.proven === undefined) {
|
|
1049
|
+
return [];
|
|
1050
|
+
}
|
|
1051
|
+
const slot = RollupContract.stfStorageSlot;
|
|
1052
|
+
const currentValue = await this.client.getStorageAt({
|
|
1053
|
+
address: this.address,
|
|
1054
|
+
slot
|
|
1055
|
+
});
|
|
1056
|
+
const currentRaw = currentValue ? hexToBigInt(currentValue) : 0n;
|
|
1057
|
+
const currentPending = currentRaw >> 128n;
|
|
1058
|
+
const currentProven = currentRaw & (1n << 128n) - 1n;
|
|
1059
|
+
const newPending = override.pending !== undefined ? BigInt(override.pending) : currentPending;
|
|
1060
|
+
const newProven = override.proven !== undefined ? BigInt(override.proven) : currentProven;
|
|
1061
|
+
if (newProven > newPending) {
|
|
1062
|
+
throw new Error(`Invalid chain tips override: proven (${newProven}) > pending (${newPending})`);
|
|
1063
|
+
}
|
|
1064
|
+
const newValue = newPending << 128n | newProven;
|
|
1065
|
+
return [
|
|
1066
|
+
{
|
|
1067
|
+
address: this.address,
|
|
1068
|
+
stateDiff: [
|
|
1069
|
+
{
|
|
1070
|
+
slot,
|
|
1071
|
+
value: `0x${newValue.toString(16).padStart(64, '0')}`
|
|
1072
|
+
}
|
|
1073
|
+
]
|
|
1074
|
+
}
|
|
1075
|
+
];
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* Returns a state override that patches `tempCheckpointLogs[checkpointNumber]` with every field that
|
|
1079
|
+
* the L1 contract reads during `propose()` for the checkpoint that builds on top of it (proposer
|
|
1080
|
+
* pipelining simulation). Mirrors the writes done by `ProposeLib.addTempCheckpointLog`.
|
|
1081
|
+
*
|
|
1082
|
+
* `blobCommitmentsHash` and `attestationsHash` are intentionally not exposed here — the propose path
|
|
1083
|
+
* never asserts against them, so leaving them at storage zero is harmless.
|
|
1084
|
+
*/ async makeTempCheckpointLogOverride(checkpointNumber, fields) {
|
|
1085
|
+
const constants = await this.getRollupConstants();
|
|
1086
|
+
const slotAt = (field)=>`0x${this.computeTempCheckpointLogStorageSlot(checkpointNumber, field, constants).toString(16).padStart(64, '0')}`;
|
|
1087
|
+
const word = (v)=>`0x${v.toString(16).padStart(64, '0')}`;
|
|
1088
|
+
const stateDiff = [];
|
|
1089
|
+
if (fields.headerHash) {
|
|
1090
|
+
stateDiff.push({
|
|
1091
|
+
slot: slotAt(0),
|
|
1092
|
+
value: fields.headerHash.toString()
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
if (fields.outHash) {
|
|
1096
|
+
stateDiff.push({
|
|
1097
|
+
slot: slotAt(2),
|
|
1098
|
+
value: fields.outHash.toString()
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1101
|
+
if (fields.payloadDigest) {
|
|
1102
|
+
stateDiff.push({
|
|
1103
|
+
slot: slotAt(4),
|
|
1104
|
+
value: fields.payloadDigest.toString()
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
if (fields.slotNumber !== undefined) {
|
|
1108
|
+
// CompressedSlot is uint32 on L1 (SafeCast.toUint32 reverts on overflow). Match that behavior here
|
|
1109
|
+
// so a malformed override surfaces immediately rather than silently truncating into a wrong slot.
|
|
1110
|
+
const slotNumber = BigInt(fields.slotNumber);
|
|
1111
|
+
if (slotNumber < 0n || slotNumber > 0xffffffffn) {
|
|
1112
|
+
throw new Error(`slotNumber ${slotNumber} does not fit in uint32`);
|
|
1113
|
+
}
|
|
1114
|
+
stateDiff.push({
|
|
1115
|
+
slot: slotAt(5),
|
|
1116
|
+
value: word(slotNumber)
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
if (fields.feeHeader) {
|
|
1120
|
+
stateDiff.push({
|
|
1121
|
+
slot: slotAt(6),
|
|
1122
|
+
value: word(RollupContract.compressFeeHeader(fields.feeHeader))
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
if (stateDiff.length === 0) {
|
|
1126
|
+
return [];
|
|
1127
|
+
}
|
|
1128
|
+
return [
|
|
1129
|
+
{
|
|
1130
|
+
address: this.address,
|
|
1131
|
+
stateDiff
|
|
1132
|
+
}
|
|
1133
|
+
];
|
|
1134
|
+
}
|
|
1135
|
+
/**
|
|
1136
|
+
* Returns a state override that sets archives[checkpointNumber] to the given archive value.
|
|
1137
|
+
* Used when simulating a canProposeAtTime call where the local archive differs from L1
|
|
1138
|
+
* (e.g. pipelining where the parent checkpoint hasn't landed on L1 yet).
|
|
1139
|
+
*/ makeArchiveOverride(checkpointNumber, archive) {
|
|
1140
|
+
const archivesMappingBase = hexToBigInt(RollupContract.stfStorageSlot) + 1n;
|
|
1141
|
+
const archiveSlot = hexToBigInt(keccak256(encodeAbiParameters([
|
|
1142
|
+
{
|
|
1143
|
+
type: 'uint256'
|
|
1144
|
+
},
|
|
1145
|
+
{
|
|
1146
|
+
type: 'uint256'
|
|
1147
|
+
}
|
|
1148
|
+
], [
|
|
1149
|
+
BigInt(checkpointNumber),
|
|
1150
|
+
archivesMappingBase
|
|
1151
|
+
])));
|
|
1152
|
+
return [
|
|
1153
|
+
{
|
|
1154
|
+
address: this.address,
|
|
1155
|
+
stateDiff: [
|
|
1156
|
+
{
|
|
1157
|
+
slot: `0x${archiveSlot.toString(16).padStart(64, '0')}`,
|
|
1158
|
+
value: archive.toString()
|
|
1159
|
+
}
|
|
1160
|
+
]
|
|
1161
|
+
}
|
|
1162
|
+
];
|
|
1163
|
+
}
|
|
1164
|
+
/** Merges multiple StateOverride arrays, combining stateDiff entries for the same address. */ static mergeStateOverrides(...overrides) {
|
|
1165
|
+
const byAddress = new Map();
|
|
1166
|
+
for (const override of overrides){
|
|
1167
|
+
for (const entry of override){
|
|
1168
|
+
const key = entry.address.toLowerCase();
|
|
1169
|
+
const existing = byAddress.get(key);
|
|
1170
|
+
if (existing) {
|
|
1171
|
+
existing.stateDiff.push(...entry.stateDiff ?? []);
|
|
1172
|
+
if (entry.balance !== undefined) {
|
|
1173
|
+
existing.balance = entry.balance;
|
|
1174
|
+
}
|
|
1175
|
+
} else {
|
|
1176
|
+
byAddress.set(key, {
|
|
1177
|
+
address: entry.address,
|
|
1178
|
+
balance: entry.balance,
|
|
1179
|
+
stateDiff: [
|
|
1180
|
+
...entry.stateDiff ?? []
|
|
1181
|
+
]
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
return [
|
|
1187
|
+
...byAddress.values()
|
|
1188
|
+
];
|
|
1189
|
+
}
|
|
1190
|
+
/** Compresses a FeeHeader into a uint256 matching FeeHeaderLib.compress() in FeeStructs.sol. */ static compressFeeHeader(feeHeader) {
|
|
1191
|
+
const MASK_48_BITS = (1n << 48n) - 1n;
|
|
1192
|
+
const MASK_64_BITS = (1n << 64n) - 1n;
|
|
1193
|
+
const MASK_63_BITS = (1n << 63n) - 1n;
|
|
1194
|
+
let value = BigInt(feeHeader.manaUsed) & (1n << 32n) - 1n; // bits [0:31]
|
|
1195
|
+
value |= (feeHeader.excessMana < MASK_48_BITS ? feeHeader.excessMana : MASK_48_BITS) << 32n; // bits [32:79]
|
|
1196
|
+
value |= (BigInt(feeHeader.ethPerFeeAsset) & MASK_48_BITS) << 80n; // bits [80:127]
|
|
1197
|
+
value |= (feeHeader.congestionCost < MASK_64_BITS ? feeHeader.congestionCost : MASK_64_BITS) << 128n; // bits [128:191]
|
|
1198
|
+
value |= (feeHeader.proverCost < MASK_63_BITS ? feeHeader.proverCost : MASK_63_BITS) << 192n; // bits [192:254]
|
|
1199
|
+
value |= 1n << 255n; // preheat flag
|
|
1200
|
+
return value;
|
|
1201
|
+
}
|
|
1202
|
+
/** Computes the fee header for a child checkpoint given parent fee header and child data.
|
|
1203
|
+
* Must stay in sync with Solidity FeeLib.sol (computeNewEthPerFeeAsset, clampedAdd). */ static computeChildFeeHeader(parentFeeHeader, childManaUsed, feeAssetPriceModifier, manaTarget) {
|
|
1204
|
+
const MIN_ETH_PER_FEE_ASSET = 100n;
|
|
1205
|
+
const MAX_ETH_PER_FEE_ASSET = 100_000_000_000_000n; // 1e14, matches FeeLib.sol
|
|
1206
|
+
// excessMana = clampedAdd(parent.excessMana + parent.manaUsed, -manaTarget)
|
|
1207
|
+
const sum = parentFeeHeader.excessMana + parentFeeHeader.manaUsed;
|
|
1208
|
+
const excessMana = sum > manaTarget ? sum - manaTarget : 0n;
|
|
1209
|
+
// ethPerFeeAsset = computeNewEthPerFeeAsset(max(parent.ethPerFeeAsset, MIN), modifier)
|
|
1210
|
+
const parentPrice = parentFeeHeader.ethPerFeeAsset > MIN_ETH_PER_FEE_ASSET ? parentFeeHeader.ethPerFeeAsset : MIN_ETH_PER_FEE_ASSET;
|
|
1211
|
+
let newPrice;
|
|
1212
|
+
if (feeAssetPriceModifier >= 0n) {
|
|
1213
|
+
newPrice = parentPrice * (10_000n + feeAssetPriceModifier) / 10_000n;
|
|
1214
|
+
} else {
|
|
1215
|
+
const absMod = -feeAssetPriceModifier;
|
|
1216
|
+
newPrice = parentPrice * (10_000n - absMod) / 10_000n;
|
|
1217
|
+
}
|
|
1218
|
+
if (newPrice < MIN_ETH_PER_FEE_ASSET) {
|
|
1219
|
+
newPrice = MIN_ETH_PER_FEE_ASSET;
|
|
1220
|
+
}
|
|
1221
|
+
if (newPrice > MAX_ETH_PER_FEE_ASSET) {
|
|
1222
|
+
newPrice = MAX_ETH_PER_FEE_ASSET;
|
|
1223
|
+
}
|
|
1224
|
+
return {
|
|
1225
|
+
excessMana,
|
|
1226
|
+
manaUsed: childManaUsed,
|
|
1227
|
+
ethPerFeeAsset: newPrice,
|
|
1228
|
+
congestionCost: 0n,
|
|
1229
|
+
proverCost: 0n
|
|
1230
|
+
};
|
|
1231
|
+
}
|
|
1232
|
+
/** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */ buildInvalidateBadAttestationRequest(checkpointNumber, attestationsAndSigners, committee, invalidIndex) {
|
|
1233
|
+
return {
|
|
1234
|
+
to: this.address,
|
|
1235
|
+
abi: RollupAbi,
|
|
1236
|
+
data: encodeFunctionData({
|
|
1237
|
+
abi: RollupAbi,
|
|
1238
|
+
functionName: 'invalidateBadAttestation',
|
|
1239
|
+
args: [
|
|
1240
|
+
BigInt(checkpointNumber),
|
|
1241
|
+
attestationsAndSigners,
|
|
1242
|
+
committee.map((addr)=>addr.toString()),
|
|
1243
|
+
BigInt(invalidIndex)
|
|
1244
|
+
]
|
|
1245
|
+
})
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
/** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */ buildInvalidateInsufficientAttestationsRequest(checkpointNumber, attestationsAndSigners, committee) {
|
|
1249
|
+
return {
|
|
1250
|
+
to: this.address,
|
|
1251
|
+
abi: RollupAbi,
|
|
1252
|
+
data: encodeFunctionData({
|
|
1253
|
+
abi: RollupAbi,
|
|
1254
|
+
functionName: 'invalidateInsufficientAttestations',
|
|
1255
|
+
args: [
|
|
1256
|
+
BigInt(checkpointNumber),
|
|
1257
|
+
attestationsAndSigners,
|
|
1258
|
+
committee.map((addr)=>addr.toString())
|
|
1259
|
+
]
|
|
1260
|
+
})
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1263
|
+
/** Calls getHasSubmitted directly. Returns whether the given prover has submitted a proof with the given length for the given epoch. */ getHasSubmittedProof(epochNumber, numberOfCheckpointsInEpoch, prover) {
|
|
1264
|
+
if (prover instanceof EthAddress) {
|
|
1265
|
+
prover = prover.toString();
|
|
1266
|
+
}
|
|
204
1267
|
return this.rollup.read.getHasSubmitted([
|
|
205
1268
|
BigInt(epochNumber),
|
|
206
|
-
BigInt(
|
|
207
|
-
prover
|
|
1269
|
+
BigInt(numberOfCheckpointsInEpoch),
|
|
1270
|
+
prover
|
|
208
1271
|
]);
|
|
209
1272
|
}
|
|
1273
|
+
getManaMinFeeAt(timestamp, inFeeAsset, stateOverride) {
|
|
1274
|
+
return this.rollup.read.getManaMinFeeAt([
|
|
1275
|
+
timestamp,
|
|
1276
|
+
inFeeAsset
|
|
1277
|
+
], {
|
|
1278
|
+
stateOverride
|
|
1279
|
+
});
|
|
1280
|
+
}
|
|
1281
|
+
async getManaMinFeeComponentsAt(timestamp, inFeeAsset) {
|
|
1282
|
+
const result = await this.rollup.read.getManaMinFeeComponentsAt([
|
|
1283
|
+
timestamp,
|
|
1284
|
+
inFeeAsset
|
|
1285
|
+
]);
|
|
1286
|
+
return {
|
|
1287
|
+
sequencerCost: result.sequencerCost,
|
|
1288
|
+
proverCost: result.proverCost,
|
|
1289
|
+
congestionCost: result.congestionCost,
|
|
1290
|
+
congestionMultiplier: result.congestionMultiplier
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
async getSlotAt(timestamp) {
|
|
1294
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([
|
|
1295
|
+
timestamp
|
|
1296
|
+
]));
|
|
1297
|
+
}
|
|
1298
|
+
async status(checkpointNumber, options) {
|
|
1299
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
1300
|
+
const result = await this.rollup.read.status([
|
|
1301
|
+
BigInt(checkpointNumber)
|
|
1302
|
+
], options);
|
|
1303
|
+
return {
|
|
1304
|
+
provenCheckpointNumber: CheckpointNumber.fromBigInt(result[0]),
|
|
1305
|
+
provenArchive: Fr.fromString(result[1]),
|
|
1306
|
+
pendingCheckpointNumber: CheckpointNumber.fromBigInt(result[2]),
|
|
1307
|
+
pendingArchive: Fr.fromString(result[3]),
|
|
1308
|
+
archiveOfMyCheckpoint: Fr.fromString(result[4])
|
|
1309
|
+
};
|
|
1310
|
+
}
|
|
1311
|
+
async canPruneAtTime(timestamp, options) {
|
|
1312
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
1313
|
+
return this.rollup.read.canPruneAtTime([
|
|
1314
|
+
timestamp
|
|
1315
|
+
], options);
|
|
1316
|
+
}
|
|
1317
|
+
async archive() {
|
|
1318
|
+
return Fr.fromString(await this.rollup.read.archive());
|
|
1319
|
+
}
|
|
1320
|
+
async archiveAt(checkpointNumber) {
|
|
1321
|
+
return Fr.fromString(await this.rollup.read.archiveAt([
|
|
1322
|
+
BigInt(checkpointNumber)
|
|
1323
|
+
]));
|
|
1324
|
+
}
|
|
1325
|
+
getSequencerRewards(address) {
|
|
1326
|
+
if (address instanceof EthAddress) {
|
|
1327
|
+
address = address.toString();
|
|
1328
|
+
}
|
|
1329
|
+
return this.rollup.read.getSequencerRewards([
|
|
1330
|
+
address
|
|
1331
|
+
]);
|
|
1332
|
+
}
|
|
1333
|
+
getSpecificProverRewardsForEpoch(epoch, prover) {
|
|
1334
|
+
if (prover instanceof EthAddress) {
|
|
1335
|
+
prover = prover.toString();
|
|
1336
|
+
}
|
|
1337
|
+
return this.rollup.read.getSpecificProverRewardsForEpoch([
|
|
1338
|
+
epoch,
|
|
1339
|
+
prover
|
|
1340
|
+
]);
|
|
1341
|
+
}
|
|
1342
|
+
async getAttesters(timestamp) {
|
|
1343
|
+
const attesterSize = await this.getActiveAttesterCount();
|
|
1344
|
+
const gse = new GSEContract(this.client, await this.getGSE());
|
|
1345
|
+
const ts = timestamp ?? (await this.client.getBlock()).timestamp;
|
|
1346
|
+
const indices = Array.from({
|
|
1347
|
+
length: attesterSize
|
|
1348
|
+
}, (_, i)=>BigInt(i));
|
|
1349
|
+
const chunks = chunk(indices, 1000);
|
|
1350
|
+
const results = await Promise.all(chunks.map((chunk)=>gse.getAttestersFromIndicesAtTime(this.address, ts, chunk)));
|
|
1351
|
+
return results.flat().map((addr)=>EthAddress.fromString(addr));
|
|
1352
|
+
}
|
|
1353
|
+
async getAttesterView(address) {
|
|
1354
|
+
if (address instanceof EthAddress) {
|
|
1355
|
+
address = address.toString();
|
|
1356
|
+
}
|
|
1357
|
+
const result = await this.rollup.read.getAttesterView([
|
|
1358
|
+
address
|
|
1359
|
+
]);
|
|
1360
|
+
return {
|
|
1361
|
+
status: result.status,
|
|
1362
|
+
effectiveBalance: result.effectiveBalance,
|
|
1363
|
+
exit: {
|
|
1364
|
+
withdrawalId: result.exit.withdrawalId,
|
|
1365
|
+
amount: result.exit.amount,
|
|
1366
|
+
exitableAt: result.exit.exitableAt,
|
|
1367
|
+
recipientOrWithdrawer: EthAddress.fromString(result.exit.recipientOrWithdrawer),
|
|
1368
|
+
isRecipient: result.exit.isRecipient,
|
|
1369
|
+
exists: result.exit.exists
|
|
1370
|
+
},
|
|
1371
|
+
config: {
|
|
1372
|
+
publicKey: {
|
|
1373
|
+
x: result.config.publicKey.x,
|
|
1374
|
+
y: result.config.publicKey.y
|
|
1375
|
+
},
|
|
1376
|
+
withdrawer: EthAddress.fromString(result.config.withdrawer)
|
|
1377
|
+
}
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
async getStatus(address) {
|
|
1381
|
+
if (address instanceof EthAddress) {
|
|
1382
|
+
address = address.toString();
|
|
1383
|
+
}
|
|
1384
|
+
return await this.rollup.read.getStatus([
|
|
1385
|
+
address
|
|
1386
|
+
]);
|
|
1387
|
+
}
|
|
1388
|
+
async getBlobCommitmentsHash(checkpointNumber) {
|
|
1389
|
+
return Buffer32.fromString(await this.rollup.read.getBlobCommitmentsHash([
|
|
1390
|
+
BigInt(checkpointNumber)
|
|
1391
|
+
]));
|
|
1392
|
+
}
|
|
1393
|
+
async getCurrentBlobCommitmentsHash() {
|
|
1394
|
+
return Buffer32.fromString(await this.rollup.read.getCurrentBlobCommitmentsHash());
|
|
1395
|
+
}
|
|
1396
|
+
async getStakingAsset() {
|
|
1397
|
+
return EthAddress.fromString(await this.rollup.read.getStakingAsset());
|
|
1398
|
+
}
|
|
1399
|
+
async getRewardConfig() {
|
|
1400
|
+
const result = await this.rollup.read.getRewardConfig();
|
|
1401
|
+
return {
|
|
1402
|
+
rewardDistributor: EthAddress.fromString(result.rewardDistributor),
|
|
1403
|
+
sequencerBps: BigInt(result.sequencerBps),
|
|
1404
|
+
booster: EthAddress.fromString(result.booster),
|
|
1405
|
+
checkpointReward: result.checkpointReward
|
|
1406
|
+
};
|
|
1407
|
+
}
|
|
1408
|
+
setupEpoch(l1TxUtils) {
|
|
1409
|
+
return l1TxUtils.sendAndMonitorTransaction({
|
|
1410
|
+
to: this.address,
|
|
1411
|
+
abi: RollupAbi,
|
|
1412
|
+
data: encodeFunctionData({
|
|
1413
|
+
abi: RollupAbi,
|
|
1414
|
+
functionName: 'setupEpoch',
|
|
1415
|
+
args: []
|
|
1416
|
+
})
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1419
|
+
vote(l1TxUtils, proposalId) {
|
|
1420
|
+
return l1TxUtils.sendAndMonitorTransaction({
|
|
1421
|
+
to: this.address,
|
|
1422
|
+
abi: RollupAbi,
|
|
1423
|
+
data: encodeFunctionData({
|
|
1424
|
+
abi: RollupAbi,
|
|
1425
|
+
functionName: 'vote',
|
|
1426
|
+
args: [
|
|
1427
|
+
proposalId
|
|
1428
|
+
]
|
|
1429
|
+
})
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
listenToSlasherChanged(callback) {
|
|
1433
|
+
return this.rollup.watchEvent.SlasherUpdated({}, {
|
|
1434
|
+
onLogs: (logs)=>{
|
|
1435
|
+
for (const log of logs){
|
|
1436
|
+
const args = log.args;
|
|
1437
|
+
if (args.oldSlasher && args.newSlasher) {
|
|
1438
|
+
callback(args);
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
listenToCheckpointInvalidated(callback) {
|
|
1445
|
+
return this.rollup.watchEvent.CheckpointInvalidated({}, {
|
|
1446
|
+
onLogs: (logs)=>{
|
|
1447
|
+
for (const log of logs){
|
|
1448
|
+
const args = log.args;
|
|
1449
|
+
if (args.checkpointNumber !== undefined) {
|
|
1450
|
+
callback({
|
|
1451
|
+
checkpointNumber: CheckpointNumber.fromBigInt(args.checkpointNumber),
|
|
1452
|
+
event: log
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
async getSlashEvents(l1BlockHash) {
|
|
1460
|
+
const events = await this.rollup.getEvents.Slashed({}, {
|
|
1461
|
+
blockHash: l1BlockHash,
|
|
1462
|
+
strict: true
|
|
1463
|
+
});
|
|
1464
|
+
return events.map((event)=>({
|
|
1465
|
+
amount: event.args.amount,
|
|
1466
|
+
attester: EthAddress.fromString(event.args.attester)
|
|
1467
|
+
}));
|
|
1468
|
+
}
|
|
1469
|
+
listenToSlash(callback) {
|
|
1470
|
+
return this.rollup.watchEvent.Slashed({}, {
|
|
1471
|
+
strict: true,
|
|
1472
|
+
onLogs: (logs)=>{
|
|
1473
|
+
for (const log of logs){
|
|
1474
|
+
const args = log.args;
|
|
1475
|
+
callback({
|
|
1476
|
+
amount: args.amount,
|
|
1477
|
+
attester: EthAddress.fromString(args.attester)
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* Fetches OwnershipTransferred events emitted on the L1 block this rollup was deployed on.
|
|
1485
|
+
* The Rollup inherits from Ownable and emits this event in its constructor, so the event
|
|
1486
|
+
* is guaranteed to exist on `l1StartBlock` for any correctly deployed rollup. Used as a
|
|
1487
|
+
* probe to detect RPC nodes that prune historical logs.
|
|
1488
|
+
*/ async getOwnershipTransferredEventsAtDeploy() {
|
|
1489
|
+
const l1StartBlock = await this.getL1StartBlock();
|
|
1490
|
+
return await this.rollup.getEvents.OwnershipTransferred({}, {
|
|
1491
|
+
fromBlock: l1StartBlock,
|
|
1492
|
+
toBlock: l1StartBlock
|
|
1493
|
+
});
|
|
1494
|
+
}
|
|
1495
|
+
/** Fetches CheckpointProposed events within the given block range. */ async getCheckpointProposedEvents(fromBlock, toBlock) {
|
|
1496
|
+
const logs = await this.rollup.getEvents.CheckpointProposed({}, {
|
|
1497
|
+
fromBlock,
|
|
1498
|
+
toBlock
|
|
1499
|
+
});
|
|
1500
|
+
return logs.filter((log)=>log.blockNumber >= fromBlock && log.blockNumber <= toBlock).map((log)=>({
|
|
1501
|
+
l1BlockNumber: log.blockNumber,
|
|
1502
|
+
l1BlockHash: Buffer32.fromString(log.blockHash),
|
|
1503
|
+
l1TransactionHash: log.transactionHash,
|
|
1504
|
+
args: {
|
|
1505
|
+
checkpointNumber: CheckpointNumber.fromBigInt(log.args.checkpointNumber),
|
|
1506
|
+
archive: Fr.fromString(log.args.archive),
|
|
1507
|
+
versionedBlobHashes: log.args.versionedBlobHashes.map((h)=>Buffer.from(h.slice(2), 'hex')),
|
|
1508
|
+
attestationsHash: (()=>{
|
|
1509
|
+
if (!log.args.attestationsHash) {
|
|
1510
|
+
throw new Error(`CheckpointProposed event missing attestationsHash for checkpoint ${log.args.checkpointNumber}`);
|
|
1511
|
+
}
|
|
1512
|
+
return Buffer32.fromString(log.args.attestationsHash);
|
|
1513
|
+
})(),
|
|
1514
|
+
payloadDigest: (()=>{
|
|
1515
|
+
if (!log.args.payloadDigest) {
|
|
1516
|
+
throw new Error(`CheckpointProposed event missing payloadDigest for checkpoint ${log.args.checkpointNumber}`);
|
|
1517
|
+
}
|
|
1518
|
+
return Buffer32.fromString(log.args.payloadDigest);
|
|
1519
|
+
})()
|
|
1520
|
+
}
|
|
1521
|
+
}));
|
|
1522
|
+
}
|
|
1523
|
+
/** Packs pending and proven checkpoint numbers into the chain tips storage format. */ static packChainTips(pendingCheckpointNumber, provenCheckpointNumber) {
|
|
1524
|
+
return pendingCheckpointNumber << 128n | provenCheckpointNumber & (1n << 128n) - 1n;
|
|
1525
|
+
}
|
|
1526
|
+
/** Storage slot for the chain tips (offset 0 within the STF storage struct). */ static get chainTipsStorageSlot() {
|
|
1527
|
+
return BigInt(RollupContract.stfStorageSlot);
|
|
1528
|
+
}
|
|
1529
|
+
/**
|
|
1530
|
+
* Computes the storage slot for a field within a tempCheckpointLog entry.
|
|
1531
|
+
* @param checkpointNumber - The checkpoint number
|
|
1532
|
+
* @param field - The field within the CompressedTempCheckpointLog struct
|
|
1533
|
+
*/ async getTempCheckpointLogStorageSlot(checkpointNumber, field) {
|
|
1534
|
+
const [epochDuration, proofSubmissionEpochs] = await Promise.all([
|
|
1535
|
+
this.getEpochDuration(),
|
|
1536
|
+
this.getProofSubmissionEpochs()
|
|
1537
|
+
]);
|
|
1538
|
+
return this.computeTempCheckpointLogStorageSlot(checkpointNumber, field, {
|
|
1539
|
+
epochDuration,
|
|
1540
|
+
proofSubmissionEpochs
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
computeTempCheckpointLogStorageSlot(checkpointNumber, field, constants) {
|
|
1544
|
+
const fieldOffset = BigInt(field);
|
|
1545
|
+
const { epochDuration, proofSubmissionEpochs } = constants;
|
|
1546
|
+
const roundaboutSize = BigInt(epochDuration) * (BigInt(proofSubmissionEpochs) + 1n) + 1n;
|
|
1547
|
+
const tempCheckpointLogsBase = BigInt(RollupContract.stfStorageSlot) + 2n;
|
|
1548
|
+
const circularIndex = BigInt(checkpointNumber) % roundaboutSize;
|
|
1549
|
+
const entryBase = BigInt(keccak256(encodeAbiParameters([
|
|
1550
|
+
{
|
|
1551
|
+
type: 'uint256'
|
|
1552
|
+
},
|
|
1553
|
+
{
|
|
1554
|
+
type: 'uint256'
|
|
1555
|
+
}
|
|
1556
|
+
], [
|
|
1557
|
+
circularIndex,
|
|
1558
|
+
tempCheckpointLogsBase
|
|
1559
|
+
])));
|
|
1560
|
+
return entryBase + fieldOffset;
|
|
1561
|
+
}
|
|
210
1562
|
}
|
|
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);
|