@aztec/ethereum 0.0.1-commit.c7c42ec → 0.0.1-commit.c80b6263
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/config.d.ts +15 -28
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +46 -55
- package/dest/contracts/fee_asset_handler.d.ts +6 -5
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.js +9 -9
- package/dest/contracts/governance.d.ts +3 -1
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +9 -1
- package/dest/contracts/governance_proposer.js +382 -8
- package/dest/contracts/inbox.d.ts +18 -1
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +32 -1
- package/dest/contracts/index.d.ts +3 -1
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +2 -0
- 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/outbox.d.ts +41 -0
- package/dest/contracts/outbox.d.ts.map +1 -0
- package/dest/contracts/outbox.js +86 -0
- package/dest/contracts/rollup.d.ts +160 -96
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +668 -129
- package/dest/deploy_aztec_l1_contracts.d.ts +15 -2
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +74 -12
- 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 +4866 -1513
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/index.d.ts +3 -2
- package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/index.js +2 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +2 -12
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +35 -17
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +2 -11
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +36 -18
- package/dest/l1_tx_utils/fee-strategies/types.d.ts +14 -27
- package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/types.js +0 -21
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +2 -2
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_fee_analyzer.js +3 -3
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -5
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +14 -51
- package/dest/publisher_manager.d.ts +3 -2
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +2 -2
- package/dest/queries.d.ts +2 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +6 -3
- package/dest/test/chain_monitor.js +1 -2
- package/dest/test/eth_cheat_codes.d.ts +13 -1
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.d.ts +5 -2
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +19 -2
- package/dest/test/start_anvil.js +1 -1
- package/package.json +8 -7
- package/src/config.ts +55 -54
- package/src/contracts/README.md +157 -0
- package/src/contracts/fee_asset_handler.ts +8 -7
- package/src/contracts/governance.ts +8 -1
- package/src/contracts/inbox.ts +48 -1
- package/src/contracts/index.ts +2 -0
- package/src/contracts/log.ts +13 -0
- package/src/contracts/outbox.ts +98 -0
- package/src/contracts/rollup.ts +333 -93
- package/src/deploy_aztec_l1_contracts.ts +76 -14
- package/src/generated/l1-contracts-defaults.ts +32 -0
- package/src/l1_tx_utils/fee-strategies/index.ts +1 -1
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +45 -41
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +48 -44
- package/src/l1_tx_utils/fee-strategies/types.ts +14 -46
- package/src/l1_tx_utils/l1_fee_analyzer.ts +2 -3
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +20 -59
- package/src/publisher_manager.ts +4 -2
- package/src/queries.ts +5 -3
- package/src/test/chain_monitor.ts +1 -1
- package/src/test/rollup_cheat_codes.ts +21 -3
- package/src/test/start_anvil.ts +1 -1
package/src/contracts/inbox.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
5
|
import { InboxAbi } from '@aztec/l1-artifacts/InboxAbi';
|
|
4
6
|
|
|
@@ -8,8 +10,20 @@ import { getPublicClient } from '../client.js';
|
|
|
8
10
|
import type { DeployAztecL1ContractsReturnType } from '../deploy_aztec_l1_contracts.js';
|
|
9
11
|
import type { L1ReaderConfig } from '../l1_reader.js';
|
|
10
12
|
import type { ViemClient } from '../types.js';
|
|
13
|
+
import type { L1EventLog } from './log.js';
|
|
11
14
|
import { checkBlockTag } from './utils.js';
|
|
12
15
|
|
|
16
|
+
/** Arguments for the MessageSent event. */
|
|
17
|
+
export type MessageSentArgs = {
|
|
18
|
+
index: bigint;
|
|
19
|
+
leaf: Fr;
|
|
20
|
+
checkpointNumber: CheckpointNumber;
|
|
21
|
+
rollingHash: Buffer16;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** Log type for MessageSent events. */
|
|
25
|
+
export type MessageSentLog = L1EventLog<MessageSentArgs>;
|
|
26
|
+
|
|
13
27
|
export class InboxContract {
|
|
14
28
|
private readonly inbox: GetContractReturnType<typeof InboxAbi, ViemClient>;
|
|
15
29
|
|
|
@@ -59,6 +73,39 @@ export class InboxContract {
|
|
|
59
73
|
treeInProgress: state.inProgress,
|
|
60
74
|
};
|
|
61
75
|
}
|
|
76
|
+
|
|
77
|
+
/** Fetches MessageSent events within the given block range. */
|
|
78
|
+
async getMessageSentEvents(fromBlock: bigint, toBlock: bigint): Promise<MessageSentLog[]> {
|
|
79
|
+
const logs = await this.inbox.getEvents.MessageSent({}, { fromBlock, toBlock });
|
|
80
|
+
return logs
|
|
81
|
+
.filter(log => log.blockNumber! >= fromBlock && log.blockNumber! <= toBlock)
|
|
82
|
+
.map(log => this.mapMessageSentLog(log));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Fetches MessageSent events for a specific message hash within the given block range. */
|
|
86
|
+
async getMessageSentEventByHash(hash: Hex, fromBlock: bigint, toBlock: bigint): Promise<MessageSentLog[]> {
|
|
87
|
+
const logs = await this.inbox.getEvents.MessageSent({ hash }, { fromBlock, toBlock });
|
|
88
|
+
return logs.map(log => this.mapMessageSentLog(log));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
private mapMessageSentLog(log: {
|
|
92
|
+
blockNumber: bigint | null;
|
|
93
|
+
blockHash: `0x${string}` | null;
|
|
94
|
+
transactionHash: `0x${string}` | null;
|
|
95
|
+
args: { index?: bigint; hash?: `0x${string}`; checkpointNumber?: bigint; rollingHash?: `0x${string}` };
|
|
96
|
+
}): MessageSentLog {
|
|
97
|
+
return {
|
|
98
|
+
l1BlockNumber: log.blockNumber!,
|
|
99
|
+
l1BlockHash: Buffer32.fromString(log.blockHash!),
|
|
100
|
+
l1TransactionHash: log.transactionHash!,
|
|
101
|
+
args: {
|
|
102
|
+
index: log.args.index!,
|
|
103
|
+
leaf: Fr.fromString(log.args.hash!),
|
|
104
|
+
checkpointNumber: CheckpointNumber.fromBigInt(log.args.checkpointNumber!),
|
|
105
|
+
rollingHash: Buffer16.fromString(log.args.rollingHash!),
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
62
109
|
}
|
|
63
110
|
|
|
64
111
|
export type InboxContractState = {
|
package/src/contracts/index.ts
CHANGED
|
@@ -6,7 +6,9 @@ export * from './governance.js';
|
|
|
6
6
|
export * from './governance_proposer.js';
|
|
7
7
|
export * from './gse.js';
|
|
8
8
|
export * from './inbox.js';
|
|
9
|
+
export * from './log.js';
|
|
9
10
|
export * from './multicall.js';
|
|
11
|
+
export * from './outbox.js';
|
|
10
12
|
export * from './registry.js';
|
|
11
13
|
export * from './rollup.js';
|
|
12
14
|
export * from './empire_slashing_proposer.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
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import { OutboxAbi } from '@aztec/l1-artifacts/OutboxAbi';
|
|
4
|
+
|
|
5
|
+
import { type GetContractReturnType, type Hex, encodeAbiParameters, getContract, hexToBigInt, keccak256 } 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 ExtendedViemWalletClient, type ViemClient, isExtendedClient } from '../types.js';
|
|
11
|
+
|
|
12
|
+
export type ViemL1Actor = {
|
|
13
|
+
actor: Hex;
|
|
14
|
+
chainId: bigint;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type ViemL2Actor = {
|
|
18
|
+
actor: Hex;
|
|
19
|
+
version: bigint;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type ViemL2ToL1Msg = {
|
|
23
|
+
sender: ViemL2Actor;
|
|
24
|
+
recipient: ViemL1Actor;
|
|
25
|
+
content: Hex;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export class OutboxContract {
|
|
29
|
+
private readonly outbox: GetContractReturnType<typeof OutboxAbi, ViemClient>;
|
|
30
|
+
|
|
31
|
+
static getFromL1ContractsValues(deployL1ContractsValues: DeployAztecL1ContractsReturnType) {
|
|
32
|
+
const {
|
|
33
|
+
l1Client,
|
|
34
|
+
l1ContractAddresses: { outboxAddress },
|
|
35
|
+
} = deployL1ContractsValues;
|
|
36
|
+
return new OutboxContract(l1Client, outboxAddress.toString());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static getFromConfig(config: L1ReaderConfig) {
|
|
40
|
+
const client = getPublicClient(config);
|
|
41
|
+
const address = config.l1Contracts.outboxAddress.toString();
|
|
42
|
+
return new OutboxContract(client, address);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static getEpochRootStorageSlot(epoch: EpochNumber) {
|
|
46
|
+
return hexToBigInt(keccak256(encodeAbiParameters([{ type: 'uint256' }, { type: 'uint256' }], [BigInt(epoch), 0n])));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
constructor(
|
|
50
|
+
public readonly client: ViemClient,
|
|
51
|
+
address: Hex | EthAddress,
|
|
52
|
+
) {
|
|
53
|
+
if (address instanceof EthAddress) {
|
|
54
|
+
address = address.toString();
|
|
55
|
+
}
|
|
56
|
+
this.outbox = getContract({ address, abi: OutboxAbi, client });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public get address() {
|
|
60
|
+
return this.outbox.address;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public getContract(): GetContractReturnType<typeof OutboxAbi, ViemClient> {
|
|
64
|
+
return this.outbox;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public hasMessageBeenConsumedAtEpoch(epoch: EpochNumber, leafId: bigint) {
|
|
68
|
+
return this.outbox.read.hasMessageBeenConsumedAtEpoch([BigInt(epoch), leafId]);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public getRootData(epoch: EpochNumber) {
|
|
72
|
+
return this.outbox.read.getRootData([BigInt(epoch)]);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public consume(message: ViemL2ToL1Msg, epoch: EpochNumber, leafIndex: bigint, path: Hex[]) {
|
|
76
|
+
const wallet = this.assertWallet();
|
|
77
|
+
return wallet.write.consume([message, BigInt(epoch), leafIndex, path]);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public async getMessageConsumedEvents(
|
|
81
|
+
l1BlockHash: Hex,
|
|
82
|
+
): Promise<{ epoch: bigint; root: Hex; messageHash: Hex; leafId: bigint }[]> {
|
|
83
|
+
const events = await this.outbox.getEvents.MessageConsumed({}, { blockHash: l1BlockHash, strict: true });
|
|
84
|
+
return events.map(event => ({
|
|
85
|
+
epoch: event.args.epoch!,
|
|
86
|
+
root: event.args.root!,
|
|
87
|
+
messageHash: event.args.messageHash!,
|
|
88
|
+
leafId: event.args.leafId!,
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private assertWallet(): GetContractReturnType<typeof OutboxAbi, ExtendedViemWalletClient> {
|
|
93
|
+
if (!isExtendedClient(this.client)) {
|
|
94
|
+
throw new Error('Wallet client is required for this operation');
|
|
95
|
+
}
|
|
96
|
+
return this.outbox as GetContractReturnType<typeof OutboxAbi, ExtendedViemWalletClient>;
|
|
97
|
+
}
|
|
98
|
+
}
|