@aztec/ethereum 0.0.1-commit.b655e406 → 0.0.1-commit.b8a057fa
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 +1 -1
- package/dest/chain.d.ts +1 -1
- package/dest/client.d.ts +25 -3
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +60 -4
- package/dest/config.d.ts +48 -73
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +120 -386
- 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 +7 -5
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_base.js +1 -1
- package/dest/contracts/errors.d.ts +1 -1
- package/dest/contracts/errors.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.d.ts +6 -5
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.js +11 -9
- package/dest/contracts/fee_asset_price_oracle.d.ts +105 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
- package/dest/contracts/fee_asset_price_oracle.js +656 -0
- package/dest/contracts/fee_juice.d.ts +1 -1
- package/dest/contracts/fee_juice.d.ts.map +1 -1
- package/dest/contracts/governance.d.ts +113 -36
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +207 -16
- package/dest/contracts/governance_proposer.d.ts +38 -4
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +455 -12
- package/dest/contracts/gse.d.ts +4 -2
- package/dest/contracts/gse.d.ts.map +1 -1
- package/dest/contracts/gse.js +2 -2
- package/dest/contracts/inbox.d.ts +24 -3
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +42 -2
- package/dest/contracts/index.d.ts +6 -3
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +5 -2
- package/dest/contracts/log.d.ts +13 -0
- package/dest/contracts/log.d.ts.map +1 -0
- package/dest/contracts/log.js +1 -0
- package/dest/contracts/multicall.d.ts +130 -13
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +203 -93
- 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 +3 -1
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +30 -1
- package/dest/contracts/rollup.d.ts +5591 -131
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +1125 -232
- package/dest/contracts/slasher_contract.d.ts +1 -1
- package/dest/contracts/slasher_contract.d.ts.map +1 -1
- package/dest/contracts/{tally_slashing_proposer.d.ts → slashing_proposer.d.ts} +11 -10
- package/dest/contracts/slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/{tally_slashing_proposer.js → slashing_proposer.js} +21 -16
- package/dest/contracts/utils.d.ts +1 -1
- package/dest/deploy_aztec_l1_contracts.d.ts +267 -0
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
- package/dest/deploy_aztec_l1_contracts.js +417 -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 +1 -1
- package/dest/eth-signer/index.d.ts +1 -1
- 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/l1_artifacts.d.ts +21007 -16779
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_artifacts.js +9 -24
- package/dest/l1_contract_addresses.d.ts +61 -65
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +99 -80
- package/dest/l1_reader.d.ts +7 -5
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +15 -7
- package/dest/l1_tx_utils/config.d.ts +11 -5
- package/dest/l1_tx_utils/config.d.ts.map +1 -1
- package/dest/l1_tx_utils/config.js +46 -10
- package/dest/l1_tx_utils/constants.d.ts +8 -2
- package/dest/l1_tx_utils/constants.d.ts.map +1 -1
- package/dest/l1_tx_utils/constants.js +27 -2
- package/dest/l1_tx_utils/factory.d.ts +18 -10
- package/dest/l1_tx_utils/factory.d.ts.map +1 -1
- package/dest/l1_tx_utils/factory.js +17 -7
- package/dest/l1_tx_utils/fee-strategies/index.d.ts +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 +4 -1
- package/dest/l1_tx_utils/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/index.js +3 -0
- package/dest/l1_tx_utils/interfaces.d.ts +2 -2
- package/dest/l1_tx_utils/interfaces.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +252 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.js +568 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +26 -8
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +202 -92
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +19 -30
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +65 -168
- package/dest/l1_tx_utils/signer.d.ts +1 -1
- package/dest/l1_tx_utils/tx_delayer.d.ts +58 -0
- package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
- package/dest/{test → l1_tx_utils}/tx_delayer.js +70 -39
- package/dest/l1_tx_utils/types.d.ts +27 -1
- package/dest/l1_tx_utils/types.d.ts.map +1 -1
- package/dest/l1_tx_utils/types.js +10 -0
- package/dest/l1_tx_utils/utils.d.ts +1 -1
- package/dest/l1_types.d.ts +1 -1
- package/dest/publisher_manager.d.ts +34 -7
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +119 -8
- package/dest/queries.d.ts +14 -3
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +84 -9
- package/dest/test/blob_kzg_warmup.d.ts +19 -0
- package/dest/test/blob_kzg_warmup.d.ts.map +1 -0
- package/dest/test/blob_kzg_warmup.js +64 -0
- package/dest/test/chain_monitor.d.ts +80 -26
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +137 -39
- package/dest/test/eth_cheat_codes.d.ts +47 -8
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +100 -44
- package/dest/test/eth_cheat_codes_with_state.d.ts +1 -1
- package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
- package/dest/test/index.d.ts +2 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +1 -2
- package/dest/test/rollup_cheat_codes.d.ts +75 -14
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +145 -42
- package/dest/test/start_anvil.d.ts +25 -2
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +143 -28
- package/dest/test/upgrade_utils.d.ts +1 -1
- package/dest/test/upgrade_utils.js +2 -2
- package/dest/types.d.ts +57 -2
- package/dest/types.d.ts.map +1 -1
- package/dest/utils.d.ts +24 -4
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +112 -16
- package/dest/zkPassportVerifierAddress.d.ts +1 -1
- package/package.json +34 -17
- package/src/client.ts +66 -2
- package/src/config.ts +162 -470
- package/src/contracts/README.md +157 -0
- package/src/contracts/chain_state_override.ts +200 -0
- package/src/contracts/empire_base.ts +6 -5
- package/src/contracts/fee_asset_handler.ts +10 -7
- package/src/contracts/fee_asset_price_oracle.ts +285 -0
- package/src/contracts/governance.ts +279 -13
- package/src/contracts/governance_proposer.ts +74 -7
- package/src/contracts/gse.ts +7 -2
- package/src/contracts/inbox.ts +64 -4
- package/src/contracts/index.ts +5 -2
- package/src/contracts/log.ts +13 -0
- package/src/contracts/multicall.ts +247 -103
- package/src/contracts/outbox.ts +132 -0
- package/src/contracts/registry.ts +31 -1
- package/src/contracts/rollup.ts +830 -194
- package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +26 -21
- package/src/deploy_aztec_l1_contracts.ts +652 -0
- package/src/deploy_l1_contract.ts +362 -0
- package/src/forwarder_proxy.ts +108 -0
- package/src/l1_artifacts.ts +12 -35
- package/src/l1_contract_addresses.ts +120 -92
- package/src/l1_reader.ts +25 -10
- package/src/l1_tx_utils/config.ts +55 -14
- package/src/l1_tx_utils/constants.ts +13 -2
- package/src/l1_tx_utils/factory.ts +31 -31
- 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 +3 -0
- package/src/l1_tx_utils/interfaces.ts +1 -1
- package/src/l1_tx_utils/l1_fee_analyzer.ts +875 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +194 -72
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +79 -214
- package/src/{test → l1_tx_utils}/tx_delayer.ts +97 -58
- package/src/l1_tx_utils/types.ts +32 -0
- package/src/publisher_manager.ts +145 -12
- package/src/queries.ts +93 -10
- package/src/test/blob_kzg_warmup.ts +65 -0
- package/src/test/chain_monitor.ts +198 -51
- package/src/test/eth_cheat_codes.ts +91 -48
- package/src/test/index.ts +1 -2
- package/src/test/rollup_cheat_codes.ts +174 -45
- package/src/test/start_anvil.ts +179 -27
- package/src/test/upgrade_utils.ts +2 -2
- package/src/types.ts +62 -0
- package/src/utils.ts +128 -19
- package/dest/contracts/empire_slashing_proposer.d.ts +0 -65
- package/dest/contracts/empire_slashing_proposer.d.ts.map +0 -1
- package/dest/contracts/empire_slashing_proposer.js +0 -194
- package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
- package/dest/deploy_l1_contracts.d.ts +0 -226
- package/dest/deploy_l1_contracts.d.ts.map +0 -1
- package/dest/deploy_l1_contracts.js +0 -1473
- package/dest/index.d.ts +0 -18
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -17
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +0 -26
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +0 -26
- package/dest/test/delayed_tx_utils.d.ts +0 -13
- package/dest/test/delayed_tx_utils.d.ts.map +0 -1
- package/dest/test/delayed_tx_utils.js +0 -28
- package/dest/test/tx_delayer.d.ts +0 -36
- package/dest/test/tx_delayer.d.ts.map +0 -1
- package/src/contracts/empire_slashing_proposer.ts +0 -259
- package/src/deploy_l1_contracts.ts +0 -1849
- package/src/index.ts +0 -17
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
- package/src/test/delayed_tx_utils.ts +0 -52
package/dest/contracts/rollup.js
CHANGED
|
@@ -1,32 +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';
|
|
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';
|
|
9
383
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
10
384
|
import { RollupStorage } from '@aztec/l1-artifacts/RollupStorage';
|
|
11
385
|
import chunk from 'lodash.chunk';
|
|
12
|
-
import { encodeFunctionData, getContract, hexToBigInt, keccak256 } from 'viem';
|
|
386
|
+
import { ContractFunctionRevertedError, RpcRequestError, decodeErrorResult, encodeAbiParameters, encodeFunctionData, getContract, hexToBigInt, keccak256 } from 'viem';
|
|
13
387
|
import { getPublicClient } from '../client.js';
|
|
14
388
|
import { formatViemError } from '../utils.js';
|
|
15
|
-
import { EmpireSlashingProposerContract } from './empire_slashing_proposer.js';
|
|
16
389
|
import { GSEContract } from './gse.js';
|
|
17
390
|
import { SlasherContract } from './slasher_contract.js';
|
|
18
|
-
import {
|
|
391
|
+
import { SlashingProposerContract } from './slashing_proposer.js';
|
|
19
392
|
import { checkBlockTag } from './utils.js';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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;
|
|
25
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
|
+
}
|
|
26
434
|
export class RollupContract {
|
|
27
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
|
+
}
|
|
28
545
|
rollup;
|
|
546
|
+
logger;
|
|
29
547
|
static cachedStfStorageSlot;
|
|
548
|
+
cachedEscapeHatch;
|
|
30
549
|
static get checkBlobStorageSlot() {
|
|
31
550
|
const asString = RollupStorage.find((storage)=>storage.label === 'checkBlob')?.slot;
|
|
32
551
|
if (asString === undefined) {
|
|
@@ -43,11 +562,12 @@ export class RollupContract {
|
|
|
43
562
|
}
|
|
44
563
|
static getFromConfig(config) {
|
|
45
564
|
const client = getPublicClient(config);
|
|
46
|
-
const address = config.
|
|
565
|
+
const address = config.rollupAddress.toString();
|
|
47
566
|
return new RollupContract(client, address);
|
|
48
567
|
}
|
|
49
568
|
constructor(client, address){
|
|
50
569
|
this.client = client;
|
|
570
|
+
this.logger = (_initProto(this), createLogger('ethereum:rollup'));
|
|
51
571
|
if (address instanceof EthAddress) {
|
|
52
572
|
address = address.toString();
|
|
53
573
|
}
|
|
@@ -57,8 +577,8 @@ export class RollupContract {
|
|
|
57
577
|
client
|
|
58
578
|
});
|
|
59
579
|
}
|
|
60
|
-
getGSE() {
|
|
61
|
-
return this.rollup.read.getGSE();
|
|
580
|
+
async getGSE() {
|
|
581
|
+
return EthAddress.fromString(await this.rollup.read.getGSE());
|
|
62
582
|
}
|
|
63
583
|
get address() {
|
|
64
584
|
return this.rollup.address;
|
|
@@ -72,34 +592,10 @@ export class RollupContract {
|
|
|
72
592
|
return undefined;
|
|
73
593
|
}
|
|
74
594
|
const proposerAddress = await slasher.getProposer();
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
type: 'function',
|
|
78
|
-
name: 'SLASHING_PROPOSER_TYPE',
|
|
79
|
-
inputs: [],
|
|
80
|
-
outputs: [
|
|
81
|
-
{
|
|
82
|
-
name: '',
|
|
83
|
-
type: 'uint8',
|
|
84
|
-
internalType: 'enum SlasherFlavor'
|
|
85
|
-
}
|
|
86
|
-
],
|
|
87
|
-
stateMutability: 'view'
|
|
88
|
-
}
|
|
89
|
-
];
|
|
90
|
-
const proposer = getContract({
|
|
91
|
-
address: proposerAddress.toString(),
|
|
92
|
-
abi: proposerAbi,
|
|
93
|
-
client: this.client
|
|
94
|
-
});
|
|
95
|
-
const proposerType = await proposer.read.SLASHING_PROPOSER_TYPE();
|
|
96
|
-
if (proposerType === 1..valueOf()) {
|
|
97
|
-
return new TallySlashingProposerContract(this.client, proposerAddress);
|
|
98
|
-
} else if (proposerType === 2..valueOf()) {
|
|
99
|
-
return new EmpireSlashingProposerContract(this.client, proposerAddress);
|
|
100
|
-
} else {
|
|
101
|
-
throw new Error(`Unknown slashing proposer type: ${proposerType}`);
|
|
595
|
+
if (proposerAddress.isZero()) {
|
|
596
|
+
return undefined;
|
|
102
597
|
}
|
|
598
|
+
return new SlashingProposerContract(this.client, proposerAddress);
|
|
103
599
|
}
|
|
104
600
|
getL1StartBlock() {
|
|
105
601
|
return this.rollup.read.L1_BLOCK_AT_GENESIS();
|
|
@@ -107,17 +603,17 @@ export class RollupContract {
|
|
|
107
603
|
getL1GenesisTime() {
|
|
108
604
|
return this.rollup.read.getGenesisTime();
|
|
109
605
|
}
|
|
110
|
-
getProofSubmissionEpochs() {
|
|
111
|
-
return this.rollup.read.getProofSubmissionEpochs();
|
|
606
|
+
async getProofSubmissionEpochs() {
|
|
607
|
+
return Number(await this.rollup.read.getProofSubmissionEpochs());
|
|
112
608
|
}
|
|
113
|
-
getEpochDuration() {
|
|
114
|
-
return this.rollup.read.getEpochDuration();
|
|
609
|
+
async getEpochDuration() {
|
|
610
|
+
return Number(await this.rollup.read.getEpochDuration());
|
|
115
611
|
}
|
|
116
|
-
getSlotDuration() {
|
|
117
|
-
return this.rollup.read.getSlotDuration();
|
|
612
|
+
async getSlotDuration() {
|
|
613
|
+
return Number(await this.rollup.read.getSlotDuration());
|
|
118
614
|
}
|
|
119
|
-
getTargetCommitteeSize() {
|
|
120
|
-
return this.rollup.read.getTargetCommitteeSize();
|
|
615
|
+
async getTargetCommitteeSize() {
|
|
616
|
+
return Number(await this.rollup.read.getTargetCommitteeSize());
|
|
121
617
|
}
|
|
122
618
|
getEjectionThreshold() {
|
|
123
619
|
return this.rollup.read.getEjectionThreshold();
|
|
@@ -125,14 +621,17 @@ export class RollupContract {
|
|
|
125
621
|
getLocalEjectionThreshold() {
|
|
126
622
|
return this.rollup.read.getLocalEjectionThreshold();
|
|
127
623
|
}
|
|
128
|
-
|
|
129
|
-
return this.rollup.read.
|
|
624
|
+
async getLagInEpochsForValidatorSet() {
|
|
625
|
+
return Number(await this.rollup.read.getLagInEpochsForValidatorSet());
|
|
626
|
+
}
|
|
627
|
+
async getLagInEpochsForRandao() {
|
|
628
|
+
return Number(await this.rollup.read.getLagInEpochsForRandao());
|
|
130
629
|
}
|
|
131
630
|
getActivationThreshold() {
|
|
132
631
|
return this.rollup.read.getActivationThreshold();
|
|
133
632
|
}
|
|
134
|
-
getExitDelay() {
|
|
135
|
-
return this.rollup.read.getExitDelay();
|
|
633
|
+
async getExitDelay() {
|
|
634
|
+
return Number(await this.rollup.read.getExitDelay());
|
|
136
635
|
}
|
|
137
636
|
getManaTarget() {
|
|
138
637
|
return this.rollup.read.getManaTarget();
|
|
@@ -150,47 +649,116 @@ export class RollupContract {
|
|
|
150
649
|
return this.rollup.read.getVersion();
|
|
151
650
|
}
|
|
152
651
|
async getGenesisArchiveTreeRoot() {
|
|
153
|
-
return await this.rollup.read.archiveAt([
|
|
652
|
+
return Fr.fromString(await this.rollup.read.archiveAt([
|
|
154
653
|
0n
|
|
155
|
-
]);
|
|
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)}`
|
|
669
|
+
});
|
|
670
|
+
return Fr.fromString(value ?? '0x0');
|
|
156
671
|
}
|
|
157
672
|
/**
|
|
158
673
|
* Returns rollup constants used for epoch queries.
|
|
159
674
|
* Return type is `L1RollupConstants` which is defined in stdlib,
|
|
160
675
|
* so we cant reference it until we move this contract to that package.
|
|
161
676
|
*/ async getRollupConstants() {
|
|
162
|
-
const [l1StartBlock, l1GenesisTime, slotDuration, epochDuration, proofSubmissionEpochs] = await Promise.all([
|
|
677
|
+
const [l1StartBlock, l1GenesisTime, slotDuration, epochDuration, proofSubmissionEpochs, targetCommitteeSize, rollupManaLimit] = await Promise.all([
|
|
163
678
|
this.getL1StartBlock(),
|
|
164
679
|
this.getL1GenesisTime(),
|
|
165
680
|
this.getSlotDuration(),
|
|
166
681
|
this.getEpochDuration(),
|
|
167
|
-
this.getProofSubmissionEpochs()
|
|
682
|
+
this.getProofSubmissionEpochs(),
|
|
683
|
+
this.getTargetCommitteeSize(),
|
|
684
|
+
this.getManaLimit()
|
|
168
685
|
]);
|
|
169
686
|
return {
|
|
170
687
|
l1StartBlock,
|
|
171
688
|
l1GenesisTime,
|
|
172
|
-
slotDuration
|
|
689
|
+
slotDuration,
|
|
173
690
|
epochDuration: Number(epochDuration),
|
|
174
|
-
proofSubmissionEpochs: Number(proofSubmissionEpochs)
|
|
691
|
+
proofSubmissionEpochs: Number(proofSubmissionEpochs),
|
|
692
|
+
targetCommitteeSize,
|
|
693
|
+
rollupManaLimit: Number(rollupManaLimit)
|
|
175
694
|
};
|
|
176
695
|
}
|
|
177
|
-
getSlasherAddress() {
|
|
178
|
-
return this.rollup.read.getSlasher();
|
|
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
|
+
}
|
|
179
746
|
}
|
|
180
747
|
/**
|
|
181
748
|
* Returns a SlasherContract instance for interacting with the slasher contract.
|
|
182
749
|
*/ async getSlasherContract() {
|
|
183
|
-
const slasherAddress =
|
|
750
|
+
const slasherAddress = await this.getSlasherAddress();
|
|
184
751
|
if (slasherAddress.isZero()) {
|
|
185
752
|
return undefined;
|
|
186
753
|
}
|
|
187
754
|
return new SlasherContract(this.client, slasherAddress);
|
|
188
755
|
}
|
|
189
|
-
getOwner() {
|
|
190
|
-
return this.rollup.read.owner();
|
|
756
|
+
async getOwner() {
|
|
757
|
+
return EthAddress.fromString(await this.rollup.read.owner());
|
|
191
758
|
}
|
|
192
|
-
getActiveAttesterCount() {
|
|
193
|
-
|
|
759
|
+
async getActiveAttesterCount(options) {
|
|
760
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
761
|
+
return Number(await this.rollup.read.getActiveAttesterCount(options));
|
|
194
762
|
}
|
|
195
763
|
async getSlashingProposerAddress() {
|
|
196
764
|
const slasher = await this.getSlasherContract();
|
|
@@ -199,25 +767,45 @@ export class RollupContract {
|
|
|
199
767
|
}
|
|
200
768
|
return await slasher.getProposer();
|
|
201
769
|
}
|
|
202
|
-
|
|
203
|
-
return this.rollup.read.
|
|
770
|
+
getCheckpointReward() {
|
|
771
|
+
return this.rollup.read.getCheckpointReward();
|
|
204
772
|
}
|
|
205
|
-
|
|
206
|
-
|
|
773
|
+
async getCheckpointNumber(options) {
|
|
774
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
775
|
+
return CheckpointNumber.fromBigInt(await this.rollup.read.getPendingCheckpointNumber(options));
|
|
207
776
|
}
|
|
208
|
-
|
|
209
|
-
|
|
777
|
+
async getProvenCheckpointNumber(options) {
|
|
778
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
779
|
+
return CheckpointNumber.fromBigInt(await this.rollup.read.getProvenCheckpointNumber(options));
|
|
210
780
|
}
|
|
211
|
-
getSlotNumber() {
|
|
212
|
-
|
|
781
|
+
async getSlotNumber(options) {
|
|
782
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
783
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot(options));
|
|
213
784
|
}
|
|
214
|
-
getL1FeesAt(timestamp) {
|
|
215
|
-
|
|
785
|
+
async getL1FeesAt(timestamp, options) {
|
|
786
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
787
|
+
const result = await this.rollup.read.getL1FeesAt([
|
|
216
788
|
timestamp
|
|
789
|
+
], options);
|
|
790
|
+
return {
|
|
791
|
+
baseFee: result.baseFee,
|
|
792
|
+
blobFee: result.blobFee
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
async getFeeHeader(checkpointNumber) {
|
|
796
|
+
const result = await this.rollup.read.getFeeHeader([
|
|
797
|
+
checkpointNumber
|
|
217
798
|
]);
|
|
799
|
+
return {
|
|
800
|
+
excessMana: result.excessMana,
|
|
801
|
+
manaUsed: result.manaUsed,
|
|
802
|
+
ethPerFeeAsset: result.ethPerFeeAsset,
|
|
803
|
+
congestionCost: result.congestionCost,
|
|
804
|
+
proverCost: result.proverCost
|
|
805
|
+
};
|
|
218
806
|
}
|
|
219
|
-
|
|
220
|
-
return this.rollup.read.
|
|
807
|
+
getEthPerFeeAsset() {
|
|
808
|
+
return this.rollup.read.getEthPerFeeAsset();
|
|
221
809
|
}
|
|
222
810
|
async getCommitteeAt(timestamp) {
|
|
223
811
|
const { result } = await this.client.simulateContract({
|
|
@@ -228,25 +816,25 @@ export class RollupContract {
|
|
|
228
816
|
timestamp
|
|
229
817
|
]
|
|
230
818
|
}).catch((e)=>{
|
|
231
|
-
if (e
|
|
819
|
+
if (isValidatorSelectionError(e, INSUFFICIENT_VALIDATOR_SET_SIZE_ERROR)) {
|
|
232
820
|
return {
|
|
233
821
|
result: undefined
|
|
234
822
|
};
|
|
235
823
|
}
|
|
236
824
|
throw e;
|
|
237
825
|
});
|
|
238
|
-
return result;
|
|
826
|
+
return result ? result.map((addr)=>EthAddress.fromString(addr)) : undefined;
|
|
239
827
|
}
|
|
240
|
-
getSampleSeedAt(timestamp) {
|
|
241
|
-
return this.rollup.read.getSampleSeedAt([
|
|
828
|
+
async getSampleSeedAt(timestamp) {
|
|
829
|
+
return Buffer32.fromBigInt(await this.rollup.read.getSampleSeedAt([
|
|
242
830
|
timestamp
|
|
243
|
-
]);
|
|
831
|
+
]));
|
|
244
832
|
}
|
|
245
|
-
getCurrentSampleSeed() {
|
|
246
|
-
return this.rollup.read.getCurrentSampleSeed();
|
|
833
|
+
async getCurrentSampleSeed() {
|
|
834
|
+
return Buffer32.fromBigInt(await this.rollup.read.getCurrentSampleSeed());
|
|
247
835
|
}
|
|
248
|
-
getCurrentEpoch() {
|
|
249
|
-
return this.rollup.read.getCurrentEpoch();
|
|
836
|
+
async getCurrentEpoch() {
|
|
837
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
250
838
|
}
|
|
251
839
|
async getCurrentEpochCommittee() {
|
|
252
840
|
const { result } = await this.client.simulateContract({
|
|
@@ -255,14 +843,14 @@ export class RollupContract {
|
|
|
255
843
|
functionName: 'getCurrentEpochCommittee',
|
|
256
844
|
args: []
|
|
257
845
|
}).catch((e)=>{
|
|
258
|
-
if (e
|
|
846
|
+
if (isValidatorSelectionError(e, INSUFFICIENT_VALIDATOR_SET_SIZE_ERROR)) {
|
|
259
847
|
return {
|
|
260
848
|
result: undefined
|
|
261
849
|
};
|
|
262
850
|
}
|
|
263
851
|
throw e;
|
|
264
852
|
});
|
|
265
|
-
return result;
|
|
853
|
+
return result ? result.map((addr)=>EthAddress.fromString(addr)) : undefined;
|
|
266
854
|
}
|
|
267
855
|
async getCurrentProposer() {
|
|
268
856
|
const { result } = await this.client.simulateContract({
|
|
@@ -271,7 +859,7 @@ export class RollupContract {
|
|
|
271
859
|
functionName: 'getCurrentProposer',
|
|
272
860
|
args: []
|
|
273
861
|
});
|
|
274
|
-
return result;
|
|
862
|
+
return EthAddress.fromString(result);
|
|
275
863
|
}
|
|
276
864
|
async getProposerAt(timestamp) {
|
|
277
865
|
const { result } = await this.client.simulateContract({
|
|
@@ -282,37 +870,92 @@ export class RollupContract {
|
|
|
282
870
|
timestamp
|
|
283
871
|
]
|
|
284
872
|
});
|
|
285
|
-
return result;
|
|
873
|
+
return EthAddress.fromString(result);
|
|
286
874
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
875
|
+
async getCheckpoint(checkpointNumber, options) {
|
|
876
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
877
|
+
const result = await this.rollup.read.getCheckpoint([
|
|
878
|
+
BigInt(checkpointNumber)
|
|
879
|
+
], options);
|
|
880
|
+
return {
|
|
881
|
+
archive: Fr.fromString(result.archive),
|
|
882
|
+
headerHash: Buffer32.fromString(result.headerHash),
|
|
883
|
+
blobCommitmentsHash: Buffer32.fromString(result.blobCommitmentsHash),
|
|
884
|
+
attestationsHash: Buffer32.fromString(result.attestationsHash),
|
|
885
|
+
payloadDigest: Buffer32.fromString(result.payloadDigest),
|
|
886
|
+
slotNumber: SlotNumber.fromBigInt(result.slotNumber),
|
|
887
|
+
feeHeader: {
|
|
888
|
+
excessMana: result.feeHeader.excessMana,
|
|
889
|
+
manaUsed: result.feeHeader.manaUsed,
|
|
890
|
+
ethPerFeeAsset: result.feeHeader.ethPerFeeAsset,
|
|
891
|
+
congestionCost: result.feeHeader.congestionCost,
|
|
892
|
+
proverCost: result.feeHeader.proverCost
|
|
893
|
+
}
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
/** Returns the pending checkpoint from the rollup contract */ getPendingCheckpoint() {
|
|
897
|
+
// We retry because of race conditions during prunes: we may get a pending checkpoint number which is immediately
|
|
898
|
+
// reorged out due to a prune happening, causing the subsequent getCheckpoint call to fail. So we try again in that case.
|
|
899
|
+
return retry(async ()=>{
|
|
900
|
+
const pendingCheckpointNumber = await this.getCheckpointNumber();
|
|
901
|
+
const pendingCheckpoint = await this.getCheckpoint(pendingCheckpointNumber);
|
|
902
|
+
return pendingCheckpoint;
|
|
903
|
+
}, 'getting pending checkpoint', makeBackoff([
|
|
904
|
+
0.5,
|
|
905
|
+
0.5,
|
|
906
|
+
0.5
|
|
907
|
+
]));
|
|
291
908
|
}
|
|
292
|
-
|
|
293
|
-
|
|
909
|
+
/**
|
|
910
|
+
* Returns the effective pending checkpoint, accounting for potential prunes.
|
|
911
|
+
* When a prune can happen, the L1 contract uses the proven checkpoint instead of the pending one.
|
|
912
|
+
* This mirrors the behavior of getEffectivePendingCheckpointNumber in STFLib.sol.
|
|
913
|
+
* @param atTimestamp - The timestamp to evaluate pruneability at. Defaults to the current L1 block timestamp.
|
|
914
|
+
* @param options - Optional L1 block number to pin the queries to.
|
|
915
|
+
*/ getEffectivePendingCheckpoint(atTimestamp, options) {
|
|
916
|
+
return retry(async ()=>{
|
|
917
|
+
const timestamp = atTimestamp ?? (await this.client.getBlock()).timestamp;
|
|
918
|
+
const canPrune = await this.canPruneAtTime(timestamp, options);
|
|
919
|
+
if (canPrune) {
|
|
920
|
+
const provenCheckpointNumber = await this.getProvenCheckpointNumber(options);
|
|
921
|
+
return await this.getCheckpoint(provenCheckpointNumber, options);
|
|
922
|
+
}
|
|
923
|
+
const pendingCheckpointNumber = await this.getCheckpointNumber(options);
|
|
924
|
+
return await this.getCheckpoint(pendingCheckpointNumber, options);
|
|
925
|
+
}, 'getting effective pending checkpoint', makeBackoff([
|
|
926
|
+
0.5,
|
|
927
|
+
0.5,
|
|
928
|
+
0.5
|
|
929
|
+
]));
|
|
930
|
+
}
|
|
931
|
+
async getTips() {
|
|
932
|
+
const { pending, proven } = await this.rollup.read.getTips();
|
|
933
|
+
return {
|
|
934
|
+
pending: CheckpointNumber.fromBigInt(pending),
|
|
935
|
+
proven: CheckpointNumber.fromBigInt(proven)
|
|
936
|
+
};
|
|
294
937
|
}
|
|
295
938
|
getTimestampForSlot(slot) {
|
|
296
939
|
return this.rollup.read.getTimestampForSlot([
|
|
297
|
-
slot
|
|
940
|
+
BigInt(slot)
|
|
298
941
|
]);
|
|
299
942
|
}
|
|
300
|
-
getEntryQueueLength() {
|
|
301
|
-
return this.rollup.read.getEntryQueueLength();
|
|
943
|
+
async getEntryQueueLength() {
|
|
944
|
+
return Number(await this.rollup.read.getEntryQueueLength());
|
|
302
945
|
}
|
|
303
|
-
getAvailableValidatorFlushes() {
|
|
304
|
-
return this.rollup.read.getAvailableValidatorFlushes();
|
|
946
|
+
async getAvailableValidatorFlushes() {
|
|
947
|
+
return Number(await this.rollup.read.getAvailableValidatorFlushes());
|
|
305
948
|
}
|
|
306
|
-
getNextFlushableEpoch() {
|
|
307
|
-
return this.rollup.read.getNextFlushableEpoch();
|
|
949
|
+
async getNextFlushableEpoch() {
|
|
950
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getNextFlushableEpoch());
|
|
308
951
|
}
|
|
309
|
-
getCurrentEpochNumber() {
|
|
310
|
-
return this.rollup.read.getCurrentEpoch();
|
|
952
|
+
async getCurrentEpochNumber() {
|
|
953
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
311
954
|
}
|
|
312
|
-
|
|
313
|
-
return this.rollup.read.
|
|
314
|
-
BigInt(
|
|
315
|
-
]);
|
|
955
|
+
async getEpochNumberForCheckpoint(checkpointNumber) {
|
|
956
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochForCheckpoint([
|
|
957
|
+
BigInt(checkpointNumber)
|
|
958
|
+
]));
|
|
316
959
|
}
|
|
317
960
|
async getRollupAddresses() {
|
|
318
961
|
const [inboxAddress, outboxAddress, feeJuicePortalAddress, rewardDistributorAddress, feeJuiceAddress, stakingAssetAddress, gseAddress] = (await Promise.all([
|
|
@@ -339,12 +982,13 @@ export class RollupContract {
|
|
|
339
982
|
return EthAddress.fromString(await this.rollup.read.getFeeAssetPortal());
|
|
340
983
|
}
|
|
341
984
|
async getEpochNumberForSlotNumber(slotNumber) {
|
|
342
|
-
return await this.rollup.read.getEpochAtSlot([
|
|
343
|
-
slotNumber
|
|
344
|
-
]);
|
|
985
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([
|
|
986
|
+
BigInt(slotNumber)
|
|
987
|
+
]));
|
|
345
988
|
}
|
|
346
|
-
getEpochProofPublicInputs(args) {
|
|
347
|
-
|
|
989
|
+
async getEpochProofPublicInputs(args) {
|
|
990
|
+
const result = await this.rollup.read.getEpochProofPublicInputs(args);
|
|
991
|
+
return result.map(Fr.fromString);
|
|
348
992
|
}
|
|
349
993
|
async validateHeader(args, account) {
|
|
350
994
|
try {
|
|
@@ -365,17 +1009,14 @@ export class RollupContract {
|
|
|
365
1009
|
* @dev Throws if unable to propose
|
|
366
1010
|
*
|
|
367
1011
|
* @param archive - The archive that we expect to be current state
|
|
368
|
-
* @return [slot,
|
|
1012
|
+
* @return [slot, checkpointNumber, timeOfNextL1Slot] - If you can propose, the L2 slot number, checkpoint number and
|
|
1013
|
+
* timestamp of the next L1 block
|
|
369
1014
|
* @throws otherwise
|
|
370
|
-
*/ async
|
|
371
|
-
|
|
372
|
-
slotDuration = BigInt(slotDuration);
|
|
373
|
-
}
|
|
374
|
-
const latestBlock = await this.client.getBlock();
|
|
375
|
-
const timeOfNextL1Slot = latestBlock.timestamp + slotDuration;
|
|
1015
|
+
*/ async canProposeAt(archive, account, timestamp, stateOverride = []) {
|
|
1016
|
+
const timeOfNextL1Slot = timestamp;
|
|
376
1017
|
const who = typeof account === 'string' ? account : account.address;
|
|
377
1018
|
try {
|
|
378
|
-
const { result: [slot,
|
|
1019
|
+
const { result: [slot, checkpointNumber] } = await this.client.simulateContract({
|
|
379
1020
|
address: this.address,
|
|
380
1021
|
abi: RollupAbi,
|
|
381
1022
|
functionName: 'canProposeAtTime',
|
|
@@ -385,11 +1026,11 @@ export class RollupContract {
|
|
|
385
1026
|
who
|
|
386
1027
|
],
|
|
387
1028
|
account,
|
|
388
|
-
stateOverride
|
|
1029
|
+
stateOverride
|
|
389
1030
|
});
|
|
390
1031
|
return {
|
|
391
|
-
slot,
|
|
392
|
-
|
|
1032
|
+
slot: SlotNumber.fromBigInt(slot),
|
|
1033
|
+
checkpointNumber: CheckpointNumber.fromBigInt(checkpointNumber),
|
|
393
1034
|
timeOfNextL1Slot
|
|
394
1035
|
};
|
|
395
1036
|
} catch (err) {
|
|
@@ -397,11 +1038,15 @@ export class RollupContract {
|
|
|
397
1038
|
}
|
|
398
1039
|
}
|
|
399
1040
|
/**
|
|
400
|
-
* Returns a state override that sets the pending
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
|
|
404
|
-
|
|
1041
|
+
* Returns a state override that sets the pending and/or proven checkpoint numbers. Useful for simulations.
|
|
1042
|
+
* Both values share a single storage slot (pending in the upper 128 bits, proven in the lower 128 bits), so
|
|
1043
|
+
* a single combined override is emitted to avoid the second state-diff clobbering the first. The current live
|
|
1044
|
+
* value is read once to preserve any half not being overridden. Returns an empty override if neither is set.
|
|
1045
|
+
*
|
|
1046
|
+
* Throws if the resulting `proven > pending`, which would crash the simulation: `STFLib.canPruneAtTime` calls
|
|
1047
|
+
* `getEpochForCheckpoint(proven + 1)` whenever `pending != proven`, and that asserts `_n <= tips.pending`.
|
|
1048
|
+
*/ async makeChainTipsOverride(override) {
|
|
1049
|
+
if (override.pending === undefined && override.proven === undefined) {
|
|
405
1050
|
return [];
|
|
406
1051
|
}
|
|
407
1052
|
const slot = RollupContract.stfStorageSlot;
|
|
@@ -409,8 +1054,15 @@ export class RollupContract {
|
|
|
409
1054
|
address: this.address,
|
|
410
1055
|
slot
|
|
411
1056
|
});
|
|
412
|
-
const
|
|
413
|
-
const
|
|
1057
|
+
const currentRaw = currentValue ? hexToBigInt(currentValue) : 0n;
|
|
1058
|
+
const currentPending = currentRaw >> 128n;
|
|
1059
|
+
const currentProven = currentRaw & (1n << 128n) - 1n;
|
|
1060
|
+
const newPending = override.pending !== undefined ? BigInt(override.pending) : currentPending;
|
|
1061
|
+
const newProven = override.proven !== undefined ? BigInt(override.proven) : currentProven;
|
|
1062
|
+
if (newProven > newPending) {
|
|
1063
|
+
throw new Error(`Invalid chain tips override: proven (${newProven}) > pending (${newPending})`);
|
|
1064
|
+
}
|
|
1065
|
+
const newValue = newPending << 128n | newProven;
|
|
414
1066
|
return [
|
|
415
1067
|
{
|
|
416
1068
|
address: this.address,
|
|
@@ -423,14 +1075,170 @@ export class RollupContract {
|
|
|
423
1075
|
}
|
|
424
1076
|
];
|
|
425
1077
|
}
|
|
426
|
-
/**
|
|
1078
|
+
/**
|
|
1079
|
+
* Returns a state override that patches `tempCheckpointLogs[checkpointNumber]` with every field that
|
|
1080
|
+
* the L1 contract reads during `propose()` for the checkpoint that builds on top of it (proposer
|
|
1081
|
+
* pipelining simulation). Mirrors the writes done by `ProposeLib.addTempCheckpointLog`.
|
|
1082
|
+
*
|
|
1083
|
+
* `blobCommitmentsHash` and `attestationsHash` are intentionally not exposed here — the propose path
|
|
1084
|
+
* never asserts against them, so leaving them at storage zero is harmless.
|
|
1085
|
+
*/ async makeTempCheckpointLogOverride(checkpointNumber, fields) {
|
|
1086
|
+
const constants = await this.getRollupConstants();
|
|
1087
|
+
const slotAt = (field)=>`0x${this.computeTempCheckpointLogStorageSlot(checkpointNumber, field, constants).toString(16).padStart(64, '0')}`;
|
|
1088
|
+
const word = (v)=>`0x${v.toString(16).padStart(64, '0')}`;
|
|
1089
|
+
const stateDiff = [];
|
|
1090
|
+
if (fields.headerHash) {
|
|
1091
|
+
stateDiff.push({
|
|
1092
|
+
slot: slotAt(0),
|
|
1093
|
+
value: fields.headerHash.toString()
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
if (fields.outHash) {
|
|
1097
|
+
stateDiff.push({
|
|
1098
|
+
slot: slotAt(2),
|
|
1099
|
+
value: fields.outHash.toString()
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
if (fields.payloadDigest) {
|
|
1103
|
+
stateDiff.push({
|
|
1104
|
+
slot: slotAt(4),
|
|
1105
|
+
value: fields.payloadDigest.toString()
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
if (fields.slotNumber !== undefined) {
|
|
1109
|
+
// CompressedSlot is uint32 on L1 (SafeCast.toUint32 reverts on overflow). Match that behavior here
|
|
1110
|
+
// so a malformed override surfaces immediately rather than silently truncating into a wrong slot.
|
|
1111
|
+
const slotNumber = BigInt(fields.slotNumber);
|
|
1112
|
+
if (slotNumber < 0n || slotNumber > 0xffffffffn) {
|
|
1113
|
+
throw new Error(`slotNumber ${slotNumber} does not fit in uint32`);
|
|
1114
|
+
}
|
|
1115
|
+
stateDiff.push({
|
|
1116
|
+
slot: slotAt(5),
|
|
1117
|
+
value: word(slotNumber)
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
if (fields.feeHeader) {
|
|
1121
|
+
stateDiff.push({
|
|
1122
|
+
slot: slotAt(6),
|
|
1123
|
+
value: word(RollupContract.compressFeeHeader(fields.feeHeader))
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
if (stateDiff.length === 0) {
|
|
1127
|
+
return [];
|
|
1128
|
+
}
|
|
1129
|
+
return [
|
|
1130
|
+
{
|
|
1131
|
+
address: this.address,
|
|
1132
|
+
stateDiff
|
|
1133
|
+
}
|
|
1134
|
+
];
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* Returns a state override that sets archives[checkpointNumber] to the given archive value.
|
|
1138
|
+
* Used when simulating a canProposeAtTime call where the local archive differs from L1
|
|
1139
|
+
* (e.g. pipelining where the parent checkpoint hasn't landed on L1 yet).
|
|
1140
|
+
*/ makeArchiveOverride(checkpointNumber, archive) {
|
|
1141
|
+
const archivesMappingBase = hexToBigInt(RollupContract.stfStorageSlot) + 1n;
|
|
1142
|
+
const archiveSlot = hexToBigInt(keccak256(encodeAbiParameters([
|
|
1143
|
+
{
|
|
1144
|
+
type: 'uint256'
|
|
1145
|
+
},
|
|
1146
|
+
{
|
|
1147
|
+
type: 'uint256'
|
|
1148
|
+
}
|
|
1149
|
+
], [
|
|
1150
|
+
BigInt(checkpointNumber),
|
|
1151
|
+
archivesMappingBase
|
|
1152
|
+
])));
|
|
1153
|
+
return [
|
|
1154
|
+
{
|
|
1155
|
+
address: this.address,
|
|
1156
|
+
stateDiff: [
|
|
1157
|
+
{
|
|
1158
|
+
slot: `0x${archiveSlot.toString(16).padStart(64, '0')}`,
|
|
1159
|
+
value: archive.toString()
|
|
1160
|
+
}
|
|
1161
|
+
]
|
|
1162
|
+
}
|
|
1163
|
+
];
|
|
1164
|
+
}
|
|
1165
|
+
/** Merges multiple StateOverride arrays, combining stateDiff entries for the same address. */ static mergeStateOverrides(...overrides) {
|
|
1166
|
+
const byAddress = new Map();
|
|
1167
|
+
for (const override of overrides){
|
|
1168
|
+
for (const entry of override){
|
|
1169
|
+
const key = entry.address.toLowerCase();
|
|
1170
|
+
const existing = byAddress.get(key);
|
|
1171
|
+
if (existing) {
|
|
1172
|
+
existing.stateDiff.push(...entry.stateDiff ?? []);
|
|
1173
|
+
if (entry.balance !== undefined) {
|
|
1174
|
+
existing.balance = entry.balance;
|
|
1175
|
+
}
|
|
1176
|
+
} else {
|
|
1177
|
+
byAddress.set(key, {
|
|
1178
|
+
address: entry.address,
|
|
1179
|
+
balance: entry.balance,
|
|
1180
|
+
stateDiff: [
|
|
1181
|
+
...entry.stateDiff ?? []
|
|
1182
|
+
]
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
return [
|
|
1188
|
+
...byAddress.values()
|
|
1189
|
+
];
|
|
1190
|
+
}
|
|
1191
|
+
/** Compresses a FeeHeader into a uint256 matching FeeHeaderLib.compress() in FeeStructs.sol. */ static compressFeeHeader(feeHeader) {
|
|
1192
|
+
const MASK_48_BITS = (1n << 48n) - 1n;
|
|
1193
|
+
const MASK_64_BITS = (1n << 64n) - 1n;
|
|
1194
|
+
const MASK_63_BITS = (1n << 63n) - 1n;
|
|
1195
|
+
let value = BigInt(feeHeader.manaUsed) & (1n << 32n) - 1n; // bits [0:31]
|
|
1196
|
+
value |= (feeHeader.excessMana < MASK_48_BITS ? feeHeader.excessMana : MASK_48_BITS) << 32n; // bits [32:79]
|
|
1197
|
+
value |= (BigInt(feeHeader.ethPerFeeAsset) & MASK_48_BITS) << 80n; // bits [80:127]
|
|
1198
|
+
value |= (feeHeader.congestionCost < MASK_64_BITS ? feeHeader.congestionCost : MASK_64_BITS) << 128n; // bits [128:191]
|
|
1199
|
+
value |= (feeHeader.proverCost < MASK_63_BITS ? feeHeader.proverCost : MASK_63_BITS) << 192n; // bits [192:254]
|
|
1200
|
+
value |= 1n << 255n; // preheat flag
|
|
1201
|
+
return value;
|
|
1202
|
+
}
|
|
1203
|
+
/** Computes the fee header for a child checkpoint given parent fee header and child data.
|
|
1204
|
+
* Must stay in sync with Solidity FeeLib.sol (computeNewEthPerFeeAsset, clampedAdd). */ static computeChildFeeHeader(parentFeeHeader, childManaUsed, feeAssetPriceModifier, manaTarget) {
|
|
1205
|
+
const MIN_ETH_PER_FEE_ASSET = 100n;
|
|
1206
|
+
const MAX_ETH_PER_FEE_ASSET = 100_000_000_000_000n; // 1e14, matches FeeLib.sol
|
|
1207
|
+
// excessMana = clampedAdd(parent.excessMana + parent.manaUsed, -manaTarget)
|
|
1208
|
+
const sum = parentFeeHeader.excessMana + parentFeeHeader.manaUsed;
|
|
1209
|
+
const excessMana = sum > manaTarget ? sum - manaTarget : 0n;
|
|
1210
|
+
// ethPerFeeAsset = computeNewEthPerFeeAsset(max(parent.ethPerFeeAsset, MIN), modifier)
|
|
1211
|
+
const parentPrice = parentFeeHeader.ethPerFeeAsset > MIN_ETH_PER_FEE_ASSET ? parentFeeHeader.ethPerFeeAsset : MIN_ETH_PER_FEE_ASSET;
|
|
1212
|
+
let newPrice;
|
|
1213
|
+
if (feeAssetPriceModifier >= 0n) {
|
|
1214
|
+
newPrice = parentPrice * (10_000n + feeAssetPriceModifier) / 10_000n;
|
|
1215
|
+
} else {
|
|
1216
|
+
const absMod = -feeAssetPriceModifier;
|
|
1217
|
+
newPrice = parentPrice * (10_000n - absMod) / 10_000n;
|
|
1218
|
+
}
|
|
1219
|
+
if (newPrice < MIN_ETH_PER_FEE_ASSET) {
|
|
1220
|
+
newPrice = MIN_ETH_PER_FEE_ASSET;
|
|
1221
|
+
}
|
|
1222
|
+
if (newPrice > MAX_ETH_PER_FEE_ASSET) {
|
|
1223
|
+
newPrice = MAX_ETH_PER_FEE_ASSET;
|
|
1224
|
+
}
|
|
1225
|
+
return {
|
|
1226
|
+
excessMana,
|
|
1227
|
+
manaUsed: childManaUsed,
|
|
1228
|
+
ethPerFeeAsset: newPrice,
|
|
1229
|
+
congestionCost: 0n,
|
|
1230
|
+
proverCost: 0n
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
/** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */ buildInvalidateBadAttestationRequest(checkpointNumber, attestationsAndSigners, committee, invalidIndex) {
|
|
427
1234
|
return {
|
|
428
1235
|
to: this.address,
|
|
1236
|
+
abi: RollupAbi,
|
|
429
1237
|
data: encodeFunctionData({
|
|
430
1238
|
abi: RollupAbi,
|
|
431
1239
|
functionName: 'invalidateBadAttestation',
|
|
432
1240
|
args: [
|
|
433
|
-
BigInt(
|
|
1241
|
+
BigInt(checkpointNumber),
|
|
434
1242
|
attestationsAndSigners,
|
|
435
1243
|
committee.map((addr)=>addr.toString()),
|
|
436
1244
|
BigInt(invalidIndex)
|
|
@@ -438,46 +1246,68 @@ export class RollupContract {
|
|
|
438
1246
|
})
|
|
439
1247
|
};
|
|
440
1248
|
}
|
|
441
|
-
/** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */ buildInvalidateInsufficientAttestationsRequest(
|
|
1249
|
+
/** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */ buildInvalidateInsufficientAttestationsRequest(checkpointNumber, attestationsAndSigners, committee) {
|
|
442
1250
|
return {
|
|
443
1251
|
to: this.address,
|
|
1252
|
+
abi: RollupAbi,
|
|
444
1253
|
data: encodeFunctionData({
|
|
445
1254
|
abi: RollupAbi,
|
|
446
1255
|
functionName: 'invalidateInsufficientAttestations',
|
|
447
1256
|
args: [
|
|
448
|
-
BigInt(
|
|
1257
|
+
BigInt(checkpointNumber),
|
|
449
1258
|
attestationsAndSigners,
|
|
450
1259
|
committee.map((addr)=>addr.toString())
|
|
451
1260
|
]
|
|
452
1261
|
})
|
|
453
1262
|
};
|
|
454
1263
|
}
|
|
455
|
-
/** Calls getHasSubmitted directly. Returns whether the given prover has submitted a proof with the given length for the given epoch. */ getHasSubmittedProof(epochNumber,
|
|
1264
|
+
/** Calls getHasSubmitted directly. Returns whether the given prover has submitted a proof with the given length for the given epoch. */ getHasSubmittedProof(epochNumber, numberOfCheckpointsInEpoch, prover) {
|
|
456
1265
|
if (prover instanceof EthAddress) {
|
|
457
1266
|
prover = prover.toString();
|
|
458
1267
|
}
|
|
459
1268
|
return this.rollup.read.getHasSubmitted([
|
|
460
1269
|
BigInt(epochNumber),
|
|
461
|
-
BigInt(
|
|
1270
|
+
BigInt(numberOfCheckpointsInEpoch),
|
|
462
1271
|
prover
|
|
463
1272
|
]);
|
|
464
1273
|
}
|
|
465
|
-
|
|
466
|
-
return this.rollup.read.
|
|
1274
|
+
getManaMinFeeAt(timestamp, inFeeAsset, stateOverride) {
|
|
1275
|
+
return this.rollup.read.getManaMinFeeAt([
|
|
1276
|
+
timestamp,
|
|
1277
|
+
inFeeAsset
|
|
1278
|
+
], {
|
|
1279
|
+
stateOverride
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
async getManaMinFeeComponentsAt(timestamp, inFeeAsset) {
|
|
1283
|
+
const result = await this.rollup.read.getManaMinFeeComponentsAt([
|
|
467
1284
|
timestamp,
|
|
468
1285
|
inFeeAsset
|
|
469
1286
|
]);
|
|
1287
|
+
return {
|
|
1288
|
+
sequencerCost: result.sequencerCost,
|
|
1289
|
+
proverCost: result.proverCost,
|
|
1290
|
+
congestionCost: result.congestionCost,
|
|
1291
|
+
congestionMultiplier: result.congestionMultiplier
|
|
1292
|
+
};
|
|
470
1293
|
}
|
|
471
|
-
getSlotAt(timestamp) {
|
|
472
|
-
return this.rollup.read.getSlotAt([
|
|
1294
|
+
async getSlotAt(timestamp) {
|
|
1295
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([
|
|
473
1296
|
timestamp
|
|
474
|
-
]);
|
|
1297
|
+
]));
|
|
475
1298
|
}
|
|
476
|
-
async status(
|
|
1299
|
+
async status(checkpointNumber, options) {
|
|
477
1300
|
await checkBlockTag(options?.blockNumber, this.client);
|
|
478
|
-
|
|
479
|
-
|
|
1301
|
+
const result = await this.rollup.read.status([
|
|
1302
|
+
BigInt(checkpointNumber)
|
|
480
1303
|
], options);
|
|
1304
|
+
return {
|
|
1305
|
+
provenCheckpointNumber: CheckpointNumber.fromBigInt(result[0]),
|
|
1306
|
+
provenArchive: Fr.fromString(result[1]),
|
|
1307
|
+
pendingCheckpointNumber: CheckpointNumber.fromBigInt(result[2]),
|
|
1308
|
+
pendingArchive: Fr.fromString(result[3]),
|
|
1309
|
+
archiveOfMyCheckpoint: Fr.fromString(result[4])
|
|
1310
|
+
};
|
|
481
1311
|
}
|
|
482
1312
|
async canPruneAtTime(timestamp, options) {
|
|
483
1313
|
await checkBlockTag(options?.blockNumber, this.client);
|
|
@@ -485,13 +1315,13 @@ export class RollupContract {
|
|
|
485
1315
|
timestamp
|
|
486
1316
|
], options);
|
|
487
1317
|
}
|
|
488
|
-
archive() {
|
|
489
|
-
return this.rollup.read.archive();
|
|
1318
|
+
async archive() {
|
|
1319
|
+
return Fr.fromString(await this.rollup.read.archive());
|
|
490
1320
|
}
|
|
491
|
-
archiveAt(
|
|
492
|
-
return this.rollup.read.archiveAt([
|
|
493
|
-
|
|
494
|
-
]);
|
|
1321
|
+
async archiveAt(checkpointNumber) {
|
|
1322
|
+
return Fr.fromString(await this.rollup.read.archiveAt([
|
|
1323
|
+
BigInt(checkpointNumber)
|
|
1324
|
+
]));
|
|
495
1325
|
}
|
|
496
1326
|
getSequencerRewards(address) {
|
|
497
1327
|
if (address instanceof EthAddress) {
|
|
@@ -510,49 +1340,85 @@ export class RollupContract {
|
|
|
510
1340
|
prover
|
|
511
1341
|
]);
|
|
512
1342
|
}
|
|
513
|
-
async getAttesters() {
|
|
514
|
-
|
|
1343
|
+
async getAttesters(timestamp) {
|
|
1344
|
+
// Pin every read to a single L1 block so the attester count and the chunked index reads
|
|
1345
|
+
// observe a consistent set. Without this, the count and each chunk default to `latest` and
|
|
1346
|
+
// can straddle a block boundary (or reorg), yielding an inconsistent or truncated set.
|
|
1347
|
+
const block = await this.client.getBlock();
|
|
1348
|
+
const blockNumber = block.number ?? undefined;
|
|
1349
|
+
const ts = timestamp ?? block.timestamp;
|
|
1350
|
+
const attesterSize = await this.getActiveAttesterCount({
|
|
1351
|
+
blockNumber
|
|
1352
|
+
});
|
|
515
1353
|
const gse = new GSEContract(this.client, await this.getGSE());
|
|
516
|
-
const ts = (await this.client.getBlock()).timestamp;
|
|
517
1354
|
const indices = Array.from({
|
|
518
|
-
length:
|
|
1355
|
+
length: attesterSize
|
|
519
1356
|
}, (_, i)=>BigInt(i));
|
|
520
1357
|
const chunks = chunk(indices, 1000);
|
|
521
|
-
|
|
1358
|
+
const results = await Promise.all(chunks.map((chunk)=>gse.getAttestersFromIndicesAtTime(this.address, ts, chunk, {
|
|
1359
|
+
blockNumber
|
|
1360
|
+
})));
|
|
1361
|
+
return results.flat().map((addr)=>EthAddress.fromString(addr));
|
|
522
1362
|
}
|
|
523
|
-
getAttesterView(address) {
|
|
1363
|
+
async getAttesterView(address) {
|
|
524
1364
|
if (address instanceof EthAddress) {
|
|
525
1365
|
address = address.toString();
|
|
526
1366
|
}
|
|
527
|
-
|
|
1367
|
+
const result = await this.rollup.read.getAttesterView([
|
|
528
1368
|
address
|
|
529
1369
|
]);
|
|
1370
|
+
return {
|
|
1371
|
+
status: result.status,
|
|
1372
|
+
effectiveBalance: result.effectiveBalance,
|
|
1373
|
+
exit: {
|
|
1374
|
+
withdrawalId: result.exit.withdrawalId,
|
|
1375
|
+
amount: result.exit.amount,
|
|
1376
|
+
exitableAt: result.exit.exitableAt,
|
|
1377
|
+
recipientOrWithdrawer: EthAddress.fromString(result.exit.recipientOrWithdrawer),
|
|
1378
|
+
isRecipient: result.exit.isRecipient,
|
|
1379
|
+
exists: result.exit.exists
|
|
1380
|
+
},
|
|
1381
|
+
config: {
|
|
1382
|
+
publicKey: {
|
|
1383
|
+
x: result.config.publicKey.x,
|
|
1384
|
+
y: result.config.publicKey.y
|
|
1385
|
+
},
|
|
1386
|
+
withdrawer: EthAddress.fromString(result.config.withdrawer)
|
|
1387
|
+
}
|
|
1388
|
+
};
|
|
530
1389
|
}
|
|
531
|
-
getStatus(address) {
|
|
1390
|
+
async getStatus(address) {
|
|
532
1391
|
if (address instanceof EthAddress) {
|
|
533
1392
|
address = address.toString();
|
|
534
1393
|
}
|
|
535
|
-
return this.rollup.read.getStatus([
|
|
1394
|
+
return await this.rollup.read.getStatus([
|
|
536
1395
|
address
|
|
537
1396
|
]);
|
|
538
1397
|
}
|
|
539
|
-
getBlobCommitmentsHash(
|
|
540
|
-
return this.rollup.read.getBlobCommitmentsHash([
|
|
541
|
-
|
|
542
|
-
]);
|
|
1398
|
+
async getBlobCommitmentsHash(checkpointNumber) {
|
|
1399
|
+
return Buffer32.fromString(await this.rollup.read.getBlobCommitmentsHash([
|
|
1400
|
+
BigInt(checkpointNumber)
|
|
1401
|
+
]));
|
|
543
1402
|
}
|
|
544
|
-
getCurrentBlobCommitmentsHash() {
|
|
545
|
-
return this.rollup.read.getCurrentBlobCommitmentsHash();
|
|
1403
|
+
async getCurrentBlobCommitmentsHash() {
|
|
1404
|
+
return Buffer32.fromString(await this.rollup.read.getCurrentBlobCommitmentsHash());
|
|
546
1405
|
}
|
|
547
|
-
getStakingAsset() {
|
|
548
|
-
return this.rollup.read.getStakingAsset();
|
|
1406
|
+
async getStakingAsset() {
|
|
1407
|
+
return EthAddress.fromString(await this.rollup.read.getStakingAsset());
|
|
549
1408
|
}
|
|
550
|
-
getRewardConfig() {
|
|
551
|
-
|
|
1409
|
+
async getRewardConfig() {
|
|
1410
|
+
const result = await this.rollup.read.getRewardConfig();
|
|
1411
|
+
return {
|
|
1412
|
+
rewardDistributor: EthAddress.fromString(result.rewardDistributor),
|
|
1413
|
+
sequencerBps: BigInt(result.sequencerBps),
|
|
1414
|
+
booster: EthAddress.fromString(result.booster),
|
|
1415
|
+
checkpointReward: result.checkpointReward
|
|
1416
|
+
};
|
|
552
1417
|
}
|
|
553
1418
|
setupEpoch(l1TxUtils) {
|
|
554
1419
|
return l1TxUtils.sendAndMonitorTransaction({
|
|
555
1420
|
to: this.address,
|
|
1421
|
+
abi: RollupAbi,
|
|
556
1422
|
data: encodeFunctionData({
|
|
557
1423
|
abi: RollupAbi,
|
|
558
1424
|
functionName: 'setupEpoch',
|
|
@@ -563,6 +1429,7 @@ export class RollupContract {
|
|
|
563
1429
|
vote(l1TxUtils, proposalId) {
|
|
564
1430
|
return l1TxUtils.sendAndMonitorTransaction({
|
|
565
1431
|
to: this.address,
|
|
1432
|
+
abi: RollupAbi,
|
|
566
1433
|
data: encodeFunctionData({
|
|
567
1434
|
abi: RollupAbi,
|
|
568
1435
|
functionName: 'vote',
|
|
@@ -584,14 +1451,15 @@ export class RollupContract {
|
|
|
584
1451
|
}
|
|
585
1452
|
});
|
|
586
1453
|
}
|
|
587
|
-
|
|
588
|
-
return this.rollup.watchEvent.
|
|
1454
|
+
listenToCheckpointInvalidated(callback) {
|
|
1455
|
+
return this.rollup.watchEvent.CheckpointInvalidated({}, {
|
|
589
1456
|
onLogs: (logs)=>{
|
|
590
1457
|
for (const log of logs){
|
|
591
1458
|
const args = log.args;
|
|
592
|
-
if (args.
|
|
1459
|
+
if (args.checkpointNumber !== undefined) {
|
|
593
1460
|
callback({
|
|
594
|
-
|
|
1461
|
+
checkpointNumber: CheckpointNumber.fromBigInt(args.checkpointNumber),
|
|
1462
|
+
event: log
|
|
595
1463
|
});
|
|
596
1464
|
}
|
|
597
1465
|
}
|
|
@@ -622,58 +1490,83 @@ export class RollupContract {
|
|
|
622
1490
|
}
|
|
623
1491
|
});
|
|
624
1492
|
}
|
|
1493
|
+
/**
|
|
1494
|
+
* Fetches OwnershipTransferred events emitted on the L1 block this rollup was deployed on.
|
|
1495
|
+
* The Rollup inherits from Ownable and emits this event in its constructor, so the event
|
|
1496
|
+
* is guaranteed to exist on `l1StartBlock` for any correctly deployed rollup. Used as a
|
|
1497
|
+
* probe to detect RPC nodes that prune historical logs.
|
|
1498
|
+
*/ async getOwnershipTransferredEventsAtDeploy() {
|
|
1499
|
+
const l1StartBlock = await this.getL1StartBlock();
|
|
1500
|
+
return await this.rollup.getEvents.OwnershipTransferred({}, {
|
|
1501
|
+
fromBlock: l1StartBlock,
|
|
1502
|
+
toBlock: l1StartBlock
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1505
|
+
/** Fetches CheckpointProposed events within the given block range. */ async getCheckpointProposedEvents(fromBlock, toBlock) {
|
|
1506
|
+
const logs = await this.rollup.getEvents.CheckpointProposed({}, {
|
|
1507
|
+
fromBlock,
|
|
1508
|
+
toBlock
|
|
1509
|
+
});
|
|
1510
|
+
return logs.filter((log)=>log.blockNumber >= fromBlock && log.blockNumber <= toBlock).map((log)=>({
|
|
1511
|
+
l1BlockNumber: log.blockNumber,
|
|
1512
|
+
l1BlockHash: Buffer32.fromString(log.blockHash),
|
|
1513
|
+
l1TransactionHash: log.transactionHash,
|
|
1514
|
+
args: {
|
|
1515
|
+
checkpointNumber: CheckpointNumber.fromBigInt(log.args.checkpointNumber),
|
|
1516
|
+
archive: Fr.fromString(log.args.archive),
|
|
1517
|
+
versionedBlobHashes: log.args.versionedBlobHashes.map((h)=>Buffer.from(h.slice(2), 'hex')),
|
|
1518
|
+
attestationsHash: (()=>{
|
|
1519
|
+
if (!log.args.attestationsHash) {
|
|
1520
|
+
throw new Error(`CheckpointProposed event missing attestationsHash for checkpoint ${log.args.checkpointNumber}`);
|
|
1521
|
+
}
|
|
1522
|
+
return Buffer32.fromString(log.args.attestationsHash);
|
|
1523
|
+
})(),
|
|
1524
|
+
payloadDigest: (()=>{
|
|
1525
|
+
if (!log.args.payloadDigest) {
|
|
1526
|
+
throw new Error(`CheckpointProposed event missing payloadDigest for checkpoint ${log.args.checkpointNumber}`);
|
|
1527
|
+
}
|
|
1528
|
+
return Buffer32.fromString(log.args.payloadDigest);
|
|
1529
|
+
})()
|
|
1530
|
+
}
|
|
1531
|
+
}));
|
|
1532
|
+
}
|
|
1533
|
+
/** Packs pending and proven checkpoint numbers into the chain tips storage format. */ static packChainTips(pendingCheckpointNumber, provenCheckpointNumber) {
|
|
1534
|
+
return pendingCheckpointNumber << 128n | provenCheckpointNumber & (1n << 128n) - 1n;
|
|
1535
|
+
}
|
|
1536
|
+
/** Storage slot for the chain tips (offset 0 within the STF storage struct). */ static get chainTipsStorageSlot() {
|
|
1537
|
+
return BigInt(RollupContract.stfStorageSlot);
|
|
1538
|
+
}
|
|
1539
|
+
/**
|
|
1540
|
+
* Computes the storage slot for a field within a tempCheckpointLog entry.
|
|
1541
|
+
* @param checkpointNumber - The checkpoint number
|
|
1542
|
+
* @param field - The field within the CompressedTempCheckpointLog struct
|
|
1543
|
+
*/ async getTempCheckpointLogStorageSlot(checkpointNumber, field) {
|
|
1544
|
+
const [epochDuration, proofSubmissionEpochs] = await Promise.all([
|
|
1545
|
+
this.getEpochDuration(),
|
|
1546
|
+
this.getProofSubmissionEpochs()
|
|
1547
|
+
]);
|
|
1548
|
+
return this.computeTempCheckpointLogStorageSlot(checkpointNumber, field, {
|
|
1549
|
+
epochDuration,
|
|
1550
|
+
proofSubmissionEpochs
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
computeTempCheckpointLogStorageSlot(checkpointNumber, field, constants) {
|
|
1554
|
+
const fieldOffset = BigInt(field);
|
|
1555
|
+
const { epochDuration, proofSubmissionEpochs } = constants;
|
|
1556
|
+
const roundaboutSize = BigInt(epochDuration) * (BigInt(proofSubmissionEpochs) + 1n) + 1n;
|
|
1557
|
+
const tempCheckpointLogsBase = BigInt(RollupContract.stfStorageSlot) + 2n;
|
|
1558
|
+
const circularIndex = BigInt(checkpointNumber) % roundaboutSize;
|
|
1559
|
+
const entryBase = BigInt(keccak256(encodeAbiParameters([
|
|
1560
|
+
{
|
|
1561
|
+
type: 'uint256'
|
|
1562
|
+
},
|
|
1563
|
+
{
|
|
1564
|
+
type: 'uint256'
|
|
1565
|
+
}
|
|
1566
|
+
], [
|
|
1567
|
+
circularIndex,
|
|
1568
|
+
tempCheckpointLogsBase
|
|
1569
|
+
])));
|
|
1570
|
+
return entryBase + fieldOffset;
|
|
1571
|
+
}
|
|
625
1572
|
}
|
|
626
|
-
_ts_decorate([
|
|
627
|
-
memoize
|
|
628
|
-
], RollupContract.prototype, "getL1StartBlock", null);
|
|
629
|
-
_ts_decorate([
|
|
630
|
-
memoize
|
|
631
|
-
], RollupContract.prototype, "getL1GenesisTime", null);
|
|
632
|
-
_ts_decorate([
|
|
633
|
-
memoize
|
|
634
|
-
], RollupContract.prototype, "getProofSubmissionEpochs", null);
|
|
635
|
-
_ts_decorate([
|
|
636
|
-
memoize
|
|
637
|
-
], RollupContract.prototype, "getEpochDuration", null);
|
|
638
|
-
_ts_decorate([
|
|
639
|
-
memoize
|
|
640
|
-
], RollupContract.prototype, "getSlotDuration", null);
|
|
641
|
-
_ts_decorate([
|
|
642
|
-
memoize
|
|
643
|
-
], RollupContract.prototype, "getTargetCommitteeSize", null);
|
|
644
|
-
_ts_decorate([
|
|
645
|
-
memoize
|
|
646
|
-
], RollupContract.prototype, "getEjectionThreshold", null);
|
|
647
|
-
_ts_decorate([
|
|
648
|
-
memoize
|
|
649
|
-
], RollupContract.prototype, "getLocalEjectionThreshold", null);
|
|
650
|
-
_ts_decorate([
|
|
651
|
-
memoize
|
|
652
|
-
], RollupContract.prototype, "getLagInEpochs", null);
|
|
653
|
-
_ts_decorate([
|
|
654
|
-
memoize
|
|
655
|
-
], RollupContract.prototype, "getActivationThreshold", null);
|
|
656
|
-
_ts_decorate([
|
|
657
|
-
memoize
|
|
658
|
-
], RollupContract.prototype, "getExitDelay", null);
|
|
659
|
-
_ts_decorate([
|
|
660
|
-
memoize
|
|
661
|
-
], RollupContract.prototype, "getManaTarget", null);
|
|
662
|
-
_ts_decorate([
|
|
663
|
-
memoize
|
|
664
|
-
], RollupContract.prototype, "getProvingCostPerMana", null);
|
|
665
|
-
_ts_decorate([
|
|
666
|
-
memoize
|
|
667
|
-
], RollupContract.prototype, "getProvingCostPerManaInFeeAsset", null);
|
|
668
|
-
_ts_decorate([
|
|
669
|
-
memoize
|
|
670
|
-
], RollupContract.prototype, "getManaLimit", null);
|
|
671
|
-
_ts_decorate([
|
|
672
|
-
memoize
|
|
673
|
-
], RollupContract.prototype, "getVersion", null);
|
|
674
|
-
_ts_decorate([
|
|
675
|
-
memoize
|
|
676
|
-
], RollupContract.prototype, "getGenesisArchiveTreeRoot", null);
|
|
677
|
-
_ts_decorate([
|
|
678
|
-
memoize
|
|
679
|
-
], RollupContract.prototype, "getRollupConstants", null);
|