@aztec/ethereum 0.0.0-test.0 → 0.0.1-commit.03f7ef2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/account.d.ts +2 -0
- package/dest/account.d.ts.map +1 -0
- package/dest/account.js +4 -0
- package/dest/chain.d.ts +1 -1
- package/dest/client.d.ts +6 -4
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +21 -3
- package/dest/config.d.ts +71 -16
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +138 -22
- package/dest/constants.d.ts +1 -1
- package/dest/contracts/empire_base.d.ts +25 -8
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_base.js +75 -2
- package/dest/contracts/empire_slashing_proposer.d.ts +67 -0
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/empire_slashing_proposer.js +209 -0
- package/dest/contracts/errors.d.ts +7 -0
- package/dest/contracts/errors.d.ts.map +1 -0
- package/dest/contracts/errors.js +12 -0
- package/dest/contracts/fee_asset_handler.d.ts +19 -0
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -0
- package/dest/contracts/fee_asset_handler.js +57 -0
- package/dest/contracts/fee_juice.d.ts +6 -7
- package/dest/contracts/fee_juice.d.ts.map +1 -1
- package/dest/contracts/fee_juice.js +27 -20
- package/dest/contracts/governance.d.ts +43 -32
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +87 -84
- package/dest/contracts/governance_proposer.d.ts +17 -13
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +46 -17
- package/dest/contracts/gse.d.ts +32 -0
- package/dest/contracts/gse.d.ts.map +1 -0
- package/dest/contracts/gse.js +72 -0
- package/dest/contracts/inbox.d.ts +26 -0
- package/dest/contracts/inbox.d.ts.map +1 -0
- package/dest/contracts/inbox.js +45 -0
- package/dest/contracts/index.d.ts +9 -3
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +8 -2
- package/dest/contracts/multicall.d.ts +21 -0
- package/dest/contracts/multicall.d.ts.map +1 -0
- package/dest/contracts/multicall.js +156 -0
- package/dest/contracts/registry.d.ts +10 -5
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +44 -16
- package/dest/contracts/rollup.d.ts +221 -41
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +549 -81
- package/dest/contracts/slasher_contract.d.ts +44 -0
- package/dest/contracts/slasher_contract.d.ts.map +1 -0
- package/dest/contracts/slasher_contract.js +75 -0
- package/dest/contracts/tally_slashing_proposer.d.ts +140 -0
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/tally_slashing_proposer.js +313 -0
- package/dest/contracts/utils.d.ts +3 -0
- package/dest/contracts/utils.d.ts.map +1 -0
- package/dest/contracts/utils.js +11 -0
- package/dest/deploy_aztec_l1_contracts.d.ts +245 -0
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
- package/dest/deploy_aztec_l1_contracts.js +335 -0
- package/dest/deploy_l1_contract.d.ts +68 -0
- package/dest/deploy_l1_contract.d.ts.map +1 -0
- package/dest/deploy_l1_contract.js +312 -0
- package/dest/eth-signer/eth-signer.d.ts +21 -0
- package/dest/eth-signer/eth-signer.d.ts.map +1 -0
- package/dest/eth-signer/eth-signer.js +5 -0
- package/dest/eth-signer/index.d.ts +2 -0
- package/dest/eth-signer/index.d.ts.map +1 -0
- package/dest/eth-signer/index.js +1 -0
- package/dest/forwarder_proxy.d.ts +32 -0
- package/dest/forwarder_proxy.d.ts.map +1 -0
- package/dest/forwarder_proxy.js +93 -0
- package/dest/l1_artifacts.d.ts +77364 -0
- package/dest/l1_artifacts.d.ts.map +1 -0
- package/dest/l1_artifacts.js +166 -0
- package/dest/l1_contract_addresses.d.ts +24 -4
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +25 -21
- package/dest/l1_reader.d.ts +4 -2
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +14 -8
- package/dest/l1_tx_utils/config.d.ts +59 -0
- package/dest/l1_tx_utils/config.d.ts.map +1 -0
- package/dest/l1_tx_utils/config.js +96 -0
- package/dest/l1_tx_utils/constants.d.ts +12 -0
- package/dest/l1_tx_utils/constants.d.ts.map +1 -0
- package/dest/l1_tx_utils/constants.js +39 -0
- package/dest/l1_tx_utils/factory.d.ts +24 -0
- package/dest/l1_tx_utils/factory.d.ts.map +1 -0
- package/dest/l1_tx_utils/factory.js +12 -0
- package/dest/l1_tx_utils/fee-strategies/index.d.ts +9 -0
- package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/index.js +11 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +18 -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 +111 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +32 -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 +173 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts +64 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/types.js +24 -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 +48 -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 +12 -0
- package/dest/l1_tx_utils/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/index.js +12 -0
- package/dest/l1_tx_utils/interfaces.d.ts +76 -0
- package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
- package/dest/l1_tx_utils/interfaces.js +4 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +94 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_tx_utils.js +623 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +26 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +26 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +87 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +360 -0
- package/dest/l1_tx_utils/signer.d.ts +4 -0
- package/dest/l1_tx_utils/signer.d.ts.map +1 -0
- package/dest/l1_tx_utils/signer.js +16 -0
- package/dest/l1_tx_utils/types.d.ts +67 -0
- package/dest/l1_tx_utils/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/types.js +26 -0
- package/dest/l1_tx_utils/utils.d.ts +4 -0
- package/dest/l1_tx_utils/utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/utils.js +14 -0
- package/dest/l1_types.d.ts +6 -0
- package/dest/l1_types.d.ts.map +1 -0
- package/dest/l1_types.js +1 -0
- package/dest/publisher_manager.d.ts +15 -0
- package/dest/publisher_manager.d.ts.map +1 -0
- package/dest/publisher_manager.js +88 -0
- package/dest/queries.d.ts +4 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +53 -12
- package/dest/test/chain_monitor.d.ts +75 -0
- package/dest/test/chain_monitor.d.ts.map +1 -0
- package/dest/test/chain_monitor.js +214 -0
- package/dest/test/delayed_tx_utils.d.ts +8 -3
- package/dest/test/delayed_tx_utils.d.ts.map +1 -1
- package/dest/test/delayed_tx_utils.js +13 -6
- package/dest/test/eth_cheat_codes.d.ts +217 -0
- package/dest/test/eth_cheat_codes.d.ts.map +1 -0
- package/dest/test/eth_cheat_codes.js +560 -0
- package/dest/test/eth_cheat_codes_with_state.d.ts +2 -2
- package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes_with_state.js +1 -1
- package/dest/test/index.d.ts +4 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +3 -0
- package/dest/test/rollup_cheat_codes.d.ts +87 -0
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
- package/dest/test/rollup_cheat_codes.js +275 -0
- package/dest/test/start_anvil.d.ts +9 -1
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +16 -7
- package/dest/test/tx_delayer.d.ts +18 -7
- package/dest/test/tx_delayer.d.ts.map +1 -1
- package/dest/test/tx_delayer.js +97 -20
- package/dest/test/upgrade_utils.d.ts +6 -5
- package/dest/test/upgrade_utils.d.ts.map +1 -1
- package/dest/test/upgrade_utils.js +23 -16
- package/dest/types.d.ts +62 -8
- package/dest/types.d.ts.map +1 -1
- package/dest/types.js +3 -1
- package/dest/utils.d.ts +16 -3
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +61 -88
- package/dest/zkPassportVerifierAddress.d.ts +15 -0
- package/dest/zkPassportVerifierAddress.d.ts.map +1 -0
- package/dest/zkPassportVerifierAddress.js +11 -0
- package/package.json +50 -23
- package/src/account.ts +5 -0
- package/src/client.ts +43 -5
- package/src/config.ts +188 -31
- package/src/contracts/empire_base.ts +77 -7
- package/src/contracts/empire_slashing_proposer.ts +270 -0
- package/src/contracts/errors.ts +13 -0
- package/src/contracts/fee_asset_handler.ts +63 -0
- package/src/contracts/fee_juice.ts +29 -15
- package/src/contracts/governance.ts +80 -77
- package/src/contracts/governance_proposer.ts +71 -24
- package/src/contracts/gse.ts +88 -0
- package/src/contracts/inbox.ts +63 -0
- package/src/contracts/index.ts +8 -2
- package/src/contracts/multicall.ts +155 -0
- package/src/contracts/registry.ts +51 -26
- package/src/contracts/rollup.ts +624 -78
- package/src/contracts/slasher_contract.ts +89 -0
- package/src/contracts/tally_slashing_proposer.ts +318 -0
- package/src/contracts/utils.ts +14 -0
- package/src/deploy_aztec_l1_contracts.ts +556 -0
- package/src/deploy_l1_contract.ts +362 -0
- package/src/eth-signer/eth-signer.ts +25 -0
- package/src/eth-signer/index.ts +1 -0
- package/src/forwarder_proxy.ts +108 -0
- package/src/l1_artifacts.ts +254 -0
- package/src/l1_contract_addresses.ts +49 -34
- package/src/l1_reader.ts +17 -9
- package/src/l1_tx_utils/README.md +177 -0
- package/src/l1_tx_utils/config.ts +161 -0
- package/src/l1_tx_utils/constants.ts +29 -0
- package/src/l1_tx_utils/factory.ts +64 -0
- package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +159 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +241 -0
- package/src/l1_tx_utils/fee-strategies/types.ts +88 -0
- package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +119 -0
- package/src/l1_tx_utils/index-blobs.ts +2 -0
- package/src/l1_tx_utils/index.ts +14 -0
- package/src/l1_tx_utils/interfaces.ts +86 -0
- package/src/l1_tx_utils/l1_fee_analyzer.ts +804 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +738 -0
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +77 -0
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +458 -0
- package/src/l1_tx_utils/signer.ts +28 -0
- package/src/l1_tx_utils/types.ts +85 -0
- package/src/l1_tx_utils/utils.ts +16 -0
- package/src/l1_types.ts +6 -0
- package/src/publisher_manager.ts +106 -0
- package/src/queries.ts +73 -15
- package/src/test/chain_monitor.ts +245 -0
- package/src/test/delayed_tx_utils.ts +34 -6
- package/src/test/eth_cheat_codes.ts +588 -0
- package/src/test/eth_cheat_codes_with_state.ts +1 -1
- package/src/test/index.ts +3 -0
- package/src/test/rollup_cheat_codes.ts +312 -0
- package/src/test/start_anvil.ts +24 -5
- package/src/test/tx_delayer.ts +130 -27
- package/src/test/upgrade_utils.ts +30 -21
- package/src/types.ts +71 -7
- package/src/utils.ts +79 -91
- package/src/zkPassportVerifierAddress.ts +15 -0
- package/dest/contracts/forwarder.d.ts +0 -24
- package/dest/contracts/forwarder.d.ts.map +0 -1
- package/dest/contracts/forwarder.js +0 -101
- package/dest/contracts/slashing_proposer.d.ts +0 -21
- package/dest/contracts/slashing_proposer.d.ts.map +0 -1
- package/dest/contracts/slashing_proposer.js +0 -47
- package/dest/deploy_l1_contracts.d.ts +0 -21210
- package/dest/deploy_l1_contracts.d.ts.map +0 -1
- package/dest/deploy_l1_contracts.js +0 -687
- package/dest/eth_cheat_codes.d.ts +0 -147
- package/dest/eth_cheat_codes.d.ts.map +0 -1
- package/dest/eth_cheat_codes.js +0 -303
- package/dest/index.d.ts +0 -14
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -13
- package/dest/l1_tx_utils.d.ts +0 -192
- package/dest/l1_tx_utils.d.ts.map +0 -1
- package/dest/l1_tx_utils.js +0 -641
- package/dest/l1_tx_utils_with_blobs.d.ts +0 -12
- package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils_with_blobs.js +0 -64
- package/src/contracts/forwarder.ts +0 -132
- package/src/contracts/slashing_proposer.ts +0 -51
- package/src/deploy_l1_contracts.ts +0 -948
- package/src/eth_cheat_codes.ts +0 -314
- package/src/index.ts +0 -13
- package/src/l1_tx_utils.ts +0 -847
- package/src/l1_tx_utils_with_blobs.ts +0 -86
|
@@ -1,17 +1,32 @@
|
|
|
1
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { memoize } from '@aztec/foundation/decorators';
|
|
2
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
-
import { GovernanceProposerAbi } from '@aztec/l1-artifacts';
|
|
4
|
+
import { GovernanceProposerAbi } from '@aztec/l1-artifacts/GovernanceProposerAbi';
|
|
4
5
|
|
|
5
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
type GetContractReturnType,
|
|
8
|
+
type Hex,
|
|
9
|
+
type TransactionReceipt,
|
|
10
|
+
type TypedDataDefinition,
|
|
11
|
+
encodeFunctionData,
|
|
12
|
+
getContract,
|
|
13
|
+
} from 'viem';
|
|
6
14
|
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import { type IEmpireBase,
|
|
15
|
+
import type { L1TxRequest, L1TxUtils } from '../l1_tx_utils/index.js';
|
|
16
|
+
import type { ViemClient } from '../types.js';
|
|
17
|
+
import { type IEmpireBase, encodeSignal, encodeSignalWithSignature, signSignalWithSig } from './empire_base.js';
|
|
18
|
+
import { extractProposalIdFromLogs } from './governance.js';
|
|
10
19
|
|
|
11
20
|
export class GovernanceProposerContract implements IEmpireBase {
|
|
12
|
-
private readonly proposer: GetContractReturnType<typeof GovernanceProposerAbi,
|
|
21
|
+
private readonly proposer: GetContractReturnType<typeof GovernanceProposerAbi, ViemClient>;
|
|
13
22
|
|
|
14
|
-
constructor(
|
|
23
|
+
constructor(
|
|
24
|
+
public readonly client: ViemClient,
|
|
25
|
+
address: Hex | EthAddress,
|
|
26
|
+
) {
|
|
27
|
+
if (address instanceof EthAddress) {
|
|
28
|
+
address = address.toString();
|
|
29
|
+
}
|
|
15
30
|
this.proposer = getContract({ address, abi: GovernanceProposerAbi, client });
|
|
16
31
|
}
|
|
17
32
|
|
|
@@ -29,54 +44,86 @@ export class GovernanceProposerContract implements IEmpireBase {
|
|
|
29
44
|
}
|
|
30
45
|
|
|
31
46
|
public getQuorumSize(): Promise<bigint> {
|
|
32
|
-
return this.proposer.read.
|
|
47
|
+
return this.proposer.read.QUORUM_SIZE();
|
|
33
48
|
}
|
|
34
49
|
|
|
35
50
|
public getRoundSize(): Promise<bigint> {
|
|
36
|
-
return this.proposer.read.
|
|
51
|
+
return this.proposer.read.ROUND_SIZE();
|
|
37
52
|
}
|
|
38
53
|
|
|
39
|
-
public
|
|
40
|
-
return this.proposer.read.
|
|
54
|
+
public getInstance() {
|
|
55
|
+
return this.proposer.read.getInstance();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public computeRound(slot: SlotNumber): Promise<bigint> {
|
|
59
|
+
return this.proposer.read.computeRound([BigInt(slot)]);
|
|
41
60
|
}
|
|
42
61
|
|
|
43
62
|
public async getRoundInfo(
|
|
44
63
|
rollupAddress: Hex,
|
|
45
64
|
round: bigint,
|
|
46
|
-
): Promise<{
|
|
47
|
-
const
|
|
65
|
+
): Promise<{ lastSignalSlot: SlotNumber; payloadWithMostSignals: Hex; quorumReached: boolean; executed: boolean }> {
|
|
66
|
+
const result = await this.proposer.read.getRoundData([rollupAddress, round]);
|
|
67
|
+
const [signalCount, quorum] = await Promise.all([
|
|
68
|
+
this.proposer.read.signalCount([rollupAddress, round, result.payloadWithMostSignals]),
|
|
69
|
+
this.getQuorumSize(),
|
|
70
|
+
]);
|
|
48
71
|
return {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
72
|
+
lastSignalSlot: SlotNumber.fromBigInt(result.lastSignalSlot),
|
|
73
|
+
payloadWithMostSignals: result.payloadWithMostSignals,
|
|
74
|
+
quorumReached: signalCount >= quorum,
|
|
75
|
+
executed: result.executed,
|
|
52
76
|
};
|
|
53
77
|
}
|
|
54
78
|
|
|
55
|
-
public
|
|
56
|
-
return this.proposer.read.
|
|
79
|
+
public getPayloadSignals(rollupAddress: Hex, round: bigint, payload: Hex): Promise<bigint> {
|
|
80
|
+
return this.proposer.read.signalCount([rollupAddress, round, payload]);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public createSignalRequest(payload: Hex): L1TxRequest {
|
|
84
|
+
return {
|
|
85
|
+
to: this.address.toString(),
|
|
86
|
+
data: encodeSignal(payload),
|
|
87
|
+
};
|
|
57
88
|
}
|
|
58
89
|
|
|
59
|
-
public
|
|
90
|
+
public async createSignalRequestWithSignature(
|
|
91
|
+
payload: Hex,
|
|
92
|
+
slot: SlotNumber,
|
|
93
|
+
chainId: number,
|
|
94
|
+
signerAddress: Hex,
|
|
95
|
+
signer: (msg: TypedDataDefinition) => Promise<Hex>,
|
|
96
|
+
): Promise<L1TxRequest> {
|
|
97
|
+
const signature = await signSignalWithSig(
|
|
98
|
+
signer,
|
|
99
|
+
payload,
|
|
100
|
+
slot,
|
|
101
|
+
await this.getInstance(),
|
|
102
|
+
this.address.toString(),
|
|
103
|
+
chainId,
|
|
104
|
+
);
|
|
60
105
|
return {
|
|
61
106
|
to: this.address.toString(),
|
|
62
|
-
data:
|
|
107
|
+
data: encodeSignalWithSignature(payload, signature),
|
|
63
108
|
};
|
|
64
109
|
}
|
|
65
110
|
|
|
66
|
-
public
|
|
111
|
+
public async submitRoundWinner(
|
|
67
112
|
round: bigint,
|
|
68
113
|
l1TxUtils: L1TxUtils,
|
|
69
114
|
): Promise<{
|
|
70
115
|
receipt: TransactionReceipt;
|
|
71
|
-
|
|
116
|
+
proposalId: bigint;
|
|
72
117
|
}> {
|
|
73
|
-
|
|
118
|
+
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
74
119
|
to: this.address.toString(),
|
|
75
120
|
data: encodeFunctionData({
|
|
76
121
|
abi: this.proposer.abi,
|
|
77
|
-
functionName: '
|
|
122
|
+
functionName: 'submitRoundWinner',
|
|
78
123
|
args: [round],
|
|
79
124
|
}),
|
|
80
125
|
});
|
|
126
|
+
const proposalId = extractProposalIdFromLogs(receipt.logs);
|
|
127
|
+
return { receipt, proposalId };
|
|
81
128
|
}
|
|
82
129
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import { GSEAbi } from '@aztec/l1-artifacts/GSEAbi';
|
|
3
|
+
|
|
4
|
+
import type { ProjPointType } from '@noble/curves/abstract/weierstrass';
|
|
5
|
+
import { bn254 } from '@noble/curves/bn254';
|
|
6
|
+
import { type GetContractReturnType, type Hex, getContract } from 'viem';
|
|
7
|
+
|
|
8
|
+
import type { ViemClient } from '../types.js';
|
|
9
|
+
|
|
10
|
+
export type RegistrationTuple = {
|
|
11
|
+
publicKeyInG1: {
|
|
12
|
+
x: bigint;
|
|
13
|
+
y: bigint;
|
|
14
|
+
};
|
|
15
|
+
publicKeyInG2: {
|
|
16
|
+
x0: bigint;
|
|
17
|
+
x1: bigint;
|
|
18
|
+
y0: bigint;
|
|
19
|
+
y1: bigint;
|
|
20
|
+
};
|
|
21
|
+
proofOfPossession: {
|
|
22
|
+
x: bigint;
|
|
23
|
+
y: bigint;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export class GSEContract {
|
|
28
|
+
public address: EthAddress;
|
|
29
|
+
private readonly gse: GetContractReturnType<typeof GSEAbi, ViemClient>;
|
|
30
|
+
|
|
31
|
+
constructor(
|
|
32
|
+
public readonly client: ViemClient,
|
|
33
|
+
address: Hex | EthAddress,
|
|
34
|
+
) {
|
|
35
|
+
if (address instanceof EthAddress) {
|
|
36
|
+
address = address.toString();
|
|
37
|
+
}
|
|
38
|
+
this.address = EthAddress.fromString(address);
|
|
39
|
+
this.gse = getContract({ address, abi: GSEAbi, client });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public async getOwner(): Promise<EthAddress> {
|
|
43
|
+
return EthAddress.fromString(await this.gse.read.owner());
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public async getGovernance(): Promise<EthAddress> {
|
|
47
|
+
return EthAddress.fromString(await this.gse.read.getGovernance());
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getAttestersFromIndicesAtTime(instance: Hex | EthAddress, ts: bigint, indices: bigint[]) {
|
|
51
|
+
if (instance instanceof EthAddress) {
|
|
52
|
+
instance = instance.toString();
|
|
53
|
+
}
|
|
54
|
+
return this.gse.read.getAttestersFromIndicesAtTime([instance, ts, indices]);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public async getRegistrationDigest(publicKey: ProjPointType<bigint>): Promise<ProjPointType<bigint>> {
|
|
58
|
+
const affinePublicKey = publicKey.toAffine();
|
|
59
|
+
const g1PointDigest = await this.gse.read.getRegistrationDigest([{ x: affinePublicKey.x, y: affinePublicKey.y }]);
|
|
60
|
+
return bn254.G1.ProjectivePoint.fromAffine(g1PointDigest);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public async makeRegistrationTuple(privateKey: bigint): Promise<RegistrationTuple> {
|
|
64
|
+
const publicKeyG1 = bn254.G1.ProjectivePoint.BASE.multiply(privateKey);
|
|
65
|
+
const digest = await this.getRegistrationDigest(publicKeyG1);
|
|
66
|
+
const signature = digest.multiply(privateKey);
|
|
67
|
+
const publicKeyG2 = bn254.G2.ProjectivePoint.BASE.multiply(privateKey);
|
|
68
|
+
const publicKeyG1Affine = publicKeyG1.toAffine();
|
|
69
|
+
const signatureAffine = signature.toAffine();
|
|
70
|
+
const publicKeyG2Affine = publicKeyG2.toAffine();
|
|
71
|
+
return {
|
|
72
|
+
publicKeyInG1: {
|
|
73
|
+
x: publicKeyG1Affine.x,
|
|
74
|
+
y: publicKeyG1Affine.y,
|
|
75
|
+
},
|
|
76
|
+
publicKeyInG2: {
|
|
77
|
+
x0: publicKeyG2Affine.x.c0,
|
|
78
|
+
x1: publicKeyG2Affine.x.c1,
|
|
79
|
+
y0: publicKeyG2Affine.y.c0,
|
|
80
|
+
y1: publicKeyG2Affine.y.c1,
|
|
81
|
+
},
|
|
82
|
+
proofOfPossession: {
|
|
83
|
+
x: signatureAffine.x,
|
|
84
|
+
y: signatureAffine.y,
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Buffer16 } from '@aztec/foundation/buffer';
|
|
2
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import { InboxAbi } from '@aztec/l1-artifacts/InboxAbi';
|
|
4
|
+
|
|
5
|
+
import { type BlockTag, type GetContractReturnType, type Hex, getContract } from 'viem';
|
|
6
|
+
|
|
7
|
+
import { getPublicClient } from '../client.js';
|
|
8
|
+
import type { DeployAztecL1ContractsReturnType } from '../deploy_aztec_l1_contracts.js';
|
|
9
|
+
import type { L1ReaderConfig } from '../l1_reader.js';
|
|
10
|
+
import type { ViemClient } from '../types.js';
|
|
11
|
+
import { checkBlockTag } from './utils.js';
|
|
12
|
+
|
|
13
|
+
export class InboxContract {
|
|
14
|
+
private readonly inbox: GetContractReturnType<typeof InboxAbi, ViemClient>;
|
|
15
|
+
|
|
16
|
+
static getFromL1ContractsValues(deployL1ContractsValues: DeployAztecL1ContractsReturnType) {
|
|
17
|
+
const {
|
|
18
|
+
l1Client,
|
|
19
|
+
l1ContractAddresses: { inboxAddress },
|
|
20
|
+
} = deployL1ContractsValues;
|
|
21
|
+
return new InboxContract(l1Client, inboxAddress.toString());
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static getFromConfig(config: L1ReaderConfig) {
|
|
25
|
+
const client = getPublicClient(config);
|
|
26
|
+
const address = config.l1Contracts.inboxAddress.toString();
|
|
27
|
+
return new InboxContract(client, address);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
constructor(
|
|
31
|
+
public readonly client: ViemClient,
|
|
32
|
+
address: Hex | EthAddress,
|
|
33
|
+
) {
|
|
34
|
+
if (address instanceof EthAddress) {
|
|
35
|
+
address = address.toString();
|
|
36
|
+
}
|
|
37
|
+
this.inbox = getContract({ address, abi: InboxAbi, client });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public get address() {
|
|
41
|
+
return this.inbox.address;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public getContract(): GetContractReturnType<typeof InboxAbi, ViemClient> {
|
|
45
|
+
return this.inbox;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public async getState(opts: { blockTag?: BlockTag; blockNumber?: bigint } = {}): Promise<InboxContractState> {
|
|
49
|
+
await checkBlockTag(opts.blockNumber, this.client);
|
|
50
|
+
const state = await this.inbox.read.getState(opts);
|
|
51
|
+
return {
|
|
52
|
+
totalMessagesInserted: state.totalMessagesInserted,
|
|
53
|
+
messagesRollingHash: Buffer16.fromString(state.rollingHash),
|
|
54
|
+
treeInProgress: state.inProgress,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type InboxContractState = {
|
|
60
|
+
totalMessagesInserted: bigint;
|
|
61
|
+
messagesRollingHash: Buffer16;
|
|
62
|
+
treeInProgress: bigint;
|
|
63
|
+
};
|
package/src/contracts/index.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
export * from './empire_base.js';
|
|
2
|
+
export * from './errors.js';
|
|
3
|
+
export * from './fee_asset_handler.js';
|
|
2
4
|
export * from './fee_juice.js';
|
|
3
|
-
export * from './forwarder.js';
|
|
4
5
|
export * from './governance.js';
|
|
5
6
|
export * from './governance_proposer.js';
|
|
7
|
+
export * from './gse.js';
|
|
8
|
+
export * from './inbox.js';
|
|
9
|
+
export * from './multicall.js';
|
|
6
10
|
export * from './registry.js';
|
|
7
11
|
export * from './rollup.js';
|
|
8
|
-
export * from './
|
|
12
|
+
export * from './empire_slashing_proposer.js';
|
|
13
|
+
export * from './tally_slashing_proposer.js';
|
|
14
|
+
export * from './slasher_contract.js';
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { toHex as toPaddedHex } from '@aztec/foundation/bigint-buffer';
|
|
2
|
+
import { TimeoutError } from '@aztec/foundation/error';
|
|
3
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
4
|
+
|
|
5
|
+
import { type EncodeFunctionDataParameters, type Hex, encodeFunctionData, multicall3Abi } from 'viem';
|
|
6
|
+
|
|
7
|
+
import type { L1BlobInputs, L1TxConfig, L1TxRequest, L1TxUtils } from '../l1_tx_utils/index.js';
|
|
8
|
+
import type { ExtendedViemWalletClient } from '../types.js';
|
|
9
|
+
import { FormattedViemError, formatViemError } from '../utils.js';
|
|
10
|
+
import { RollupContract } from './rollup.js';
|
|
11
|
+
|
|
12
|
+
export const MULTI_CALL_3_ADDRESS = '0xcA11bde05977b3631167028862bE2a173976CA11' as const;
|
|
13
|
+
|
|
14
|
+
export class Multicall3 {
|
|
15
|
+
static async forward(
|
|
16
|
+
requests: L1TxRequest[],
|
|
17
|
+
l1TxUtils: L1TxUtils,
|
|
18
|
+
gasConfig: L1TxConfig | undefined,
|
|
19
|
+
blobConfig: L1BlobInputs | undefined,
|
|
20
|
+
rollupAddress: Hex,
|
|
21
|
+
logger: Logger,
|
|
22
|
+
opts: { revertOnFailure?: boolean } = {},
|
|
23
|
+
) {
|
|
24
|
+
requests = requests.filter(request => request.to !== null);
|
|
25
|
+
const args = requests.map(r => ({
|
|
26
|
+
target: r.to!,
|
|
27
|
+
callData: r.data!,
|
|
28
|
+
allowFailure: !opts.revertOnFailure,
|
|
29
|
+
}));
|
|
30
|
+
const forwarderFunctionData: Required<EncodeFunctionDataParameters<typeof multicall3Abi, 'aggregate3'>> = {
|
|
31
|
+
abi: multicall3Abi,
|
|
32
|
+
functionName: 'aggregate3',
|
|
33
|
+
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
|
+
}
|
|
96
|
+
|
|
97
|
+
for (const request of requests) {
|
|
98
|
+
logger.debug('Simulating request', { request });
|
|
99
|
+
const result = await l1TxUtils
|
|
100
|
+
.simulate(request, undefined, [
|
|
101
|
+
{
|
|
102
|
+
address: rollupAddress,
|
|
103
|
+
stateDiff: [
|
|
104
|
+
{ slot: toPaddedHex(RollupContract.checkBlobStorageSlot, true), value: toPaddedHex(0n, true) },
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
])
|
|
108
|
+
.catch(err => formatViemError(err, request.abi));
|
|
109
|
+
if (result instanceof FormattedViemError) {
|
|
110
|
+
logger.error('Found error in simulation', result, {
|
|
111
|
+
to: request.to ?? 'null',
|
|
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;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export async function deployMulticall3(l1Client: ExtendedViemWalletClient, logger: Logger) {
|
|
125
|
+
const existing = await l1Client.getCode({ address: MULTI_CALL_3_ADDRESS });
|
|
126
|
+
if (existing && existing !== '0x') {
|
|
127
|
+
logger.verbose('Multicall3 already deployed', { address: MULTI_CALL_3_ADDRESS });
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const deployer = '0x05f32b3cc3888453ff71b01135b34ff8e41263f2';
|
|
132
|
+
const sendEth = await l1Client.sendTransaction({ to: deployer, value: 10n ** 17n });
|
|
133
|
+
logger.info('Sent 0.1 ETH to deployer', { deployer, value: 10n ** 17n });
|
|
134
|
+
const sendEthReceipt = await l1Client.waitForTransactionReceipt({ hash: sendEth });
|
|
135
|
+
if (sendEthReceipt.status !== 'success') {
|
|
136
|
+
logger.error('Failed to send ETH to deployer', undefined, { sendEthReceipt });
|
|
137
|
+
throw new Error('Failed to send ETH to deployer');
|
|
138
|
+
} else {
|
|
139
|
+
logger.info('Sent 0.1 ETH to deployer', { deployer, value: 10n ** 17n });
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const tx =
|
|
143
|
+
'0xf90f538085174876e800830f42408080b90f00608060405234801561001057600080fd5b50610ee0806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e1461025a578063bce38bd714610275578063c3077fa914610288578063ee82ac5e1461029b57600080fd5b80634d2301cc146101ec57806372425d9d1461022157806382ad56cb1461023457806386d516e81461024757600080fd5b80633408e470116100c65780633408e47014610191578063399542e9146101a45780633e64a696146101c657806342cbb15c146101d957600080fd5b80630f28c97d146100f8578063174dea711461011a578063252dba421461013a57806327e86d6e1461015b575b600080fd5b34801561010457600080fd5b50425b6040519081526020015b60405180910390f35b61012d610128366004610a85565b6102ba565b6040516101119190610bbe565b61014d610148366004610a85565b6104ef565b604051610111929190610bd8565b34801561016757600080fd5b50437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0140610107565b34801561019d57600080fd5b5046610107565b6101b76101b2366004610c60565b610690565b60405161011193929190610cba565b3480156101d257600080fd5b5048610107565b3480156101e557600080fd5b5043610107565b3480156101f857600080fd5b50610107610207366004610ce2565b73ffffffffffffffffffffffffffffffffffffffff163190565b34801561022d57600080fd5b5044610107565b61012d610242366004610a85565b6106ab565b34801561025357600080fd5b5045610107565b34801561026657600080fd5b50604051418152602001610111565b61012d610283366004610c60565b61085a565b6101b7610296366004610a85565b610a1a565b3480156102a757600080fd5b506101076102b6366004610d18565b4090565b60606000828067ffffffffffffffff8111156102d8576102d8610d31565b60405190808252806020026020018201604052801561031e57816020015b6040805180820190915260008152606060208201528152602001906001900390816102f65790505b5092503660005b8281101561047757600085828151811061034157610341610d60565b6020026020010151905087878381811061035d5761035d610d60565b905060200281019061036f9190610d8f565b6040810135958601959093506103886020850185610ce2565b73ffffffffffffffffffffffffffffffffffffffff16816103ac6060870187610dcd565b6040516103ba929190610e32565b60006040518083038185875af1925050503d80600081146103f7576040519150601f19603f3d011682016040523d82523d6000602084013e6103fc565b606091505b50602080850191909152901515808452908501351761046d577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b5050600101610325565b508234146104e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d756c746963616c6c333a2076616c7565206d69736d6174636800000000000060448201526064015b60405180910390fd5b50505092915050565b436060828067ffffffffffffffff81111561050c5761050c610d31565b60405190808252806020026020018201604052801561053f57816020015b606081526020019060019003908161052a5790505b5091503660005b8281101561068657600087878381811061056257610562610d60565b90506020028101906105749190610e42565b92506105836020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff166105a66020850185610dcd565b6040516105b4929190610e32565b6000604051808303816000865af19150503d80600081146105f1576040519150601f19603f3d011682016040523d82523d6000602084013e6105f6565b606091505b5086848151811061060957610609610d60565b602090810291909101015290508061067d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b50600101610546565b5050509250929050565b43804060606106a086868661085a565b905093509350939050565b6060818067ffffffffffffffff8111156106c7576106c7610d31565b60405190808252806020026020018201604052801561070d57816020015b6040805180820190915260008152606060208201528152602001906001900390816106e55790505b5091503660005b828110156104e657600084828151811061073057610730610d60565b6020026020010151905086868381811061074c5761074c610d60565b905060200281019061075e9190610e76565b925061076d6020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff166107906040850185610dcd565b60405161079e929190610e32565b6000604051808303816000865af19150503d80600081146107db576040519150601f19603f3d011682016040523d82523d6000602084013e6107e0565b606091505b506020808401919091529015158083529084013517610851577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b50600101610714565b6060818067ffffffffffffffff81111561087657610876610d31565b6040519080825280602002602001820160405280156108bc57816020015b6040805180820190915260008152606060208201528152602001906001900390816108945790505b5091503660005b82811015610a105760008482815181106108df576108df610d60565b602002602001015190508686838181106108fb576108fb610d60565b905060200281019061090d9190610e42565b925061091c6020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff1661093f6020850185610dcd565b60405161094d929190610e32565b6000604051808303816000865af19150503d806000811461098a576040519150601f19603f3d011682016040523d82523d6000602084013e61098f565b606091505b506020830152151581528715610a07578051610a07576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b506001016108c3565b5050509392505050565b6000806060610a2b60018686610690565b919790965090945092505050565b60008083601f840112610a4b57600080fd5b50813567ffffffffffffffff811115610a6357600080fd5b6020830191508360208260051b8501011115610a7e57600080fd5b9250929050565b60008060208385031215610a9857600080fd5b823567ffffffffffffffff811115610aaf57600080fd5b610abb85828601610a39565b90969095509350505050565b6000815180845260005b81811015610aed57602081850181015186830182015201610ad1565b81811115610aff576000602083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600082825180855260208086019550808260051b84010181860160005b84811015610bb1578583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001895281518051151584528401516040858501819052610b9d81860183610ac7565b9a86019a9450505090830190600101610b4f565b5090979650505050505050565b602081526000610bd16020830184610b32565b9392505050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015610c52577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0888703018452610c40868351610ac7565b95509284019290840190600101610c06565b509398975050505050505050565b600080600060408486031215610c7557600080fd5b83358015158114610c8557600080fd5b9250602084013567ffffffffffffffff811115610ca157600080fd5b610cad86828701610a39565b9497909650939450505050565b838152826020820152606060408201526000610cd96060830184610b32565b95945050505050565b600060208284031215610cf457600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610bd157600080fd5b600060208284031215610d2a57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81833603018112610dc357600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112610e0257600080fd5b83018035915067ffffffffffffffff821115610e1d57600080fd5b602001915036819003821315610a7e57600080fd5b8183823760009101908152919050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112610dc357600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1833603018112610dc357600080fdfea2646970667358221220bb2b5c71a328032f97c676ae39a1ec2148d3e5d6f73d95e9b17910152d61f16264736f6c634300080c00331ca0edce47092c0f398cebf3ffc267f05c8e7076e3b89445e0fe50f6332273d4569ba01b0b9d000e19b24c5869b0fc3b22b0d6fa47cd63316875cbbd577d76e6fde086';
|
|
144
|
+
|
|
145
|
+
const deployTx = await l1Client.sendRawTransaction({
|
|
146
|
+
serializedTransaction: tx,
|
|
147
|
+
});
|
|
148
|
+
const deployTxReceipt = await l1Client.waitForTransactionReceipt({ hash: deployTx });
|
|
149
|
+
if (deployTxReceipt.status !== 'success') {
|
|
150
|
+
logger.error('Failed to deploy Multicall3', undefined, { deployTxReceipt });
|
|
151
|
+
throw new Error('Failed to deploy Multicall3');
|
|
152
|
+
} else {
|
|
153
|
+
logger.info('Deployed Multicall3');
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import { RegistryAbi } from '@aztec/l1-artifacts/RegistryAbi';
|
|
3
4
|
import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi';
|
|
4
5
|
|
|
5
|
-
import {
|
|
6
|
-
type Chain,
|
|
7
|
-
type GetContractReturnType,
|
|
8
|
-
type Hex,
|
|
9
|
-
type HttpTransport,
|
|
10
|
-
type PublicClient,
|
|
11
|
-
getContract,
|
|
12
|
-
} from 'viem';
|
|
6
|
+
import { type GetContractReturnType, type Hex, getContract } from 'viem';
|
|
13
7
|
|
|
14
8
|
import type { L1ContractAddresses } from '../l1_contract_addresses.js';
|
|
15
|
-
import type {
|
|
16
|
-
import {
|
|
9
|
+
import type { ViemClient } from '../types.js';
|
|
10
|
+
import { ReadOnlyGovernanceContract } from './governance.js';
|
|
17
11
|
import { RollupContract } from './rollup.js';
|
|
18
12
|
|
|
19
13
|
export class RegistryContract {
|
|
20
14
|
public address: EthAddress;
|
|
21
|
-
private readonly registry: GetContractReturnType<typeof RegistryAbi, PublicClient<HttpTransport, Chain>>;
|
|
22
15
|
|
|
23
|
-
|
|
16
|
+
private readonly log = createLogger('ethereum:contracts:registry');
|
|
17
|
+
private readonly registry: GetContractReturnType<typeof RegistryAbi, ViemClient>;
|
|
18
|
+
|
|
19
|
+
constructor(
|
|
20
|
+
public readonly client: ViemClient,
|
|
21
|
+
address: Hex | EthAddress,
|
|
22
|
+
) {
|
|
24
23
|
if (address instanceof EthAddress) {
|
|
25
24
|
address = address.toString();
|
|
26
25
|
}
|
|
@@ -28,6 +27,10 @@ export class RegistryContract {
|
|
|
28
27
|
this.registry = getContract({ address, abi: RegistryAbi, client });
|
|
29
28
|
}
|
|
30
29
|
|
|
30
|
+
public async getOwner(): Promise<EthAddress> {
|
|
31
|
+
return EthAddress.fromString(await this.registry.read.owner());
|
|
32
|
+
}
|
|
33
|
+
|
|
31
34
|
/**
|
|
32
35
|
* Returns the address of the rollup for a given version.
|
|
33
36
|
* @param version - The version of the rollup. 'canonical' can be used to get the canonical address (i.e. the latest version).
|
|
@@ -42,12 +45,19 @@ export class RegistryContract {
|
|
|
42
45
|
version = BigInt(version);
|
|
43
46
|
}
|
|
44
47
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
try {
|
|
49
|
+
return EthAddress.fromString(await this.registry.read.getRollup([version]));
|
|
50
|
+
} catch {
|
|
51
|
+
this.log.warn(`Failed fetching rollup address for version ${version}. Retrying as index.`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
const actualVersion = await this.registry.read.getVersion([version]);
|
|
56
|
+
const rollupAddress = await this.registry.read.getRollup([actualVersion]);
|
|
57
|
+
return EthAddress.fromString(rollupAddress);
|
|
58
|
+
} catch {
|
|
48
59
|
throw new Error('Rollup address is undefined');
|
|
49
60
|
}
|
|
50
|
-
return address;
|
|
51
61
|
}
|
|
52
62
|
|
|
53
63
|
/**
|
|
@@ -55,28 +65,23 @@ export class RegistryContract {
|
|
|
55
65
|
* @returns The canonical address of the rollup. If the rollup is not set, throws an error.
|
|
56
66
|
*/
|
|
57
67
|
public async getCanonicalAddress(): Promise<EthAddress> {
|
|
58
|
-
|
|
59
|
-
const address = EthAddress.fromString(snapshot.rollup);
|
|
60
|
-
if (address.equals(EthAddress.ZERO)) {
|
|
61
|
-
throw new Error('Rollup address is undefined');
|
|
62
|
-
}
|
|
63
|
-
return address;
|
|
68
|
+
return EthAddress.fromString(await this.registry.read.getCanonicalRollup());
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
public async getGovernanceAddresses(): Promise<
|
|
67
72
|
Pick<L1ContractAddresses, 'governanceProposerAddress' | 'governanceAddress'>
|
|
68
73
|
> {
|
|
69
74
|
const governanceAddress = await this.registry.read.getGovernance();
|
|
70
|
-
const governance = new
|
|
71
|
-
const
|
|
75
|
+
const governance = new ReadOnlyGovernanceContract(governanceAddress, this.client);
|
|
76
|
+
const governanceProposerAddress = await governance.getGovernanceProposerAddress();
|
|
72
77
|
return {
|
|
73
78
|
governanceAddress: governance.address,
|
|
74
|
-
governanceProposerAddress:
|
|
79
|
+
governanceProposerAddress: governanceProposerAddress,
|
|
75
80
|
};
|
|
76
81
|
}
|
|
77
82
|
|
|
78
83
|
public static async collectAddresses(
|
|
79
|
-
client:
|
|
84
|
+
client: ViemClient,
|
|
80
85
|
registryAddress: Hex | EthAddress,
|
|
81
86
|
rollupVersion: number | bigint | 'canonical',
|
|
82
87
|
): Promise<L1ContractAddresses> {
|
|
@@ -103,4 +108,24 @@ export class RegistryContract {
|
|
|
103
108
|
coinIssuerAddress: EthAddress.fromString(coinIssuer),
|
|
104
109
|
};
|
|
105
110
|
}
|
|
111
|
+
|
|
112
|
+
public async getNumberOfVersions(): Promise<number> {
|
|
113
|
+
const version = await this.registry.read.numberOfVersions();
|
|
114
|
+
return Number(version);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public async getRollupVersions(): Promise<bigint[]> {
|
|
118
|
+
const count = await this.getNumberOfVersions();
|
|
119
|
+
|
|
120
|
+
const versions: bigint[] = [];
|
|
121
|
+
for (let i = 0; i < count; i++) {
|
|
122
|
+
versions.push(await this.registry.read.getVersion([BigInt(i)]));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return versions;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
public async getRewardDistributor(): Promise<EthAddress> {
|
|
129
|
+
return EthAddress.fromString(await this.registry.read.getRewardDistributor());
|
|
130
|
+
}
|
|
106
131
|
}
|