@aztec/ethereum 0.0.1-commit.2ed92850 → 0.0.1-commit.3100065
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/client.d.ts +25 -3
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +60 -8
- package/dest/config.d.ts +17 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +39 -11
- package/dest/contracts/chain_state_override.d.ts +78 -0
- package/dest/contracts/chain_state_override.d.ts.map +1 -0
- package/dest/contracts/chain_state_override.js +137 -0
- package/dest/contracts/fee_asset_handler.d.ts +1 -1
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.js +2 -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/governance.d.ts +108 -33
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +198 -15
- package/dest/contracts/governance_proposer.d.ts +33 -1
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +57 -3
- 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 +3 -3
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +12 -7
- package/dest/contracts/index.d.ts +4 -3
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +3 -2
- package/dest/contracts/multicall.d.ts +127 -12
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +201 -93
- package/dest/contracts/outbox.d.ts +27 -4
- package/dest/contracts/outbox.d.ts.map +1 -1
- package/dest/contracts/outbox.js +34 -7
- 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 +5420 -31
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +406 -75
- package/dest/contracts/{tally_slashing_proposer.d.ts → slashing_proposer.d.ts} +3 -4
- package/dest/contracts/slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/{tally_slashing_proposer.js → slashing_proposer.js} +18 -13
- package/dest/deploy_aztec_l1_contracts.d.ts +5 -9
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +41 -26
- package/dest/deploy_l1_contract.js +3 -3
- package/dest/generated/l1-contracts-defaults.d.ts +3 -3
- package/dest/generated/l1-contracts-defaults.js +3 -3
- package/dest/l1_artifacts.d.ts +15524 -15847
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_artifacts.js +9 -24
- package/dest/l1_contract_addresses.d.ts +61 -65
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +101 -82
- package/dest/l1_reader.d.ts +5 -5
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +9 -7
- package/dest/l1_tx_utils/config.d.ts +7 -1
- package/dest/l1_tx_utils/config.d.ts.map +1 -1
- package/dest/l1_tx_utils/config.js +17 -4
- package/dest/l1_tx_utils/constants.d.ts +1 -1
- package/dest/l1_tx_utils/constants.js +2 -2
- package/dest/l1_tx_utils/factory.d.ts +18 -10
- package/dest/l1_tx_utils/factory.d.ts.map +1 -1
- package/dest/l1_tx_utils/factory.js +17 -7
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +1 -1
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +15 -15
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +9 -15
- package/dest/l1_tx_utils/index-blobs.d.ts +3 -3
- package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -1
- package/dest/l1_tx_utils/index-blobs.js +2 -2
- package/dest/l1_tx_utils/index.d.ts +2 -1
- package/dest/l1_tx_utils/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/index.js +1 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +26 -7
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +158 -81
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +13 -8
- package/dest/l1_tx_utils/tx_delayer.d.ts +58 -0
- package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
- package/dest/{test → l1_tx_utils}/tx_delayer.js +67 -37
- package/dest/publisher_manager.d.ts +34 -7
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +119 -8
- package/dest/queries.d.ts +13 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +62 -3
- 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 +55 -4
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +104 -3
- package/dest/test/eth_cheat_codes.d.ts +31 -6
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +67 -44
- 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 +62 -3
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +95 -7
- package/dest/test/start_anvil.d.ts +23 -3
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +143 -29
- package/dest/test/upgrade_utils.js +2 -2
- package/dest/utils.d.ts +10 -2
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +105 -24
- package/package.json +6 -8
- package/src/client.ts +66 -2
- package/src/config.ts +59 -15
- package/src/contracts/chain_state_override.ts +200 -0
- package/src/contracts/fee_asset_handler.ts +2 -0
- package/src/contracts/fee_asset_price_oracle.ts +285 -0
- package/src/contracts/governance.ts +271 -12
- package/src/contracts/governance_proposer.ts +58 -2
- package/src/contracts/gse.ts +7 -2
- package/src/contracts/inbox.ts +13 -5
- package/src/contracts/index.ts +3 -2
- package/src/contracts/multicall.ts +243 -102
- package/src/contracts/outbox.ts +42 -8
- package/src/contracts/registry.ts +31 -1
- package/src/contracts/rollup.ts +457 -78
- package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +16 -14
- package/src/deploy_aztec_l1_contracts.ts +63 -35
- package/src/deploy_l1_contract.ts +3 -3
- package/src/generated/l1-contracts-defaults.ts +3 -3
- package/src/l1_artifacts.ts +12 -35
- package/src/l1_contract_addresses.ts +120 -94
- package/src/l1_reader.ts +17 -10
- package/src/l1_tx_utils/config.ts +23 -3
- package/src/l1_tx_utils/constants.ts +2 -2
- package/src/l1_tx_utils/factory.ts +31 -31
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +1 -1
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +1 -1
- package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +43 -54
- package/src/l1_tx_utils/index-blobs.ts +2 -2
- package/src/l1_tx_utils/index.ts +1 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +151 -66
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +13 -8
- package/src/{test → l1_tx_utils}/tx_delayer.ts +93 -56
- package/src/publisher_manager.ts +145 -12
- package/src/queries.ts +70 -4
- package/src/test/blob_kzg_warmup.ts +65 -0
- package/src/test/chain_monitor.ts +148 -3
- package/src/test/eth_cheat_codes.ts +63 -47
- package/src/test/index.ts +1 -2
- package/src/test/rollup_cheat_codes.ts +124 -6
- package/src/test/start_anvil.ts +177 -29
- package/src/test/upgrade_utils.ts +2 -2
- package/src/utils.ts +109 -29
- package/dest/contracts/empire_slashing_proposer.d.ts +0 -67
- package/dest/contracts/empire_slashing_proposer.d.ts.map +0 -1
- package/dest/contracts/empire_slashing_proposer.js +0 -209
- package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +0 -26
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +0 -26
- package/dest/test/delayed_tx_utils.d.ts +0 -13
- package/dest/test/delayed_tx_utils.d.ts.map +0 -1
- package/dest/test/delayed_tx_utils.js +0 -28
- package/dest/test/tx_delayer.d.ts +0 -36
- package/dest/test/tx_delayer.d.ts.map +0 -1
- package/src/contracts/empire_slashing_proposer.ts +0 -270
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
- package/src/test/delayed_tx_utils.ts +0 -52
|
@@ -15,11 +15,19 @@ import {
|
|
|
15
15
|
import type { L1TxRequest, L1TxUtils } from '../l1_tx_utils/index.js';
|
|
16
16
|
import type { ViemClient } from '../types.js';
|
|
17
17
|
import { type IEmpireBase, encodeSignal, encodeSignalWithSignature, signSignalWithSig } from './empire_base.js';
|
|
18
|
-
import { extractProposalIdFromLogs } from './governance.js';
|
|
18
|
+
import { ReadOnlyGovernanceContract, extractProposalIdFromLogs } from './governance.js';
|
|
19
19
|
|
|
20
20
|
export class GovernanceProposerContract implements IEmpireBase {
|
|
21
21
|
private readonly proposer: GetContractReturnType<typeof GovernanceProposerAbi, ViemClient>;
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Cache of bytecode-existence checks keyed by payload address. The check is stable for a
|
|
25
|
+
* contract's lifetime -- a contract either has code or it does not, and code cannot be removed
|
|
26
|
+
* after deployment (selfdestruct aside, which is not relevant here). Safe to memoize
|
|
27
|
+
* indefinitely for the lifetime of this instance.
|
|
28
|
+
*/
|
|
29
|
+
private readonly emptyPayloadCache: Map<Hex, boolean> = new Map();
|
|
30
|
+
|
|
23
31
|
constructor(
|
|
24
32
|
public readonly client: ViemClient,
|
|
25
33
|
address: Hex | EthAddress,
|
|
@@ -83,6 +91,7 @@ export class GovernanceProposerContract implements IEmpireBase {
|
|
|
83
91
|
public createSignalRequest(payload: Hex): L1TxRequest {
|
|
84
92
|
return {
|
|
85
93
|
to: this.address.toString(),
|
|
94
|
+
abi: GovernanceProposerAbi,
|
|
86
95
|
data: encodeSignal(payload),
|
|
87
96
|
};
|
|
88
97
|
}
|
|
@@ -104,10 +113,56 @@ export class GovernanceProposerContract implements IEmpireBase {
|
|
|
104
113
|
);
|
|
105
114
|
return {
|
|
106
115
|
to: this.address.toString(),
|
|
116
|
+
abi: GovernanceProposerAbi,
|
|
107
117
|
data: encodeSignalWithSignature(payload, signature),
|
|
108
118
|
};
|
|
109
119
|
}
|
|
110
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Resolves the Governance contract this proposer submits winners to. Lazily reads
|
|
123
|
+
* `GovernanceProposer.getGovernance()` (which itself looks the address up via the registry) and
|
|
124
|
+
* memoizes the resulting wrapper.
|
|
125
|
+
*/
|
|
126
|
+
@memoize
|
|
127
|
+
public async getGovernance(): Promise<ReadOnlyGovernanceContract> {
|
|
128
|
+
const address = await this.proposer.read.getGovernance();
|
|
129
|
+
return new ReadOnlyGovernanceContract(address, this.client);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Returns true iff the given original payload is currently the subject of a live (non-terminal)
|
|
134
|
+
* Governance proposal. Delegates to `ReadOnlyGovernanceContract.hasActiveProposalWithPayload`, which
|
|
135
|
+
* implements the actual sweep against the Governance contract -- this method exists only as a
|
|
136
|
+
* convenience wrapper so callers that already hold a GovernanceProposer reference don't have to
|
|
137
|
+
* resolve the Governance address themselves.
|
|
138
|
+
*/
|
|
139
|
+
public async hasActiveProposalWithPayload(payload: Hex): Promise<boolean> {
|
|
140
|
+
const governance = await this.getGovernance();
|
|
141
|
+
return governance.hasActiveProposalWithPayload(payload);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Returns true if the given payload address has no deployed bytecode. Used as a cheap
|
|
146
|
+
* pre-flight check before casting a governance signal — voting for a zero-code address
|
|
147
|
+
* is unrecoverable.
|
|
148
|
+
*
|
|
149
|
+
* We only cache the `false` result (address has bytecode). The `true` result is NOT
|
|
150
|
+
* cached because a CREATE2-redeployed address could go from empty to populated, and
|
|
151
|
+
* caching `true` would make us keep skipping a payload that later becomes valid.
|
|
152
|
+
*/
|
|
153
|
+
public async isPayloadEmpty(payload: EthAddress): Promise<boolean> {
|
|
154
|
+
const key = payload.toString() as Hex;
|
|
155
|
+
if (this.emptyPayloadCache.get(key) === false) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
const code = await this.client.getCode({ address: key });
|
|
159
|
+
const isEmpty = !code || code === '0x';
|
|
160
|
+
if (!isEmpty) {
|
|
161
|
+
this.emptyPayloadCache.set(key, false);
|
|
162
|
+
}
|
|
163
|
+
return isEmpty;
|
|
164
|
+
}
|
|
165
|
+
|
|
111
166
|
public async submitRoundWinner(
|
|
112
167
|
round: bigint,
|
|
113
168
|
l1TxUtils: L1TxUtils,
|
|
@@ -117,8 +172,9 @@ export class GovernanceProposerContract implements IEmpireBase {
|
|
|
117
172
|
}> {
|
|
118
173
|
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
119
174
|
to: this.address.toString(),
|
|
175
|
+
abi: GovernanceProposerAbi,
|
|
120
176
|
data: encodeFunctionData({
|
|
121
|
-
abi:
|
|
177
|
+
abi: GovernanceProposerAbi,
|
|
122
178
|
functionName: 'submitRoundWinner',
|
|
123
179
|
args: [round],
|
|
124
180
|
}),
|
package/src/contracts/gse.ts
CHANGED
|
@@ -47,11 +47,16 @@ export class GSEContract {
|
|
|
47
47
|
return EthAddress.fromString(await this.gse.read.getGovernance());
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
getAttestersFromIndicesAtTime(
|
|
50
|
+
getAttestersFromIndicesAtTime(
|
|
51
|
+
instance: Hex | EthAddress,
|
|
52
|
+
ts: bigint,
|
|
53
|
+
indices: bigint[],
|
|
54
|
+
options?: { blockNumber?: bigint },
|
|
55
|
+
) {
|
|
51
56
|
if (instance instanceof EthAddress) {
|
|
52
57
|
instance = instance.toString();
|
|
53
58
|
}
|
|
54
|
-
return this.gse.read.getAttestersFromIndicesAtTime([instance, ts, indices]);
|
|
59
|
+
return this.gse.read.getAttestersFromIndicesAtTime([instance, ts, indices], options);
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
public async getRegistrationDigest(publicKey: ProjPointType<bigint>): Promise<ProjPointType<bigint>> {
|
package/src/contracts/inbox.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { maxBigint } from '@aztec/foundation/bigint';
|
|
1
2
|
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
|
|
3
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -37,7 +38,7 @@ export class InboxContract {
|
|
|
37
38
|
|
|
38
39
|
static getFromConfig(config: L1ReaderConfig) {
|
|
39
40
|
const client = getPublicClient(config);
|
|
40
|
-
const address = config.
|
|
41
|
+
const address = config.inboxAddress.toString();
|
|
41
42
|
return new InboxContract(client, address);
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -82,10 +83,17 @@ export class InboxContract {
|
|
|
82
83
|
.map(log => this.mapMessageSentLog(log));
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
/** Fetches MessageSent events for a specific message hash
|
|
86
|
-
async getMessageSentEventByHash(
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
/** Fetches MessageSent events for a specific message hash around a specific block. */
|
|
87
|
+
async getMessageSentEventByHash(msgHash: Hex, aroundL1BlockNumber: bigint): Promise<MessageSentLog> {
|
|
88
|
+
// We don't use blockHash here because we don't want the query to throw if the L1 block number no longer exists on chain
|
|
89
|
+
// due to an L1 reorg. The use case for this method is usually checking if a message still exists on the Inbox after
|
|
90
|
+
// a reorg, so it's possible the message was moved one block up or down, and that the original L1 block where we
|
|
91
|
+
// saw it no longer exists, rendering the block-by-hash approach invalid.
|
|
92
|
+
const [log] = await this.inbox.getEvents.MessageSent(
|
|
93
|
+
{ hash: msgHash },
|
|
94
|
+
{ fromBlock: maxBigint(aroundL1BlockNumber - 5n, 1n), toBlock: aroundL1BlockNumber + 5n },
|
|
95
|
+
);
|
|
96
|
+
return log && this.mapMessageSentLog(log);
|
|
89
97
|
}
|
|
90
98
|
|
|
91
99
|
private mapMessageSentLog(log: {
|
package/src/contracts/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export * from './chain_state_override.js';
|
|
1
2
|
export * from './empire_base.js';
|
|
2
3
|
export * from './errors.js';
|
|
3
4
|
export * from './fee_asset_handler.js';
|
|
5
|
+
export * from './fee_asset_price_oracle.js';
|
|
4
6
|
export * from './fee_juice.js';
|
|
5
7
|
export * from './governance.js';
|
|
6
8
|
export * from './governance_proposer.js';
|
|
@@ -11,6 +13,5 @@ export * from './multicall.js';
|
|
|
11
13
|
export * from './outbox.js';
|
|
12
14
|
export * from './registry.js';
|
|
13
15
|
export * from './rollup.js';
|
|
14
|
-
export * from './
|
|
15
|
-
export * from './tally_slashing_proposer.js';
|
|
16
|
+
export * from './slashing_proposer.js';
|
|
16
17
|
export * from './slasher_contract.js';
|
|
@@ -1,123 +1,264 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TimeoutError } from '@aztec/foundation/error';
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
2
|
import type { Logger } from '@aztec/foundation/log';
|
|
4
3
|
|
|
5
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
type Abi,
|
|
6
|
+
type Address,
|
|
7
|
+
type BlockOverrides,
|
|
8
|
+
type Hex,
|
|
9
|
+
type RequiredBy,
|
|
10
|
+
type StateOverride,
|
|
11
|
+
type TransactionReceipt,
|
|
12
|
+
decodeFunctionResult,
|
|
13
|
+
encodeFunctionData,
|
|
14
|
+
multicall3Abi,
|
|
15
|
+
} from 'viem';
|
|
6
16
|
|
|
7
17
|
import type { L1BlobInputs, L1TxConfig, L1TxRequest, L1TxUtils } from '../l1_tx_utils/index.js';
|
|
8
18
|
import type { ExtendedViemWalletClient } from '../types.js';
|
|
9
|
-
import {
|
|
10
|
-
import { RollupContract } from './rollup.js';
|
|
19
|
+
import { tryDecodeRevertReason } from '../utils.js';
|
|
11
20
|
|
|
12
21
|
export const MULTI_CALL_3_ADDRESS = '0xcA11bde05977b3631167028862bE2a173976CA11' as const;
|
|
13
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Thrown by `Multicall3.forward` when the forwarder transaction lands but the receipt reports a
|
|
25
|
+
* reverted status. This is not expected (aggregate3 uses allowFailure: true), so callers should
|
|
26
|
+
* treat it as a fatal on-chain failure rather than retrying on a different publisher.
|
|
27
|
+
*/
|
|
28
|
+
export class MulticallForwarderRevertedError extends Error {
|
|
29
|
+
constructor(public readonly receipt: TransactionReceipt) {
|
|
30
|
+
super(`Multicall3 forwarder tx reverted: ${receipt.transactionHash}`);
|
|
31
|
+
this.name = 'MulticallForwarderRevertedError';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** ABI fragment for aggregate3Value — not included in viem's multicall3Abi. */
|
|
36
|
+
export const aggregate3ValueAbi = [
|
|
37
|
+
{
|
|
38
|
+
inputs: [
|
|
39
|
+
{
|
|
40
|
+
components: [
|
|
41
|
+
{ internalType: 'address', name: 'target', type: 'address' },
|
|
42
|
+
{ internalType: 'bool', name: 'allowFailure', type: 'bool' },
|
|
43
|
+
{ internalType: 'uint256', name: 'value', type: 'uint256' },
|
|
44
|
+
{ internalType: 'bytes', name: 'callData', type: 'bytes' },
|
|
45
|
+
],
|
|
46
|
+
internalType: 'struct Multicall3.Call3Value[]',
|
|
47
|
+
name: 'calls',
|
|
48
|
+
type: 'tuple[]',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
name: 'aggregate3Value',
|
|
52
|
+
outputs: [
|
|
53
|
+
{
|
|
54
|
+
components: [
|
|
55
|
+
{ internalType: 'bool', name: 'success', type: 'bool' },
|
|
56
|
+
{ internalType: 'bytes', name: 'returnData', type: 'bytes' },
|
|
57
|
+
],
|
|
58
|
+
internalType: 'struct Multicall3.Result[]',
|
|
59
|
+
name: 'returnData',
|
|
60
|
+
type: 'tuple[]',
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
stateMutability: 'payable',
|
|
64
|
+
type: 'function',
|
|
65
|
+
},
|
|
66
|
+
] as const;
|
|
67
|
+
|
|
68
|
+
/** A single call to embed inside an aggregate3 simulation. The abi is used to decode revert reasons. */
|
|
69
|
+
export type SimulateAggregate3Request = {
|
|
70
|
+
to: Address;
|
|
71
|
+
data: Hex;
|
|
72
|
+
/** Optional ABI used to decode the revert reason if this entry reverts. */
|
|
73
|
+
abi?: Abi;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type SimulateAggregate3EntryResult = {
|
|
77
|
+
success: boolean;
|
|
78
|
+
/** Decoded revert reason text when `success === false` and a request abi was provided. */
|
|
79
|
+
revertReason?: string;
|
|
80
|
+
/** Raw return data hex. `'0x'` for successful entries with void return. */
|
|
81
|
+
returnData: Hex;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Outcome of a bundle simulation.
|
|
86
|
+
* - `decoded`: eth_simulateV1 ran and produced a per-entry Result[]. Use `entries` for filtering.
|
|
87
|
+
* - `fallback`: the node does not support eth_simulateV1; `fallbackGasEstimate` was returned and no
|
|
88
|
+
* per-entry info is available. Caller should send the bundle as-is with a conservative gas cap.
|
|
89
|
+
*/
|
|
90
|
+
export type SimulateAggregate3Result =
|
|
91
|
+
| { kind: 'decoded'; entries: SimulateAggregate3EntryResult[]; gasUsed: bigint }
|
|
92
|
+
| { kind: 'fallback'; gasUsed: bigint };
|
|
93
|
+
|
|
94
|
+
export type SimulateAggregate3Options = {
|
|
95
|
+
blockOverrides?: BlockOverrides<bigint, number>;
|
|
96
|
+
stateOverrides?: StateOverride;
|
|
97
|
+
/**
|
|
98
|
+
* If set, append a state override that fakes the sender's balance during the simulation so a
|
|
99
|
+
* low or zero balance does not cause the simulate to fail with insufficient funds. The fake
|
|
100
|
+
* balance is applied to `l1TxUtils.getSenderAddress()`.
|
|
101
|
+
*/
|
|
102
|
+
fakeSenderBalance?: bigint;
|
|
103
|
+
/** Gas cap to pass on the simulate call itself (defaults to viem's behavior). */
|
|
104
|
+
gas?: bigint;
|
|
105
|
+
/** When eth_simulateV1 is unavailable, fall back to this gas estimate instead of throwing. */
|
|
106
|
+
fallbackGasEstimate?: bigint;
|
|
107
|
+
};
|
|
108
|
+
|
|
14
109
|
export class Multicall3 {
|
|
15
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Returns true iff Multicall3 bytecode is deployed at MULTI_CALL_3_ADDRESS. An empty result from
|
|
112
|
+
* a non-existent contract would otherwise silently validate any bundle that uses Multicall3.
|
|
113
|
+
*/
|
|
114
|
+
static async hasCode(l1TxUtils: L1TxUtils): Promise<boolean> {
|
|
115
|
+
const code = await l1TxUtils.getCode(EthAddress.fromString(MULTI_CALL_3_ADDRESS));
|
|
116
|
+
return !!code && code !== '0x';
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Simulates an aggregate3 call composed of the given requests via eth_simulateV1 and decodes the
|
|
121
|
+
* per-entry Result[]. Entries that revert are returned with a decoded revertReason (if the request
|
|
122
|
+
* provided an abi).
|
|
123
|
+
*
|
|
124
|
+
* Use this to pre-validate a bundle before sending it through `Multicall3.forward`. The caller can
|
|
125
|
+
* drop reverted entries from the bundle and re-simulate with the reduced list to get an accurate
|
|
126
|
+
* `gasUsed`.
|
|
127
|
+
*/
|
|
128
|
+
static async simulateAggregate3(
|
|
129
|
+
requests: SimulateAggregate3Request[],
|
|
130
|
+
l1TxUtils: L1TxUtils,
|
|
131
|
+
opts: SimulateAggregate3Options = {},
|
|
132
|
+
): Promise<SimulateAggregate3Result> {
|
|
133
|
+
const calldata = encodeFunctionData({
|
|
134
|
+
abi: multicall3Abi,
|
|
135
|
+
functionName: 'aggregate3',
|
|
136
|
+
args: [
|
|
137
|
+
requests.map(r => ({
|
|
138
|
+
target: r.to,
|
|
139
|
+
callData: r.data,
|
|
140
|
+
allowFailure: true,
|
|
141
|
+
})),
|
|
142
|
+
],
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const stateOverrides: StateOverride = [...(opts.stateOverrides ?? [])];
|
|
146
|
+
if (opts.fakeSenderBalance !== undefined) {
|
|
147
|
+
stateOverrides.push({
|
|
148
|
+
address: l1TxUtils.getSenderAddress().toString(),
|
|
149
|
+
balance: opts.fakeSenderBalance,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const simResult = await l1TxUtils.simulate(
|
|
154
|
+
{ to: MULTI_CALL_3_ADDRESS, data: calldata, gas: opts.gas },
|
|
155
|
+
opts.blockOverrides,
|
|
156
|
+
stateOverrides,
|
|
157
|
+
multicall3Abi,
|
|
158
|
+
{ fallbackGasEstimate: opts.fallbackGasEstimate },
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
if (simResult.result === '0x') {
|
|
162
|
+
return { kind: 'fallback', gasUsed: simResult.gasUsed };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const decoded = decodeFunctionResult({
|
|
166
|
+
abi: multicall3Abi,
|
|
167
|
+
functionName: 'aggregate3',
|
|
168
|
+
data: simResult.result,
|
|
169
|
+
}) as readonly { success: boolean; returnData: `0x${string}` }[];
|
|
170
|
+
|
|
171
|
+
const entries: SimulateAggregate3EntryResult[] = decoded.map((entry, i) => {
|
|
172
|
+
if (entry.success) {
|
|
173
|
+
return { success: true, returnData: entry.returnData };
|
|
174
|
+
}
|
|
175
|
+
const abi = requests[i].abi;
|
|
176
|
+
const revertReason = abi ? tryDecodeRevertReason(entry.returnData, abi) : undefined;
|
|
177
|
+
return { success: false, returnData: entry.returnData, revertReason };
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
return { kind: 'decoded', entries, gasUsed: simResult.gasUsed };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Sends a batch of requests through aggregate3. Individual calls may fail (allowFailure: true),
|
|
185
|
+
* but the top-level multicall is expected to land successfully. Throws if the send fails or if
|
|
186
|
+
* the receipt reports a reverted status.
|
|
187
|
+
*/
|
|
188
|
+
static async forward<TOptGasLimitRequired extends boolean>(
|
|
16
189
|
requests: L1TxRequest[],
|
|
17
190
|
l1TxUtils: L1TxUtils,
|
|
18
|
-
gasConfig: L1TxConfig | undefined,
|
|
191
|
+
gasConfig: TOptGasLimitRequired extends true ? RequiredBy<L1TxConfig, 'gasLimit'> : L1TxConfig | undefined,
|
|
19
192
|
blobConfig: L1BlobInputs | undefined,
|
|
20
|
-
|
|
21
|
-
logger: Logger,
|
|
22
|
-
opts: { revertOnFailure?: boolean } = {},
|
|
193
|
+
opts: { gasLimitRequired?: TOptGasLimitRequired } = {},
|
|
23
194
|
) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
195
|
+
if (opts.gasLimitRequired && !gasConfig?.gasLimit) {
|
|
196
|
+
throw new Error('Multicall gasLimit is required when gasLimitRequired is true');
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const args = requests
|
|
200
|
+
.filter(request => request.to !== null)
|
|
201
|
+
.map(r => ({
|
|
202
|
+
target: r.to!,
|
|
203
|
+
callData: r.data!,
|
|
204
|
+
allowFailure: true,
|
|
205
|
+
}));
|
|
206
|
+
const encodedForwarderData = encodeFunctionData({
|
|
31
207
|
abi: multicall3Abi,
|
|
32
208
|
functionName: 'aggregate3',
|
|
33
209
|
args: [args],
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const encodedForwarderData = encodeFunctionData(forwarderFunctionData);
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
const { receipt, state } = await l1TxUtils.sendAndMonitorTransaction(
|
|
40
|
-
{ to: MULTI_CALL_3_ADDRESS, data: encodedForwarderData },
|
|
41
|
-
gasConfig,
|
|
42
|
-
blobConfig,
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
if (receipt.status === 'success') {
|
|
46
|
-
const stats = await l1TxUtils.getTransactionStats(receipt.transactionHash);
|
|
47
|
-
return { receipt, stats };
|
|
48
|
-
} else {
|
|
49
|
-
logger.error('Forwarder transaction failed', undefined, { receipt });
|
|
50
|
-
|
|
51
|
-
const args = {
|
|
52
|
-
...forwarderFunctionData,
|
|
53
|
-
address: MULTI_CALL_3_ADDRESS,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
let errorMsg: string | undefined;
|
|
57
|
-
|
|
58
|
-
if (blobConfig) {
|
|
59
|
-
const maxFeePerBlobGas = blobConfig.maxFeePerBlobGas ?? state.gasPrice.maxFeePerBlobGas;
|
|
60
|
-
if (maxFeePerBlobGas === undefined) {
|
|
61
|
-
errorMsg = 'maxFeePerBlobGas is required to get the error message';
|
|
62
|
-
} else {
|
|
63
|
-
logger.debug('Trying to get error from reverted tx with blob config');
|
|
64
|
-
errorMsg = await l1TxUtils.tryGetErrorFromRevertedTx(
|
|
65
|
-
encodedForwarderData,
|
|
66
|
-
args,
|
|
67
|
-
{
|
|
68
|
-
blobs: blobConfig.blobs,
|
|
69
|
-
kzg: blobConfig.kzg,
|
|
70
|
-
maxFeePerBlobGas,
|
|
71
|
-
},
|
|
72
|
-
[
|
|
73
|
-
{
|
|
74
|
-
address: rollupAddress,
|
|
75
|
-
stateDiff: [
|
|
76
|
-
{
|
|
77
|
-
slot: toPaddedHex(RollupContract.checkBlobStorageSlot, true),
|
|
78
|
-
value: toPaddedHex(0n, true),
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
} else {
|
|
86
|
-
logger.debug('Trying to get error from reverted tx without blob config');
|
|
87
|
-
errorMsg = await l1TxUtils.tryGetErrorFromRevertedTx(encodedForwarderData, args, undefined, []);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return { receipt, errorMsg };
|
|
91
|
-
}
|
|
92
|
-
} catch (err) {
|
|
93
|
-
if (err instanceof TimeoutError) {
|
|
94
|
-
throw err;
|
|
95
|
-
}
|
|
210
|
+
});
|
|
96
211
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
data: request.data,
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
return result;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
logger.warn('Failed to get error from reverted tx', { err });
|
|
119
|
-
throw err;
|
|
212
|
+
const { receipt } = await l1TxUtils.sendAndMonitorTransaction(
|
|
213
|
+
{
|
|
214
|
+
to: MULTI_CALL_3_ADDRESS,
|
|
215
|
+
data: encodedForwarderData,
|
|
216
|
+
abi: multicall3Abi,
|
|
217
|
+
},
|
|
218
|
+
gasConfig,
|
|
219
|
+
blobConfig,
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
// This shouldn't happen. Any failure in individual calls is swallowed by forward since we set
|
|
223
|
+
// allowFailure to true for all calls, so a reverted status here would indicate a problem with
|
|
224
|
+
// the Multicall3 contract itself or the forwarder transaction (such as an out-of-gas).
|
|
225
|
+
if (receipt.status !== 'success') {
|
|
226
|
+
throw new MulticallForwarderRevertedError(receipt);
|
|
120
227
|
}
|
|
228
|
+
|
|
229
|
+
const stats = await l1TxUtils.getTransactionStats(receipt.transactionHash);
|
|
230
|
+
return { receipt, stats, multicallData: encodedForwarderData };
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** Batch multiple value transfers into a single aggregate3Value call on Multicall3. */
|
|
234
|
+
static async forwardValue(calls: { to: Address; value: bigint }[], l1TxUtils: L1TxUtils, logger: Logger) {
|
|
235
|
+
const args = calls.map(c => ({
|
|
236
|
+
target: c.to,
|
|
237
|
+
allowFailure: false,
|
|
238
|
+
value: c.value,
|
|
239
|
+
callData: '0x' as Hex,
|
|
240
|
+
}));
|
|
241
|
+
|
|
242
|
+
const data = encodeFunctionData({
|
|
243
|
+
abi: aggregate3ValueAbi,
|
|
244
|
+
functionName: 'aggregate3Value',
|
|
245
|
+
args: [args],
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
const totalValue = calls.reduce((sum, c) => sum + c.value, 0n);
|
|
249
|
+
|
|
250
|
+
logger.info(`Sending aggregate3Value with ${calls.length} calls`, { totalValue });
|
|
251
|
+
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
252
|
+
to: MULTI_CALL_3_ADDRESS,
|
|
253
|
+
data,
|
|
254
|
+
value: totalValue,
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
if (receipt.status !== 'success') {
|
|
258
|
+
throw new Error(`aggregate3Value transaction reverted: ${receipt.transactionHash}`);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return { receipt };
|
|
121
262
|
}
|
|
122
263
|
}
|
|
123
264
|
|
package/src/contracts/outbox.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
4
|
import { OutboxAbi } from '@aztec/l1-artifacts/OutboxAbi';
|
|
4
5
|
|
|
@@ -38,12 +39,24 @@ export class OutboxContract {
|
|
|
38
39
|
|
|
39
40
|
static getFromConfig(config: L1ReaderConfig) {
|
|
40
41
|
const client = getPublicClient(config);
|
|
41
|
-
const address = config.
|
|
42
|
+
const address = config.outboxAddress.toString();
|
|
42
43
|
return new OutboxContract(client, address);
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Storage slot of `epochs[epoch].roots[numCheckpointsInEpoch - 1]` in the Outbox contract.
|
|
48
|
+
*
|
|
49
|
+
* The Outbox lays out storage as `mapping(Epoch => EpochData) internal epochs` at base slot 0
|
|
50
|
+
* (ROLLUP and VERSION are immutable and do not occupy slots). For a mapping at slot `b`, the
|
|
51
|
+
* value for key `k` begins at `keccak256(abi.encode(k, b))`. `EpochData` starts with a fixed-
|
|
52
|
+
* size `bytes32[MAX_CHECKPOINTS_PER_EPOCH] roots` array, so `roots[i]` sits at the EpochData's
|
|
53
|
+
* base slot plus `i`. `numCheckpointsInEpoch` is 1-indexed (matches `Outbox.insert`/`consume`).
|
|
54
|
+
*/
|
|
55
|
+
static getEpochRootStorageSlot(epoch: EpochNumber, numCheckpointsInEpoch: number) {
|
|
56
|
+
const epochDataSlot = hexToBigInt(
|
|
57
|
+
keccak256(encodeAbiParameters([{ type: 'uint256' }, { type: 'uint256' }], [BigInt(epoch), 0n])),
|
|
58
|
+
);
|
|
59
|
+
return epochDataSlot + BigInt(numCheckpointsInEpoch - 1);
|
|
47
60
|
}
|
|
48
61
|
|
|
49
62
|
constructor(
|
|
@@ -68,24 +81,45 @@ export class OutboxContract {
|
|
|
68
81
|
return this.outbox.read.hasMessageBeenConsumedAtEpoch([BigInt(epoch), leafId]);
|
|
69
82
|
}
|
|
70
83
|
|
|
71
|
-
public getRootData(epoch: EpochNumber) {
|
|
72
|
-
return this.outbox.read.getRootData([BigInt(epoch)]);
|
|
84
|
+
public getRootData(epoch: EpochNumber, numCheckpointsInEpoch: number) {
|
|
85
|
+
return this.outbox.read.getRootData([BigInt(epoch), BigInt(numCheckpointsInEpoch)]);
|
|
73
86
|
}
|
|
74
87
|
|
|
75
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Returns every root stored for `epoch`. Slot `i` of the returned array holds the root inserted
|
|
90
|
+
* for `numCheckpointsInEpoch = i + 1`, or `Fr.ZERO` if no proof of that depth has been inserted
|
|
91
|
+
* yet. The array length is always `MAX_CHECKPOINTS_PER_EPOCH`.
|
|
92
|
+
*
|
|
93
|
+
* @param opts - Optional viem read options. Pass `blockNumber` to pin the read to a specific L1
|
|
94
|
+
* block, which is important for callers that want a consistent snapshot across multiple reads
|
|
95
|
+
* (e.g. the archiver's outbox-trees resolver, which pins to the node's synced L1 block).
|
|
96
|
+
*/
|
|
97
|
+
public async getRoots(epoch: EpochNumber, opts?: { blockNumber?: bigint }): Promise<Fr[]> {
|
|
98
|
+
const raw = await this.outbox.read.getRoots([BigInt(epoch)], opts);
|
|
99
|
+
return raw.map(hex => Fr.fromString(hex));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public consume(
|
|
103
|
+
message: ViemL2ToL1Msg,
|
|
104
|
+
epoch: EpochNumber,
|
|
105
|
+
numCheckpointsInEpoch: number,
|
|
106
|
+
leafIndex: bigint,
|
|
107
|
+
path: Hex[],
|
|
108
|
+
) {
|
|
76
109
|
const wallet = this.assertWallet();
|
|
77
|
-
return wallet.write.consume([message, BigInt(epoch), leafIndex, path]);
|
|
110
|
+
return wallet.write.consume([message, BigInt(epoch), BigInt(numCheckpointsInEpoch), leafIndex, path]);
|
|
78
111
|
}
|
|
79
112
|
|
|
80
113
|
public async getMessageConsumedEvents(
|
|
81
114
|
l1BlockHash: Hex,
|
|
82
|
-
): Promise<{ epoch: bigint; root: Hex; messageHash: Hex; leafId: bigint }[]> {
|
|
115
|
+
): Promise<{ epoch: bigint; root: Hex; messageHash: Hex; leafId: bigint; numCheckpointsInEpoch: bigint }[]> {
|
|
83
116
|
const events = await this.outbox.getEvents.MessageConsumed({}, { blockHash: l1BlockHash, strict: true });
|
|
84
117
|
return events.map(event => ({
|
|
85
118
|
epoch: event.args.epoch!,
|
|
86
119
|
root: event.args.root!,
|
|
87
120
|
messageHash: event.args.messageHash!,
|
|
88
121
|
leafId: event.args.leafId!,
|
|
122
|
+
numCheckpointsInEpoch: event.args.numCheckpointsInEpoch!,
|
|
89
123
|
}));
|
|
90
124
|
}
|
|
91
125
|
|
|
@@ -3,7 +3,7 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
3
3
|
import { RegistryAbi } from '@aztec/l1-artifacts/RegistryAbi';
|
|
4
4
|
import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi';
|
|
5
5
|
|
|
6
|
-
import { type GetContractReturnType, type Hex, getContract } from 'viem';
|
|
6
|
+
import { type GetContractReturnType, type Hex, getAbiItem, getContract } from 'viem';
|
|
7
7
|
|
|
8
8
|
import type { L1ContractAddresses } from '../l1_contract_addresses.js';
|
|
9
9
|
import type { ViemClient } from '../types.js';
|
|
@@ -128,4 +128,34 @@ export class RegistryContract {
|
|
|
128
128
|
public async getRewardDistributor(): Promise<EthAddress> {
|
|
129
129
|
return EthAddress.fromString(await this.registry.read.getRewardDistributor());
|
|
130
130
|
}
|
|
131
|
+
|
|
132
|
+
/** Returns the L1 timestamp at which the given rollup was registered via addRollup(). */
|
|
133
|
+
public async getCanonicalRollupRegistrationTimestamp(
|
|
134
|
+
rollupAddress: EthAddress,
|
|
135
|
+
fromBlock?: bigint,
|
|
136
|
+
): Promise<bigint | undefined> {
|
|
137
|
+
const event = getAbiItem({ abi: RegistryAbi, name: 'CanonicalRollupUpdated' });
|
|
138
|
+
const start = fromBlock ?? 0n;
|
|
139
|
+
const latestBlock = await this.client.getBlockNumber();
|
|
140
|
+
const chunkSize = 1_000n;
|
|
141
|
+
|
|
142
|
+
for (let from = start; from <= latestBlock; from += chunkSize) {
|
|
143
|
+
const to = from + chunkSize - 1n > latestBlock ? latestBlock : from + chunkSize - 1n;
|
|
144
|
+
const logs = await this.client.getLogs({
|
|
145
|
+
address: this.address.toString(),
|
|
146
|
+
fromBlock: from,
|
|
147
|
+
toBlock: to,
|
|
148
|
+
strict: true,
|
|
149
|
+
event,
|
|
150
|
+
args: { instance: rollupAddress.toString() },
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
if (logs.length > 0) {
|
|
154
|
+
const block = await this.client.getBlock({ blockNumber: logs[0].blockNumber });
|
|
155
|
+
return block.timestamp;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
131
161
|
}
|