@aztec/ethereum 0.87.7 → 1.0.0-nightly.20250604
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/contracts/empire_base.d.ts +15 -1
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_base.js +49 -0
- package/dest/contracts/forwarder.d.ts +1 -2
- package/dest/contracts/forwarder.d.ts.map +1 -1
- package/dest/contracts/forwarder.js +7 -12
- package/dest/contracts/governance.d.ts +1 -1
- package/dest/contracts/governance_proposer.d.ts +2 -1
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +8 -1
- package/dest/contracts/rollup.d.ts +30 -9
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +40 -13
- package/dest/contracts/slashing_proposer.d.ts +19 -3
- package/dest/contracts/slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/slashing_proposer.js +92 -4
- package/dest/deploy_l1_contracts.d.ts +5085 -303
- package/dest/deploy_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_l1_contracts.js +123 -27
- package/dest/l1_contract_addresses.d.ts +5 -1
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +2 -1
- package/dest/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils.js +11 -2
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +152 -152
- package/package.json +4 -4
- package/src/contracts/empire_base.ts +56 -1
- package/src/contracts/forwarder.ts +9 -10
- package/src/contracts/governance_proposer.ts +10 -2
- package/src/contracts/rollup.ts +46 -11
- package/src/contracts/slashing_proposer.ts +123 -5
- package/src/deploy_l1_contracts.ts +142 -38
- package/src/l1_contract_addresses.ts +3 -1
- package/src/l1_tx_utils.ts +6 -2
- package/src/utils.ts +173 -172
- package/dest/cli/forwarder_address.d.ts +0 -2
- package/dest/cli/forwarder_address.d.ts.map +0 -1
- package/dest/cli/forwarder_address.js +0 -10
- package/src/cli/forwarder_address.ts +0 -12
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Signature } from '@aztec/foundation/eth-signature';
|
|
2
|
+
import { type Hex, type WalletClient } from 'viem';
|
|
2
3
|
import type { L1TxRequest } from '../l1_tx_utils.js';
|
|
4
|
+
import type { ExtendedViemWalletClient } from '../types.js';
|
|
3
5
|
export interface IEmpireBase {
|
|
4
6
|
getRoundInfo(rollupAddress: Hex, round: bigint): Promise<{
|
|
5
7
|
lastVote: bigint;
|
|
@@ -8,6 +10,18 @@ export interface IEmpireBase {
|
|
|
8
10
|
}>;
|
|
9
11
|
computeRound(slot: bigint): Promise<bigint>;
|
|
10
12
|
createVoteRequest(payload: Hex): L1TxRequest;
|
|
13
|
+
createVoteRequestWithSignature(payload: Hex, wallet: ExtendedViemWalletClient): Promise<L1TxRequest>;
|
|
11
14
|
}
|
|
12
15
|
export declare function encodeVote(payload: Hex): Hex;
|
|
16
|
+
export declare function encodeVoteWithSignature(payload: Hex, signature: Signature): `0x${string}`;
|
|
17
|
+
/**
|
|
18
|
+
* Signs a vote proposal using EIP-712 typed data for use with voteWithSig
|
|
19
|
+
* @param walletClient - The viem wallet client to sign with
|
|
20
|
+
* @param proposal - The proposal address to vote on
|
|
21
|
+
* @param verifyingContract - The address of the EmpireBase contract
|
|
22
|
+
* @param chainId - The chain ID where the contract is deployed
|
|
23
|
+
* @param account - The account to sign with (optional if hoisted on wallet client)
|
|
24
|
+
* @returns The EIP-712 signature
|
|
25
|
+
*/
|
|
26
|
+
export declare function signVoteWithSig(walletClient: WalletClient, proposal: Hex, verifyingContract: Hex, chainId: number): Promise<Signature>;
|
|
13
27
|
//# sourceMappingURL=empire_base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"empire_base.d.ts","sourceRoot":"","sources":["../../src/contracts/empire_base.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"empire_base.d.ts","sourceRoot":"","sources":["../../src/contracts/empire_base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,YAAY,EAAsB,MAAM,MAAM,CAAC;AAEvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B,YAAY,CAAC,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC/G,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,iBAAiB,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,CAAC;IAC7C,8BAA8B,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACtG;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,CAM5C;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,iBAMzE;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,GAAG,EACb,iBAAiB,EAAE,GAAG,EACtB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,CAAC,CA4BpB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Signature } from '@aztec/foundation/eth-signature';
|
|
1
2
|
import { EmpireBaseAbi } from '@aztec/l1-artifacts/EmpireBaseAbi';
|
|
2
3
|
import { encodeFunctionData } from 'viem';
|
|
3
4
|
export function encodeVote(payload) {
|
|
@@ -9,3 +10,51 @@ export function encodeVote(payload) {
|
|
|
9
10
|
]
|
|
10
11
|
});
|
|
11
12
|
}
|
|
13
|
+
export function encodeVoteWithSignature(payload, signature) {
|
|
14
|
+
return encodeFunctionData({
|
|
15
|
+
abi: EmpireBaseAbi,
|
|
16
|
+
functionName: 'voteWithSig',
|
|
17
|
+
args: [
|
|
18
|
+
payload,
|
|
19
|
+
signature.toViemSignature()
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Signs a vote proposal using EIP-712 typed data for use with voteWithSig
|
|
25
|
+
* @param walletClient - The viem wallet client to sign with
|
|
26
|
+
* @param proposal - The proposal address to vote on
|
|
27
|
+
* @param verifyingContract - The address of the EmpireBase contract
|
|
28
|
+
* @param chainId - The chain ID where the contract is deployed
|
|
29
|
+
* @param account - The account to sign with (optional if hoisted on wallet client)
|
|
30
|
+
* @returns The EIP-712 signature
|
|
31
|
+
*/ export async function signVoteWithSig(walletClient, proposal, verifyingContract, chainId) {
|
|
32
|
+
const domain = {
|
|
33
|
+
name: 'EmpireBase',
|
|
34
|
+
version: '1',
|
|
35
|
+
chainId,
|
|
36
|
+
verifyingContract
|
|
37
|
+
};
|
|
38
|
+
const types = {
|
|
39
|
+
Vote: [
|
|
40
|
+
{
|
|
41
|
+
name: 'proposal',
|
|
42
|
+
type: 'address'
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
};
|
|
46
|
+
const message = {
|
|
47
|
+
proposal
|
|
48
|
+
};
|
|
49
|
+
if (!walletClient.account) {
|
|
50
|
+
throw new Error('Wallet client must be connected to an account');
|
|
51
|
+
}
|
|
52
|
+
const signatureHex = await walletClient.signTypedData({
|
|
53
|
+
account: walletClient.account.address,
|
|
54
|
+
domain,
|
|
55
|
+
types,
|
|
56
|
+
primaryType: 'Vote',
|
|
57
|
+
message
|
|
58
|
+
});
|
|
59
|
+
return Signature.fromString(signatureHex);
|
|
60
|
+
}
|
|
@@ -7,8 +7,7 @@ export declare class ForwarderContract {
|
|
|
7
7
|
readonly rollupAddress: Hex;
|
|
8
8
|
private readonly forwarder;
|
|
9
9
|
constructor(client: ExtendedViemWalletClient, address: Hex, rollupAddress: Hex);
|
|
10
|
-
static
|
|
11
|
-
static create(owner: Hex, l1Client: ExtendedViemWalletClient, logger: Logger, rollupAddress: Hex): Promise<ForwarderContract>;
|
|
10
|
+
static create(l1Client: ExtendedViemWalletClient, logger: Logger, rollupAddress: Hex): Promise<ForwarderContract>;
|
|
12
11
|
getAddress(): `0x${string}`;
|
|
13
12
|
forward(requests: L1TxRequest[], l1TxUtils: L1TxUtils, gasConfig: L1GasConfig | undefined, blobConfig: L1BlobInputs | undefined, logger: Logger): Promise<{
|
|
14
13
|
receipt: import("viem").TransactionReceipt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forwarder.d.ts","sourceRoot":"","sources":["../../src/contracts/forwarder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAIpD,OAAO,EAGL,KAAK,GAAG,EAGT,MAAM,MAAM,CAAC;AAGd,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,KAAK,EAAE,wBAAwB,EAAc,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"forwarder.d.ts","sourceRoot":"","sources":["../../src/contracts/forwarder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAIpD,OAAO,EAGL,KAAK,GAAG,EAGT,MAAM,MAAM,CAAC;AAGd,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,KAAK,EAAE,wBAAwB,EAAc,MAAM,aAAa,CAAC;AAOxE,qBAAa,iBAAiB;aAIV,MAAM,EAAE,wBAAwB;aAEhC,aAAa,EAAE,GAAG;IALpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyD;gBAGjE,MAAM,EAAE,wBAAwB,EAChD,OAAO,EAAE,GAAG,EACI,aAAa,EAAE,GAAG;WAKvB,MAAM,CAAC,QAAQ,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG;IAsBnF,UAAU;IAIJ,OAAO,CAClB,QAAQ,EAAE,WAAW,EAAE,EACvB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,WAAW,GAAG,SAAS,EAClC,UAAU,EAAE,YAAY,GAAG,SAAS,EACpC,MAAM,EAAE,MAAM;;;;;;;;;;;CAqEjB"}
|
|
@@ -2,8 +2,11 @@ import { toHex } from '@aztec/foundation/bigint-buffer';
|
|
|
2
2
|
import { ForwarderAbi } from '@aztec/l1-artifacts/ForwarderAbi';
|
|
3
3
|
import { ForwarderBytecode } from '@aztec/l1-artifacts/ForwarderBytecode';
|
|
4
4
|
import { encodeFunctionData, getContract } from 'viem';
|
|
5
|
-
import { deployL1Contract
|
|
5
|
+
import { deployL1Contract } from '../deploy_l1_contracts.js';
|
|
6
6
|
import { RollupContract } from './rollup.js';
|
|
7
|
+
// No harm in this, since the default forwarder is effectively multi-call,
|
|
8
|
+
// and has no owner or state
|
|
9
|
+
const DEFAULT_FORWARDER_SALT = '0x42';
|
|
7
10
|
export class ForwarderContract {
|
|
8
11
|
client;
|
|
9
12
|
rollupAddress;
|
|
@@ -17,23 +20,15 @@ export class ForwarderContract {
|
|
|
17
20
|
client
|
|
18
21
|
});
|
|
19
22
|
}
|
|
20
|
-
static
|
|
21
|
-
const { address } = getExpectedAddress(ForwarderAbi, ForwarderBytecode, [
|
|
22
|
-
owner
|
|
23
|
-
], owner);
|
|
24
|
-
return address;
|
|
25
|
-
}
|
|
26
|
-
static async create(owner, l1Client, logger, rollupAddress) {
|
|
23
|
+
static async create(l1Client, logger, rollupAddress) {
|
|
27
24
|
logger.info('Deploying forwarder contract');
|
|
28
|
-
const { address, txHash } = await deployL1Contract(l1Client, ForwarderAbi, ForwarderBytecode, [
|
|
29
|
-
owner
|
|
30
|
-
], owner, undefined, logger);
|
|
25
|
+
const { address, txHash } = await deployL1Contract(l1Client, ForwarderAbi, ForwarderBytecode, [], DEFAULT_FORWARDER_SALT, undefined, logger);
|
|
31
26
|
if (txHash) {
|
|
32
27
|
await l1Client.waitForTransactionReceipt({
|
|
33
28
|
hash: txHash
|
|
34
29
|
});
|
|
35
30
|
}
|
|
36
|
-
logger.info(`Forwarder contract deployed at ${address}
|
|
31
|
+
logger.info(`Forwarder contract deployed at ${address}`);
|
|
37
32
|
return new ForwarderContract(l1Client, address.toString(), rollupAddress);
|
|
38
33
|
}
|
|
39
34
|
getAddress() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import { type Hex, type TransactionReceipt } from 'viem';
|
|
3
3
|
import type { GasPrice, L1TxRequest, L1TxUtils } from '../l1_tx_utils.js';
|
|
4
|
-
import type { ViemClient } from '../types.js';
|
|
4
|
+
import type { ExtendedViemWalletClient, ViemClient } from '../types.js';
|
|
5
5
|
import { type IEmpireBase } from './empire_base.js';
|
|
6
6
|
export declare class GovernanceProposerContract implements IEmpireBase {
|
|
7
7
|
readonly client: ViemClient;
|
|
@@ -20,6 +20,7 @@ export declare class GovernanceProposerContract implements IEmpireBase {
|
|
|
20
20
|
}>;
|
|
21
21
|
getProposalVotes(rollupAddress: Hex, round: bigint, proposal: Hex): Promise<bigint>;
|
|
22
22
|
createVoteRequest(payload: Hex): L1TxRequest;
|
|
23
|
+
createVoteRequestWithSignature(payload: Hex, wallet: ExtendedViemWalletClient): Promise<L1TxRequest>;
|
|
23
24
|
executeProposal(round: bigint, l1TxUtils: L1TxUtils): Promise<{
|
|
24
25
|
receipt: TransactionReceipt;
|
|
25
26
|
gasPrice: GasPrice;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"governance_proposer.d.ts","sourceRoot":"","sources":["../../src/contracts/governance_proposer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D,OAAO,EAA8B,KAAK,GAAG,EAAE,KAAK,kBAAkB,EAAmC,MAAM,MAAM,CAAC;AAEtH,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"governance_proposer.d.ts","sourceRoot":"","sources":["../../src/contracts/governance_proposer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D,OAAO,EAA8B,KAAK,GAAG,EAAE,KAAK,kBAAkB,EAAmC,MAAM,MAAM,CAAC;AAEtH,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,wBAAwB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,KAAK,WAAW,EAAwD,MAAM,kBAAkB,CAAC;AAG1G,qBAAa,0BAA2B,YAAW,WAAW;aAI1C,MAAM,EAAE,UAAU;IAHpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkE;gBAGzE,MAAM,EAAE,UAAU,EAClC,OAAO,EAAE,GAAG;IAKd,IAAW,OAAO,eAEjB;IAEY,gBAAgB;IAKhB,kBAAkB;IAIxB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAIhC,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAI/B,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrC,YAAY,CACvB,aAAa,EAAE,GAAG,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IASzD,gBAAgB,CAAC,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAInF,iBAAiB,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW;IAOtC,8BAA8B,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,WAAW,CAAC;IAQpG,eAAe,CAC1B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC;QACT,OAAO,EAAE,kBAAkB,CAAC;QAC5B,QAAQ,EAAE,QAAQ,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CAYH"}
|
|
@@ -8,7 +8,7 @@ import { memoize } from '@aztec/foundation/decorators';
|
|
|
8
8
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
9
|
import { GovernanceProposerAbi } from '@aztec/l1-artifacts/GovernanceProposerAbi';
|
|
10
10
|
import { encodeFunctionData, getContract } from 'viem';
|
|
11
|
-
import { encodeVote } from './empire_base.js';
|
|
11
|
+
import { encodeVote, encodeVoteWithSignature, signVoteWithSig } from './empire_base.js';
|
|
12
12
|
import { extractProposalIdFromLogs } from './governance.js';
|
|
13
13
|
export class GovernanceProposerContract {
|
|
14
14
|
client;
|
|
@@ -65,6 +65,13 @@ export class GovernanceProposerContract {
|
|
|
65
65
|
data: encodeVote(payload)
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
|
+
async createVoteRequestWithSignature(payload, wallet) {
|
|
69
|
+
const signature = await signVoteWithSig(wallet, payload, this.address.toString(), wallet.chain.id);
|
|
70
|
+
return {
|
|
71
|
+
to: this.address.toString(),
|
|
72
|
+
data: encodeVoteWithSignature(payload, signature)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
68
75
|
async executeProposal(round, l1TxUtils) {
|
|
69
76
|
const { receipt, gasPrice } = await l1TxUtils.sendAndMonitorTransaction({
|
|
70
77
|
to: this.address.toString(),
|
|
@@ -5,14 +5,17 @@ import { type Account, type GetContractReturnType, type Hex } from 'viem';
|
|
|
5
5
|
import type { DeployL1ContractsReturnType } from '../deploy_l1_contracts.js';
|
|
6
6
|
import type { L1ContractAddresses } from '../l1_contract_addresses.js';
|
|
7
7
|
import type { L1ReaderConfig } from '../l1_reader.js';
|
|
8
|
+
import type { L1TxUtils } from '../l1_tx_utils.js';
|
|
8
9
|
import type { ViemClient } from '../types.js';
|
|
9
10
|
import { SlashingProposerContract } from './slashing_proposer.js';
|
|
10
|
-
export type
|
|
11
|
+
export type ViemCommitteeAttestation = {
|
|
12
|
+
addr: `0x${string}`;
|
|
13
|
+
signature: ViemSignature;
|
|
14
|
+
};
|
|
15
|
+
export type L1RollupContractAddresses = Pick<L1ContractAddresses, 'rollupAddress' | 'inboxAddress' | 'outboxAddress' | 'feeJuicePortalAddress' | 'feeJuiceAddress' | 'stakingAssetAddress' | 'rewardDistributorAddress' | 'slashFactoryAddress' | 'gseAddress'>;
|
|
11
16
|
export type EpochProofPublicInputArgs = {
|
|
12
17
|
previousArchive: `0x${string}`;
|
|
13
18
|
endArchive: `0x${string}`;
|
|
14
|
-
endTimestamp: bigint;
|
|
15
|
-
outHash: `0x${string}`;
|
|
16
19
|
proverId: `0x${string}`;
|
|
17
20
|
};
|
|
18
21
|
export declare class RollupContract {
|
|
@@ -22,6 +25,7 @@ export declare class RollupContract {
|
|
|
22
25
|
static getFromL1ContractsValues(deployL1ContractsValues: DeployL1ContractsReturnType): RollupContract;
|
|
23
26
|
static getFromConfig(config: L1ReaderConfig): RollupContract;
|
|
24
27
|
constructor(client: ViemClient, address: Hex | EthAddress);
|
|
28
|
+
getGSE(): Promise<`0x${string}`>;
|
|
25
29
|
get address(): `0x${string}`;
|
|
26
30
|
getContract(): GetContractReturnType<typeof RollupAbi, ViemClient>;
|
|
27
31
|
getSlashingProposer(): Promise<SlashingProposerContract>;
|
|
@@ -73,7 +77,7 @@ export declare class RollupContract {
|
|
|
73
77
|
getEpochProofPublicInputs(args: readonly [bigint, bigint, EpochProofPublicInputArgs, readonly `0x${string}`[], `0x${string}`]): Promise<readonly `0x${string}`[]>;
|
|
74
78
|
validateHeader(args: readonly [
|
|
75
79
|
`0x${string}`,
|
|
76
|
-
|
|
80
|
+
ViemCommitteeAttestation[],
|
|
77
81
|
`0x${string}`,
|
|
78
82
|
bigint,
|
|
79
83
|
`0x${string}`,
|
|
@@ -107,14 +111,31 @@ export declare class RollupContract {
|
|
|
107
111
|
getSequencerRewards(address: Hex | EthAddress): Promise<bigint>;
|
|
108
112
|
getSpecificProverRewardsForEpoch(epoch: bigint, prover: Hex | EthAddress): Promise<bigint>;
|
|
109
113
|
getAttesters(): Promise<readonly `0x${string}`[]>;
|
|
110
|
-
|
|
111
|
-
stake: bigint;
|
|
112
|
-
withdrawer: `0x${string}`;
|
|
113
|
-
proposer: `0x${string}`;
|
|
114
|
+
getAttesterView(address: Hex | EthAddress): Promise<{
|
|
114
115
|
status: number;
|
|
116
|
+
effectiveBalance: bigint;
|
|
117
|
+
exit: {
|
|
118
|
+
withdrawalId: bigint;
|
|
119
|
+
amount: bigint;
|
|
120
|
+
exitableAt: bigint;
|
|
121
|
+
recipientOrWithdrawer: `0x${string}`;
|
|
122
|
+
isRecipient: boolean;
|
|
123
|
+
exists: boolean;
|
|
124
|
+
};
|
|
125
|
+
config: {
|
|
126
|
+
withdrawer: `0x${string}`;
|
|
127
|
+
};
|
|
115
128
|
}>;
|
|
129
|
+
getStatus(address: Hex | EthAddress): Promise<number>;
|
|
116
130
|
getBlobPublicInputsHash(blockNumber: bigint): Promise<`0x${string}`>;
|
|
117
131
|
getStakingAsset(): Promise<`0x${string}`>;
|
|
118
|
-
|
|
132
|
+
setupEpoch(l1TxUtils: L1TxUtils): Promise<{
|
|
133
|
+
receipt: import("viem").TransactionReceipt;
|
|
134
|
+
gasPrice: import("../l1_tx_utils.js").GasPrice;
|
|
135
|
+
}>;
|
|
136
|
+
vote(l1TxUtils: L1TxUtils, proposalId: bigint): Promise<{
|
|
137
|
+
receipt: import("viem").TransactionReceipt;
|
|
138
|
+
gasPrice: import("../l1_tx_utils.js").GasPrice;
|
|
139
|
+
}>;
|
|
119
140
|
}
|
|
120
141
|
//# sourceMappingURL=rollup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../../src/contracts/rollup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAI1D,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../../src/contracts/rollup.ts"],"names":[],"mappings":"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"}
|
package/dest/contracts/rollup.js
CHANGED
|
@@ -9,7 +9,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
9
9
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
10
10
|
import { RollupStorage } from '@aztec/l1-artifacts/RollupStorage';
|
|
11
11
|
import { SlasherAbi } from '@aztec/l1-artifacts/SlasherAbi';
|
|
12
|
-
import { getAddress, getContract } from 'viem';
|
|
12
|
+
import { encodeFunctionData, getAddress, getContract } from 'viem';
|
|
13
13
|
import { getPublicClient } from '../client.js';
|
|
14
14
|
import { formatViemError } from '../utils.js';
|
|
15
15
|
import { SlashingProposerContract } from './slashing_proposer.js';
|
|
@@ -44,6 +44,9 @@ export class RollupContract {
|
|
|
44
44
|
client
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
+
getGSE() {
|
|
48
|
+
return this.rollup.read.getGSE();
|
|
49
|
+
}
|
|
47
50
|
get address() {
|
|
48
51
|
return this.rollup.address;
|
|
49
52
|
}
|
|
@@ -213,13 +216,14 @@ export class RollupContract {
|
|
|
213
216
|
]);
|
|
214
217
|
}
|
|
215
218
|
async getRollupAddresses() {
|
|
216
|
-
const [inboxAddress, outboxAddress, feeJuicePortalAddress, rewardDistributorAddress, feeJuiceAddress, stakingAssetAddress] = (await Promise.all([
|
|
219
|
+
const [inboxAddress, outboxAddress, feeJuicePortalAddress, rewardDistributorAddress, feeJuiceAddress, stakingAssetAddress, gseAddress] = (await Promise.all([
|
|
217
220
|
this.rollup.read.getInbox(),
|
|
218
221
|
this.rollup.read.getOutbox(),
|
|
219
222
|
this.rollup.read.getFeeAssetPortal(),
|
|
220
223
|
this.rollup.read.getRewardDistributor(),
|
|
221
224
|
this.rollup.read.getFeeAsset(),
|
|
222
|
-
this.rollup.read.getStakingAsset()
|
|
225
|
+
this.rollup.read.getStakingAsset(),
|
|
226
|
+
this.rollup.read.getGSE()
|
|
223
227
|
])).map(EthAddress.fromString);
|
|
224
228
|
return {
|
|
225
229
|
rollupAddress: EthAddress.fromString(this.address),
|
|
@@ -228,7 +232,8 @@ export class RollupContract {
|
|
|
228
232
|
feeJuicePortalAddress,
|
|
229
233
|
feeJuiceAddress,
|
|
230
234
|
stakingAssetAddress,
|
|
231
|
-
rewardDistributorAddress
|
|
235
|
+
rewardDistributorAddress,
|
|
236
|
+
gseAddress
|
|
232
237
|
};
|
|
233
238
|
}
|
|
234
239
|
async getFeeJuicePortal() {
|
|
@@ -348,11 +353,19 @@ export class RollupContract {
|
|
|
348
353
|
getAttesters() {
|
|
349
354
|
return this.rollup.read.getAttesters();
|
|
350
355
|
}
|
|
351
|
-
|
|
356
|
+
getAttesterView(address) {
|
|
357
|
+
if (address instanceof EthAddress) {
|
|
358
|
+
address = address.toString();
|
|
359
|
+
}
|
|
360
|
+
return this.rollup.read.getAttesterView([
|
|
361
|
+
address
|
|
362
|
+
]);
|
|
363
|
+
}
|
|
364
|
+
getStatus(address) {
|
|
352
365
|
if (address instanceof EthAddress) {
|
|
353
366
|
address = address.toString();
|
|
354
367
|
}
|
|
355
|
-
return this.rollup.read.
|
|
368
|
+
return this.rollup.read.getStatus([
|
|
356
369
|
address
|
|
357
370
|
]);
|
|
358
371
|
}
|
|
@@ -364,13 +377,27 @@ export class RollupContract {
|
|
|
364
377
|
getStakingAsset() {
|
|
365
378
|
return this.rollup.read.getStakingAsset();
|
|
366
379
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
380
|
+
setupEpoch(l1TxUtils) {
|
|
381
|
+
return l1TxUtils.sendAndMonitorTransaction({
|
|
382
|
+
to: this.address,
|
|
383
|
+
data: encodeFunctionData({
|
|
384
|
+
abi: RollupAbi,
|
|
385
|
+
functionName: 'setupEpoch',
|
|
386
|
+
args: []
|
|
387
|
+
})
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
vote(l1TxUtils, proposalId) {
|
|
391
|
+
return l1TxUtils.sendAndMonitorTransaction({
|
|
392
|
+
to: this.address,
|
|
393
|
+
data: encodeFunctionData({
|
|
394
|
+
abi: RollupAbi,
|
|
395
|
+
functionName: 'vote',
|
|
396
|
+
args: [
|
|
397
|
+
proposalId
|
|
398
|
+
]
|
|
399
|
+
})
|
|
400
|
+
});
|
|
374
401
|
}
|
|
375
402
|
}
|
|
376
403
|
_ts_decorate([
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import EventEmitter from 'events';
|
|
2
3
|
import { type Hex } from 'viem';
|
|
3
|
-
import type { L1TxRequest } from '../l1_tx_utils.js';
|
|
4
|
-
import type { ViemClient } from '../types.js';
|
|
4
|
+
import type { L1TxRequest, L1TxUtils } from '../l1_tx_utils.js';
|
|
5
|
+
import type { ExtendedViemWalletClient, ViemClient } from '../types.js';
|
|
5
6
|
import { type IEmpireBase } from './empire_base.js';
|
|
6
|
-
export declare class
|
|
7
|
+
export declare class ProposalAlreadyExecutedError extends Error {
|
|
8
|
+
constructor(round: bigint);
|
|
9
|
+
}
|
|
10
|
+
export declare class SlashingProposerContract extends EventEmitter implements IEmpireBase {
|
|
7
11
|
readonly client: ViemClient;
|
|
8
12
|
private readonly proposer;
|
|
9
13
|
constructor(client: ViemClient, address: Hex);
|
|
@@ -16,6 +20,18 @@ export declare class SlashingProposerContract implements IEmpireBase {
|
|
|
16
20
|
leader: Hex;
|
|
17
21
|
executed: boolean;
|
|
18
22
|
}>;
|
|
23
|
+
getProposalVotes(rollupAddress: Hex, round: bigint, proposal: Hex): Promise<bigint>;
|
|
19
24
|
createVoteRequest(payload: Hex): L1TxRequest;
|
|
25
|
+
createVoteRequestWithSignature(payload: Hex, wallet: ExtendedViemWalletClient): Promise<L1TxRequest>;
|
|
26
|
+
listenToExecutableProposals(callback: (args: {
|
|
27
|
+
proposal: `0x${string}`;
|
|
28
|
+
round: bigint;
|
|
29
|
+
}) => unknown): import("viem").WatchContractEventReturnType;
|
|
30
|
+
listenToProposalExecuted(callback: (args: {
|
|
31
|
+
round: bigint;
|
|
32
|
+
proposal: `0x${string}`;
|
|
33
|
+
}) => unknown): import("viem").WatchContractEventReturnType;
|
|
34
|
+
waitForRound(round: bigint, pollingIntervalSeconds?: number): Promise<boolean>;
|
|
35
|
+
executeRound(txUtils: L1TxUtils, round: bigint | number): Promise<void>;
|
|
20
36
|
}
|
|
21
37
|
//# sourceMappingURL=slashing_proposer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slashing_proposer.d.ts","sourceRoot":"","sources":["../../src/contracts/slashing_proposer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"slashing_proposer.d.ts","sourceRoot":"","sources":["../../src/contracts/slashing_proposer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAI3D,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAGL,KAAK,GAAG,EAGT,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,wBAAwB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAExE,OAAO,EAAE,KAAK,WAAW,EAAwD,MAAM,kBAAkB,CAAC;AAE1G,qBAAa,4BAA6B,SAAQ,KAAK;gBACzC,KAAK,EAAE,MAAM;CAG1B;AAED,qBAAa,wBAAyB,SAAQ,YAAa,YAAW,WAAW;aAI7D,MAAM,EAAE,UAAU;IAHpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgE;gBAGvE,MAAM,EAAE,UAAU,EAClC,OAAO,EAAE,GAAG;IAMd,IAAW,OAAO,eAEjB;IAEM,aAAa;IAIb,YAAY;IAIZ,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrC,YAAY,CACvB,aAAa,EAAE,GAAG,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IASzD,gBAAgB,CAAC,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAInF,iBAAiB,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW;IAOtC,8BAA8B,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,WAAW,CAAC;IAQ1G,2BAA2B,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO;IAiBnG,wBAAwB,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAA;KAAE,KAAK,OAAO;IAgBhG,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,sBAAsB,GAAE,MAAU;IAYxD,YAAY,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CA4CrF"}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
2
3
|
import { SlashingProposerAbi } from '@aztec/l1-artifacts/SlashingProposerAbi';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import EventEmitter from 'events';
|
|
5
|
+
import { encodeFunctionData, getContract } from 'viem';
|
|
6
|
+
import { FormattedViemError } from '../utils.js';
|
|
7
|
+
import { encodeVote, encodeVoteWithSignature, signVoteWithSig } from './empire_base.js';
|
|
8
|
+
export class ProposalAlreadyExecutedError extends Error {
|
|
9
|
+
constructor(round){
|
|
10
|
+
super(`Proposal already executed: ${round}`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class SlashingProposerContract extends EventEmitter {
|
|
6
14
|
client;
|
|
7
15
|
proposer;
|
|
8
16
|
constructor(client, address){
|
|
9
|
-
this.client = client;
|
|
17
|
+
super(), this.client = client;
|
|
10
18
|
this.proposer = getContract({
|
|
11
19
|
address,
|
|
12
20
|
abi: SlashingProposerAbi,
|
|
@@ -38,10 +46,90 @@ export class SlashingProposerContract {
|
|
|
38
46
|
executed: roundInfo[2]
|
|
39
47
|
};
|
|
40
48
|
}
|
|
49
|
+
getProposalVotes(rollupAddress, round, proposal) {
|
|
50
|
+
return this.proposer.read.yeaCount([
|
|
51
|
+
rollupAddress,
|
|
52
|
+
round,
|
|
53
|
+
proposal
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
41
56
|
createVoteRequest(payload) {
|
|
42
57
|
return {
|
|
43
58
|
to: this.address.toString(),
|
|
44
59
|
data: encodeVote(payload)
|
|
45
60
|
};
|
|
46
61
|
}
|
|
62
|
+
async createVoteRequestWithSignature(payload, wallet) {
|
|
63
|
+
const signature = await signVoteWithSig(wallet, payload, this.address.toString(), wallet.chain.id);
|
|
64
|
+
return {
|
|
65
|
+
to: this.address.toString(),
|
|
66
|
+
data: encodeVoteWithSignature(payload, signature)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
listenToExecutableProposals(callback) {
|
|
70
|
+
return this.proposer.watchEvent.ProposalExecutable({}, {
|
|
71
|
+
onLogs: (logs)=>{
|
|
72
|
+
for (const payload of logs){
|
|
73
|
+
const args = payload.args;
|
|
74
|
+
if (args.proposal && args.round) {
|
|
75
|
+
// why compiler can't figure it out? no one knows
|
|
76
|
+
callback(args);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
listenToProposalExecuted(callback) {
|
|
83
|
+
return this.proposer.watchEvent.ProposalExecuted({}, {
|
|
84
|
+
onLogs: (logs)=>{
|
|
85
|
+
for (const payload of logs){
|
|
86
|
+
const args = payload.args;
|
|
87
|
+
if (args.round && args.proposal) {
|
|
88
|
+
callback(args);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
waitForRound(round, pollingIntervalSeconds = 1) {
|
|
95
|
+
return retryUntil(async ()=>{
|
|
96
|
+
const currentRound = await this.proposer.read.getCurrentRound();
|
|
97
|
+
return currentRound >= round;
|
|
98
|
+
}, `Waiting for round ${round} to be reached`, 0, pollingIntervalSeconds);
|
|
99
|
+
}
|
|
100
|
+
async executeRound(txUtils, round) {
|
|
101
|
+
if (typeof round === 'number') {
|
|
102
|
+
round = BigInt(round);
|
|
103
|
+
}
|
|
104
|
+
const args = {
|
|
105
|
+
abi: SlashingProposerAbi,
|
|
106
|
+
functionName: 'executeProposal',
|
|
107
|
+
args: [
|
|
108
|
+
round
|
|
109
|
+
]
|
|
110
|
+
};
|
|
111
|
+
const data = encodeFunctionData(args);
|
|
112
|
+
const response = await txUtils.sendAndMonitorTransaction({
|
|
113
|
+
to: this.address.toString(),
|
|
114
|
+
data
|
|
115
|
+
}, {
|
|
116
|
+
// Gas estimation is more than 20% off for this tx.
|
|
117
|
+
gasLimitBufferPercentage: 100
|
|
118
|
+
}).catch((err)=>{
|
|
119
|
+
if (err instanceof FormattedViemError && err.message.includes('ProposalAlreadyExecuted')) {
|
|
120
|
+
throw new ProposalAlreadyExecutedError(round);
|
|
121
|
+
}
|
|
122
|
+
throw err;
|
|
123
|
+
});
|
|
124
|
+
if (response.receipt.status === 'reverted') {
|
|
125
|
+
const error = await txUtils.tryGetErrorFromRevertedTx(data, {
|
|
126
|
+
...args,
|
|
127
|
+
address: this.address.toString()
|
|
128
|
+
}, undefined, []);
|
|
129
|
+
if (error?.includes('ProposalAlreadyExecuted')) {
|
|
130
|
+
throw new ProposalAlreadyExecutedError(round);
|
|
131
|
+
}
|
|
132
|
+
throw new Error(error ?? 'Unknown error');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
47
135
|
}
|