@aztec/ethereum 0.0.0-test.1 → 0.0.1-commit.017a351
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/account.d.ts +2 -0
- package/dest/account.d.ts.map +1 -0
- package/dest/account.js +4 -0
- package/dest/chain.d.ts +1 -1
- package/dest/client.d.ts +28 -4
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +73 -3
- package/dest/config.d.ts +70 -23
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +151 -34
- package/dest/constants.d.ts +1 -1
- package/dest/contracts/chain_state_override.d.ts +78 -0
- package/dest/contracts/chain_state_override.d.ts.map +1 -0
- package/dest/contracts/chain_state_override.js +137 -0
- package/dest/contracts/empire_base.d.ts +25 -8
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_base.js +75 -2
- package/dest/contracts/errors.d.ts +7 -0
- package/dest/contracts/errors.d.ts.map +1 -0
- package/dest/contracts/errors.js +12 -0
- package/dest/contracts/fee_asset_handler.d.ts +20 -0
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -0
- package/dest/contracts/fee_asset_handler.js +59 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts +105 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
- package/dest/contracts/fee_asset_price_oracle.js +656 -0
- package/dest/contracts/fee_juice.d.ts +6 -7
- package/dest/contracts/fee_juice.d.ts.map +1 -1
- package/dest/contracts/fee_juice.js +27 -20
- package/dest/contracts/governance.d.ts +131 -43
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +281 -87
- package/dest/contracts/governance_proposer.d.ts +49 -13
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +483 -26
- package/dest/contracts/gse.d.ts +32 -0
- package/dest/contracts/gse.d.ts.map +1 -0
- package/dest/contracts/gse.js +72 -0
- package/dest/contracts/inbox.d.ts +47 -0
- package/dest/contracts/inbox.d.ts.map +1 -0
- package/dest/contracts/inbox.js +85 -0
- package/dest/contracts/index.d.ts +11 -2
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +10 -1
- package/dest/contracts/log.d.ts +13 -0
- package/dest/contracts/log.d.ts.map +1 -0
- package/dest/contracts/log.js +1 -0
- package/dest/contracts/multicall.d.ts +136 -0
- package/dest/contracts/multicall.d.ts.map +1 -0
- package/dest/contracts/multicall.js +264 -0
- package/dest/contracts/outbox.d.ts +64 -0
- package/dest/contracts/outbox.d.ts.map +1 -0
- package/dest/contracts/outbox.js +113 -0
- package/dest/contracts/registry.d.ts +12 -5
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +74 -17
- package/dest/contracts/rollup.d.ts +5526 -52
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +1446 -118
- package/dest/contracts/slasher_contract.d.ts +44 -0
- package/dest/contracts/slasher_contract.d.ts.map +1 -0
- package/dest/contracts/slasher_contract.js +75 -0
- package/dest/contracts/slashing_proposer.d.ts +133 -15
- package/dest/contracts/slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/slashing_proposer.js +293 -22
- package/dest/contracts/utils.d.ts +3 -0
- package/dest/contracts/utils.d.ts.map +1 -0
- package/dest/contracts/utils.js +11 -0
- package/dest/deploy_aztec_l1_contracts.d.ts +256 -0
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
- package/dest/deploy_aztec_l1_contracts.js +411 -0
- package/dest/deploy_l1_contract.d.ts +68 -0
- package/dest/deploy_l1_contract.d.ts.map +1 -0
- package/dest/deploy_l1_contract.js +312 -0
- package/dest/eth-signer/eth-signer.d.ts +21 -0
- package/dest/eth-signer/eth-signer.d.ts.map +1 -0
- package/dest/eth-signer/eth-signer.js +5 -0
- package/dest/eth-signer/index.d.ts +2 -0
- package/dest/eth-signer/index.d.ts.map +1 -0
- package/dest/eth-signer/index.js +1 -0
- package/dest/forwarder_proxy.d.ts +32 -0
- package/dest/forwarder_proxy.d.ts.map +1 -0
- package/dest/forwarder_proxy.js +93 -0
- package/dest/generated/l1-contracts-defaults.d.ts +30 -0
- package/dest/generated/l1-contracts-defaults.d.ts.map +1 -0
- package/dest/generated/l1-contracts-defaults.js +30 -0
- package/dest/l1_artifacts.d.ts +79270 -0
- package/dest/l1_artifacts.d.ts.map +1 -0
- package/dest/l1_artifacts.js +151 -0
- package/dest/l1_contract_addresses.d.ts +61 -45
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +99 -76
- package/dest/l1_reader.d.ts +8 -6
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +20 -12
- package/dest/l1_tx_utils/config.d.ts +65 -0
- package/dest/l1_tx_utils/config.d.ts.map +1 -0
- package/dest/l1_tx_utils/config.js +109 -0
- package/dest/l1_tx_utils/constants.d.ts +12 -0
- package/dest/l1_tx_utils/constants.d.ts.map +1 -0
- package/dest/l1_tx_utils/constants.js +39 -0
- package/dest/l1_tx_utils/factory.d.ts +32 -0
- package/dest/l1_tx_utils/factory.d.ts.map +1 -0
- package/dest/l1_tx_utils/factory.js +22 -0
- package/dest/l1_tx_utils/fee-strategies/index.d.ts +10 -0
- package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +129 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +191 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/types.js +3 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +41 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +42 -0
- package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
- package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
- package/dest/l1_tx_utils/index-blobs.js +2 -0
- package/dest/l1_tx_utils/index.d.ts +13 -0
- package/dest/l1_tx_utils/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/index.js +13 -0
- package/dest/l1_tx_utils/interfaces.d.ts +76 -0
- package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
- package/dest/l1_tx_utils/interfaces.js +4 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +113 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_tx_utils.js +658 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +83 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +328 -0
- package/dest/l1_tx_utils/signer.d.ts +4 -0
- package/dest/l1_tx_utils/signer.d.ts.map +1 -0
- package/dest/l1_tx_utils/signer.js +16 -0
- package/dest/l1_tx_utils/tx_delayer.d.ts +58 -0
- package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
- package/dest/l1_tx_utils/tx_delayer.js +223 -0
- package/dest/l1_tx_utils/types.d.ts +67 -0
- package/dest/l1_tx_utils/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/types.js +26 -0
- package/dest/l1_tx_utils/utils.d.ts +4 -0
- package/dest/l1_tx_utils/utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/utils.js +14 -0
- package/dest/l1_types.d.ts +6 -0
- package/dest/l1_types.d.ts.map +1 -0
- package/dest/l1_types.js +1 -0
- package/dest/publisher_manager.d.ts +30 -0
- package/dest/publisher_manager.d.ts.map +1 -0
- package/dest/publisher_manager.js +162 -0
- package/dest/queries.d.ts +17 -4
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +120 -12
- package/dest/test/chain_monitor.d.ts +95 -0
- package/dest/test/chain_monitor.d.ts.map +1 -0
- package/dest/test/chain_monitor.js +249 -0
- package/dest/test/eth_cheat_codes.d.ts +237 -0
- package/dest/test/eth_cheat_codes.d.ts.map +1 -0
- package/dest/test/eth_cheat_codes.js +573 -0
- package/dest/test/eth_cheat_codes_with_state.d.ts +2 -2
- package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes_with_state.js +1 -1
- package/dest/test/index.d.ts +4 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +3 -2
- package/dest/test/rollup_cheat_codes.d.ts +118 -0
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
- package/dest/test/rollup_cheat_codes.js +344 -0
- package/dest/test/start_anvil.d.ts +30 -2
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +147 -24
- package/dest/test/upgrade_utils.d.ts +6 -5
- package/dest/test/upgrade_utils.d.ts.map +1 -1
- package/dest/test/upgrade_utils.js +23 -16
- package/dest/types.d.ts +62 -8
- package/dest/types.d.ts.map +1 -1
- package/dest/types.js +3 -1
- package/dest/utils.d.ts +25 -4
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +142 -91
- package/dest/zkPassportVerifierAddress.d.ts +15 -0
- package/dest/zkPassportVerifierAddress.d.ts.map +1 -0
- package/dest/zkPassportVerifierAddress.js +11 -0
- package/package.json +52 -26
- package/src/account.ts +5 -0
- package/src/client.ts +107 -5
- package/src/config.ts +218 -43
- package/src/contracts/README.md +157 -0
- package/src/contracts/chain_state_override.ts +200 -0
- package/src/contracts/empire_base.ts +77 -7
- package/src/contracts/errors.ts +13 -0
- package/src/contracts/fee_asset_handler.ts +66 -0
- package/src/contracts/fee_asset_price_oracle.ts +285 -0
- package/src/contracts/fee_juice.ts +29 -15
- package/src/contracts/governance.ts +343 -74
- package/src/contracts/governance_proposer.ts +128 -25
- package/src/contracts/gse.ts +88 -0
- package/src/contracts/inbox.ts +123 -0
- package/src/contracts/index.ts +10 -1
- package/src/contracts/log.ts +13 -0
- package/src/contracts/multicall.ts +296 -0
- package/src/contracts/outbox.ts +132 -0
- package/src/contracts/registry.ts +81 -26
- package/src/contracts/rollup.ts +1246 -90
- package/src/contracts/slasher_contract.ts +89 -0
- package/src/contracts/slashing_proposer.ts +296 -27
- package/src/contracts/utils.ts +14 -0
- package/src/deploy_aztec_l1_contracts.ts +646 -0
- package/src/deploy_l1_contract.ts +362 -0
- package/src/eth-signer/eth-signer.ts +25 -0
- package/src/eth-signer/index.ts +1 -0
- package/src/forwarder_proxy.ts +108 -0
- package/src/generated/l1-contracts-defaults.ts +32 -0
- package/src/l1_artifacts.ts +231 -0
- package/src/l1_contract_addresses.ts +121 -80
- package/src/l1_reader.ts +31 -16
- package/src/l1_tx_utils/README.md +177 -0
- package/src/l1_tx_utils/config.ts +181 -0
- package/src/l1_tx_utils/constants.ts +29 -0
- package/src/l1_tx_utils/factory.ts +64 -0
- package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +163 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +245 -0
- package/src/l1_tx_utils/fee-strategies/types.ts +56 -0
- package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +108 -0
- package/src/l1_tx_utils/index-blobs.ts +2 -0
- package/src/l1_tx_utils/index.ts +15 -0
- package/src/l1_tx_utils/interfaces.ts +86 -0
- package/src/l1_tx_utils/l1_fee_analyzer.ts +803 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +789 -0
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +424 -0
- package/src/l1_tx_utils/signer.ts +28 -0
- package/src/l1_tx_utils/tx_delayer.ts +303 -0
- package/src/l1_tx_utils/types.ts +85 -0
- package/src/l1_tx_utils/utils.ts +16 -0
- package/src/l1_types.ts +6 -0
- package/src/publisher_manager.ts +203 -0
- package/src/queries.ts +149 -17
- package/src/test/chain_monitor.ts +307 -0
- package/src/test/eth_cheat_codes.ts +600 -0
- package/src/test/eth_cheat_codes_with_state.ts +1 -1
- package/src/test/index.ts +3 -2
- package/src/test/rollup_cheat_codes.ts +388 -0
- package/src/test/start_anvil.ts +189 -22
- package/src/test/upgrade_utils.ts +30 -21
- package/src/types.ts +71 -7
- package/src/utils.ts +164 -96
- package/src/zkPassportVerifierAddress.ts +15 -0
- package/dest/contracts/forwarder.d.ts +0 -24
- package/dest/contracts/forwarder.d.ts.map +0 -1
- package/dest/contracts/forwarder.js +0 -101
- package/dest/deploy_l1_contracts.d.ts +0 -21210
- package/dest/deploy_l1_contracts.d.ts.map +0 -1
- package/dest/deploy_l1_contracts.js +0 -687
- package/dest/eth_cheat_codes.d.ts +0 -147
- package/dest/eth_cheat_codes.d.ts.map +0 -1
- package/dest/eth_cheat_codes.js +0 -303
- package/dest/index.d.ts +0 -14
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -13
- package/dest/l1_tx_utils.d.ts +0 -192
- package/dest/l1_tx_utils.d.ts.map +0 -1
- package/dest/l1_tx_utils.js +0 -641
- package/dest/l1_tx_utils_with_blobs.d.ts +0 -12
- package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils_with_blobs.js +0 -64
- package/dest/test/delayed_tx_utils.d.ts +0 -8
- package/dest/test/delayed_tx_utils.d.ts.map +0 -1
- package/dest/test/delayed_tx_utils.js +0 -21
- package/dest/test/tx_delayer.d.ts +0 -25
- package/dest/test/tx_delayer.d.ts.map +0 -1
- package/dest/test/tx_delayer.js +0 -116
- package/src/contracts/forwarder.ts +0 -132
- package/src/deploy_l1_contracts.ts +0 -948
- package/src/eth_cheat_codes.ts +0 -314
- package/src/index.ts +0 -13
- package/src/l1_tx_utils.ts +0 -847
- package/src/l1_tx_utils_with_blobs.ts +0 -86
- package/src/test/delayed_tx_utils.ts +0 -24
- package/src/test/tx_delayer.ts +0 -163
|
@@ -1,17 +1,40 @@
|
|
|
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 { ReadOnlyGovernanceContract, 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
|
-
|
|
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
|
+
|
|
31
|
+
constructor(
|
|
32
|
+
public readonly client: ViemClient,
|
|
33
|
+
address: Hex | EthAddress,
|
|
34
|
+
) {
|
|
35
|
+
if (address instanceof EthAddress) {
|
|
36
|
+
address = address.toString();
|
|
37
|
+
}
|
|
15
38
|
this.proposer = getContract({ address, abi: GovernanceProposerAbi, client });
|
|
16
39
|
}
|
|
17
40
|
|
|
@@ -29,54 +52,134 @@ export class GovernanceProposerContract implements IEmpireBase {
|
|
|
29
52
|
}
|
|
30
53
|
|
|
31
54
|
public getQuorumSize(): Promise<bigint> {
|
|
32
|
-
return this.proposer.read.
|
|
55
|
+
return this.proposer.read.QUORUM_SIZE();
|
|
33
56
|
}
|
|
34
57
|
|
|
35
58
|
public getRoundSize(): Promise<bigint> {
|
|
36
|
-
return this.proposer.read.
|
|
59
|
+
return this.proposer.read.ROUND_SIZE();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public getInstance() {
|
|
63
|
+
return this.proposer.read.getInstance();
|
|
37
64
|
}
|
|
38
65
|
|
|
39
|
-
public computeRound(slot:
|
|
40
|
-
return this.proposer.read.computeRound([slot]);
|
|
66
|
+
public computeRound(slot: SlotNumber): Promise<bigint> {
|
|
67
|
+
return this.proposer.read.computeRound([BigInt(slot)]);
|
|
41
68
|
}
|
|
42
69
|
|
|
43
70
|
public async getRoundInfo(
|
|
44
71
|
rollupAddress: Hex,
|
|
45
72
|
round: bigint,
|
|
46
|
-
): Promise<{
|
|
47
|
-
const
|
|
73
|
+
): Promise<{ lastSignalSlot: SlotNumber; payloadWithMostSignals: Hex; quorumReached: boolean; executed: boolean }> {
|
|
74
|
+
const result = await this.proposer.read.getRoundData([rollupAddress, round]);
|
|
75
|
+
const [signalCount, quorum] = await Promise.all([
|
|
76
|
+
this.proposer.read.signalCount([rollupAddress, round, result.payloadWithMostSignals]),
|
|
77
|
+
this.getQuorumSize(),
|
|
78
|
+
]);
|
|
48
79
|
return {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
80
|
+
lastSignalSlot: SlotNumber.fromBigInt(result.lastSignalSlot),
|
|
81
|
+
payloadWithMostSignals: result.payloadWithMostSignals,
|
|
82
|
+
quorumReached: signalCount >= quorum,
|
|
83
|
+
executed: result.executed,
|
|
52
84
|
};
|
|
53
85
|
}
|
|
54
86
|
|
|
55
|
-
public
|
|
56
|
-
return this.proposer.read.
|
|
87
|
+
public getPayloadSignals(rollupAddress: Hex, round: bigint, payload: Hex): Promise<bigint> {
|
|
88
|
+
return this.proposer.read.signalCount([rollupAddress, round, payload]);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public createSignalRequest(payload: Hex): L1TxRequest {
|
|
92
|
+
return {
|
|
93
|
+
to: this.address.toString(),
|
|
94
|
+
abi: GovernanceProposerAbi,
|
|
95
|
+
data: encodeSignal(payload),
|
|
96
|
+
};
|
|
57
97
|
}
|
|
58
98
|
|
|
59
|
-
public
|
|
99
|
+
public async createSignalRequestWithSignature(
|
|
100
|
+
payload: Hex,
|
|
101
|
+
slot: SlotNumber,
|
|
102
|
+
chainId: number,
|
|
103
|
+
signerAddress: Hex,
|
|
104
|
+
signer: (msg: TypedDataDefinition) => Promise<Hex>,
|
|
105
|
+
): Promise<L1TxRequest> {
|
|
106
|
+
const signature = await signSignalWithSig(
|
|
107
|
+
signer,
|
|
108
|
+
payload,
|
|
109
|
+
slot,
|
|
110
|
+
await this.getInstance(),
|
|
111
|
+
this.address.toString(),
|
|
112
|
+
chainId,
|
|
113
|
+
);
|
|
60
114
|
return {
|
|
61
115
|
to: this.address.toString(),
|
|
62
|
-
|
|
116
|
+
abi: GovernanceProposerAbi,
|
|
117
|
+
data: encodeSignalWithSignature(payload, signature),
|
|
63
118
|
};
|
|
64
119
|
}
|
|
65
120
|
|
|
66
|
-
|
|
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
|
+
|
|
166
|
+
public async submitRoundWinner(
|
|
67
167
|
round: bigint,
|
|
68
168
|
l1TxUtils: L1TxUtils,
|
|
69
169
|
): Promise<{
|
|
70
170
|
receipt: TransactionReceipt;
|
|
71
|
-
|
|
171
|
+
proposalId: bigint;
|
|
72
172
|
}> {
|
|
73
|
-
|
|
173
|
+
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
74
174
|
to: this.address.toString(),
|
|
175
|
+
abi: GovernanceProposerAbi,
|
|
75
176
|
data: encodeFunctionData({
|
|
76
|
-
abi:
|
|
77
|
-
functionName: '
|
|
177
|
+
abi: GovernanceProposerAbi,
|
|
178
|
+
functionName: 'submitRoundWinner',
|
|
78
179
|
args: [round],
|
|
79
180
|
}),
|
|
80
181
|
});
|
|
182
|
+
const proposalId = extractProposalIdFromLogs(receipt.logs);
|
|
183
|
+
return { receipt, proposalId };
|
|
81
184
|
}
|
|
82
185
|
}
|
|
@@ -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,123 @@
|
|
|
1
|
+
import { maxBigint } from '@aztec/foundation/bigint';
|
|
2
|
+
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
|
+
import { InboxAbi } from '@aztec/l1-artifacts/InboxAbi';
|
|
7
|
+
|
|
8
|
+
import { type BlockTag, type GetContractReturnType, type Hex, getContract } from 'viem';
|
|
9
|
+
|
|
10
|
+
import { getPublicClient } from '../client.js';
|
|
11
|
+
import type { DeployAztecL1ContractsReturnType } from '../deploy_aztec_l1_contracts.js';
|
|
12
|
+
import type { L1ReaderConfig } from '../l1_reader.js';
|
|
13
|
+
import type { ViemClient } from '../types.js';
|
|
14
|
+
import type { L1EventLog } from './log.js';
|
|
15
|
+
import { checkBlockTag } from './utils.js';
|
|
16
|
+
|
|
17
|
+
/** Arguments for the MessageSent event. */
|
|
18
|
+
export type MessageSentArgs = {
|
|
19
|
+
index: bigint;
|
|
20
|
+
leaf: Fr;
|
|
21
|
+
checkpointNumber: CheckpointNumber;
|
|
22
|
+
rollingHash: Buffer16;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** Log type for MessageSent events. */
|
|
26
|
+
export type MessageSentLog = L1EventLog<MessageSentArgs>;
|
|
27
|
+
|
|
28
|
+
export class InboxContract {
|
|
29
|
+
private readonly inbox: GetContractReturnType<typeof InboxAbi, ViemClient>;
|
|
30
|
+
|
|
31
|
+
static getFromL1ContractsValues(deployL1ContractsValues: DeployAztecL1ContractsReturnType) {
|
|
32
|
+
const {
|
|
33
|
+
l1Client,
|
|
34
|
+
l1ContractAddresses: { inboxAddress },
|
|
35
|
+
} = deployL1ContractsValues;
|
|
36
|
+
return new InboxContract(l1Client, inboxAddress.toString());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static getFromConfig(config: L1ReaderConfig) {
|
|
40
|
+
const client = getPublicClient(config);
|
|
41
|
+
const address = config.inboxAddress.toString();
|
|
42
|
+
return new InboxContract(client, address);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
constructor(
|
|
46
|
+
public readonly client: ViemClient,
|
|
47
|
+
address: Hex | EthAddress,
|
|
48
|
+
) {
|
|
49
|
+
if (address instanceof EthAddress) {
|
|
50
|
+
address = address.toString();
|
|
51
|
+
}
|
|
52
|
+
this.inbox = getContract({ address, abi: InboxAbi, client });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public get address() {
|
|
56
|
+
return this.inbox.address;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public getContract(): GetContractReturnType<typeof InboxAbi, ViemClient> {
|
|
60
|
+
return this.inbox;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public async getLag(opts: { blockTag?: BlockTag; blockNumber?: bigint } = {}): Promise<bigint> {
|
|
64
|
+
await checkBlockTag(opts.blockNumber, this.client);
|
|
65
|
+
return await this.inbox.read.LAG(opts);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public async getState(opts: { blockTag?: BlockTag; blockNumber?: bigint } = {}): Promise<InboxContractState> {
|
|
69
|
+
await checkBlockTag(opts.blockNumber, this.client);
|
|
70
|
+
const state = await this.inbox.read.getState(opts);
|
|
71
|
+
return {
|
|
72
|
+
totalMessagesInserted: state.totalMessagesInserted,
|
|
73
|
+
messagesRollingHash: Buffer16.fromString(state.rollingHash),
|
|
74
|
+
treeInProgress: state.inProgress,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Fetches MessageSent events within the given block range. */
|
|
79
|
+
async getMessageSentEvents(fromBlock: bigint, toBlock: bigint): Promise<MessageSentLog[]> {
|
|
80
|
+
const logs = await this.inbox.getEvents.MessageSent({}, { fromBlock, toBlock });
|
|
81
|
+
return logs
|
|
82
|
+
.filter(log => log.blockNumber! >= fromBlock && log.blockNumber! <= toBlock)
|
|
83
|
+
.map(log => this.mapMessageSentLog(log));
|
|
84
|
+
}
|
|
85
|
+
|
|
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);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private mapMessageSentLog(log: {
|
|
100
|
+
blockNumber: bigint | null;
|
|
101
|
+
blockHash: `0x${string}` | null;
|
|
102
|
+
transactionHash: `0x${string}` | null;
|
|
103
|
+
args: { index?: bigint; hash?: `0x${string}`; checkpointNumber?: bigint; rollingHash?: `0x${string}` };
|
|
104
|
+
}): MessageSentLog {
|
|
105
|
+
return {
|
|
106
|
+
l1BlockNumber: log.blockNumber!,
|
|
107
|
+
l1BlockHash: Buffer32.fromString(log.blockHash!),
|
|
108
|
+
l1TransactionHash: log.transactionHash!,
|
|
109
|
+
args: {
|
|
110
|
+
index: log.args.index!,
|
|
111
|
+
leaf: Fr.fromString(log.args.hash!),
|
|
112
|
+
checkpointNumber: CheckpointNumber.fromBigInt(log.args.checkpointNumber!),
|
|
113
|
+
rollingHash: Buffer16.fromString(log.args.rollingHash!),
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export type InboxContractState = {
|
|
120
|
+
totalMessagesInserted: bigint;
|
|
121
|
+
messagesRollingHash: Buffer16;
|
|
122
|
+
treeInProgress: bigint;
|
|
123
|
+
};
|
package/src/contracts/index.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
export * from './chain_state_override.js';
|
|
1
2
|
export * from './empire_base.js';
|
|
3
|
+
export * from './errors.js';
|
|
4
|
+
export * from './fee_asset_handler.js';
|
|
5
|
+
export * from './fee_asset_price_oracle.js';
|
|
2
6
|
export * from './fee_juice.js';
|
|
3
|
-
export * from './forwarder.js';
|
|
4
7
|
export * from './governance.js';
|
|
5
8
|
export * from './governance_proposer.js';
|
|
9
|
+
export * from './gse.js';
|
|
10
|
+
export * from './inbox.js';
|
|
11
|
+
export * from './log.js';
|
|
12
|
+
export * from './multicall.js';
|
|
13
|
+
export * from './outbox.js';
|
|
6
14
|
export * from './registry.js';
|
|
7
15
|
export * from './rollup.js';
|
|
8
16
|
export * from './slashing_proposer.js';
|
|
17
|
+
export * from './slasher_contract.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
+
|
|
3
|
+
/** Base L1 event log with common fields. */
|
|
4
|
+
export type L1EventLog<T> = {
|
|
5
|
+
/** L1 block number where the event was emitted. */
|
|
6
|
+
l1BlockNumber: bigint;
|
|
7
|
+
/** L1 block hash. */
|
|
8
|
+
l1BlockHash: Buffer32;
|
|
9
|
+
/** L1 transaction hash that emitted the event. */
|
|
10
|
+
l1TransactionHash: `0x${string}`;
|
|
11
|
+
/** Event-specific arguments. */
|
|
12
|
+
args: T;
|
|
13
|
+
};
|