@aztec/ethereum 0.0.1-commit.fcb71a6 → 0.0.1-commit.fffb133c
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/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 +3 -2
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +10 -2
- 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/queries.ts +5 -3
- package/src/test/chain_monitor.ts +1 -1
- package/src/test/rollup_cheat_codes.ts +12 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/rollup_cheat_codes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAG5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,GAAG,EAMT,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,8CAA8C;AAC9C,qBAAa,gBAAgB;IAOzB,OAAO,CAAC,aAAa;IANvB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,MAAM,CAA4D;IAE1E,OAAO,CAAC,MAAM,CAAuC;IAErD,YACU,aAAa,EAAE,aAAa,EACpC,SAAS,EAAE,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC,EAWtD;IAED,MAAM,CAAC,MAAM,CACX,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC,EACrD,YAAY,EAAE,YAAY,GACzB,gBAAgB,CAGlB;IAED,+BAA+B;IAClB,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,CAG1C;IAED,gCAAgC;IACnB,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC,CAG5C;IAED;;;OAGG;IACU,OAAO,IAAI,OAAO,CAAC;QAC9B,4BAA4B,CAAC,OAAO,EAAE,gBAAgB,CAAC;QACvD,2BAA2B,CAAC,MAAM,EAAE,gBAAgB,CAAC;KACtD,CAAC,CAMD;IAED;;OAEG;IACU,WAAW,kBAiBvB;IAED,0EAA0E;IAC7D,SAAS,IAAI,OAAO,CAAC;QAChC,qBAAqB,CAAC,aAAa,EAAE,MAAM,CAAC;QAC5C,oBAAoB,CAAC,YAAY,EAAE,MAAM,CAAC;KAC3C,CAAC,CAMD;IAED;;;;OAIG;IACU,cAAc,CACzB,KAAK,EAAE,WAAW,EAClB,IAAI,GAAE;QACJ,wBAAwB;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;KACZ,mBAYP;IAED,4CAA4C;IAC/B,kBAAkB,kBAW9B;IAED,6DAA6D;IAChD,iBAAiB,qCAO7B;IAED;;;OAGG;IACU,YAAY,CAAC,OAAO,EAAE,MAAM,iBAOxC;IAED;;;OAGG;IACI,YAAY,CAAC,qBAAqB,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"rollup_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/rollup_cheat_codes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAG5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,GAAG,EAMT,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,8CAA8C;AAC9C,qBAAa,gBAAgB;IAOzB,OAAO,CAAC,aAAa;IANvB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,MAAM,CAA4D;IAE1E,OAAO,CAAC,MAAM,CAAuC;IAErD,YACU,aAAa,EAAE,aAAa,EACpC,SAAS,EAAE,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC,EAWtD;IAED,MAAM,CAAC,MAAM,CACX,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC,EACrD,YAAY,EAAE,YAAY,GACzB,gBAAgB,CAGlB;IAED,+BAA+B;IAClB,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,CAG1C;IAED,gCAAgC;IACnB,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC,CAG5C;IAED;;;OAGG;IACU,OAAO,IAAI,OAAO,CAAC;QAC9B,4BAA4B,CAAC,OAAO,EAAE,gBAAgB,CAAC;QACvD,2BAA2B,CAAC,MAAM,EAAE,gBAAgB,CAAC;KACtD,CAAC,CAMD;IAED;;OAEG;IACU,WAAW,kBAiBvB;IAED,0EAA0E;IAC7D,SAAS,IAAI,OAAO,CAAC;QAChC,qBAAqB,CAAC,aAAa,EAAE,MAAM,CAAC;QAC5C,oBAAoB,CAAC,YAAY,EAAE,MAAM,CAAC;KAC3C,CAAC,CAMD;IAED;;;;OAIG;IACU,cAAc,CACzB,KAAK,EAAE,WAAW,EAClB,IAAI,GAAE;QACJ,wBAAwB;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;KACZ,mBAYP;IAED,4CAA4C;IAC/B,kBAAkB,kBAW9B;IAED,6DAA6D;IAChD,iBAAiB,qCAO7B;IAED;;;OAGG;IACU,YAAY,CAAC,OAAO,EAAE,MAAM,iBAOxC;IAED;;;OAGG;IACI,YAAY,CAAC,qBAAqB,CAAC,EAAE,gBAAgB,iBA+B3D;IAED;;;OAGG;IACI,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAmCvE;IAEM,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iBAOtD;IAED;;;OAGG;IACU,OAAO,CAClB,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,qBAAqB,CAAC,OAAO,SAAS,EAAE,gBAAgB,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,iBAMzG;IAED;;OAEG;IACU,UAAU,kBAOtB;IAED,4CAA4C;IAC/B,oBAAoB,kBAMhC;IAED;;;OAGG;IACU,sBAAsB,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,iBAIrE;IAED;;;OAGG;IACU,qBAAqB,CAAC,QAAQ,EAAE,MAAM,iBAUlD;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
1
|
+
import { OutboxContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
2
2
|
import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
@@ -86,7 +86,7 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
86
86
|
* @param opts - Options
|
|
87
87
|
*/ async advanceToEpoch(epoch, opts = {}) {
|
|
88
88
|
const { epochDuration: slotsInEpoch } = await this.getConfig();
|
|
89
|
-
const slotNumber = SlotNumber(epoch * Number(slotsInEpoch));
|
|
89
|
+
const slotNumber = SlotNumber(Number(epoch) * Number(slotsInEpoch));
|
|
90
90
|
const timestamp = await this.rollup.read.getTimestampForSlot([
|
|
91
91
|
BigInt(slotNumber)
|
|
92
92
|
]) + BigInt(opts.offset ?? 0);
|
|
@@ -211,6 +211,14 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
211
211
|
return newInProgress;
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
|
+
insertOutbox(epoch, outHash) {
|
|
215
|
+
return this.ethCheatCodes.execWithPausedAnvil(async ()=>{
|
|
216
|
+
const outboxAddress = await this.rollup.read.getOutbox();
|
|
217
|
+
const epochRootSlot = OutboxContract.getEpochRootStorageSlot(epoch);
|
|
218
|
+
await this.ethCheatCodes.store(EthAddress.fromString(outboxAddress), epochRootSlot, outHash);
|
|
219
|
+
this.logger.warn(`Advanced outbox to epoch ${epoch} with out hash ${outHash}`);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
214
222
|
/**
|
|
215
223
|
* Executes an action impersonated as the owner of the Rollup contract.
|
|
216
224
|
* @param action - The action to execute
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/ethereum",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.fffb133c",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./account": "./dest/account.js",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"build": "yarn clean && ../scripts/tsc.sh",
|
|
41
41
|
"build:dev": "../scripts/tsc.sh --watch",
|
|
42
42
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
43
|
-
"
|
|
43
|
+
"generate": "./scripts/generate.sh",
|
|
44
|
+
"start:dev": "concurrently -k \"../scripts/tsc.sh --watch\" \"nodemon --watch dest --exec yarn start\"",
|
|
44
45
|
"start": "node ./dest/index.js",
|
|
45
46
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
|
|
46
47
|
"proposer-address": "node ./dest/cli/forwarder_address.js"
|
|
@@ -49,10 +50,10 @@
|
|
|
49
50
|
"../package.common.json"
|
|
50
51
|
],
|
|
51
52
|
"dependencies": {
|
|
52
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
53
|
-
"@aztec/constants": "0.0.1-commit.
|
|
54
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
55
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
53
|
+
"@aztec/blob-lib": "0.0.1-commit.fffb133c",
|
|
54
|
+
"@aztec/constants": "0.0.1-commit.fffb133c",
|
|
55
|
+
"@aztec/foundation": "0.0.1-commit.fffb133c",
|
|
56
|
+
"@aztec/l1-artifacts": "0.0.1-commit.fffb133c",
|
|
56
57
|
"@viem/anvil": "^0.0.10",
|
|
57
58
|
"dotenv": "^16.0.3",
|
|
58
59
|
"lodash.chunk": "^4.2.0",
|
|
@@ -67,7 +68,7 @@
|
|
|
67
68
|
"@types/jest": "^30.0.0",
|
|
68
69
|
"@types/lodash.pickby": "^4",
|
|
69
70
|
"@types/node": "^22.15.17",
|
|
70
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
71
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
71
72
|
"@viem/anvil": "^0.0.10",
|
|
72
73
|
"get-port": "^7.1.0",
|
|
73
74
|
"jest": "^30.0.0",
|
package/src/config.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ConfigMappingsType,
|
|
3
|
-
// type NetworkNames,
|
|
4
3
|
bigintConfigHelper,
|
|
5
4
|
booleanConfigHelper,
|
|
6
5
|
enumConfigHelper,
|
|
7
6
|
getConfigFromMappings,
|
|
7
|
+
getDefaultConfig,
|
|
8
8
|
numberConfigHelper,
|
|
9
9
|
optionalNumberConfigHelper,
|
|
10
10
|
} from '@aztec/foundation/config';
|
|
11
11
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
12
12
|
|
|
13
|
+
import { l1ContractsDefaultEnv } from './generated/l1-contracts-defaults.js';
|
|
13
14
|
import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from './l1_tx_utils/config.js';
|
|
14
15
|
|
|
15
16
|
export type GenesisStateConfig = {
|
|
@@ -68,124 +69,108 @@ export type L1ContractsConfig = {
|
|
|
68
69
|
governanceProposerQuorum?: number;
|
|
69
70
|
/** Governance proposing round size */
|
|
70
71
|
governanceProposerRoundSize: number;
|
|
72
|
+
/** Governance voting duration in seconds (only for local/devnet/next-net, default 3600) */
|
|
73
|
+
governanceVotingDuration?: number;
|
|
71
74
|
/** The mana target for the rollup */
|
|
72
75
|
manaTarget: bigint;
|
|
73
76
|
/** The proving cost per mana */
|
|
74
77
|
provingCostPerMana: bigint;
|
|
78
|
+
/** The initial ETH per fee asset price (with 1e12 precision) */
|
|
79
|
+
initialEthPerFeeAsset: bigint;
|
|
75
80
|
/** The number of seconds to wait for an exit */
|
|
76
81
|
exitDelaySeconds: number;
|
|
77
82
|
} & L1TxUtilsConfig;
|
|
78
83
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
lagInEpochsForValidatorSet: 2,
|
|
85
|
-
lagInEpochsForRandao: 2, // For PROD, this value should be > lagInEpochsForValidatorSet
|
|
86
|
-
inboxLag: 1, // Default inbox lag to prevent sequencer DOS attacks
|
|
87
|
-
aztecProofSubmissionEpochs: 1, // you have a full epoch to submit a proof after the epoch to prove ends
|
|
88
|
-
activationThreshold: 100n * 10n ** 18n,
|
|
89
|
-
ejectionThreshold: 50n * 10n ** 18n,
|
|
90
|
-
localEjectionThreshold: 98n * 10n ** 18n,
|
|
91
|
-
slashAmountSmall: 10n * 10n ** 18n,
|
|
92
|
-
slashAmountMedium: 20n * 10n ** 18n,
|
|
93
|
-
slashAmountLarge: 50n * 10n ** 18n,
|
|
94
|
-
slashingRoundSizeInEpochs: 4,
|
|
95
|
-
slashingLifetimeInRounds: 5,
|
|
96
|
-
slashingExecutionDelayInRounds: 0, // round N may be submitted in round N + 1
|
|
97
|
-
slashingVetoer: EthAddress.ZERO,
|
|
98
|
-
governanceProposerRoundSize: 300,
|
|
99
|
-
manaTarget: BigInt(100e6),
|
|
100
|
-
provingCostPerMana: BigInt(100),
|
|
101
|
-
exitDelaySeconds: 2 * 24 * 60 * 60,
|
|
102
|
-
slasherFlavor: 'tally' as const,
|
|
103
|
-
slashingOffsetInRounds: 2,
|
|
104
|
-
slashingDisableDuration: 5 * 24 * 60 * 60, // 5 days in seconds
|
|
105
|
-
} satisfies L1ContractsConfig;
|
|
106
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Config mappings for L1ContractsConfig.
|
|
86
|
+
* Default values come from generated l1-contracts-defaults.json (source: defaults.yml).
|
|
87
|
+
* Real deployments use forge scripts which require explicit env vars (vm.envUint).
|
|
88
|
+
*/
|
|
107
89
|
export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> = {
|
|
108
90
|
ethereumSlotDuration: {
|
|
109
91
|
env: 'ETHEREUM_SLOT_DURATION',
|
|
110
92
|
description: 'How many seconds an L1 slot lasts.',
|
|
111
|
-
...numberConfigHelper(
|
|
93
|
+
...numberConfigHelper(l1ContractsDefaultEnv.ETHEREUM_SLOT_DURATION),
|
|
112
94
|
},
|
|
113
95
|
aztecSlotDuration: {
|
|
114
96
|
env: 'AZTEC_SLOT_DURATION',
|
|
115
97
|
description: 'How many seconds an L2 slots lasts (must be multiple of ethereum slot duration).',
|
|
116
|
-
...numberConfigHelper(
|
|
98
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLOT_DURATION),
|
|
117
99
|
},
|
|
118
100
|
aztecEpochDuration: {
|
|
119
101
|
env: 'AZTEC_EPOCH_DURATION',
|
|
120
102
|
description: `How many L2 slots an epoch lasts (maximum AZTEC_MAX_EPOCH_DURATION).`,
|
|
121
|
-
...numberConfigHelper(
|
|
103
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EPOCH_DURATION),
|
|
122
104
|
},
|
|
123
105
|
aztecTargetCommitteeSize: {
|
|
124
106
|
env: 'AZTEC_TARGET_COMMITTEE_SIZE',
|
|
125
107
|
description: 'The target validator committee size.',
|
|
126
|
-
...numberConfigHelper(
|
|
108
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_TARGET_COMMITTEE_SIZE),
|
|
127
109
|
},
|
|
128
110
|
lagInEpochsForValidatorSet: {
|
|
129
111
|
env: 'AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET',
|
|
130
112
|
description: 'The number of epochs to lag behind the current epoch for validator selection.',
|
|
131
|
-
...numberConfigHelper(
|
|
113
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET),
|
|
132
114
|
},
|
|
133
115
|
lagInEpochsForRandao: {
|
|
134
116
|
env: 'AZTEC_LAG_IN_EPOCHS_FOR_RANDAO',
|
|
135
117
|
description: 'The number of epochs to lag behind the current epoch for randao selection.',
|
|
136
|
-
...numberConfigHelper(
|
|
118
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_LAG_IN_EPOCHS_FOR_RANDAO),
|
|
137
119
|
},
|
|
138
120
|
inboxLag: {
|
|
139
121
|
env: 'AZTEC_INBOX_LAG',
|
|
140
122
|
description: 'The number of checkpoints to lag in the inbox (prevents sequencer DOS attacks).',
|
|
141
|
-
...numberConfigHelper(
|
|
123
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_INBOX_LAG),
|
|
142
124
|
},
|
|
143
125
|
aztecProofSubmissionEpochs: {
|
|
144
126
|
env: 'AZTEC_PROOF_SUBMISSION_EPOCHS',
|
|
145
127
|
description: 'The number of epochs after an epoch ends that proofs are still accepted.',
|
|
146
|
-
...numberConfigHelper(
|
|
128
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_PROOF_SUBMISSION_EPOCHS),
|
|
147
129
|
},
|
|
148
130
|
activationThreshold: {
|
|
149
131
|
env: 'AZTEC_ACTIVATION_THRESHOLD',
|
|
150
132
|
description: 'The deposit amount for a validator',
|
|
151
|
-
...bigintConfigHelper(
|
|
133
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_ACTIVATION_THRESHOLD)),
|
|
152
134
|
},
|
|
153
135
|
ejectionThreshold: {
|
|
154
136
|
env: 'AZTEC_EJECTION_THRESHOLD',
|
|
155
137
|
description: 'The minimum stake for a validator.',
|
|
156
|
-
...bigintConfigHelper(
|
|
138
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_EJECTION_THRESHOLD)),
|
|
157
139
|
},
|
|
158
140
|
localEjectionThreshold: {
|
|
159
141
|
env: 'AZTEC_LOCAL_EJECTION_THRESHOLD',
|
|
160
142
|
description:
|
|
161
143
|
'The local ejection threshold for a validator. Stricter than ejectionThreshold but local to a specific rollup',
|
|
162
|
-
...bigintConfigHelper(
|
|
144
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_LOCAL_EJECTION_THRESHOLD)),
|
|
163
145
|
},
|
|
164
146
|
slashingOffsetInRounds: {
|
|
165
147
|
env: 'AZTEC_SLASHING_OFFSET_IN_ROUNDS',
|
|
166
148
|
description:
|
|
167
149
|
'How many slashing rounds back we slash (ie when slashing in round N, we slash for offenses committed during epochs of round N-offset)',
|
|
168
|
-
...numberConfigHelper(
|
|
150
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_OFFSET_IN_ROUNDS),
|
|
169
151
|
},
|
|
170
152
|
slasherFlavor: {
|
|
171
153
|
env: 'AZTEC_SLASHER_FLAVOR',
|
|
172
154
|
description: 'Type of slasher proposer (empire, tally, or none)',
|
|
173
|
-
...enumConfigHelper(
|
|
155
|
+
...enumConfigHelper(
|
|
156
|
+
['empire', 'tally', 'none'] as const,
|
|
157
|
+
l1ContractsDefaultEnv.AZTEC_SLASHER_FLAVOR as 'empire' | 'tally' | 'none',
|
|
158
|
+
),
|
|
174
159
|
},
|
|
175
160
|
slashAmountSmall: {
|
|
176
161
|
env: 'AZTEC_SLASH_AMOUNT_SMALL',
|
|
177
162
|
description: 'Small slashing amount for light offenses',
|
|
178
|
-
...bigintConfigHelper(
|
|
163
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_SMALL)),
|
|
179
164
|
},
|
|
180
165
|
slashAmountMedium: {
|
|
181
166
|
env: 'AZTEC_SLASH_AMOUNT_MEDIUM',
|
|
182
167
|
description: 'Medium slashing amount for moderate offenses',
|
|
183
|
-
...bigintConfigHelper(
|
|
168
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_MEDIUM)),
|
|
184
169
|
},
|
|
185
170
|
slashAmountLarge: {
|
|
186
171
|
env: 'AZTEC_SLASH_AMOUNT_LARGE',
|
|
187
172
|
description: 'Large slashing amount for severe offenses',
|
|
188
|
-
...bigintConfigHelper(
|
|
173
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_LARGE)),
|
|
189
174
|
},
|
|
190
175
|
slashingQuorum: {
|
|
191
176
|
env: 'AZTEC_SLASHING_QUORUM',
|
|
@@ -195,28 +180,28 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
195
180
|
slashingRoundSizeInEpochs: {
|
|
196
181
|
env: 'AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS',
|
|
197
182
|
description: 'The slashing round size',
|
|
198
|
-
...numberConfigHelper(
|
|
183
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS),
|
|
199
184
|
},
|
|
200
185
|
slashingLifetimeInRounds: {
|
|
201
186
|
env: 'AZTEC_SLASHING_LIFETIME_IN_ROUNDS',
|
|
202
187
|
description: 'The slashing lifetime in rounds',
|
|
203
|
-
...numberConfigHelper(
|
|
188
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_LIFETIME_IN_ROUNDS),
|
|
204
189
|
},
|
|
205
190
|
slashingExecutionDelayInRounds: {
|
|
206
191
|
env: 'AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS',
|
|
207
192
|
description: 'The slashing execution delay in rounds',
|
|
208
|
-
...numberConfigHelper(
|
|
193
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS),
|
|
209
194
|
},
|
|
210
195
|
slashingVetoer: {
|
|
211
196
|
env: 'AZTEC_SLASHING_VETOER',
|
|
212
197
|
description: 'The slashing vetoer',
|
|
213
198
|
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
214
|
-
defaultValue:
|
|
199
|
+
defaultValue: EthAddress.fromString(l1ContractsDefaultEnv.AZTEC_SLASHING_VETOER),
|
|
215
200
|
},
|
|
216
201
|
slashingDisableDuration: {
|
|
217
202
|
env: 'AZTEC_SLASHING_DISABLE_DURATION',
|
|
218
203
|
description: 'How long slashing can be disabled for in seconds when vetoer disables it',
|
|
219
|
-
...numberConfigHelper(
|
|
204
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_DISABLE_DURATION),
|
|
220
205
|
},
|
|
221
206
|
governanceProposerQuorum: {
|
|
222
207
|
env: 'AZTEC_GOVERNANCE_PROPOSER_QUORUM',
|
|
@@ -226,26 +211,42 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
226
211
|
governanceProposerRoundSize: {
|
|
227
212
|
env: 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE',
|
|
228
213
|
description: 'The governance proposing round size',
|
|
229
|
-
...numberConfigHelper(
|
|
214
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE),
|
|
215
|
+
},
|
|
216
|
+
governanceVotingDuration: {
|
|
217
|
+
env: 'AZTEC_GOVERNANCE_VOTING_DURATION',
|
|
218
|
+
description: 'Governance voting duration in seconds (only for local/devnet/next-net)',
|
|
219
|
+
...numberConfigHelper(3600), // 1 hour default, not in generated defaults as it's deployment-time only
|
|
230
220
|
},
|
|
231
221
|
manaTarget: {
|
|
232
222
|
env: 'AZTEC_MANA_TARGET',
|
|
233
223
|
description: 'The mana target for the rollup',
|
|
234
|
-
...bigintConfigHelper(
|
|
224
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_MANA_TARGET)),
|
|
235
225
|
},
|
|
236
226
|
provingCostPerMana: {
|
|
237
227
|
env: 'AZTEC_PROVING_COST_PER_MANA',
|
|
238
228
|
description: 'The proving cost per mana',
|
|
239
|
-
...bigintConfigHelper(
|
|
229
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_PROVING_COST_PER_MANA)),
|
|
230
|
+
},
|
|
231
|
+
initialEthPerFeeAsset: {
|
|
232
|
+
env: 'AZTEC_INITIAL_ETH_PER_FEE_ASSET',
|
|
233
|
+
description: 'The initial ETH per fee asset price (with 1e12 precision)',
|
|
234
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_INITIAL_ETH_PER_FEE_ASSET)),
|
|
240
235
|
},
|
|
241
236
|
exitDelaySeconds: {
|
|
242
237
|
env: 'AZTEC_EXIT_DELAY_SECONDS',
|
|
243
238
|
description: 'The delay before a validator can exit the set',
|
|
244
|
-
...numberConfigHelper(
|
|
239
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EXIT_DELAY_SECONDS),
|
|
245
240
|
},
|
|
246
241
|
...l1TxUtilsConfigMappings,
|
|
247
242
|
};
|
|
248
243
|
|
|
244
|
+
/**
|
|
245
|
+
* Default L1 contracts configuration derived from l1ContractsConfigMappings.
|
|
246
|
+
* Source of truth: spartan/environments/defaults.yml -> defaults.l1-contracts
|
|
247
|
+
*/
|
|
248
|
+
export const DefaultL1ContractsConfig = getDefaultConfig(l1ContractsConfigMappings);
|
|
249
|
+
|
|
249
250
|
export const genesisStateConfigMappings: ConfigMappingsType<GenesisStateConfig> = {
|
|
250
251
|
testAccounts: {
|
|
251
252
|
env: 'TEST_ACCOUNTS',
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# L1 Contract Wrappers
|
|
2
|
+
|
|
3
|
+
This folder contains TypeScript wrappers for L1 contracts defined in `l1-contracts/`. These wrappers are used by the node client to interact with the rollup and related contracts on Ethereum.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
The goal of wrapping is to shield consumers from L1-specific and viem-specific details. Clients using these wrappers interact with domain types and branded types native to the Aztec codebase, without needing to understand viem's ABI type system or deal with raw types like `Hex` and `bigint`.
|
|
8
|
+
|
|
9
|
+
## Type Safety
|
|
10
|
+
|
|
11
|
+
### Explicit Return Types
|
|
12
|
+
|
|
13
|
+
Every function in the contract wrappers must declare its return type explicitly. This is critical because viem's type inference over ABI types is slow and significantly impacts IDE performance.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
// Good: Explicit return type
|
|
17
|
+
async getSlotNumber(): Promise<SlotNumber> {
|
|
18
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Bad: Inferred return type (slow)
|
|
22
|
+
async getSlotNumber() {
|
|
23
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Branded and Domain Types
|
|
28
|
+
|
|
29
|
+
Use branded types and domain-specific types instead of viem's autogenerated types for both arguments and return values:
|
|
30
|
+
|
|
31
|
+
- `CheckpointNumber`, `EpochNumber`, `SlotNumber` instead of `bigint`
|
|
32
|
+
- `EthAddress` instead of `` `0x${string}` `` or `Hex`
|
|
33
|
+
- `Fr`, `Buffer32` instead of `Hex` for hashes and field elements
|
|
34
|
+
- Custom domain types (e.g., `CheckpointLog`, `AttesterView`) instead of raw tuples
|
|
35
|
+
|
|
36
|
+
Type conversions happen inside wrapper methods, not at the call site:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
async getCheckpoint(checkpointNumber: CheckpointNumber): Promise<CheckpointLog> {
|
|
40
|
+
const result = await this.rollup.read.getCheckpoint([BigInt(checkpointNumber)]);
|
|
41
|
+
return {
|
|
42
|
+
archive: Fr.fromString(result.archive),
|
|
43
|
+
headerHash: Buffer32.fromString(result.headerHash),
|
|
44
|
+
blockCount: result.blockCount,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Wrapper Pattern
|
|
50
|
+
|
|
51
|
+
### Basic Structure
|
|
52
|
+
|
|
53
|
+
Each wrapper follows a consistent structure:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
export class FooContract {
|
|
57
|
+
private readonly foo: GetContractReturnType<typeof FooAbi, ViemClient>;
|
|
58
|
+
|
|
59
|
+
constructor(
|
|
60
|
+
public readonly client: ViemClient,
|
|
61
|
+
address: Hex | EthAddress,
|
|
62
|
+
) {
|
|
63
|
+
if (address instanceof EthAddress) {
|
|
64
|
+
address = address.toString();
|
|
65
|
+
}
|
|
66
|
+
this.foo = getContract({ address, abi: FooAbi, client });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public get address(): Hex {
|
|
70
|
+
return this.foo.address;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public getContract(): GetContractReturnType<typeof FooAbi, ViemClient> {
|
|
74
|
+
return this.foo;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The raw contract is exposed via `getContract()` for cases where direct access is needed, but most consumers should use the typed wrapper methods. Relying on `getContract()` is a code smell and should be avoided.
|
|
80
|
+
|
|
81
|
+
### Static Factory Methods
|
|
82
|
+
|
|
83
|
+
Wrappers may provide static factory methods for common initialization patterns:
|
|
84
|
+
|
|
85
|
+
- `getFromConfig(config)` - construct from configuration object
|
|
86
|
+
- `getFromL1ContractsValues(deployResult)` - construct from deployment result
|
|
87
|
+
|
|
88
|
+
### Wallet Assertions
|
|
89
|
+
|
|
90
|
+
For write operations that require a wallet, use an assertion helper:
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
private assertWallet(): GetContractReturnType<typeof FooAbi, ExtendedViemWalletClient> {
|
|
94
|
+
if (!isExtendedClient(this.client)) {
|
|
95
|
+
throw new Error('Wallet client is required for this operation');
|
|
96
|
+
}
|
|
97
|
+
return this.foo as GetContractReturnType<typeof FooAbi, ExtendedViemWalletClient>;
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Event Handling
|
|
102
|
+
|
|
103
|
+
### Event Log Types
|
|
104
|
+
|
|
105
|
+
Event logs are wrapped in `L1EventLog<T>` to include L1 block context:
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
type L1EventLog<T> = {
|
|
109
|
+
l1BlockNumber: bigint;
|
|
110
|
+
l1BlockHash: Buffer32;
|
|
111
|
+
l1TransactionHash: Hex;
|
|
112
|
+
args: T;
|
|
113
|
+
};
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Event Fetching
|
|
117
|
+
|
|
118
|
+
Methods that fetch events convert viem's raw logs to domain types:
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
async getCheckpointProposedEvents(fromBlock: bigint, toBlock: bigint): Promise<CheckpointProposedLog[]> {
|
|
122
|
+
const logs = await this.rollup.getEvents.CheckpointProposed({}, { fromBlock, toBlock });
|
|
123
|
+
return logs.map(log => ({
|
|
124
|
+
l1BlockNumber: log.blockNumber!,
|
|
125
|
+
l1BlockHash: Buffer32.fromString(log.blockHash!),
|
|
126
|
+
l1TransactionHash: log.transactionHash!,
|
|
127
|
+
args: {
|
|
128
|
+
checkpointNumber: CheckpointNumber.fromBigInt(log.args.checkpointNumber!),
|
|
129
|
+
// ... convert other fields
|
|
130
|
+
},
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Event Listeners
|
|
136
|
+
|
|
137
|
+
For reactive event handling, wrapper methods convert arguments before invoking callbacks:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
public listenToCheckpointInvalidated(
|
|
141
|
+
callback: (args: { checkpointNumber: CheckpointNumber }) => unknown,
|
|
142
|
+
): WatchContractEventReturnType {
|
|
143
|
+
return this.rollup.watchEvent.CheckpointInvalidated({}, {
|
|
144
|
+
onLogs: logs => {
|
|
145
|
+
for (const log of logs) {
|
|
146
|
+
if (log.args.checkpointNumber !== undefined) {
|
|
147
|
+
callback({ checkpointNumber: CheckpointNumber.fromBigInt(log.args.checkpointNumber) });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Error Handling
|
|
156
|
+
|
|
157
|
+
Custom error classes in `errors.ts` extend `Error` and set `this.name` for proper error identification. Include relevant context as public readonly properties.
|
|
@@ -4,13 +4,14 @@ import { FeeAssetHandlerAbi } from '@aztec/l1-artifacts/FeeAssetHandlerAbi';
|
|
|
4
4
|
import { type Hex, encodeFunctionData, getContract } from 'viem';
|
|
5
5
|
|
|
6
6
|
import type { L1TxUtils } from '../l1_tx_utils/index.js';
|
|
7
|
+
import type { ViemClient } from '../types.js';
|
|
7
8
|
|
|
8
9
|
export class FeeAssetHandlerContract {
|
|
9
10
|
public address: EthAddress;
|
|
10
11
|
|
|
11
12
|
constructor(
|
|
13
|
+
public readonly client: ViemClient,
|
|
12
14
|
address: Hex | EthAddress,
|
|
13
|
-
public readonly txUtils: L1TxUtils,
|
|
14
15
|
) {
|
|
15
16
|
if (address instanceof EthAddress) {
|
|
16
17
|
address = address.toString();
|
|
@@ -22,7 +23,7 @@ export class FeeAssetHandlerContract {
|
|
|
22
23
|
const contract = getContract({
|
|
23
24
|
abi: FeeAssetHandlerAbi,
|
|
24
25
|
address: this.address.toString(),
|
|
25
|
-
client: this.
|
|
26
|
+
client: this.client,
|
|
26
27
|
});
|
|
27
28
|
return EthAddress.fromString(await contract.read.owner());
|
|
28
29
|
}
|
|
@@ -31,16 +32,16 @@ export class FeeAssetHandlerContract {
|
|
|
31
32
|
const contract = getContract({
|
|
32
33
|
abi: FeeAssetHandlerAbi,
|
|
33
34
|
address: this.address.toString(),
|
|
34
|
-
client: this.
|
|
35
|
+
client: this.client,
|
|
35
36
|
});
|
|
36
37
|
return contract.read.mintAmount();
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
public mint(recipient: Hex | EthAddress) {
|
|
40
|
+
public mint(txUtils: L1TxUtils, recipient: Hex | EthAddress) {
|
|
40
41
|
if (recipient instanceof EthAddress) {
|
|
41
42
|
recipient = recipient.toString();
|
|
42
43
|
}
|
|
43
|
-
return
|
|
44
|
+
return txUtils.sendAndMonitorTransaction({
|
|
44
45
|
to: this.address.toString(),
|
|
45
46
|
data: encodeFunctionData({
|
|
46
47
|
abi: FeeAssetHandlerAbi,
|
|
@@ -50,8 +51,8 @@ export class FeeAssetHandlerContract {
|
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
public setMintAmount(amount: bigint) {
|
|
54
|
-
return
|
|
54
|
+
public setMintAmount(txUtils: L1TxUtils, amount: bigint) {
|
|
55
|
+
return txUtils.sendAndMonitorTransaction({
|
|
55
56
|
to: this.address.toString(),
|
|
56
57
|
data: encodeFunctionData({
|
|
57
58
|
abi: FeeAssetHandlerAbi,
|
|
@@ -174,6 +174,13 @@ export class GovernanceContract extends ReadOnlyGovernanceContract {
|
|
|
174
174
|
return this.governanceContract.read.powerAt([this.client.account.address, now.timestamp]);
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
/** Returns the user's voting power for a specific proposal, checked at pendingThrough timestamp. */
|
|
178
|
+
public async getPowerForProposal(proposalId: bigint): Promise<bigint> {
|
|
179
|
+
const proposal = await this.getProposal(proposalId);
|
|
180
|
+
const pendingThrough = proposal.creation + proposal.config.votingDelay;
|
|
181
|
+
return this.governanceContract.read.powerAt([this.client.account.address, pendingThrough]);
|
|
182
|
+
}
|
|
183
|
+
|
|
177
184
|
public async vote({
|
|
178
185
|
proposalId,
|
|
179
186
|
voteAmount,
|
|
@@ -190,7 +197,7 @@ export class GovernanceContract extends ReadOnlyGovernanceContract {
|
|
|
190
197
|
const l1TxUtils = createL1TxUtilsFromViemWallet(this.client, { logger });
|
|
191
198
|
const retryDelaySeconds = 12;
|
|
192
199
|
|
|
193
|
-
voteAmount = voteAmount ?? (await this.
|
|
200
|
+
voteAmount = voteAmount ?? (await this.getPowerForProposal(proposalId));
|
|
194
201
|
|
|
195
202
|
let success = false;
|
|
196
203
|
for (let i = 0; i < retries; i++) {
|
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
|
+
};
|