From e99a59afd660368a3f845b71b33273313de258dd Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 14 Jan 2025 11:54:06 +0000 Subject: [PATCH 01/57] fix: use simulation to estimate gas used --- yarn-project/ethereum/package.json | 2 +- yarn-project/ethereum/src/l1_tx_utils.ts | 21 ++ .../src/publisher/l1-publisher.ts | 78 +++++-- yarn-project/yarn.lock | 221 +++++++++++++++--- 4 files changed, 275 insertions(+), 47 deletions(-) diff --git a/yarn-project/ethereum/package.json b/yarn-project/ethereum/package.json index 5081cab89dc..da480ec5820 100644 --- a/yarn-project/ethereum/package.json +++ b/yarn-project/ethereum/package.json @@ -34,7 +34,7 @@ "@viem/anvil": "^0.0.10", "dotenv": "^16.0.3", "tslib": "^2.4.0", - "viem": "^2.7.15", + "viem": "2.22", "zod": "^3.23.8" }, "devDependencies": { diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index a53f7f50b39..13dc4a56d8d 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -12,6 +12,7 @@ import { sleep } from '@aztec/foundation/sleep'; import { type Account, type Address, + type BlockOverrides, type Chain, type GetTransactionReturnType, type Hex, @@ -224,6 +225,7 @@ export class L1TxUtils { txHash = await this.walletClient.sendTransaction({ ...request, ...blobInputs, + blobs: [], gas: gasLimit, maxFeePerGas: gasPrice.maxFeePerGas, maxPriorityFeePerGas: gasPrice.maxPriorityFeePerGas, @@ -563,4 +565,23 @@ export class L1TxUtils { return withBuffer; } + + public async simulateGasUsed(request: L1TxRequest, blockOverrides: BlockOverrides): Promise { + const result = await this.publicClient.simulate({ + validation: true, + blocks: [ + { + blockOverrides, + calls: [ + { + from: this.walletClient.account.address, + to: request.to!, + data: request.data, + }, + ], + }, + ], + }); + return result[0].calls[0].gasUsed; + } } diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 22f42f2f9fe..0584133bfc7 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -1,12 +1,10 @@ import { type BlobSinkClientInterface, createBlobSinkClient } from '@aztec/blob-sink/client'; import { - ConsensusPayload, + // ConsensusPayload, type EpochProofClaim, type EpochProofQuote, - type L2Block, - SignatureDomainSeparator, - type TxHash, - getHashedSignaturePayload, + type L2Block, // SignatureDomainSeparator, + type TxHash, // getHashedSignaturePayload, } from '@aztec/circuit-types'; import { type L1PublishBlockStats, type L1PublishProofStats, type L1PublishStats } from '@aztec/circuit-types/stats'; import { @@ -583,9 +581,9 @@ export class L1Publisher { blockHash: block.hash().toString(), }; - const consensusPayload = new ConsensusPayload(block.header, block.archive.root, txHashes ?? []); + // const consensusPayload = new ConsensusPayload(block.header, block.archive.root, txHashes ?? []); - const digest = getHashedSignaturePayload(consensusPayload, SignatureDomainSeparator.blockAttestation); + // const digest = getHashedSignaturePayload(consensusPayload, SignatureDomainSeparator.blockAttestation); const blobs = Blob.getBlobs(block.body.toBlobFields()); const proposeTxArgs = { @@ -610,10 +608,10 @@ export class L1Publisher { // This means that we can avoid the simulation issues in later checks. // By simulation issue, I mean the fact that the block.timestamp is equal to the last block, not the next, which // make time consistency checks break. - await this.validateBlockForSubmission(block.header, { - digest: digest.toBuffer(), - signatures: attestations ?? [], - }); + // await this.validateBlockForSubmission(block.header, { + // digest: digest.toBuffer(), + // signatures: attestations ?? [], + // }); this.log.debug(`Submitting propose transaction`); const result = proofQuote @@ -984,7 +982,32 @@ export class L1Publisher { // we will fail estimation in the case where we are simulating for the // first ethereum block within our slot (as current time is not in the // slot yet). - const gasGuesstimate = blobEvaluationGas + L1Publisher.PROPOSE_GAS_GUESS; + // const gasGuesstimate = blobEvaluationGas + L1Publisher.PROPOSE_GAS_GUESS; + + // const timestamp = BigInt((await this.publicClient.getBlock()).timestamp + this.ethereumSlotDuration); + + // const simulationResult = await this.publicClient.simulate({ + // validation: true, + // blocks: [ + // { + // blockOverrides: { + // time: timestamp, + // }, + // calls: [ + // { + // from: this.account.address, + // to: this.rollupContract.address, + // data: encodeFunctionData({ + // abi: this.rollupContract.abi, + // functionName: 'validateBlobs', + // args: [Blob.getEthBlobEvaluationInputs(encodedData.blobs)], + // }), + // }, + // ], + // }, + // ], + // }); + const attestations = encodedData.attestations ? encodedData.attestations.map(attest => attest.toViemSignature()) : []; @@ -1007,7 +1030,7 @@ export class L1Publisher { Blob.getEthBlobEvaluationInputs(encodedData.blobs), ] as const; - return { args, gas: gasGuesstimate }; + return { args, blobEvaluationGas }; } private getSubmitEpochProofArgs(args: { @@ -1049,19 +1072,30 @@ export class L1Publisher { } try { const kzg = Blob.getViemKzgInstance(); - const { args, gas } = await this.prepareProposeTx(encodedData); + const { args, blobEvaluationGas } = await this.prepareProposeTx(encodedData); const data = encodeFunctionData({ abi: this.rollupContract.abi, functionName: 'propose', args, }); + const time = BigInt((await this.publicClient.getBlock()).timestamp + this.ethereumSlotDuration); + const simulationResult = await this.l1TxUtils.simulateGasUsed( + { + to: this.rollupContract.address, + data, + }, + { + time, + }, + ); + const result = await this.l1TxUtils.sendAndMonitorTransaction( { to: this.rollupContract.address, data, }, { - fixedGas: gas, + fixedGas: simulationResult + blobEvaluationGas, ...opts, }, { @@ -1092,19 +1126,29 @@ export class L1Publisher { } try { const kzg = Blob.getViemKzgInstance(); - const { args, gas } = await this.prepareProposeTx(encodedData); + const { args, blobEvaluationGas } = await this.prepareProposeTx(encodedData); const data = encodeFunctionData({ abi: this.rollupContract.abi, functionName: 'proposeAndClaim', args: [...args, quote.toViemArgs()], }); + const time = BigInt((await this.publicClient.getBlock()).timestamp + this.ethereumSlotDuration); + const simulationResult = await this.l1TxUtils.simulateGasUsed( + { + to: this.rollupContract.address, + data, + }, + { + time, + }, + ); const result = await this.l1TxUtils.sendAndMonitorTransaction( { to: this.rollupContract.address, data, }, { - fixedGas: gas, + fixedGas: simulationResult + blobEvaluationGas, ...opts, }, { diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 9d7882a01cb..6f7359cc0fb 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -50,6 +50,13 @@ __metadata: languageName: node linkType: hard +"@adraffy/ens-normalize@npm:^1.10.1": + version: 1.11.0 + resolution: "@adraffy/ens-normalize@npm:1.11.0" + checksum: 10/abef75f21470ea43dd6071168e092d2d13e38067e349e76186c78838ae174a46c3e18ca50921d05bea6ec3203074147c9e271f8cb6531d1c2c0e146f3199ddcb + languageName: node + linkType: hard + "@ampproject/remapping@npm:^2.2.0": version: 2.3.0 resolution: "@ampproject/remapping@npm:2.3.0" @@ -692,7 +699,7 @@ __metadata: ts-node: "npm:^10.9.1" tslib: "npm:^2.4.0" typescript: "npm:^5.0.4" - viem: "npm:^2.7.15" + viem: "npm:2.22" zod: "npm:^3.23.8" languageName: unknown linkType: soft @@ -1230,7 +1237,7 @@ __metadata: ts-node: "npm:^10.9.1" tslib: "npm:^2.4.0" typescript: "npm:^5.0.4" - viem: "npm:^2.7.15" + viem: "npm:2.22" languageName: unknown linkType: soft @@ -3797,6 +3804,15 @@ __metadata: languageName: node linkType: hard +"@noble/curves@npm:1.7.0, @noble/curves@npm:^1.3.0, @noble/curves@npm:~1.7.0": + version: 1.7.0 + resolution: "@noble/curves@npm:1.7.0" + dependencies: + "@noble/hashes": "npm:1.6.0" + checksum: 10/2a11ef4895907d0b241bd3b72f9e6ebe56f0e705949bfd5efe003f25233549f620d287550df2d24ad56a1f953b82ec5f7cf4bd7cb78b1b2e76eb6dd516d44cf8 + languageName: node + linkType: hard + "@noble/curves@npm:^1.0.0, @noble/curves@npm:^1.1.0, @noble/curves@npm:^1.2.0, @noble/curves@npm:^1.4.0": version: 1.4.0 resolution: "@noble/curves@npm:1.4.0" @@ -3806,12 +3822,12 @@ __metadata: languageName: node linkType: hard -"@noble/curves@npm:^1.3.0": - version: 1.7.0 - resolution: "@noble/curves@npm:1.7.0" +"@noble/curves@npm:^1.6.0, @noble/curves@npm:~1.8.0": + version: 1.8.0 + resolution: "@noble/curves@npm:1.8.0" dependencies: - "@noble/hashes": "npm:1.6.0" - checksum: 10/2a11ef4895907d0b241bd3b72f9e6ebe56f0e705949bfd5efe003f25233549f620d287550df2d24ad56a1f953b82ec5f7cf4bd7cb78b1b2e76eb6dd516d44cf8 + "@noble/hashes": "npm:1.7.0" + checksum: 10/c54ce84cf54b8bda1a37a10dfae2e49e5b6cdf5dd98b399efa8b8a80a286b3f8f27bde53202cb308353bfd98719938991a78bed6e43f81f13b17f8181b7b82eb languageName: node linkType: hard @@ -3843,13 +3859,20 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:^1.3.3": +"@noble/hashes@npm:1.6.1, @noble/hashes@npm:^1.3.3, @noble/hashes@npm:~1.6.0": version: 1.6.1 resolution: "@noble/hashes@npm:1.6.1" checksum: 10/74d9ad7b1437a22ba3b877584add3367587fbf818113152f293025d20d425aa74c191d18d434797312f2270458bc9ab3241c34d14ec6115fb16438b3248f631f languageName: node linkType: hard +"@noble/hashes@npm:1.7.0, @noble/hashes@npm:^1.5.0, @noble/hashes@npm:~1.7.0": + version: 1.7.0 + resolution: "@noble/hashes@npm:1.7.0" + checksum: 10/ab038a816c8c9bb986e92797e3d9c5a5b37c020e0c3edc55bcae5061dbdd457f1f0a22787f83f4787c17415ba0282a20a1e455d36ed0cdcace4ce21ef1869f60 + languageName: node + linkType: hard + "@nodelib/fs.scandir@npm:2.1.5": version: 2.1.5 resolution: "@nodelib/fs.scandir@npm:2.1.5" @@ -4534,6 +4557,13 @@ __metadata: languageName: node linkType: hard +"@scure/base@npm:~1.2.1": + version: 1.2.1 + resolution: "@scure/base@npm:1.2.1" + checksum: 10/f7bdd17618ccae7a74c8cbe410a235e4adbe54aa8afe4e2fb1294338aa92f6fd04b1f1f5dea60552f638b5f5e3e74902b7baf59d3954e5e42c0a36c6baa2ebe0 + languageName: node + linkType: hard + "@scure/bip32@npm:1.3.2": version: 1.3.2 resolution: "@scure/bip32@npm:1.3.2" @@ -4556,6 +4586,28 @@ __metadata: languageName: node linkType: hard +"@scure/bip32@npm:1.6.0": + version: 1.6.0 + resolution: "@scure/bip32@npm:1.6.0" + dependencies: + "@noble/curves": "npm:~1.7.0" + "@noble/hashes": "npm:~1.6.0" + "@scure/base": "npm:~1.2.1" + checksum: 10/2efb81ed9a7b8d5d35233e10abebc114544a3783a2a32b9fb60e1e9a67965b272c9d17910e1649083b69c8ceb80241b05b59dbeb7a5b18ea34e497aed3f16709 + languageName: node + linkType: hard + +"@scure/bip32@npm:^1.5.0": + version: 1.6.1 + resolution: "@scure/bip32@npm:1.6.1" + dependencies: + "@noble/curves": "npm:~1.8.0" + "@noble/hashes": "npm:~1.7.0" + "@scure/base": "npm:~1.2.1" + checksum: 10/967be60ab99dad33e44f0813d194d2eccffc0c5877e93fa01bd9d787b15210b383a98114aafacb704e36e58a90075a3eb51a78983914fadaed3bf4469b384064 + languageName: node + linkType: hard + "@scure/bip39@npm:1.2.1": version: 1.2.1 resolution: "@scure/bip39@npm:1.2.1" @@ -4576,6 +4628,26 @@ __metadata: languageName: node linkType: hard +"@scure/bip39@npm:1.5.0": + version: 1.5.0 + resolution: "@scure/bip39@npm:1.5.0" + dependencies: + "@noble/hashes": "npm:~1.6.0" + "@scure/base": "npm:~1.2.1" + checksum: 10/b795ee31ac4c10603bf3b726cc0e5cf43834a68f05a535e0baf2162772bac100de470b4c6cf7ddbecb95d7a3fb82b8a959badced406c329ab696cd89104194bc + languageName: node + linkType: hard + +"@scure/bip39@npm:^1.4.0": + version: 1.5.1 + resolution: "@scure/bip39@npm:1.5.1" + dependencies: + "@noble/hashes": "npm:~1.7.0" + "@scure/base": "npm:~1.2.1" + checksum: 10/a7ba42169704173b687421a0f79e94d645d3954d4f6142b2edbb8466964ac8c7260337cfaab42f0372843da49595019bb1990a323ac6a7b6980b4d7c45924ddf + languageName: node + linkType: hard + "@sinclair/typebox@npm:^0.27.8": version: 0.27.8 resolution: "@sinclair/typebox@npm:0.27.8" @@ -6519,6 +6591,21 @@ __metadata: languageName: node linkType: hard +"abitype@npm:1.0.7": + version: 1.0.7 + resolution: "abitype@npm:1.0.7" + peerDependencies: + typescript: ">=5.0.4" + zod: ^3 >=3.22.0 + peerDependenciesMeta: + typescript: + optional: true + zod: + optional: true + checksum: 10/6c2c3390a2f90186bf0df73f20cf257dfd9b62d1eb266de6ddf362030dcbd79cd113b4110e52f7802d7b042ea8fdb7ee2f113751b883787c2d9589d56fb4273b + languageName: node + linkType: hard + "abitype@npm:^0.8.11": version: 0.8.11 resolution: "abitype@npm:0.8.11" @@ -6532,6 +6619,21 @@ __metadata: languageName: node linkType: hard +"abitype@npm:^1.0.6": + version: 1.0.8 + resolution: "abitype@npm:1.0.8" + peerDependencies: + typescript: ">=5.0.4" + zod: ^3 >=3.22.0 + peerDependenciesMeta: + typescript: + optional: true + zod: + optional: true + checksum: 10/878e74fbac6a971953649b6216950437aa5834a604e9fa833a5b275a6967cff59857c7e43594ae906387d2fb7cad9370138dec4298eb8814815a3ffb6365902c + languageName: node + linkType: hard + "abortable-iterator@npm:^5.0.1": version: 5.0.1 resolution: "abortable-iterator@npm:5.0.1" @@ -10651,6 +10753,13 @@ __metadata: languageName: node linkType: hard +"eventemitter3@npm:5.0.1, eventemitter3@npm:^5.0.1": + version: 5.0.1 + resolution: "eventemitter3@npm:5.0.1" + checksum: 10/ac6423ec31124629c84c7077eed1e6987f6d66c31cf43c6fcbf6c87791d56317ce808d9ead483652436df171b526fc7220eccdc9f3225df334e81582c3cf7dd5 + languageName: node + linkType: hard + "eventemitter3@npm:^4.0.0": version: 4.0.7 resolution: "eventemitter3@npm:4.0.7" @@ -10658,13 +10767,6 @@ __metadata: languageName: node linkType: hard -"eventemitter3@npm:^5.0.1": - version: 5.0.1 - resolution: "eventemitter3@npm:5.0.1" - checksum: 10/ac6423ec31124629c84c7077eed1e6987f6d66c31cf43c6fcbf6c87791d56317ce808d9ead483652436df171b526fc7220eccdc9f3225df334e81582c3cf7dd5 - languageName: node - linkType: hard - "events@npm:^3.0.0, events@npm:^3.2.0, events@npm:^3.3.0": version: 3.3.0 resolution: "events@npm:3.3.0" @@ -12760,6 +12862,15 @@ __metadata: languageName: node linkType: hard +"isows@npm:1.0.6": + version: 1.0.6 + resolution: "isows@npm:1.0.6" + peerDependencies: + ws: "*" + checksum: 10/ab9e85b50bcc3d70aa5ec875aa2746c5daf9321cb376ed4e5434d3c2643c5d62b1f466d93a05cd2ad0ead5297224922748c31707cb4fbd68f5d05d0479dce99c + languageName: node + linkType: hard + "istanbul-lib-coverage@npm:^3.0.0, istanbul-lib-coverage@npm:^3.2.0": version: 3.2.2 resolution: "istanbul-lib-coverage@npm:3.2.2" @@ -15646,6 +15757,26 @@ __metadata: languageName: node linkType: hard +"ox@npm:0.6.0": + version: 0.6.0 + resolution: "ox@npm:0.6.0" + dependencies: + "@adraffy/ens-normalize": "npm:^1.10.1" + "@noble/curves": "npm:^1.6.0" + "@noble/hashes": "npm:^1.5.0" + "@scure/bip32": "npm:^1.5.0" + "@scure/bip39": "npm:^1.4.0" + abitype: "npm:^1.0.6" + eventemitter3: "npm:5.0.1" + peerDependencies: + typescript: ">=5.4.0" + peerDependenciesMeta: + typescript: + optional: true + checksum: 10/b089b2d09035def8d3f6d17ab1dd792fd7f1a4d8e008aa96bc50a8cef24ddb8e608ec828f4d83cf959b080a7c854921449e4d061f45f6dee944f48bd0971e60f + languageName: node + linkType: hard + "p-defer@npm:^4.0.0, p-defer@npm:^4.0.1": version: 4.0.1 resolution: "p-defer@npm:4.0.1" @@ -19576,6 +19707,28 @@ __metadata: languageName: node linkType: hard +"viem@npm:2.22": + version: 2.22.8 + resolution: "viem@npm:2.22.8" + dependencies: + "@noble/curves": "npm:1.7.0" + "@noble/hashes": "npm:1.6.1" + "@scure/bip32": "npm:1.6.0" + "@scure/bip39": "npm:1.5.0" + abitype: "npm:1.0.7" + isows: "npm:1.0.6" + ox: "npm:0.6.0" + webauthn-p256: "npm:0.0.10" + ws: "npm:8.18.0" + peerDependencies: + typescript: ">=5.0.4" + peerDependenciesMeta: + typescript: + optional: true + checksum: 10/04e3c8d1acdad0fc9a1fa5c50ff5b37081502fda5a00fedb457fb70b887dd16bbfea06984ecf1a360de446ec1bef2996bcc0c9415c1f76cc0fd0c333677e2369 + languageName: node + linkType: hard + "viem@npm:^2.7.15": version: 2.10.2 resolution: "viem@npm:2.10.2" @@ -19709,6 +19862,16 @@ __metadata: languageName: node linkType: hard +"webauthn-p256@npm:0.0.10": + version: 0.0.10 + resolution: "webauthn-p256@npm:0.0.10" + dependencies: + "@noble/curves": "npm:^1.4.0" + "@noble/hashes": "npm:^1.4.0" + checksum: 10/dde2b6313b6a0f20996f7ee90181258fc7685bfff401df7d904578da75b374f25d5b9c1189cd2fcec30625b1f276b393188d156d49783f0611623cd713bb5b09 + languageName: node + linkType: hard + "webidl-conversions@npm:^7.0.0": version: 7.0.0 resolution: "webidl-conversions@npm:7.0.0" @@ -20100,39 +20263,39 @@ __metadata: languageName: node linkType: hard -"ws@npm:^7.5.10": - version: 7.5.10 - resolution: "ws@npm:7.5.10" +"ws@npm:8.18.0, ws@npm:^8.18.0": + version: 8.18.0 + resolution: "ws@npm:8.18.0" peerDependencies: bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 + utf-8-validate: ">=5.0.2" peerDependenciesMeta: bufferutil: optional: true utf-8-validate: optional: true - checksum: 10/9c796b84ba80ffc2c2adcdfc9c8e9a219ba99caa435c9a8d45f9ac593bba325563b3f83edc5eb067cc6d21b9a6bf2c930adf76dd40af5f58a5ca6859e81858f0 + checksum: 10/70dfe53f23ff4368d46e4c0b1d4ca734db2c4149c6f68bc62cb16fc21f753c47b35fcc6e582f3bdfba0eaeb1c488cddab3c2255755a5c3eecb251431e42b3ff6 languageName: node linkType: hard -"ws@npm:^8.13.0": - version: 8.17.0 - resolution: "ws@npm:8.17.0" +"ws@npm:^7.5.10": + version: 7.5.10 + resolution: "ws@npm:7.5.10" peerDependencies: bufferutil: ^4.0.1 - utf-8-validate: ">=5.0.2" + utf-8-validate: ^5.0.2 peerDependenciesMeta: bufferutil: optional: true utf-8-validate: optional: true - checksum: 10/5e1dcb0ae70c6e2f158f5b446e0a72a2cd335b07aba73ee1872e9bae1285382286a10e53ed479db21bdd690a5dfd05641a768611ebb236253c62fefa43ef58b4 + checksum: 10/9c796b84ba80ffc2c2adcdfc9c8e9a219ba99caa435c9a8d45f9ac593bba325563b3f83edc5eb067cc6d21b9a6bf2c930adf76dd40af5f58a5ca6859e81858f0 languageName: node linkType: hard -"ws@npm:^8.18.0": - version: 8.18.0 - resolution: "ws@npm:8.18.0" +"ws@npm:^8.13.0": + version: 8.17.0 + resolution: "ws@npm:8.17.0" peerDependencies: bufferutil: ^4.0.1 utf-8-validate: ">=5.0.2" @@ -20141,7 +20304,7 @@ __metadata: optional: true utf-8-validate: optional: true - checksum: 10/70dfe53f23ff4368d46e4c0b1d4ca734db2c4149c6f68bc62cb16fc21f753c47b35fcc6e582f3bdfba0eaeb1c488cddab3c2255755a5c3eecb251431e42b3ff6 + checksum: 10/5e1dcb0ae70c6e2f158f5b446e0a72a2cd335b07aba73ee1872e9bae1285382286a10e53ed479db21bdd690a5dfd05641a768611ebb236253c62fefa43ef58b4 languageName: node linkType: hard From e4a3640386c025ae02987ac34ea2158dd9bcfaa1 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 14 Jan 2025 11:58:59 +0000 Subject: [PATCH 02/57] undo sequencer version bump --- yarn-project/yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index a9d4532be1c..661f755883e 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -1238,7 +1238,7 @@ __metadata: ts-node: "npm:^10.9.1" tslib: "npm:^2.4.0" typescript: "npm:^5.0.4" - viem: "npm:2.22" + viem: "npm:^2.7.15" languageName: unknown linkType: soft From 94be5105814a38ac5eaefe29deb8073a9cd3ded8 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 14 Jan 2025 12:40:31 +0000 Subject: [PATCH 03/57] upgrade viem in sequencer-client --- yarn-project/ethereum/package.json | 2 +- yarn-project/sequencer-client/package.json | 2 +- yarn-project/yarn.lock | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/yarn-project/ethereum/package.json b/yarn-project/ethereum/package.json index da480ec5820..d125ef6591e 100644 --- a/yarn-project/ethereum/package.json +++ b/yarn-project/ethereum/package.json @@ -34,7 +34,7 @@ "@viem/anvil": "^0.0.10", "dotenv": "^16.0.3", "tslib": "^2.4.0", - "viem": "2.22", + "viem": "2.22.8", "zod": "^3.23.8" }, "devDependencies": { diff --git a/yarn-project/sequencer-client/package.json b/yarn-project/sequencer-client/package.json index b1b6c5d5283..2cd48ce2612 100644 --- a/yarn-project/sequencer-client/package.json +++ b/yarn-project/sequencer-client/package.json @@ -52,7 +52,7 @@ "lodash.chunk": "^4.2.0", "lodash.pick": "^4.4.0", "tslib": "^2.4.0", - "viem": "^2.7.15" + "viem": "2.22.8" }, "devDependencies": { "@aztec/archiver": "workspace:^", diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 661f755883e..7b14fc691a5 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -700,7 +700,7 @@ __metadata: ts-node: "npm:^10.9.1" tslib: "npm:^2.4.0" typescript: "npm:^5.0.4" - viem: "npm:2.22" + viem: "npm:2.22.8" zod: "npm:^3.23.8" languageName: unknown linkType: soft @@ -1238,7 +1238,7 @@ __metadata: ts-node: "npm:^10.9.1" tslib: "npm:^2.4.0" typescript: "npm:^5.0.4" - viem: "npm:^2.7.15" + viem: "npm:2.22.8" languageName: unknown linkType: soft @@ -19708,7 +19708,7 @@ __metadata: languageName: node linkType: hard -"viem@npm:2.22": +"viem@npm:2.22.8": version: 2.22.8 resolution: "viem@npm:2.22.8" dependencies: From caf932c1b99455562a858a5e8c4377930d319048 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 14 Jan 2025 13:30:53 +0000 Subject: [PATCH 04/57] upgrade all viem --- yarn-project/archiver/package.json | 2 +- yarn-project/aztec-faucet/package.json | 2 +- yarn-project/aztec.js/package.json | 2 +- yarn-project/aztec/package.json | 2 +- yarn-project/bb-prover/package.json | 2 +- yarn-project/circuit-types/package.json | 2 +- yarn-project/cli/package.json | 2 +- yarn-project/end-to-end/package.json | 2 +- yarn-project/epoch-cache/package.json | 2 +- yarn-project/foundation/package.json | 2 +- yarn-project/p2p/package.json | 2 +- yarn-project/proof-verifier/package.json | 2 +- yarn-project/prover-node/package.json | 2 +- yarn-project/pxe/package.json | 2 +- yarn-project/simulator/package.json | 2 +- yarn-project/validator-client/package.json | 2 +- yarn-project/yarn.lock | 140 +++------------------ 17 files changed, 34 insertions(+), 138 deletions(-) diff --git a/yarn-project/archiver/package.json b/yarn-project/archiver/package.json index 75ae0a84e27..2134edc632e 100644 --- a/yarn-project/archiver/package.json +++ b/yarn-project/archiver/package.json @@ -80,7 +80,7 @@ "lodash.omit": "^4.5.0", "tsc-watch": "^6.0.0", "tslib": "^2.5.0", - "viem": "^2.7.15", + "viem": "2.22.8", "ws": "^8.13.0" }, "devDependencies": { diff --git a/yarn-project/aztec-faucet/package.json b/yarn-project/aztec-faucet/package.json index be649f7b998..2b51bb37705 100644 --- a/yarn-project/aztec-faucet/package.json +++ b/yarn-project/aztec-faucet/package.json @@ -68,7 +68,7 @@ "koa": "^2.14.2", "koa-bodyparser": "^4.4.1", "koa-router": "^12.0.0", - "viem": "^2.7.15", + "viem": "2.22.8", "zod": "^3.23.8" }, "devDependencies": { diff --git a/yarn-project/aztec.js/package.json b/yarn-project/aztec.js/package.json index 1c00eadb280..82ff6558047 100644 --- a/yarn-project/aztec.js/package.json +++ b/yarn-project/aztec.js/package.json @@ -87,7 +87,7 @@ "@aztec/types": "workspace:^", "axios": "^1.7.2", "tslib": "^2.4.0", - "viem": "^2.7.15" + "viem": "2.22.8" }, "devDependencies": { "@jest/globals": "^29.5.0", diff --git a/yarn-project/aztec/package.json b/yarn-project/aztec/package.json index 7c476c67213..695196152f9 100644 --- a/yarn-project/aztec/package.json +++ b/yarn-project/aztec/package.json @@ -64,7 +64,7 @@ "commander": "^12.1.0", "koa": "^2.14.2", "koa-router": "^12.0.0", - "viem": "^2.7.15" + "viem": "2.22.8" }, "files": [ "dest", diff --git a/yarn-project/bb-prover/package.json b/yarn-project/bb-prover/package.json index 4e0f86a7276..d6c9fd74194 100644 --- a/yarn-project/bb-prover/package.json +++ b/yarn-project/bb-prover/package.json @@ -96,7 +96,7 @@ "jest-mock-extended": "^3.0.3", "ts-node": "^10.9.1", "typescript": "^5.0.4", - "viem": "^2.7.15" + "viem": "2.22.8" }, "files": [ "dest", diff --git a/yarn-project/circuit-types/package.json b/yarn-project/circuit-types/package.json index 42e5e6a1855..90e86cd04dc 100644 --- a/yarn-project/circuit-types/package.json +++ b/yarn-project/circuit-types/package.json @@ -90,7 +90,7 @@ "lodash.omit": "^4.5.0", "ts-node": "^10.9.1", "typescript": "^5.0.4", - "viem": "^2.7.15" + "viem": "2.22.8" }, "files": [ "dest", diff --git a/yarn-project/cli/package.json b/yarn-project/cli/package.json index 21236b4a1c5..2ad6efcc770 100644 --- a/yarn-project/cli/package.json +++ b/yarn-project/cli/package.json @@ -82,7 +82,7 @@ "solc": "^0.8.27", "source-map-support": "^0.5.21", "tslib": "^2.4.0", - "viem": "^2.7.15" + "viem": "2.22.8" }, "devDependencies": { "@aztec/accounts": "workspace:^", diff --git a/yarn-project/end-to-end/package.json b/yarn-project/end-to-end/package.json index d6e63d75e3a..00942594844 100644 --- a/yarn-project/end-to-end/package.json +++ b/yarn-project/end-to-end/package.json @@ -96,7 +96,7 @@ "tslib": "^2.4.0", "typescript": "^5.0.4", "util": "^0.12.5", - "viem": "^2.7.15", + "viem": "2.22.8", "webpack": "^5.88.2", "webpack-cli": "^5.1.4", "zod": "^3.23.8" diff --git a/yarn-project/epoch-cache/package.json b/yarn-project/epoch-cache/package.json index b7dbabcba86..fe969ac79ab 100644 --- a/yarn-project/epoch-cache/package.json +++ b/yarn-project/epoch-cache/package.json @@ -37,7 +37,7 @@ "get-port": "^7.1.0", "jest-mock-extended": "^3.0.7", "tslib": "^2.4.0", - "viem": "^2.7.15", + "viem": "2.22.8", "zod": "^3.23.8" }, "devDependencies": { diff --git a/yarn-project/foundation/package.json b/yarn-project/foundation/package.json index 3a2d12142e1..156ed4b1779 100644 --- a/yarn-project/foundation/package.json +++ b/yarn-project/foundation/package.json @@ -160,7 +160,7 @@ "supertest": "^6.3.3", "ts-node": "^10.9.1", "typescript": "^5.0.4", - "viem": "^2.7.15" + "viem": "2.22.8" }, "files": [ "dest", diff --git a/yarn-project/p2p/package.json b/yarn-project/p2p/package.json index 10ad63bc58c..93c01eca969 100644 --- a/yarn-project/p2p/package.json +++ b/yarn-project/p2p/package.json @@ -109,7 +109,7 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4", "uint8arrays": "^5.0.3", - "viem": "^2.7.15" + "viem": "2.22.8" }, "files": [ "dest", diff --git a/yarn-project/proof-verifier/package.json b/yarn-project/proof-verifier/package.json index 99ded95a154..3f9b0985142 100644 --- a/yarn-project/proof-verifier/package.json +++ b/yarn-project/proof-verifier/package.json @@ -30,7 +30,7 @@ "@aztec/foundation": "workspace:^", "@aztec/noir-protocol-circuits-types": "workspace:^", "@aztec/telemetry-client": "workspace:^", - "viem": "^2.7.15" + "viem": "2.22.8" }, "devDependencies": { "@jest/globals": "^29.5.0", diff --git a/yarn-project/prover-node/package.json b/yarn-project/prover-node/package.json index 30f4084b633..cc41d180e7d 100644 --- a/yarn-project/prover-node/package.json +++ b/yarn-project/prover-node/package.json @@ -72,7 +72,7 @@ "@aztec/world-state": "workspace:^", "source-map-support": "^0.5.21", "tslib": "^2.4.0", - "viem": "^2.7.15" + "viem": "2.22.8" }, "devDependencies": { "@jest/globals": "^29.5.0", diff --git a/yarn-project/pxe/package.json b/yarn-project/pxe/package.json index 530972c30d4..4d655525ea1 100644 --- a/yarn-project/pxe/package.json +++ b/yarn-project/pxe/package.json @@ -86,7 +86,7 @@ "lodash.omit": "^4.5.0", "sha3": "^2.1.4", "tslib": "^2.4.0", - "viem": "^2.7.15" + "viem": "2.22.8" }, "devDependencies": { "@aztec/noir-contracts.js": "workspace:^", diff --git a/yarn-project/simulator/package.json b/yarn-project/simulator/package.json index c3a54db4863..e47f3d2c375 100644 --- a/yarn-project/simulator/package.json +++ b/yarn-project/simulator/package.json @@ -92,7 +92,7 @@ "lodash.merge": "^4.6.2", "ts-node": "^10.9.1", "typescript": "^5.0.4", - "viem": "^2.7.15" + "viem": "2.22.8" }, "files": [ "dest", diff --git a/yarn-project/validator-client/package.json b/yarn-project/validator-client/package.json index cba8738eb21..fcba4266bbc 100644 --- a/yarn-project/validator-client/package.json +++ b/yarn-project/validator-client/package.json @@ -73,7 +73,7 @@ "koa": "^2.14.2", "koa-router": "^12.0.0", "tslib": "^2.4.0", - "viem": "^2.7.15" + "viem": "2.22.8" }, "devDependencies": { "@jest/globals": "^29.5.0", diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 7b14fc691a5..86294bc7a3e 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -43,13 +43,6 @@ __metadata: languageName: node linkType: hard -"@adraffy/ens-normalize@npm:1.10.0": - version: 1.10.0 - resolution: "@adraffy/ens-normalize@npm:1.10.0" - checksum: 10/5cdb5d2a9c9f8c0a71a7bb830967da0069cae1f1235cd41ae11147e4000f368f6958386e622cd4d52bf45c1ed3f8275056b387cba28902b83354e40ff323ecde - languageName: node - linkType: hard - "@adraffy/ens-normalize@npm:^1.10.1": version: 1.11.0 resolution: "@adraffy/ens-normalize@npm:1.11.0" @@ -122,7 +115,7 @@ __metadata: tsc-watch: "npm:^6.0.0" tslib: "npm:^2.5.0" typescript: "npm:^5.0.4" - viem: "npm:^2.7.15" + viem: "npm:2.22.8" ws: "npm:^8.13.0" languageName: unknown linkType: soft @@ -145,7 +138,7 @@ __metadata: koa-router: "npm:^12.0.0" ts-node: "npm:^10.9.1" typescript: "npm:^5.0.4" - viem: "npm:^2.7.15" + viem: "npm:2.22.8" zod: "npm:^3.23.8" bin: aztec-faucet: ./dest/bin/index.js @@ -217,7 +210,7 @@ __metadata: tslib: "npm:^2.4.0" typescript: "npm:^5.0.4" util: "npm:^0.12.5" - viem: "npm:^2.7.15" + viem: "npm:2.22.8" webpack: "npm:^5.88.2" webpack-cli: "npm:^5.1.4" languageName: unknown @@ -286,7 +279,7 @@ __metadata: koa-router: "npm:^12.0.0" ts-node: "npm:^10.9.1" typescript: "npm:^5.0.4" - viem: "npm:^2.7.15" + viem: "npm:2.22.8" bin: aztec: ./dest/bin/index.js languageName: unknown @@ -323,7 +316,7 @@ __metadata: ts-node: "npm:^10.9.1" tslib: "npm:^2.4.0" typescript: "npm:^5.0.4" - viem: "npm:^2.7.15" + viem: "npm:2.22.8" bin: bb-cli: ./dest/bb/index.js languageName: unknown @@ -442,7 +435,7 @@ __metadata: ts-node: "npm:^10.9.1" tslib: "npm:^2.5.0" typescript: "npm:^5.0.4" - viem: "npm:^2.7.15" + viem: "npm:2.22.8" zod: "npm:^3.23.8" languageName: unknown linkType: soft @@ -537,7 +530,7 @@ __metadata: ts-node: "npm:^10.9.1" tslib: "npm:^2.4.0" typescript: "npm:^5.0.4" - viem: "npm:^2.7.15" + viem: "npm:2.22.8" peerDependencies: "@aztec/accounts": "workspace:^" "@aztec/bb-prover": "workspace:^" @@ -635,7 +628,7 @@ __metadata: tslib: "npm:^2.4.0" typescript: "npm:^5.0.4" util: "npm:^0.12.5" - viem: "npm:^2.7.15" + viem: "npm:2.22.8" webpack: "npm:^5.88.2" webpack-cli: "npm:^5.1.4" zod: "npm:^3.23.8" @@ -679,7 +672,7 @@ __metadata: ts-node: "npm:^10.9.1" tslib: "npm:^2.4.0" typescript: "npm:^5.0.4" - viem: "npm:^2.7.15" + viem: "npm:2.22.8" zod: "npm:^3.23.8" languageName: unknown linkType: soft @@ -764,7 +757,7 @@ __metadata: supertest: "npm:^6.3.3" ts-node: "npm:^10.9.1" typescript: "npm:^5.0.4" - viem: "npm:^2.7.15" + viem: "npm:2.22.8" zod: "npm:^3.23.8" languageName: unknown linkType: soft @@ -1007,7 +1000,7 @@ __metadata: tslib: "npm:^2.4.0" typescript: "npm:^5.0.4" uint8arrays: "npm:^5.0.3" - viem: "npm:^2.7.15" + viem: "npm:2.22.8" xxhash-wasm: "npm:^1.1.0" languageName: unknown linkType: soft @@ -1030,7 +1023,7 @@ __metadata: jest: "npm:^29.5.0" ts-node: "npm:^10.9.1" typescript: "npm:^5.0.4" - viem: "npm:^2.7.15" + viem: "npm:2.22.8" languageName: unknown linkType: soft @@ -1122,7 +1115,7 @@ __metadata: ts-node: "npm:^10.9.1" tslib: "npm:^2.4.0" typescript: "npm:^5.0.4" - viem: "npm:^2.7.15" + viem: "npm:2.22.8" languageName: unknown linkType: soft @@ -1161,7 +1154,7 @@ __metadata: ts-node: "npm:^10.9.1" tslib: "npm:^2.4.0" typescript: "npm:^5.0.4" - viem: "npm:^2.7.15" + viem: "npm:2.22.8" bin: pxe: ./dest/bin/index.js languageName: unknown @@ -1276,7 +1269,7 @@ __metadata: ts-node: "npm:^10.9.1" tslib: "npm:^2.4.0" typescript: "npm:^5.0.4" - viem: "npm:^2.7.15" + viem: "npm:2.22.8" languageName: unknown linkType: soft @@ -1388,7 +1381,7 @@ __metadata: ts-node: "npm:^10.9.1" tslib: "npm:^2.4.0" typescript: "npm:^5.0.4" - viem: "npm:^2.7.15" + viem: "npm:2.22.8" bin: validator-client: ./dest/bin/index.js languageName: unknown @@ -3787,15 +3780,6 @@ __metadata: languageName: node linkType: hard -"@noble/curves@npm:1.2.0, @noble/curves@npm:~1.2.0": - version: 1.2.0 - resolution: "@noble/curves@npm:1.2.0" - dependencies: - "@noble/hashes": "npm:1.3.2" - checksum: 10/94e02e9571a9fd42a3263362451849d2f54405cb3ce9fa7c45bc6b9b36dcd7d1d20e2e1e14cfded24937a13d82f1e60eefc4d7a14982ce0bc219a9fc0f51d1f9 - languageName: node - linkType: hard - "@noble/curves@npm:1.3.0, @noble/curves@npm:~1.3.0": version: 1.3.0 resolution: "@noble/curves@npm:1.3.0" @@ -3832,14 +3816,7 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:1.3.2": - version: 1.3.2 - resolution: "@noble/hashes@npm:1.3.2" - checksum: 10/685f59d2d44d88e738114b71011d343a9f7dce9dfb0a121f1489132f9247baa60bc985e5ec6f3213d114fbd1e1168e7294644e46cbd0ce2eba37994f28eeb51b - languageName: node - linkType: hard - -"@noble/hashes@npm:1.3.3, @noble/hashes@npm:~1.3.0, @noble/hashes@npm:~1.3.2": +"@noble/hashes@npm:1.3.3, @noble/hashes@npm:~1.3.2": version: 1.3.3 resolution: "@noble/hashes@npm:1.3.3" checksum: 10/1025ddde4d24630e95c0818e63d2d54ee131b980fe113312d17ed7468bc18f54486ac86c907685759f8a7e13c2f9b9e83ec7b67d1cc20836f36b5e4a65bb102d @@ -4551,7 +4528,7 @@ __metadata: languageName: node linkType: hard -"@scure/base@npm:~1.1.0, @scure/base@npm:~1.1.2, @scure/base@npm:~1.1.4": +"@scure/base@npm:~1.1.4": version: 1.1.6 resolution: "@scure/base@npm:1.1.6" checksum: 10/814fd1cce24f1e152751fabca2853d26aaa96ff8a9349c43d9aebc3b3d8ca88dd902966e1c289590a37f35d4c4436c6aedb1b386924b2909072045af4c3e9fe4 @@ -4565,17 +4542,6 @@ __metadata: languageName: node linkType: hard -"@scure/bip32@npm:1.3.2": - version: 1.3.2 - resolution: "@scure/bip32@npm:1.3.2" - dependencies: - "@noble/curves": "npm:~1.2.0" - "@noble/hashes": "npm:~1.3.2" - "@scure/base": "npm:~1.1.2" - checksum: 10/b90da28dfe75519496a85c97e77c9443734873910f32b8557762910a5c4e642290a462b0ed14fa42e0efed6acb9a7f6155ad5cb5d38d4ff87eb2de4760eb32a4 - languageName: node - linkType: hard - "@scure/bip32@npm:1.3.3": version: 1.3.3 resolution: "@scure/bip32@npm:1.3.3" @@ -4609,16 +4575,6 @@ __metadata: languageName: node linkType: hard -"@scure/bip39@npm:1.2.1": - version: 1.2.1 - resolution: "@scure/bip39@npm:1.2.1" - dependencies: - "@noble/hashes": "npm:~1.3.0" - "@scure/base": "npm:~1.1.0" - checksum: 10/2ea368bbed34d6b1701c20683bf465e147f231a9e37e639b8c82f585d6f978bb0f3855fca7ceff04954ae248b3e313f5d322d0210614fb7acb402739415aaf31 - languageName: node - linkType: hard - "@scure/bip39@npm:1.2.2": version: 1.2.2 resolution: "@scure/bip39@npm:1.2.2" @@ -6577,21 +6533,6 @@ __metadata: languageName: node linkType: hard -"abitype@npm:1.0.0": - version: 1.0.0 - resolution: "abitype@npm:1.0.0" - peerDependencies: - typescript: ">=5.0.4" - zod: ^3 >=3.22.0 - peerDependenciesMeta: - typescript: - optional: true - zod: - optional: true - checksum: 10/38c8d965c75c031854385f1c14da0410e271f1a8255332869a77a1ee836c4607420522c1f0077716c7ad7c4091f53c1b2681ed1d30b5161d1424fdb5a480f104 - languageName: node - linkType: hard - "abitype@npm:1.0.7": version: 1.0.7 resolution: "abitype@npm:1.0.7" @@ -12854,15 +12795,6 @@ __metadata: languageName: node linkType: hard -"isows@npm:1.0.3": - version: 1.0.3 - resolution: "isows@npm:1.0.3" - peerDependencies: - ws: "*" - checksum: 10/9cacd5cf59f67deb51e825580cd445ab1725ecb05a67c704050383fb772856f3cd5e7da8ad08f5a3bd2823680d77d099459d0c6a7037972a74d6429af61af440 - languageName: node - linkType: hard - "isows@npm:1.0.6": version: 1.0.6 resolution: "isows@npm:1.0.6" @@ -19730,27 +19662,6 @@ __metadata: languageName: node linkType: hard -"viem@npm:^2.7.15": - version: 2.10.2 - resolution: "viem@npm:2.10.2" - dependencies: - "@adraffy/ens-normalize": "npm:1.10.0" - "@noble/curves": "npm:1.2.0" - "@noble/hashes": "npm:1.3.2" - "@scure/bip32": "npm:1.3.2" - "@scure/bip39": "npm:1.2.1" - abitype: "npm:1.0.0" - isows: "npm:1.0.3" - ws: "npm:8.13.0" - peerDependencies: - typescript: ">=5.0.4" - peerDependenciesMeta: - typescript: - optional: true - checksum: 10/b59650e7c5b92dc9b14de296426c771f3061801e2556a134b983f019f01c9bfe919217b5355c0ab4df7b7effa6ba9037387baa43290b7710af148e77d368cb89 - languageName: node - linkType: hard - "vite@npm:^4.2.3": version: 4.5.3 resolution: "vite@npm:4.5.3" @@ -20249,21 +20160,6 @@ __metadata: languageName: node linkType: hard -"ws@npm:8.13.0": - version: 8.13.0 - resolution: "ws@npm:8.13.0" - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ">=5.0.2" - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - checksum: 10/1769532b6fdab9ff659f0b17810e7501831d34ecca23fd179ee64091dd93a51f42c59f6c7bb4c7a384b6c229aca8076fb312aa35626257c18081511ef62a161d - languageName: node - linkType: hard - "ws@npm:8.18.0, ws@npm:^8.18.0": version: 8.18.0 resolution: "ws@npm:8.18.0" From e3bc1736be0ad1cbd7e24f87789e5c92e63beda5 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 14 Jan 2025 15:22:22 +0000 Subject: [PATCH 05/57] fix more typings --- yarn-project/ethereum/src/contracts/rollup.ts | 2 +- yarn-project/p2p/src/mem_pools/attestation_pool/mocks.ts | 4 ++-- yarn-project/prover-node/src/bond/factory.ts | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/yarn-project/ethereum/src/contracts/rollup.ts b/yarn-project/ethereum/src/contracts/rollup.ts index cbaf9d689e0..d839b58543b 100644 --- a/yarn-project/ethereum/src/contracts/rollup.ts +++ b/yarn-project/ethereum/src/contracts/rollup.ts @@ -20,7 +20,7 @@ import { type L1ReaderConfig } from '../l1_reader.js'; export class RollupContract { private readonly rollup: GetContractReturnType>; - constructor(public readonly client: PublicClient, address: Hex) { + constructor(public readonly client: PublicClient, address: Hex) { this.rollup = getContract({ address, abi: RollupAbi, client }); } diff --git a/yarn-project/p2p/src/mem_pools/attestation_pool/mocks.ts b/yarn-project/p2p/src/mem_pools/attestation_pool/mocks.ts index 7cbf84dfcbe..0d29cb8b2b9 100644 --- a/yarn-project/p2p/src/mem_pools/attestation_pool/mocks.ts +++ b/yarn-project/p2p/src/mem_pools/attestation_pool/mocks.ts @@ -9,14 +9,14 @@ import { makeHeader } from '@aztec/circuits.js/testing'; import { type Secp256k1Signer } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; -import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'; +import { type LocalAccount, generatePrivateKey, privateKeyToAccount } from 'viem/accounts'; /** Generate Account * * Create a random signer * @returns A random viem signer */ -export const generateAccount = () => { +export const generateAccount = (): LocalAccount => { const privateKey = generatePrivateKey(); return privateKeyToAccount(privateKey); }; diff --git a/yarn-project/prover-node/src/bond/factory.ts b/yarn-project/prover-node/src/bond/factory.ts index 9e7db80de55..7ae0e03164b 100644 --- a/yarn-project/prover-node/src/bond/factory.ts +++ b/yarn-project/prover-node/src/bond/factory.ts @@ -8,10 +8,10 @@ import { type GetContractReturnType, type HttpTransport, type PrivateKeyAccount, - type PublicActions, - type PublicClient, + type PublicActions, // type PublicClient, type PublicRpcSchema, type WalletActions, + type WalletClient, type WalletRpcSchema, } from 'viem'; @@ -21,7 +21,7 @@ import { EscrowContract } from './escrow-contract.js'; import { TokenContract } from './token-contract.js'; export async function createBondManager( - rollupContract: GetContractReturnType, + rollupContract: GetContractReturnType>, client: Client< HttpTransport, Chain, From 2ed14da0d87b569b339fb43a5d55a9cb94be4c45 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 14 Jan 2025 15:54:17 +0000 Subject: [PATCH 06/57] restore block validation --- .../src/publisher/l1-publisher.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 0584133bfc7..bafc4d601f9 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -1,10 +1,12 @@ import { type BlobSinkClientInterface, createBlobSinkClient } from '@aztec/blob-sink/client'; import { - // ConsensusPayload, + ConsensusPayload, type EpochProofClaim, type EpochProofQuote, - type L2Block, // SignatureDomainSeparator, - type TxHash, // getHashedSignaturePayload, + type L2Block, + SignatureDomainSeparator, + type TxHash, + getHashedSignaturePayload, } from '@aztec/circuit-types'; import { type L1PublishBlockStats, type L1PublishProofStats, type L1PublishStats } from '@aztec/circuit-types/stats'; import { @@ -581,9 +583,9 @@ export class L1Publisher { blockHash: block.hash().toString(), }; - // const consensusPayload = new ConsensusPayload(block.header, block.archive.root, txHashes ?? []); + const consensusPayload = new ConsensusPayload(block.header, block.archive.root, txHashes ?? []); - // const digest = getHashedSignaturePayload(consensusPayload, SignatureDomainSeparator.blockAttestation); + const digest = getHashedSignaturePayload(consensusPayload, SignatureDomainSeparator.blockAttestation); const blobs = Blob.getBlobs(block.body.toBlobFields()); const proposeTxArgs = { @@ -608,10 +610,10 @@ export class L1Publisher { // This means that we can avoid the simulation issues in later checks. // By simulation issue, I mean the fact that the block.timestamp is equal to the last block, not the next, which // make time consistency checks break. - // await this.validateBlockForSubmission(block.header, { - // digest: digest.toBuffer(), - // signatures: attestations ?? [], - // }); + await this.validateBlockForSubmission(block.header, { + digest: digest.toBuffer(), + signatures: attestations ?? [], + }); this.log.debug(`Submitting propose transaction`); const result = proofQuote From 950d9ca09ce4d2ae586f8529455e94d204846c23 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 14 Jan 2025 16:22:10 +0000 Subject: [PATCH 07/57] =?UTF-8?q?remove=20typo=20=F0=9F=98=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yarn-project/ethereum/src/l1_tx_utils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index 13dc4a56d8d..fdde17de4f6 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -225,7 +225,6 @@ export class L1TxUtils { txHash = await this.walletClient.sendTransaction({ ...request, ...blobInputs, - blobs: [], gas: gasLimit, maxFeePerGas: gasPrice.maxFeePerGas, maxPriorityFeePerGas: gasPrice.maxPriorityFeePerGas, From 05cd25e0bb5bd8093bf6dc6c4aba4a68a40729b8 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 14 Jan 2025 17:24:33 +0000 Subject: [PATCH 08/57] handle node not supporting simulation --- yarn-project/ethereum/src/l1_tx_utils.ts | 54 +++++++++++++------ .../src/publisher/l1-publisher.ts | 18 ++++++- 2 files changed, 53 insertions(+), 19 deletions(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index fdde17de4f6..441fce4ccd2 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -12,11 +12,14 @@ import { sleep } from '@aztec/foundation/sleep'; import { type Account, type Address, + BaseError, type BlockOverrides, type Chain, type GetTransactionReturnType, type Hex, type HttpTransport, + MethodNotFoundRpcError, + MethodNotSupportedRpcError, type PublicClient, type TransactionReceipt, type WalletClient, @@ -565,22 +568,39 @@ export class L1TxUtils { return withBuffer; } - public async simulateGasUsed(request: L1TxRequest, blockOverrides: BlockOverrides): Promise { - const result = await this.publicClient.simulate({ - validation: true, - blocks: [ - { - blockOverrides, - calls: [ - { - from: this.walletClient.account.address, - to: request.to!, - data: request.data, - }, - ], - }, - ], - }); - return result[0].calls[0].gasUsed; + public async simulateGasUsed( + request: L1TxRequest, + _gasConfig?: L1TxUtilsConfig, + blockOverrides: BlockOverrides = {}, + ): Promise { + const gasConfig = { ...this.config, ..._gasConfig }; + const gasPrice = await this.getGasPrice(gasConfig, false); + try { + const result = await this.publicClient.simulate({ + validation: true, + blocks: [ + { + blockOverrides, + calls: [ + { + from: this.walletClient.account.address, + to: request.to!, + data: request.data, + maxFeePerGas: gasPrice.maxFeePerGas, + maxPriorityFeePerGas: gasPrice.maxPriorityFeePerGas, + }, + ], + }, + ], + }); + return result[0].calls[0].gasUsed; + } catch (err) { + if (err instanceof MethodNotFoundRpcError || err instanceof MethodNotSupportedRpcError) { + // Node doesn't support simulation, return -1n gas estimate + this.logger?.error('Node does not support simulation API'); + return -1n; + } + throw err; + } } } diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index bafc4d601f9..8ff7a9c7a94 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -1081,16 +1081,22 @@ export class L1Publisher { args, }); const time = BigInt((await this.publicClient.getBlock()).timestamp + this.ethereumSlotDuration); - const simulationResult = await this.l1TxUtils.simulateGasUsed( + let simulationResult = await this.l1TxUtils.simulateGasUsed( { to: this.rollupContract.address, data, }, + undefined, { time, }, ); + if (simulationResult === -1n) { + this.log.warn('Node does not support simulation API. Using gas guesstimate'); + simulationResult = L1Publisher.PROPOSE_GAS_GUESS; + } + const result = await this.l1TxUtils.sendAndMonitorTransaction( { to: this.rollupContract.address, @@ -1135,15 +1141,23 @@ export class L1Publisher { args: [...args, quote.toViemArgs()], }); const time = BigInt((await this.publicClient.getBlock()).timestamp + this.ethereumSlotDuration); - const simulationResult = await this.l1TxUtils.simulateGasUsed( + + let simulationResult = await this.l1TxUtils.simulateGasUsed( { to: this.rollupContract.address, data, }, + undefined, { time, }, ); + + if (simulationResult === -1n) { + this.log.warn('Node does not support simulation API. Using gas guesstimate'); + simulationResult = L1Publisher.PROPOSE_GAS_GUESS; + } + const result = await this.l1TxUtils.sendAndMonitorTransaction( { to: this.rollupContract.address, From 499bb74d6c5530b0b4f50583e368ea05090a370a Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 14 Jan 2025 17:48:26 +0000 Subject: [PATCH 09/57] rm unused import --- yarn-project/ethereum/src/l1_tx_utils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index 441fce4ccd2..f357e7c4bb6 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -12,7 +12,6 @@ import { sleep } from '@aztec/foundation/sleep'; import { type Account, type Address, - BaseError, type BlockOverrides, type Chain, type GetTransactionReturnType, From aa9cb1203b30cb88cc10a94ffd7d15ad573ddb70 Mon Sep 17 00:00:00 2001 From: spypsy Date: Wed, 15 Jan 2025 14:16:20 +0000 Subject: [PATCH 10/57] fix archiver tests --- .../archiver/src/archiver/archiver.test.ts | 102 ++++++++++++------ 1 file changed, 68 insertions(+), 34 deletions(-) diff --git a/yarn-project/archiver/src/archiver/archiver.test.ts b/yarn-project/archiver/src/archiver/archiver.test.ts index e79d48becd4..658512eed07 100644 --- a/yarn-project/archiver/src/archiver/archiver.test.ts +++ b/yarn-project/archiver/src/archiver/archiver.test.ts @@ -38,6 +38,20 @@ interface MockInboxContractRead { totalMessagesInserted: () => Promise; } +interface MockRollupContractEvents { + L2BlockProposed: ( + filter: any, + range: { fromBlock: bigint; toBlock: bigint }, + ) => Promise[]>; +} + +interface MockInboxContractEvents { + MessageSent: ( + filter: any, + range: { fromBlock: bigint; toBlock: bigint }, + ) => Promise[]>; +} + describe('Archiver', () => { const rollupAddress = EthAddress.ZERO; const inboxAddress = EthAddress.ZERO; @@ -59,8 +73,18 @@ describe('Archiver', () => { let now: number; let l1Constants: L1RollupConstants; - let rollupRead: MockProxy; - let inboxRead: MockProxy; + let mockRollupRead: MockProxy; + let mockInboxRead: MockProxy; + let mockRollupEvents: MockProxy; + let mockInboxEvents: MockProxy; + let mockRollup: { + read: typeof mockRollupRead; + getEvents: typeof mockRollupEvents; + }; + let mockInbox: { + read: typeof mockInboxRead; + getEvents: typeof mockInboxEvents; + }; let archiver: Archiver; let blocks: L2Block[]; @@ -79,20 +103,6 @@ describe('Archiver', () => { getBlock: ((args: any) => ({ timestamp: args.blockNumber * BigInt(DefaultL1ContractsConfig.ethereumSlotDuration) + BigInt(now), })) as any, - // Return the logs mocked whenever the public client is queried - getLogs: ((args: any) => { - let logs = undefined; - if (args!.event!.name === 'MessageSent') { - logs = l2MessageSentLogs; - } else if (args!.event!.name === 'L2BlockProposed') { - logs = l2BlockProposedLogs; - } else { - throw new Error(`Unknown event: ${args!.event!.name}`); - } - return Promise.resolve( - logs.filter(log => log.blockNumber >= args.fromBlock && log.blockNumber <= args.toBlock), - ); - }) as any, }); blobSinkClient = mock(); @@ -126,15 +136,36 @@ describe('Archiver', () => { }); }); - rollupRead = mock(); - rollupRead.archiveAt.mockImplementation((args: readonly [bigint]) => + mockRollupRead = mock(); + mockRollupRead.archiveAt.mockImplementation((args: readonly [bigint]) => Promise.resolve(blocks[Number(args[0] - 1n)].archive.root.toString()), ); + mockRollupEvents = mock(); + mockRollupEvents.L2BlockProposed.mockImplementation(async (filter: any, { fromBlock, toBlock }) => { + return Promise.resolve( + l2BlockProposedLogs.filter(log => log.blockNumber! >= fromBlock && log.blockNumber! <= toBlock), + ); + }); + mockRollup = { + read: mockRollupRead, + getEvents: mockRollupEvents, + }; - ((archiver as any).rollup as any).read = rollupRead; + (archiver as any).rollup = mockRollup; - inboxRead = mock(); - ((archiver as any).inbox as any).read = inboxRead; + mockInboxRead = mock(); + mockInboxRead.totalMessagesInserted.mockImplementation(() => Promise.resolve(123n)); + mockInboxEvents = mock(); + mockInboxEvents.MessageSent.mockImplementation(async (filter: any, { fromBlock, toBlock }) => { + return Promise.resolve( + l2MessageSentLogs.filter(log => log.blockNumber! >= fromBlock && log.blockNumber! <= toBlock), + ); + }); + mockInbox = { + read: mockInboxRead, + getEvents: mockInboxEvents, + }; + (archiver as any).inbox = mockInbox; l2MessageSentLogs = []; l2BlockProposedLogs = []; @@ -156,7 +187,7 @@ describe('Archiver', () => { publicClient.getBlockNumber.mockResolvedValueOnce(2500n).mockResolvedValueOnce(2600n).mockResolvedValueOnce(2700n); - rollupRead.status + mockRollup.read.status .mockResolvedValueOnce([0n, GENESIS_ROOT, 1n, blocks[0].archive.root.toString(), GENESIS_ROOT]) .mockResolvedValue([ 1n, @@ -166,7 +197,10 @@ describe('Archiver', () => { blocks[0].archive.root.toString(), ]); - inboxRead.totalMessagesInserted.mockResolvedValueOnce(2n).mockResolvedValueOnce(6n); + mockInbox.read.totalMessagesInserted + .mockResolvedValueOnce(123n) + .mockResolvedValueOnce(2n) + .mockResolvedValueOnce(6n); makeMessageSentEvent(98n, 1n, 0n); makeMessageSentEvent(99n, 1n, 1n); @@ -254,9 +288,9 @@ describe('Archiver', () => { const badArchive = Fr.random().toString(); - rollupRead.status.mockResolvedValue([0n, GENESIS_ROOT, 2n, blocks[1].archive.root.toString(), GENESIS_ROOT]); + mockRollup.read.status.mockResolvedValue([0n, GENESIS_ROOT, 2n, blocks[1].archive.root.toString(), GENESIS_ROOT]); - inboxRead.totalMessagesInserted.mockResolvedValueOnce(2n).mockResolvedValueOnce(2n); + mockInbox.read.totalMessagesInserted.mockResolvedValueOnce(2n).mockResolvedValueOnce(2n); makeMessageSentEvent(66n, 1n, 0n); makeMessageSentEvent(68n, 1n, 1n); @@ -291,11 +325,11 @@ describe('Archiver', () => { const rollupTxs = blocks.map(makeRollupTx); publicClient.getBlockNumber.mockResolvedValueOnce(50n).mockResolvedValueOnce(100n); - rollupRead.status + mockRollup.read.status .mockResolvedValueOnce([0n, GENESIS_ROOT, 0n, GENESIS_ROOT, GENESIS_ROOT]) .mockResolvedValueOnce([0n, GENESIS_ROOT, 2n, blocks[1].archive.root.toString(), GENESIS_ROOT]); - inboxRead.totalMessagesInserted.mockResolvedValueOnce(0n).mockResolvedValueOnce(2n); + mockInbox.read.totalMessagesInserted.mockResolvedValueOnce(0n).mockResolvedValueOnce(2n); makeMessageSentEvent(66n, 1n, 0n); makeMessageSentEvent(68n, 1n, 1n); @@ -329,17 +363,17 @@ describe('Archiver', () => { // We will return status at first to have an empty round, then as if we have 2 pending blocks, and finally // Just a single pending block returning a "failure" for the expected pending block - rollupRead.status + mockRollup.read.status .mockResolvedValueOnce([0n, GENESIS_ROOT, 0n, GENESIS_ROOT, GENESIS_ROOT]) .mockResolvedValueOnce([0n, GENESIS_ROOT, 2n, blocks[1].archive.root.toString(), GENESIS_ROOT]) .mockResolvedValueOnce([0n, GENESIS_ROOT, 1n, blocks[0].archive.root.toString(), Fr.ZERO.toString()]); - rollupRead.archiveAt + mockRollup.read.archiveAt .mockResolvedValueOnce(blocks[0].archive.root.toString()) .mockResolvedValueOnce(blocks[1].archive.root.toString()) .mockResolvedValueOnce(Fr.ZERO.toString()); - inboxRead.totalMessagesInserted + mockInbox.read.totalMessagesInserted .mockResolvedValueOnce(0n) .mockResolvedValueOnce(2n) .mockResolvedValueOnce(2n) @@ -394,7 +428,7 @@ describe('Archiver', () => { const rollupTxs = blocks.map(makeRollupTx); publicClient.getBlockNumber.mockResolvedValueOnce(l1BlockForL2Block); - rollupRead.status.mockResolvedValueOnce([0n, GENESIS_ROOT, 1n, l2Block.archive.root.toString(), GENESIS_ROOT]); + mockRollup.read.status.mockResolvedValueOnce([0n, GENESIS_ROOT, 1n, l2Block.archive.root.toString(), GENESIS_ROOT]); makeL2BlockProposedEvent(l1BlockForL2Block, 1n, l2Block.archive.root.toString()); rollupTxs.forEach(tx => publicClient.getTransaction.mockResolvedValueOnce(tx)); @@ -425,7 +459,7 @@ describe('Archiver', () => { const rollupTxs = blocks.map(makeRollupTx); publicClient.getBlockNumber.mockResolvedValueOnce(l1BlockForL2Block); - rollupRead.status.mockResolvedValueOnce([0n, GENESIS_ROOT, 1n, l2Block.archive.root.toString(), GENESIS_ROOT]); + mockRollup.read.status.mockResolvedValueOnce([0n, GENESIS_ROOT, 1n, l2Block.archive.root.toString(), GENESIS_ROOT]); makeL2BlockProposedEvent(l1BlockForL2Block, 1n, l2Block.archive.root.toString()); rollupTxs.forEach(tx => publicClient.getTransaction.mockResolvedValueOnce(tx)); @@ -450,7 +484,7 @@ describe('Archiver', () => { logger.info(`Syncing archiver to L1 block ${notLastL1BlockForEpoch}`); publicClient.getBlockNumber.mockResolvedValueOnce(notLastL1BlockForEpoch); - rollupRead.status.mockResolvedValueOnce([0n, GENESIS_ROOT, 0n, GENESIS_ROOT, GENESIS_ROOT]); + mockRollup.read.status.mockResolvedValueOnce([0n, GENESIS_ROOT, 0n, GENESIS_ROOT, GENESIS_ROOT]); await archiver.start(true); expect(await archiver.isEpochComplete(0n)).toBe(false); @@ -463,7 +497,7 @@ describe('Archiver', () => { logger.info(`Syncing archiver to L1 block ${lastL1BlockForEpoch}`); publicClient.getBlockNumber.mockResolvedValueOnce(lastL1BlockForEpoch); - rollupRead.status.mockResolvedValueOnce([0n, GENESIS_ROOT, 0n, GENESIS_ROOT, GENESIS_ROOT]); + mockRollup.read.status.mockResolvedValueOnce([0n, GENESIS_ROOT, 0n, GENESIS_ROOT, GENESIS_ROOT]); await archiver.start(true); expect(await archiver.isEpochComplete(0n)).toBe(true); From 8e966be0e72ecc1bb8db68b0f8f420b13d7e449a Mon Sep 17 00:00:00 2001 From: spypsy Date: Wed, 15 Jan 2025 18:03:28 +0000 Subject: [PATCH 11/57] bump simulated gas as well --- .../archiver/src/archiver/archiver.test.ts | 4 ++-- yarn-project/ethereum/src/l1_tx_utils.ts | 17 +++++++++++------ .../src/publisher/l1-publisher.ts | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/yarn-project/archiver/src/archiver/archiver.test.ts b/yarn-project/archiver/src/archiver/archiver.test.ts index 658512eed07..137bf8a2cbb 100644 --- a/yarn-project/archiver/src/archiver/archiver.test.ts +++ b/yarn-project/archiver/src/archiver/archiver.test.ts @@ -142,7 +142,7 @@ describe('Archiver', () => { ); mockRollupEvents = mock(); mockRollupEvents.L2BlockProposed.mockImplementation(async (filter: any, { fromBlock, toBlock }) => { - return Promise.resolve( + return await Promise.resolve( l2BlockProposedLogs.filter(log => log.blockNumber! >= fromBlock && log.blockNumber! <= toBlock), ); }); @@ -157,7 +157,7 @@ describe('Archiver', () => { mockInboxRead.totalMessagesInserted.mockImplementation(() => Promise.resolve(123n)); mockInboxEvents = mock(); mockInboxEvents.MessageSent.mockImplementation(async (filter: any, { fromBlock, toBlock }) => { - return Promise.resolve( + return await Promise.resolve( l2MessageSentLogs.filter(log => log.blockNumber! >= fromBlock && log.blockNumber! <= toBlock), ); }); diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index f357e7c4bb6..da3d5008ec7 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -98,9 +98,9 @@ export interface L1TxUtilsConfig { export const l1TxUtilsConfigMappings: ConfigMappingsType = { gasLimitBufferPercentage: { - description: 'How much to increase gas price by each attempt (percentage)', + description: 'How much to increase calculated gas limit by (percentage)', env: 'L1_GAS_LIMIT_BUFFER_PERCENTAGE', - ...numberConfigHelper(10), + ...numberConfigHelper(15), }, minGwei: { description: 'Minimum gas price in gwei', @@ -202,7 +202,7 @@ export class L1TxUtils { */ public async sendTransaction( request: L1TxRequest, - _gasConfig?: Partial & { fixedGas?: bigint; txTimeoutAt?: Date }, + _gasConfig?: Partial & { fixedGas?: bigint; gasLimit?: bigint; txTimeoutAt?: Date }, blobInputs?: L1BlobInputs, ): Promise<{ txHash: Hex; gasLimit: bigint; gasPrice: GasPrice }> { try { @@ -212,6 +212,8 @@ export class L1TxUtils { if (gasConfig.fixedGas) { gasLimit = gasConfig.fixedGas; + } else if (gasConfig.gasLimit) { + gasLimit = this.bumpGasLimit(gasConfig.gasLimit, gasConfig); } else { gasLimit = await this.estimateGas(account, request); } @@ -406,7 +408,7 @@ export class L1TxUtils { */ public async sendAndMonitorTransaction( request: L1TxRequest, - gasConfig?: Partial & { fixedGas?: bigint; txTimeoutAt?: Date }, + gasConfig?: Partial & { fixedGas?: bigint; gasLimit?: bigint; txTimeoutAt?: Date }, blobInputs?: L1BlobInputs, ): Promise<{ receipt: TransactionReceipt; gasPrice: GasPrice }> { const { txHash, gasLimit, gasPrice } = await this.sendTransaction(request, gasConfig, blobInputs); @@ -561,8 +563,7 @@ export class L1TxUtils { } // Add buffer based on either fixed amount or percentage - const withBuffer = - initialEstimate + (initialEstimate * BigInt((gasConfig.gasLimitBufferPercentage || 0) * 1_00)) / 100_00n; + const withBuffer = this.bumpGasLimit(initialEstimate, gasConfig); return withBuffer; } @@ -602,4 +603,8 @@ export class L1TxUtils { throw err; } } + + private bumpGasLimit(gasLimit: bigint, gasConfig: L1TxUtilsConfig): bigint { + return gasLimit + (gasLimit * BigInt((gasConfig.gasLimitBufferPercentage || 0) * 1_00)) / 100_00n; + } } diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 8ff7a9c7a94..2cd17a298bb 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -1103,7 +1103,7 @@ export class L1Publisher { data, }, { - fixedGas: simulationResult + blobEvaluationGas, + gasLimit: simulationResult + blobEvaluationGas, ...opts, }, { @@ -1164,7 +1164,7 @@ export class L1Publisher { data, }, { - fixedGas: simulationResult + blobEvaluationGas, + gasLimit: simulationResult + blobEvaluationGas, ...opts, }, { From 13b3d895cafc353077e83cec958aeb6e32309136 Mon Sep 17 00:00:00 2001 From: spypsy Date: Wed, 15 Jan 2025 18:11:03 +0000 Subject: [PATCH 12/57] add logging to simulation --- yarn-project/ethereum/src/l1_tx_utils.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index da3d5008ec7..530fa0ebff8 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -593,6 +593,11 @@ export class L1TxUtils { }, ], }); + this.logger?.debug('Gas used in simulation', { + gasUsed: result[0].calls[0].gasUsed, + gasLimit: result[0].calls[0].gasLimit, + result: result, + }); return result[0].calls[0].gasUsed; } catch (err) { if (err instanceof MethodNotFoundRpcError || err instanceof MethodNotSupportedRpcError) { From 111a6403bb311e8c4a1ca3704a716db6aebb29af Mon Sep 17 00:00:00 2001 From: spypsy Date: Wed, 15 Jan 2025 18:17:46 +0000 Subject: [PATCH 13/57] fix log --- yarn-project/ethereum/src/l1_tx_utils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index 530fa0ebff8..05805fd0681 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -595,7 +595,6 @@ export class L1TxUtils { }); this.logger?.debug('Gas used in simulation', { gasUsed: result[0].calls[0].gasUsed, - gasLimit: result[0].calls[0].gasLimit, result: result, }); return result[0].calls[0].gasUsed; From 77968f553293511bbac10947a9ca8e42d9e71ab7 Mon Sep 17 00:00:00 2001 From: spypsy Date: Wed, 15 Jan 2025 19:37:14 +0000 Subject: [PATCH 14/57] add logging, significantly bump evaluated gas --- yarn-project/ethereum/src/l1_tx_utils.ts | 9 ++++++--- .../sequencer-client/src/publisher/l1-publisher.ts | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index 05805fd0681..aca757a6661 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -311,15 +311,16 @@ export class L1TxUtils { try { const receipt = await this.publicClient.getTransactionReceipt({ hash }); if (receipt) { - this.logger?.debug(`L1 transaction ${hash} mined`); if (receipt.status === 'reverted') { - this.logger?.error(`L1 transaction ${hash} reverted`); + this.logger?.error(`L1 transaction ${hash} reverted`, receipt); + } else { + this.logger?.debug(`L1 transaction ${hash} mined`); } return receipt; } } catch (err) { if (err instanceof Error && err.message.includes('reverted')) { - throw err; + throw formatViemError(err); } } } @@ -558,8 +559,10 @@ export class L1TxUtils { maxFeePerBlobGas: gasPrice.maxFeePerBlobGas!, }) )?.gas; + this.logger?.debug('Gas used in estimateGas by blob tx', { gas: initialEstimate }); } else { initialEstimate = await this.publicClient.estimateGas({ account, ...request }); + this.logger?.debug('Gas used in estimateGas by non-blob tx', { gas: initialEstimate }); } // Add buffer based on either fixed amount or percentage diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 2cd17a298bb..741c958c7a5 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -1103,8 +1103,9 @@ export class L1Publisher { data, }, { - gasLimit: simulationResult + blobEvaluationGas, ...opts, + gasLimit: simulationResult + blobEvaluationGas, + gasLimitBufferPercentage: 100, }, { blobs: encodedData.blobs.map(b => b.dataWithZeros), @@ -1164,8 +1165,9 @@ export class L1Publisher { data, }, { - gasLimit: simulationResult + blobEvaluationGas, ...opts, + gasLimit: simulationResult + blobEvaluationGas, + gasLimitBufferPercentage: 100, }, { blobs: encodedData.blobs.map(b => b.dataWithZeros), From b5b85e1a89ab20413ab17f55e024fb2ccbe09513 Mon Sep 17 00:00:00 2001 From: spypsy Date: Wed, 15 Jan 2025 21:03:50 +0000 Subject: [PATCH 15/57] use same timestamp with validateHeader & check simulation status --- yarn-project/ethereum/src/l1_tx_utils.ts | 8 +++++++- .../src/publisher/l1-publisher.ts | 17 +++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index aca757a6661..edfeb5cc63d 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -600,7 +600,13 @@ export class L1TxUtils { gasUsed: result[0].calls[0].gasUsed, result: result, }); - return result[0].calls[0].gasUsed; + if (result[0].calls[0].status === 'failure') { + this.logger?.error('Simulation failed', { + error: result[0].calls[0].error, + }); + throw new Error(`Simulation failed with error: ${result[0].calls[0].error.message}`); + } + return result[0].gasUsed; } catch (err) { if (err instanceof MethodNotFoundRpcError || err instanceof MethodNotSupportedRpcError) { // Node doesn't support simulation, return -1n gas estimate diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 741c958c7a5..ae69ce36acc 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -417,7 +417,7 @@ export class L1Publisher { digest: Buffer.alloc(32), signatures: [], }, - ): Promise { + ): Promise { const ts = BigInt((await this.publicClient.getBlock()).timestamp + this.ethereumSlotDuration); const formattedSignatures = attestationData.signatures.map(attest => attest.toViemSignature()); @@ -442,6 +442,7 @@ export class L1Publisher { } throw error; } + return ts; } public async getCurrentEpochCommittee(): Promise { @@ -610,15 +611,15 @@ export class L1Publisher { // This means that we can avoid the simulation issues in later checks. // By simulation issue, I mean the fact that the block.timestamp is equal to the last block, not the next, which // make time consistency checks break. - await this.validateBlockForSubmission(block.header, { + const ts = await this.validateBlockForSubmission(block.header, { digest: digest.toBuffer(), signatures: attestations ?? [], }); this.log.debug(`Submitting propose transaction`); const result = proofQuote - ? await this.sendProposeAndClaimTx(proposeTxArgs, proofQuote, opts) - : await this.sendProposeTx(proposeTxArgs, opts); + ? await this.sendProposeAndClaimTx(proposeTxArgs, proofQuote, opts, ts) + : await this.sendProposeTx(proposeTxArgs, opts, ts); if (!result?.receipt) { this.log.info(`Failed to publish block ${block.number} to L1`, ctx); @@ -1068,6 +1069,7 @@ export class L1Publisher { private async sendProposeTx( encodedData: L1ProcessArgs, opts: { txTimeoutAt?: Date } = {}, + timestamp: bigint, ): Promise { if (this.interrupted) { return undefined; @@ -1080,7 +1082,6 @@ export class L1Publisher { functionName: 'propose', args, }); - const time = BigInt((await this.publicClient.getBlock()).timestamp + this.ethereumSlotDuration); let simulationResult = await this.l1TxUtils.simulateGasUsed( { to: this.rollupContract.address, @@ -1088,7 +1089,7 @@ export class L1Publisher { }, undefined, { - time, + time: timestamp, }, ); @@ -1129,6 +1130,7 @@ export class L1Publisher { encodedData: L1ProcessArgs, quote: EpochProofQuote, opts: { txTimeoutAt?: Date } = {}, + timestamp: bigint, ): Promise { if (this.interrupted) { return undefined; @@ -1141,7 +1143,6 @@ export class L1Publisher { functionName: 'proposeAndClaim', args: [...args, quote.toViemArgs()], }); - const time = BigInt((await this.publicClient.getBlock()).timestamp + this.ethereumSlotDuration); let simulationResult = await this.l1TxUtils.simulateGasUsed( { @@ -1150,7 +1151,7 @@ export class L1Publisher { }, undefined, { - time, + time: timestamp, }, ); From aac861126ffec2d388f99cfea99ac068c3f4d7d4 Mon Sep 17 00:00:00 2001 From: spypsy Date: Wed, 15 Jan 2025 23:12:13 +0000 Subject: [PATCH 16/57] temp fix test --- .../sequencer-client/src/sequencer/sequencer.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts b/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts index 76d19334f51..514fb925e2b 100644 --- a/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts +++ b/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts @@ -159,7 +159,7 @@ describe('sequencer', () => { publisher.getSenderAddress.mockImplementation(() => EthAddress.random()); publisher.getCurrentEpochCommittee.mockResolvedValue(committee); publisher.canProposeAtNextEthBlock.mockResolvedValue([BigInt(newSlotNumber), BigInt(newBlockNumber)]); - publisher.validateBlockForSubmission.mockResolvedValue(); + publisher.validateBlockForSubmission.mockResolvedValue(1n); publisher.proposeL2Block.mockResolvedValue(true); globalVariableBuilder = mock(); @@ -316,7 +316,7 @@ describe('sequencer', () => { // Now it is! publisher.validateBlockForSubmission.mockClear(); - publisher.validateBlockForSubmission.mockResolvedValue(); + publisher.validateBlockForSubmission.mockResolvedValue(1n); await sequencer.doRealWork(); expect(blockBuilder.startNewBlock).toHaveBeenCalledWith( @@ -453,7 +453,7 @@ describe('sequencer', () => { block = await makeBlock([tx]); // This could practically be for any reason, e.g., could also be that we have entered a new slot. - publisher.validateBlockForSubmission.mockResolvedValueOnce().mockRejectedValueOnce(new Error('No block for you')); + publisher.validateBlockForSubmission.mockResolvedValueOnce(1n).mockRejectedValueOnce(new Error('No block for you')); await sequencer.doRealWork(); From 6a27978c93c8ef95d44ae4d66b8a56c5ab470747 Mon Sep 17 00:00:00 2001 From: spypsy Date: Thu, 16 Jan 2025 01:12:45 +0000 Subject: [PATCH 17/57] log blob inputs --- yarn-project/ethereum/src/l1_tx_utils.ts | 1 + yarn-project/sequencer-client/src/publisher/l1-publisher.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index edfeb5cc63d..c34207ef905 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -551,6 +551,7 @@ export class L1TxUtils { // See: https://github.com/wevm/viem/issues/2075 if (_blobInputs) { const gasPrice = await this.getGasPrice(gasConfig, true, 0); + this.logger?.debug('estimateGas with blob inputs', { gasPrice, blobInputs: _blobInputs }); initialEstimate = ( await this.walletClient.prepareTransactionRequest({ account, diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index ae69ce36acc..a303ac0d4fc 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -1082,6 +1082,7 @@ export class L1Publisher { functionName: 'propose', args, }); + this.log.debug('simulateGasUsed with blob inputs', { blobInputs: args[3] }); let simulationResult = await this.l1TxUtils.simulateGasUsed( { to: this.rollupContract.address, From 506e398105e34f8e4376495369aba46ace4851b9 Mon Sep 17 00:00:00 2001 From: spypsy Date: Thu, 16 Jan 2025 10:08:00 +0000 Subject: [PATCH 18/57] better logging --- yarn-project/ethereum/src/l1_tx_utils.ts | 1 - .../src/publisher/l1-publisher.ts | 30 +++---------------- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index c34207ef905..edfeb5cc63d 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -551,7 +551,6 @@ export class L1TxUtils { // See: https://github.com/wevm/viem/issues/2075 if (_blobInputs) { const gasPrice = await this.getGasPrice(gasConfig, true, 0); - this.logger?.debug('estimateGas with blob inputs', { gasPrice, blobInputs: _blobInputs }); initialEstimate = ( await this.walletClient.prepareTransactionRequest({ account, diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index a303ac0d4fc..6761bc6383d 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -963,6 +963,8 @@ export class L1Publisher { private async prepareProposeTx(encodedData: L1ProcessArgs) { const kzg = Blob.getViemKzgInstance(); + const blobInput = Blob.getEthBlobEvaluationInputs(encodedData.blobs); + this.log.debug('validating blob input', { blobInput }); const blobEvaluationGas = await this.l1TxUtils.estimateGas( this.account, { @@ -970,7 +972,7 @@ export class L1Publisher { data: encodeFunctionData({ abi: this.rollupContract.abi, functionName: 'validateBlobs', - args: [Blob.getEthBlobEvaluationInputs(encodedData.blobs)], + args: [blobInput], }), }, {}, @@ -987,30 +989,6 @@ export class L1Publisher { // slot yet). // const gasGuesstimate = blobEvaluationGas + L1Publisher.PROPOSE_GAS_GUESS; - // const timestamp = BigInt((await this.publicClient.getBlock()).timestamp + this.ethereumSlotDuration); - - // const simulationResult = await this.publicClient.simulate({ - // validation: true, - // blocks: [ - // { - // blockOverrides: { - // time: timestamp, - // }, - // calls: [ - // { - // from: this.account.address, - // to: this.rollupContract.address, - // data: encodeFunctionData({ - // abi: this.rollupContract.abi, - // functionName: 'validateBlobs', - // args: [Blob.getEthBlobEvaluationInputs(encodedData.blobs)], - // }), - // }, - // ], - // }, - // ], - // }); - const attestations = encodedData.attestations ? encodedData.attestations.map(attest => attest.toViemSignature()) : []; @@ -1030,7 +1008,7 @@ export class L1Publisher { attestations, // TODO(#9101): Extract blobs from beacon chain => calldata will only contain what's needed to verify blob and body input can be removed `0x${encodedData.body.toString('hex')}`, - Blob.getEthBlobEvaluationInputs(encodedData.blobs), + blobInput, ] as const; return { args, blobEvaluationGas }; From 6a8019091d60d7e6dad5617d53bce468333db543 Mon Sep 17 00:00:00 2001 From: spypsy Date: Thu, 16 Jan 2025 11:39:30 +0000 Subject: [PATCH 19/57] override checkBlobs to false --- yarn-project/ethereum/src/l1_tx_utils.ts | 8 +++--- .../src/publisher/l1-publisher.ts | 25 ++++++++++++++++++- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index edfeb5cc63d..5f5dbf5624a 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -20,6 +20,7 @@ import { MethodNotFoundRpcError, MethodNotSupportedRpcError, type PublicClient, + type StateOverride, type TransactionReceipt, type WalletClient, formatGwei, @@ -575,6 +576,7 @@ export class L1TxUtils { request: L1TxRequest, _gasConfig?: L1TxUtilsConfig, blockOverrides: BlockOverrides = {}, + stateOverrides: StateOverride = [], ): Promise { const gasConfig = { ...this.config, ..._gasConfig }; const gasPrice = await this.getGasPrice(gasConfig, false); @@ -584,6 +586,7 @@ export class L1TxUtils { blocks: [ { blockOverrides, + stateOverrides, calls: [ { from: this.walletClient.account.address, @@ -596,9 +599,8 @@ export class L1TxUtils { }, ], }); - this.logger?.debug('Gas used in simulation', { - gasUsed: result[0].calls[0].gasUsed, - result: result, + this.logger?.debug(`Gas used in simulation: ${result[0].calls[0].gasUsed}`, { + result, }); if (result[0].calls[0].status === 'failure') { this.logger?.error('Simulation failed', { diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 6761bc6383d..8a751fa9ddb 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -1060,7 +1060,6 @@ export class L1Publisher { functionName: 'propose', args, }); - this.log.debug('simulateGasUsed with blob inputs', { blobInputs: args[3] }); let simulationResult = await this.l1TxUtils.simulateGasUsed( { to: this.rollupContract.address, @@ -1070,6 +1069,18 @@ export class L1Publisher { { time: timestamp, }, + [ + { + address: this.rollupContract.address, + // @note we override checkBlob to false since blobs are not part simulate() + stateDiff: [ + { + slot: toHex(9n, true), + value: toHex(0n, true), + }, + ], + }, + ], ); if (simulationResult === -1n) { @@ -1132,6 +1143,18 @@ export class L1Publisher { { time: timestamp, }, + [ + { + address: this.rollupContract.address, + // @note we override checkBlob to false since blobs are not part simulate() + stateDiff: [ + { + slot: toHex(9n, true), + value: toHex(0n, true), + }, + ], + }, + ], ); if (simulationResult === -1n) { From dc8198ae2c7e98f2be4fbcab306de5886a0b0797 Mon Sep 17 00:00:00 2001 From: spypsy Date: Fri, 17 Jan 2025 09:04:46 +0000 Subject: [PATCH 20/57] add 1s to block time --- yarn-project/ethereum/src/l1_tx_utils.ts | 2 +- .../sequencer-client/src/publisher/l1-publisher.ts | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index 5f5dbf5624a..7bf40875dd3 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -574,9 +574,9 @@ export class L1TxUtils { public async simulateGasUsed( request: L1TxRequest, - _gasConfig?: L1TxUtilsConfig, blockOverrides: BlockOverrides = {}, stateOverrides: StateOverride = [], + _gasConfig?: L1TxUtilsConfig, ): Promise { const gasConfig = { ...this.config, ..._gasConfig }; const gasPrice = await this.getGasPrice(gasConfig, false); diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 8a751fa9ddb..922c12cd70d 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -1065,9 +1065,8 @@ export class L1Publisher { to: this.rollupContract.address, data, }, - undefined, { - time: timestamp, + time: timestamp + 1n, }, [ { @@ -1096,7 +1095,6 @@ export class L1Publisher { { ...opts, gasLimit: simulationResult + blobEvaluationGas, - gasLimitBufferPercentage: 100, }, { blobs: encodedData.blobs.map(b => b.dataWithZeros), @@ -1139,9 +1137,8 @@ export class L1Publisher { to: this.rollupContract.address, data, }, - undefined, { - time: timestamp, + time: timestamp + 1n, }, [ { @@ -1170,7 +1167,6 @@ export class L1Publisher { { ...opts, gasLimit: simulationResult + blobEvaluationGas, - gasLimitBufferPercentage: 100, }, { blobs: encodedData.blobs.map(b => b.dataWithZeros), From d5d5928287241f165d6ebfacfb71c3c4a472e240 Mon Sep 17 00:00:00 2001 From: spypsy Date: Sun, 19 Jan 2025 20:05:53 +0000 Subject: [PATCH 21/57] improve custom error logging --- yarn-project/ethereum/src/l1_tx_utils.test.ts | 64 +++++++++++++++++++ yarn-project/ethereum/src/utils.ts | 40 +++++++++++- 2 files changed, 103 insertions(+), 1 deletion(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.test.ts b/yarn-project/ethereum/src/l1_tx_utils.test.ts index 37f13952864..0bbb798ee8a 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.test.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.test.ts @@ -5,6 +5,7 @@ import { sleep } from '@aztec/foundation/sleep'; import { type Anvil } from '@viem/anvil'; import { + Abi, type Account, type Chain, type HttpTransport, @@ -13,6 +14,7 @@ import { createPublicClient, createWalletClient, http, + keccak256, } from 'viem'; import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts'; import { foundry } from 'viem/chains'; @@ -395,6 +397,68 @@ describe('GasUtils', () => { } } }, 10_000); + it('handles custom errors', async () => { + // We're deploying this contract: + // pragma solidity >=0.8.27; + + // library Errors { + // error Test_Error(uint256 val); + // } + + // contract TestContract { + // function triggerError(uint256 num) external pure { + // require(false, Errors.Test_Error(num)); + // } + // } + const abi = [ + { + inputs: [ + { + internalType: 'uint256', + name: 'val', + type: 'uint256', + }, + ], + name: 'Test_Error', + type: 'error', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'num', + type: 'uint256', + }, + ], + name: 'triggerError', + outputs: [], + stateMutability: 'pure', + type: 'function', + }, + ] as Abi; + const deployHash = await walletClient.deployContract({ + abi, + bytecode: + // contract bytecode + '0x6080604052348015600e575f5ffd5b506101508061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80638291d6871461002d575b5f5ffd5b610047600480360381019061004291906100c7565b610049565b005b5f819061008c576040517fcdae48f50000000000000000000000000000000000000000000000000000000081526004016100839190610101565b60405180910390fd5b5050565b5f5ffd5b5f819050919050565b6100a681610094565b81146100b0575f5ffd5b50565b5f813590506100c18161009d565b92915050565b5f602082840312156100dc576100db610090565b5b5f6100e9848285016100b3565b91505092915050565b6100fb81610094565b82525050565b5f6020820190506101145f8301846100f2565b9291505056fea264697066735822122011972815480b23be1e371aa7c11caa30281e61b164209ae84edcd3fee026278364736f6c634300081b0033', + }); + + const receipt = await publicClient.waitForTransactionReceipt({ hash: deployHash }); + if (!receipt.contractAddress) throw new Error('No contract address'); + const contractAddress = receipt.contractAddress; + + try { + await publicClient.simulateContract({ + address: contractAddress!, + abi, + functionName: 'triggerError', + args: [33], + }); + } catch (err: any) { + const errorMessage = formatViemError(err, abi); + expect(errorMessage).toBe('Test_Error(33)'); + } + }); it('stops trying after timeout', async () => { await cheatCodes.setAutomine(false); await cheatCodes.setIntervalMining(0); diff --git a/yarn-project/ethereum/src/utils.ts b/yarn-project/ethereum/src/utils.ts index b6d585ece11..7f3a9dbc31f 100644 --- a/yarn-project/ethereum/src/utils.ts +++ b/yarn-project/ethereum/src/utils.ts @@ -1,5 +1,6 @@ import { type Fr } from '@aztec/foundation/fields'; import { type Logger } from '@aztec/foundation/log'; +import { RollupAbi } from '@aztec/l1-artifacts'; import { type Abi, @@ -9,6 +10,7 @@ import { type DecodeEventLogReturnType, type Hex, type Log, + decodeErrorResult, decodeEventLog, } from 'viem'; @@ -80,7 +82,43 @@ export function prettyLogViemErrorMsg(err: any) { return err?.message ?? err; } -export function formatViemError(error: any): string { +/** + * Formats a Viem error into a human-readable string. + * @param error - The error to format. + * @param abi - The ABI to use for decoding. + * @returns A human-readable string. + */ +export function formatViemError(error: any, abi: Abi = RollupAbi): string { + // First try to decode as a custom error using the ABI + try { + if (error?.data) { + // Try to decode the error data using the ABI + const decoded = decodeErrorResult({ + abi, + data: error.data as Hex, + }); + if (decoded) { + return `${decoded.errorName}(${decoded.args?.join(', ') ?? ''})`; + } + } + + // If it's a BaseError, try to get the custom error through ContractFunctionRevertedError + if (error instanceof BaseError) { + const revertError = error.walk(err => err instanceof ContractFunctionRevertedError); + if (revertError instanceof ContractFunctionRevertedError) { + const errorName = revertError.data?.errorName ?? ''; + const args = + revertError.metaMessages && revertError.metaMessages?.length > 1 + ? revertError.metaMessages[1].trimStart() + : ''; + return `${errorName}${args}`; + } + } + } catch (decodeErr) { + // If decoding fails, we fall back to the original formatting + } + + // Original formatting logic for non-custom errors const truncateHex = (hex: string, length = 100) => { if (!hex || typeof hex !== 'string') { return hex; From 644d00ce7705c2c8aa46938304832addd8e5123f Mon Sep 17 00:00:00 2001 From: spypsy Date: Mon, 20 Jan 2025 09:20:58 +0000 Subject: [PATCH 22/57] bump %, return entire error from viem --- .../sepolia-48-validators-with-metrics.yaml | 3 +++ yarn-project/ethereum/src/l1_tx_utils.test.ts | 1 - yarn-project/ethereum/src/l1_tx_utils.ts | 14 +++++++------- yarn-project/ethereum/src/utils.ts | 18 +++++++++++------- .../src/publisher/l1-publisher.ts | 4 ++-- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml b/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml index 089abbd9f74..04cfc6fd267 100644 --- a/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml +++ b/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml @@ -1,6 +1,9 @@ telemetry: enabled: true +aztec: + slotDuration: 36 # in seconds, + network: setupL2Contracts: false public: false diff --git a/yarn-project/ethereum/src/l1_tx_utils.test.ts b/yarn-project/ethereum/src/l1_tx_utils.test.ts index 0bbb798ee8a..2b00db10313 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.test.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.test.ts @@ -14,7 +14,6 @@ import { createPublicClient, createWalletClient, http, - keccak256, } from 'viem'; import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts'; import { foundry } from 'viem/chains'; diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index 7bf40875dd3..dc78869c128 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -101,7 +101,7 @@ export const l1TxUtilsConfigMappings: ConfigMappingsType = { gasLimitBufferPercentage: { description: 'How much to increase calculated gas limit by (percentage)', env: 'L1_GAS_LIMIT_BUFFER_PERCENTAGE', - ...numberConfigHelper(15), + ...numberConfigHelper(20), }, minGwei: { description: 'Minimum gas price in gwei', @@ -252,9 +252,9 @@ export class L1TxUtils { return { txHash, gasLimit, gasPrice }; } catch (err: any) { - const formattedErr = formatViemError(err); - this.logger?.error(`Failed to send transaction`, formattedErr); - throw formattedErr; + const { message, ...error } = formatViemError(err); + this.logger?.error(`Failed to send transaction`, message, error); + throw { ...error, message }; } } @@ -389,10 +389,10 @@ export class L1TxUtils { } await sleep(gasConfig.checkIntervalMs!); } catch (err: any) { - const formattedErr = formatViemError(err); - this.logger?.warn(`Error monitoring tx ${currentTxHash}:`, formattedErr); + const { message, ...error } = formatViemError(err); + this.logger?.warn(`Error monitoring tx ${currentTxHash}:`, message); if (err.message?.includes('reverted')) { - throw formattedErr; + throw { ...error, message }; } await sleep(gasConfig.checkIntervalMs!); } diff --git a/yarn-project/ethereum/src/utils.ts b/yarn-project/ethereum/src/utils.ts index 7f3a9dbc31f..0385e57bd13 100644 --- a/yarn-project/ethereum/src/utils.ts +++ b/yarn-project/ethereum/src/utils.ts @@ -88,7 +88,7 @@ export function prettyLogViemErrorMsg(err: any) { * @param abi - The ABI to use for decoding. * @returns A human-readable string. */ -export function formatViemError(error: any, abi: Abi = RollupAbi): string { +export function formatViemError(error: any, abi: Abi = RollupAbi) { // First try to decode as a custom error using the ABI try { if (error?.data) { @@ -98,7 +98,7 @@ export function formatViemError(error: any, abi: Abi = RollupAbi): string { data: error.data as Hex, }); if (decoded) { - return `${decoded.errorName}(${decoded.args?.join(', ') ?? ''})`; + return { ...error, message: `${decoded.errorName}(${decoded.args?.join(', ') ?? ''})` }; } } @@ -111,7 +111,7 @@ export function formatViemError(error: any, abi: Abi = RollupAbi): string { revertError.metaMessages && revertError.metaMessages?.length > 1 ? revertError.metaMessages[1].trimStart() : ''; - return `${errorName}${args}`; + return { ...error, message: `${errorName}${args}` }; } } } catch (decodeErr) { @@ -206,8 +206,12 @@ export function formatViemError(error: any, abi: Abi = RollupAbi): string { return result; }; - return JSON.stringify({ error: extractAndFormatRequestBody(error?.message || String(error)) }, null, 2).replace( - /\\n/g, - '\n', - ); + return JSON.stringify( + { + ...(typeof error === 'object' ? error : {}), + message: extractAndFormatRequestBody(error?.message || String(error)), + }, + null, + 2, + ).replace(/\\n/g, '\n'); } diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 2a9f4d50a73..09f5dcf2b58 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -546,8 +546,8 @@ export class L1Publisher { account: this.account, }); } catch (err) { - const msg = formatViemError(err); - logger.error(`Failed to vote`, msg); + const { message, ...error } = formatViemError(err); + logger.error(`Failed to vote`, message, error); this.myLastVotes[voteType] = cachedMyLastVote; return false; } From 040cc6342cf44a4bb3c7f0b1986f493d339d9f9a Mon Sep 17 00:00:00 2001 From: spypsy Date: Mon, 20 Jan 2025 09:25:30 +0000 Subject: [PATCH 23/57] fix archiver test --- yarn-project/archiver/src/archiver/archiver.test.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/yarn-project/archiver/src/archiver/archiver.test.ts b/yarn-project/archiver/src/archiver/archiver.test.ts index de639bfe4a1..57f9d2826fc 100644 --- a/yarn-project/archiver/src/archiver/archiver.test.ts +++ b/yarn-project/archiver/src/archiver/archiver.test.ts @@ -154,7 +154,6 @@ describe('Archiver', () => { (archiver as any).rollup = mockRollup; mockInboxRead = mock(); - mockInboxRead.totalMessagesInserted.mockImplementation(() => Promise.resolve(123n)); mockInboxEvents = mock(); mockInboxEvents.MessageSent.mockImplementation(async (filter: any, { fromBlock, toBlock }) => { return await Promise.resolve( @@ -175,7 +174,7 @@ describe('Archiver', () => { await archiver?.stop(); }); - it('can start, sync and stop and handle l1 to l2 messages and logs', async () => { + it.only('can start, sync and stop and handle l1 to l2 messages and logs', async () => { let latestBlockNum = await archiver.getBlockNumber(); expect(latestBlockNum).toEqual(0); @@ -197,10 +196,7 @@ describe('Archiver', () => { blocks[0].archive.root.toString(), ]); - mockInbox.read.totalMessagesInserted - .mockResolvedValueOnce(123n) - .mockResolvedValueOnce(2n) - .mockResolvedValueOnce(6n); + mockInbox.read.totalMessagesInserted.mockResolvedValueOnce(2n).mockResolvedValueOnce(6n); makeMessageSentEvent(98n, 1n, 0n); makeMessageSentEvent(99n, 1n, 1n); From de58c69849307da90588940a23620671f04a35d1 Mon Sep 17 00:00:00 2001 From: spypsy Date: Mon, 20 Jan 2025 09:36:48 +0000 Subject: [PATCH 24/57] fix publisher integration test --- .../src/composed/integration_l1_publisher.test.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts b/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts index 1334d39aadf..7ed771b8521 100644 --- a/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts +++ b/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts @@ -528,17 +528,19 @@ describe('L1Publisher integration', () => { await expect(publisher.proposeL2Block(block)).resolves.toEqual(false); // Test for both calls - expect(loggerErrorSpy).toHaveBeenCalledTimes(2); + // NOTE: First error is from the simulate fn, which isn't supported by anvil + expect(loggerErrorSpy).toHaveBeenCalledTimes(3); // Test first call expect(loggerErrorSpy).toHaveBeenNthCalledWith( - 1, + 2, expect.stringMatching(/^L1 transaction 0x[a-f0-9]{64} reverted$/i), + expect.anything(), ); // Test second call expect(loggerErrorSpy).toHaveBeenNthCalledWith( - 2, + 3, expect.stringMatching( /^Rollup process tx reverted\. The contract function "propose" reverted\. Error: Rollup__InvalidInHash/i, ), From 6b521129b0b95e6c7cee385d8fad0586172d2908 Mon Sep 17 00:00:00 2001 From: spypsy Date: Mon, 20 Jan 2025 10:00:20 +0000 Subject: [PATCH 25/57] fix testing errors --- yarn-project/archiver/src/archiver/archiver.test.ts | 2 +- yarn-project/ethereum/src/l1_tx_utils.test.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/yarn-project/archiver/src/archiver/archiver.test.ts b/yarn-project/archiver/src/archiver/archiver.test.ts index 57f9d2826fc..16ac47d9214 100644 --- a/yarn-project/archiver/src/archiver/archiver.test.ts +++ b/yarn-project/archiver/src/archiver/archiver.test.ts @@ -174,7 +174,7 @@ describe('Archiver', () => { await archiver?.stop(); }); - it.only('can start, sync and stop and handle l1 to l2 messages and logs', async () => { + it('can start, sync and stop and handle l1 to l2 messages and logs', async () => { let latestBlockNum = await archiver.getBlockNumber(); expect(latestBlockNum).toEqual(0); diff --git a/yarn-project/ethereum/src/l1_tx_utils.test.ts b/yarn-project/ethereum/src/l1_tx_utils.test.ts index 2b00db10313..d86b371c8d1 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.test.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.test.ts @@ -5,7 +5,7 @@ import { sleep } from '@aztec/foundation/sleep'; import { type Anvil } from '@viem/anvil'; import { - Abi, + type Abi, type Account, type Chain, type HttpTransport, @@ -375,7 +375,7 @@ describe('GasUtils', () => { }); fail('Should have thrown'); } catch (err: any) { - const formattedError = formatViemError(err); + const { message: formattedError } = formatViemError(err); // Verify the error contains actual newlines, not escaped \n expect(formattedError).not.toContain('\\n'); @@ -443,7 +443,9 @@ describe('GasUtils', () => { }); const receipt = await publicClient.waitForTransactionReceipt({ hash: deployHash }); - if (!receipt.contractAddress) throw new Error('No contract address'); + if (!receipt.contractAddress) { + throw new Error('No contract address'); + } const contractAddress = receipt.contractAddress; try { From b62289b09c674a7fd2be126f7685098af3ec0818 Mon Sep 17 00:00:00 2001 From: spypsy Date: Mon, 20 Jan 2025 11:00:37 +0000 Subject: [PATCH 26/57] update error tests --- yarn-project/ethereum/src/l1_tx_utils.test.ts | 21 ++++++++++--------- yarn-project/ethereum/src/utils.ts | 14 ++++++------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.test.ts b/yarn-project/ethereum/src/l1_tx_utils.test.ts index d86b371c8d1..2484e20792c 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.test.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.test.ts @@ -375,19 +375,20 @@ describe('GasUtils', () => { }); fail('Should have thrown'); } catch (err: any) { - const { message: formattedError } = formatViemError(err); - + const res = err; + // console.log('res', res); + const { message } = res; // Verify the error contains actual newlines, not escaped \n - expect(formattedError).not.toContain('\\n'); - expect(formattedError.split('\n').length).toBeGreaterThan(1); + expect(message).not.toContain('\\n'); + expect(message.split('\n').length).toBeGreaterThan(1); // Check that we have the key error information - expect(formattedError).toContain('fee cap'); + expect(message).toContain('fee cap'); // Check request body formatting if present - if (formattedError.includes('Request body:')) { - const bodyStart = formattedError.indexOf('Request body:'); - const body = formattedError.slice(bodyStart); + if (message.includes('Request body:')) { + const bodyStart = message.indexOf('Request body:'); + const body = message.slice(bodyStart); expect(body).toContain('eth_sendRawTransaction'); // Check params are truncated if too long if (body.includes('0x')) { @@ -456,8 +457,8 @@ describe('GasUtils', () => { args: [33], }); } catch (err: any) { - const errorMessage = formatViemError(err, abi); - expect(errorMessage).toBe('Test_Error(33)'); + const { message } = formatViemError(err, abi); + expect(message).toBe('Test_Error(33)'); } }); it('stops trying after timeout', async () => { diff --git a/yarn-project/ethereum/src/utils.ts b/yarn-project/ethereum/src/utils.ts index 0385e57bd13..6ee8905cd62 100644 --- a/yarn-project/ethereum/src/utils.ts +++ b/yarn-project/ethereum/src/utils.ts @@ -206,12 +206,10 @@ export function formatViemError(error: any, abi: Abi = RollupAbi) { return result; }; - return JSON.stringify( - { - ...(typeof error === 'object' ? error : {}), - message: extractAndFormatRequestBody(error?.message || String(error)), - }, - null, - 2, - ).replace(/\\n/g, '\n'); + const formattedRes = extractAndFormatRequestBody(error?.message || String(error)); + + return { + message: formattedRes.replace(/\\n/g, '\n'), + metaMessages: error?.metaMessages, + }; } From f901649efe7470c72d30fc0bb91bd4533302b918 Mon Sep 17 00:00:00 2001 From: spypsy Date: Mon, 20 Jan 2025 11:39:40 +0000 Subject: [PATCH 27/57] update publisher test --- .../sequencer-client/src/publisher/l1-publisher.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts index 7f6e178fb82..bc9c6153712 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts @@ -154,6 +154,7 @@ describe('L1Publisher', () => { gasPrice: { maxFeePerGas: 1n, maxPriorityFeePerGas: 1n }, }); (l1TxUtils as any).estimateGas.mockResolvedValue(GAS_GUESS); + (l1TxUtils as any).simulateGasUsed.mockResolvedValue(1_000_000n); }); const closeServer = (server: Server): Promise => { @@ -237,7 +238,8 @@ describe('L1Publisher', () => { to: mockRollupAddress, data: encodeFunctionData({ abi: rollupContract.abi, functionName: 'propose', args }), }, - { fixedGas: GAS_GUESS + L1Publisher.PROPOSE_GAS_GUESS }, + // 1_000_000 is the gas used by the returned by simulateGasUsed & GAS_GUESS is the gas returned by estimateGas for the blob evaluation + { gasLimit: 1_000_000n + GAS_GUESS }, { blobs: expectedBlobs.map(b => b.dataWithZeros), kzg }, ); From 019acd3fa65e8b45b83bb9dc4afb8e82a4451a93 Mon Sep 17 00:00:00 2001 From: spypsy Date: Mon, 20 Jan 2025 12:40:28 +0000 Subject: [PATCH 28/57] try fixing for reth --- yarn-project/ethereum/src/l1_tx_utils.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index dc78869c128..51bae347bd0 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -594,6 +594,9 @@ export class L1TxUtils { data: request.data, maxFeePerGas: gasPrice.maxFeePerGas, maxPriorityFeePerGas: gasPrice.maxPriorityFeePerGas, + blobVersionedHashes: [], + maxFeePerBlobGas: gasPrice.maxFeePerBlobGas, + type: 'eip4844', }, ], }, From 8d6cdbab7523a49b298b71c3fc00c0b4194748ee Mon Sep 17 00:00:00 2001 From: spypsy Date: Mon, 20 Jan 2025 14:25:24 +0000 Subject: [PATCH 29/57] try adding gas to call --- yarn-project/ethereum/src/l1_tx_utils.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index 51bae347bd0..e592b2765e3 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -580,6 +580,15 @@ export class L1TxUtils { ): Promise { const gasConfig = { ...this.config, ..._gasConfig }; const gasPrice = await this.getGasPrice(gasConfig, false); + + // "data": "0x164552d800000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000460000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000009601af87f30971f9ecdebb7a0cd9a35d37804b2ae9846482c39dc6a41d6b4576f041ec4e50a18fe245f5b7abaf93810a85990e2362d242aa9dec4f336a43d0a96060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002880237797d6a2c04d20d4fa06b74482bd970ccd51a43d9b05b57e9b91fa1ae1cae00000001000000000000000000000000000000000000000000000000000000000000000200056e3dd569ccf68f705a2ea9cf03da3955838d981c674350d5a946b9c25f1500089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb2e33ee2008411c04b99c24b313513d097a0d21a5040b6193d1f978b8226892d60000001001d8759f40db60c447bcf9c3caa0714b86ef8ebbfb2305506558d1a2d087d473000000802d0e4f11e3e53213b3453206e479ba3a4c2125c66729c6f17ab1f8703045cd91000001000fb3cd33107e1f0a7b26ec9ce709cf97442b2b7dfaf527844d9169d6d207bc7000000083000000000000000000000000000000000000000000000000000000000000053900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000678e42020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c9c6dedc400000000000000000000000000000000000000000000000000146cf4c4136e080000000000000000000000000000000000000000000000000000000000019ea200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000021c544a2d450a070fe5c83265dbebc60b49aea256e8dd4cafcc0ca8caedb329ee0f2b3aecfa548754273f007b59ab579c4e26b36c388cbc5afc4e8d0d74c3549c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004ac00000002001c544a2d450a070fe5c83265dbebc60b49aea256e8dd4cafcc0ca8caedb329ee0000000000000000000000000000000000000000000000000002e80d55cc2c0001289ef0d8eaeb8f3d4b4fbdd79c9654511dd2dca942f0dbd86562a1b9690eb848020008b025a09cdf3ca39e46b50b7afea26e8116153f323ebe5d672af8418526af1257a3e07b62dfaae78bc58cf9dbfe605958645cf28aef9afbc03e82e3a964010000011e33df95746d8f981f221481d0bed30e3bb19d40042f25dfacd2e56f86649ddd002f40da22100c7977377468089b9730a1ace9edfa224db93c5dba9486792222006340a142be3eaf891b2b7a692e8c4a4789c6634444aff8ce38a48a1482985000ad3f3c5033520fe7a9bcd317e870321e513a00000000000000000000000000000000ff67c2ba070aff482afbcce91b5c5a5e11c8eed141d2e282cf9d81034b00aed5337b72e67040368c341f285ba4f50727a0109b3b9b5a6bc3f1846dc3ed00751215d09b292858781217bab2501973a662103a2f253847667aad31162ee200dcc9b49c9b36d0e8ab936b8eb001d726af2383c7f26dcfcb7015f7fc22633c00b405607826326bf45577bc8ab6e4720eed3e5edbe90baefa9c7d19c6abb30b009f7a9e04910576a526e7f446c51faed806b1c28ccf0608eb7ee1809580f67100add059714ab88fdc03a0887fbcec98056337c5025945ffafa14bf755880956006c2f3d398493ec005af684f515289269ae432f2fea795151a2d89aaf0b3a96008119f06b0e9b8287da7c2a9e34168d682606addef9255b52abece5aad5e7a800ac940d59da0065ad91f3ec6a37c17152a5dc11bcf53ece2b02de53a989c7ee007f4ce581de83172f5e055a62947e76e8b061914e28675dcbe49d571a2636d800ce78f767184384ccc61e78ecf275574fa5a293d9019cebc244f4c3f4318f380070491506ab3389843b9642dec9a01554adfefc5ec416046b39553c01bb89f200e02c874b0014bd61a5b27f96a37cc30317cbfd76cda7c5c5efb39dcb1ca5b700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000f2b3aecfa548754273f007b59ab579c4e26b36c388cbc5afc4e8d0d74c3549c000000000000000000000000000000000000000000000000001184e76e47420800012bb4fb3a4de5840e9adc1810b15558785d85e23dcb16470f1f1c302cf165b5ed000309e66f7471b449f587c43a13a2089a2cab5475b5bce5b62ae1d537efb01a2de400000000000000000000000000000000000000000000000ad77d377357d8bdf8184dd2a6409e58c268839b38fd12b9063e970cdc076c70d522c507fba1732cbe000000000000000000000000000000000000000000000000000000000000dead064a8cbbf0b7cdf1cd038b49763d85acd50724ba2f09aa2052812d39f56c0b4e000000000000000000000000a0254526c4079c4a66b45ddacfc0809d5b8cde47000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c10101cf2677d0cb898b30e8d1adb83dd8aff2ba513896075b47482b3e26a6b8e4e511fd483c434b311fb29310f8ffa63eed594f8d8d9e716a87060d3c0b34962c726547f557dead24c186d0ffa32447f269a82df13e8a7a71429e2b1575de0d926ea99a8900bc71a904f7d08e5fa9fd00aac2530fee73a48b3799dd320162f15e23df0b183c5c0609062e3dd123a515e191842bac96e1df169b6075eb436bd250c031d37a21d414e9c49281b5d8e3933c089d03a95c997488a3baccc455be415f3400000000000000000000000000000000000000000000000000000000000000", + // "from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + // "to": "0x859EA5Ab45ec39658931eBB5A1ac08e29ed80aBf", + // "nonce": "0x17", + // "maxFeePerGas": "0x10", + // "maxPriorityFeePerGas": "0x1", + // "gas": "0x520800" + try { const result = await this.publicClient.simulate({ validation: true, @@ -594,9 +603,8 @@ export class L1TxUtils { data: request.data, maxFeePerGas: gasPrice.maxFeePerGas, maxPriorityFeePerGas: gasPrice.maxPriorityFeePerGas, - blobVersionedHashes: [], - maxFeePerBlobGas: gasPrice.maxFeePerBlobGas, - type: 'eip4844', + gas: 2_000_000n * WEI_CONST, + // gasLimit: 12_000_000n * WEI_CONST, }, ], }, From f42dbcae96d44d7c30a9f17fc1a4fed028b03828 Mon Sep 17 00:00:00 2001 From: spypsy Date: Mon, 20 Jan 2025 15:20:10 +0000 Subject: [PATCH 30/57] fix bad multiplication --- yarn-project/ethereum/src/l1_tx_utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index e592b2765e3..38757afc039 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -603,7 +603,7 @@ export class L1TxUtils { data: request.data, maxFeePerGas: gasPrice.maxFeePerGas, maxPriorityFeePerGas: gasPrice.maxPriorityFeePerGas, - gas: 2_000_000n * WEI_CONST, + gas: 12_000_000n, // gasLimit: 12_000_000n * WEI_CONST, }, ], From 0f03c60893c3414a8bf20b1014252c092accc43e Mon Sep 17 00:00:00 2001 From: spypsy Date: Mon, 20 Jan 2025 16:35:07 +0000 Subject: [PATCH 31/57] add nonce --- yarn-project/ethereum/src/l1_tx_utils.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index 38757afc039..8ea1f64e12c 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -581,13 +581,7 @@ export class L1TxUtils { const gasConfig = { ...this.config, ..._gasConfig }; const gasPrice = await this.getGasPrice(gasConfig, false); - // "data": "0x164552d800000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000460000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000009601af87f30971f9ecdebb7a0cd9a35d37804b2ae9846482c39dc6a41d6b4576f041ec4e50a18fe245f5b7abaf93810a85990e2362d242aa9dec4f336a43d0a96060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002880237797d6a2c04d20d4fa06b74482bd970ccd51a43d9b05b57e9b91fa1ae1cae00000001000000000000000000000000000000000000000000000000000000000000000200056e3dd569ccf68f705a2ea9cf03da3955838d981c674350d5a946b9c25f1500089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb2e33ee2008411c04b99c24b313513d097a0d21a5040b6193d1f978b8226892d60000001001d8759f40db60c447bcf9c3caa0714b86ef8ebbfb2305506558d1a2d087d473000000802d0e4f11e3e53213b3453206e479ba3a4c2125c66729c6f17ab1f8703045cd91000001000fb3cd33107e1f0a7b26ec9ce709cf97442b2b7dfaf527844d9169d6d207bc7000000083000000000000000000000000000000000000000000000000000000000000053900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000678e42020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c9c6dedc400000000000000000000000000000000000000000000000000146cf4c4136e080000000000000000000000000000000000000000000000000000000000019ea200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000021c544a2d450a070fe5c83265dbebc60b49aea256e8dd4cafcc0ca8caedb329ee0f2b3aecfa548754273f007b59ab579c4e26b36c388cbc5afc4e8d0d74c3549c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004ac00000002001c544a2d450a070fe5c83265dbebc60b49aea256e8dd4cafcc0ca8caedb329ee0000000000000000000000000000000000000000000000000002e80d55cc2c0001289ef0d8eaeb8f3d4b4fbdd79c9654511dd2dca942f0dbd86562a1b9690eb848020008b025a09cdf3ca39e46b50b7afea26e8116153f323ebe5d672af8418526af1257a3e07b62dfaae78bc58cf9dbfe605958645cf28aef9afbc03e82e3a964010000011e33df95746d8f981f221481d0bed30e3bb19d40042f25dfacd2e56f86649ddd002f40da22100c7977377468089b9730a1ace9edfa224db93c5dba9486792222006340a142be3eaf891b2b7a692e8c4a4789c6634444aff8ce38a48a1482985000ad3f3c5033520fe7a9bcd317e870321e513a00000000000000000000000000000000ff67c2ba070aff482afbcce91b5c5a5e11c8eed141d2e282cf9d81034b00aed5337b72e67040368c341f285ba4f50727a0109b3b9b5a6bc3f1846dc3ed00751215d09b292858781217bab2501973a662103a2f253847667aad31162ee200dcc9b49c9b36d0e8ab936b8eb001d726af2383c7f26dcfcb7015f7fc22633c00b405607826326bf45577bc8ab6e4720eed3e5edbe90baefa9c7d19c6abb30b009f7a9e04910576a526e7f446c51faed806b1c28ccf0608eb7ee1809580f67100add059714ab88fdc03a0887fbcec98056337c5025945ffafa14bf755880956006c2f3d398493ec005af684f515289269ae432f2fea795151a2d89aaf0b3a96008119f06b0e9b8287da7c2a9e34168d682606addef9255b52abece5aad5e7a800ac940d59da0065ad91f3ec6a37c17152a5dc11bcf53ece2b02de53a989c7ee007f4ce581de83172f5e055a62947e76e8b061914e28675dcbe49d571a2636d800ce78f767184384ccc61e78ecf275574fa5a293d9019cebc244f4c3f4318f380070491506ab3389843b9642dec9a01554adfefc5ec416046b39553c01bb89f200e02c874b0014bd61a5b27f96a37cc30317cbfd76cda7c5c5efb39dcb1ca5b700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000f2b3aecfa548754273f007b59ab579c4e26b36c388cbc5afc4e8d0d74c3549c000000000000000000000000000000000000000000000000001184e76e47420800012bb4fb3a4de5840e9adc1810b15558785d85e23dcb16470f1f1c302cf165b5ed000309e66f7471b449f587c43a13a2089a2cab5475b5bce5b62ae1d537efb01a2de400000000000000000000000000000000000000000000000ad77d377357d8bdf8184dd2a6409e58c268839b38fd12b9063e970cdc076c70d522c507fba1732cbe000000000000000000000000000000000000000000000000000000000000dead064a8cbbf0b7cdf1cd038b49763d85acd50724ba2f09aa2052812d39f56c0b4e000000000000000000000000a0254526c4079c4a66b45ddacfc0809d5b8cde47000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c10101cf2677d0cb898b30e8d1adb83dd8aff2ba513896075b47482b3e26a6b8e4e511fd483c434b311fb29310f8ffa63eed594f8d8d9e716a87060d3c0b34962c726547f557dead24c186d0ffa32447f269a82df13e8a7a71429e2b1575de0d926ea99a8900bc71a904f7d08e5fa9fd00aac2530fee73a48b3799dd320162f15e23df0b183c5c0609062e3dd123a515e191842bac96e1df169b6075eb436bd250c031d37a21d414e9c49281b5d8e3933c089d03a95c997488a3baccc455be415f3400000000000000000000000000000000000000000000000000000000000000", - // "from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", - // "to": "0x859EA5Ab45ec39658931eBB5A1ac08e29ed80aBf", - // "nonce": "0x17", - // "maxFeePerGas": "0x10", - // "maxPriorityFeePerGas": "0x1", - // "gas": "0x520800" + const nonce = await this.publicClient.getTransactionCount({ address: this.walletClient.account.address }); try { const result = await this.publicClient.simulate({ @@ -604,7 +598,7 @@ export class L1TxUtils { maxFeePerGas: gasPrice.maxFeePerGas, maxPriorityFeePerGas: gasPrice.maxPriorityFeePerGas, gas: 12_000_000n, - // gasLimit: 12_000_000n * WEI_CONST, + nonce, }, ], }, From 0db5e7557b4e43e96e4fce88fbb1a716fcdbfb6c Mon Sep 17 00:00:00 2001 From: spypsy Date: Mon, 20 Jan 2025 18:12:24 +0000 Subject: [PATCH 32/57] more logging fixes --- yarn-project/ethereum/src/l1_tx_utils.ts | 6 ++--- yarn-project/ethereum/src/utils.ts | 25 ++++++++++++------- .../src/publisher/l1-publisher.ts | 19 +++++++++++--- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index 8ea1f64e12c..444e188dddb 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -252,9 +252,9 @@ export class L1TxUtils { return { txHash, gasLimit, gasPrice }; } catch (err: any) { - const { message, ...error } = formatViemError(err); - this.logger?.error(`Failed to send transaction`, message, error); - throw { ...error, message }; + const { message, metaMessages } = formatViemError(err); + this.logger?.error(`Failed to send transaction`, message, { metaMessages }); + throw { ...err, message, metaMessages }; } } diff --git a/yarn-project/ethereum/src/utils.ts b/yarn-project/ethereum/src/utils.ts index 6ee8905cd62..94e69f100a6 100644 --- a/yarn-project/ethereum/src/utils.ts +++ b/yarn-project/ethereum/src/utils.ts @@ -21,6 +21,16 @@ export interface L2Claim { messageLeafIndex: bigint; } +export class FormattedViemError extends Error { + metaMessages?: any[]; + + constructor(message: string, metaMessages?: any[]) { + super(message); + this.name = 'FormattedViemError'; + this.metaMessages = metaMessages; + } +} + export function extractEvent< const TAbi extends Abi | readonly unknown[], TEventName extends ContractEventName, @@ -83,12 +93,12 @@ export function prettyLogViemErrorMsg(err: any) { } /** - * Formats a Viem error into a human-readable string. + * Formats a Viem error into a FormattedViemError instance. * @param error - The error to format. * @param abi - The ABI to use for decoding. - * @returns A human-readable string. + * @returns A FormattedViemError instance. */ -export function formatViemError(error: any, abi: Abi = RollupAbi) { +export function formatViemError(error: any, abi: Abi = RollupAbi): FormattedViemError { // First try to decode as a custom error using the ABI try { if (error?.data) { @@ -98,7 +108,7 @@ export function formatViemError(error: any, abi: Abi = RollupAbi) { data: error.data as Hex, }); if (decoded) { - return { ...error, message: `${decoded.errorName}(${decoded.args?.join(', ') ?? ''})` }; + return new FormattedViemError(`${decoded.errorName}(${decoded.args?.join(', ') ?? ''})`, error?.metaMessages); } } @@ -111,7 +121,7 @@ export function formatViemError(error: any, abi: Abi = RollupAbi) { revertError.metaMessages && revertError.metaMessages?.length > 1 ? revertError.metaMessages[1].trimStart() : ''; - return { ...error, message: `${errorName}${args}` }; + return new FormattedViemError(`${errorName}${args}`, error?.metaMessages); } } } catch (decodeErr) { @@ -208,8 +218,5 @@ export function formatViemError(error: any, abi: Abi = RollupAbi) { const formattedRes = extractAndFormatRequestBody(error?.message || String(error)); - return { - message: formattedRes.replace(/\\n/g, '\n'), - metaMessages: error?.metaMessages, - }; + return new FormattedViemError(formattedRes.replace(/\\n/g, '\n'), error?.metaMessages); } diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 09f5dcf2b58..4476bf199c0 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -19,6 +19,7 @@ import { import { type FeeRecipient, type RootRollupPublicInputs } from '@aztec/circuits.js/rollup'; import { type EthereumChain, + FormattedViemError, type GasPrice, type L1ContractsConfig, L1TxUtils, @@ -546,8 +547,8 @@ export class L1Publisher { account: this.account, }); } catch (err) { - const { message, ...error } = formatViemError(err); - logger.error(`Failed to vote`, message, error); + const { message, metaMessages } = formatViemError(err); + logger.error(`Failed to vote`, message, { metaMessages }); this.myLastVotes[voteType] = cachedMyLastVote; return false; } @@ -1108,7 +1109,12 @@ export class L1Publisher { data, }; } catch (err) { - this.log.error(`Rollup publish failed.`, err); + if (err instanceof FormattedViemError) { + const { message, metaMessages } = err; + this.log.error(`Rollup publish failed.`, message, { metaMessages }); + } else { + this.log.error(`Rollup publish failed.`, err); + } return undefined; } } @@ -1181,7 +1187,12 @@ export class L1Publisher { data, }; } catch (err) { - this.log.error(`Rollup publish failed.`, err); + if (err instanceof FormattedViemError) { + const { message, metaMessages } = err; + this.log.error(`Rollup publish failed.`, message, { metaMessages }); + } else { + this.log.error(`Rollup publish failed.`, err); + } return undefined; } } From 38fba1588f768f8b4bb1def6688987e2cf1a8e5f Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 09:10:12 +0000 Subject: [PATCH 33/57] Update yarn-project/archiver/src/archiver/archiver.test.ts Co-authored-by: Santiago Palladino --- yarn-project/archiver/src/archiver/archiver.test.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/yarn-project/archiver/src/archiver/archiver.test.ts b/yarn-project/archiver/src/archiver/archiver.test.ts index 16ac47d9214..504152dcacd 100644 --- a/yarn-project/archiver/src/archiver/archiver.test.ts +++ b/yarn-project/archiver/src/archiver/archiver.test.ts @@ -141,11 +141,10 @@ describe('Archiver', () => { Promise.resolve(blocks[Number(args[0] - 1n)].archive.root.toString()), ); mockRollupEvents = mock(); - mockRollupEvents.L2BlockProposed.mockImplementation(async (filter: any, { fromBlock, toBlock }) => { - return await Promise.resolve( + mockRollupEvents.L2BlockProposed.mockImplementation((filter: any, { fromBlock, toBlock }) => + Promise.resolve( l2BlockProposedLogs.filter(log => log.blockNumber! >= fromBlock && log.blockNumber! <= toBlock), - ); - }); + )); mockRollup = { read: mockRollupRead, getEvents: mockRollupEvents, From 8a76d0e054651da499aa3da9bd16c00711dc745a Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 09:28:06 +0000 Subject: [PATCH 34/57] Update yarn-project/prover-node/src/bond/factory.ts Co-authored-by: Santiago Palladino --- yarn-project/prover-node/src/bond/factory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/prover-node/src/bond/factory.ts b/yarn-project/prover-node/src/bond/factory.ts index 7ae0e03164b..8edd8dce24b 100644 --- a/yarn-project/prover-node/src/bond/factory.ts +++ b/yarn-project/prover-node/src/bond/factory.ts @@ -8,7 +8,7 @@ import { type GetContractReturnType, type HttpTransport, type PrivateKeyAccount, - type PublicActions, // type PublicClient, + type PublicActions, type PublicRpcSchema, type WalletActions, type WalletClient, From ab06ba7ebdac9c8cd8d873c6e7a58f4b4c1ddd53 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 09:28:29 +0000 Subject: [PATCH 35/57] Update yarn-project/sequencer-client/src/publisher/l1-publisher.ts Co-authored-by: Santiago Palladino --- yarn-project/sequencer-client/src/publisher/l1-publisher.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 4476bf199c0..9171f9a06a9 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -964,7 +964,7 @@ export class L1Publisher { private async prepareProposeTx(encodedData: L1ProcessArgs) { const kzg = Blob.getViemKzgInstance(); const blobInput = Blob.getEthBlobEvaluationInputs(encodedData.blobs); - this.log.debug('validating blob input', { blobInput }); + this.log.debug('Validating blob input', { blobInput }); const blobEvaluationGas = await this.l1TxUtils.estimateGas( this.account, { From 763cab6ead5d80790dea427f8d769f7a053db58c Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 12:03:10 +0000 Subject: [PATCH 36/57] don't bump gasLimit option by default --- yarn-project/ethereum/src/l1_tx_utils.ts | 15 +++++++-------- .../src/publisher/l1-publisher.ts | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index 444e188dddb..2c33aa977b3 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -203,7 +203,7 @@ export class L1TxUtils { */ public async sendTransaction( request: L1TxRequest, - _gasConfig?: Partial & { fixedGas?: bigint; gasLimit?: bigint; txTimeoutAt?: Date }, + _gasConfig?: Partial & { gasLimit?: bigint; txTimeoutAt?: Date }, blobInputs?: L1BlobInputs, ): Promise<{ txHash: Hex; gasLimit: bigint; gasPrice: GasPrice }> { try { @@ -211,10 +211,8 @@ export class L1TxUtils { const account = this.walletClient.account; let gasLimit: bigint; - if (gasConfig.fixedGas) { - gasLimit = gasConfig.fixedGas; - } else if (gasConfig.gasLimit) { - gasLimit = this.bumpGasLimit(gasConfig.gasLimit, gasConfig); + if (gasConfig.gasLimit) { + gasLimit = gasConfig.gasLimit; } else { gasLimit = await this.estimateGas(account, request); } @@ -410,7 +408,7 @@ export class L1TxUtils { */ public async sendAndMonitorTransaction( request: L1TxRequest, - gasConfig?: Partial & { fixedGas?: bigint; gasLimit?: bigint; txTimeoutAt?: Date }, + gasConfig?: Partial & { gasLimit?: bigint; txTimeoutAt?: Date }, blobInputs?: L1BlobInputs, ): Promise<{ receipt: TransactionReceipt; gasPrice: GasPrice }> { const { txHash, gasLimit, gasPrice } = await this.sendTransaction(request, gasConfig, blobInputs); @@ -624,7 +622,8 @@ export class L1TxUtils { } } - private bumpGasLimit(gasLimit: bigint, gasConfig: L1TxUtilsConfig): bigint { - return gasLimit + (gasLimit * BigInt((gasConfig.gasLimitBufferPercentage || 0) * 1_00)) / 100_00n; + public bumpGasLimit(gasLimit: bigint, _gasConfig?: L1TxUtilsConfig): bigint { + const gasConfig = { ...this.config, ..._gasConfig }; + return gasLimit + (gasLimit * BigInt((gasConfig?.gasLimitBufferPercentage || 0) * 1_00)) / 100_00n; } } diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 9171f9a06a9..8a3ddd07f62 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -1094,7 +1094,7 @@ export class L1Publisher { }, { ...opts, - gasLimit: simulationResult + blobEvaluationGas, + gasLimit: this.l1TxUtils.bumpGasLimit(simulationResult + blobEvaluationGas), }, { blobs: encodedData.blobs.map(b => b.dataWithZeros), @@ -1171,7 +1171,7 @@ export class L1Publisher { }, { ...opts, - gasLimit: simulationResult + blobEvaluationGas, + gasLimit: this.l1TxUtils.bumpGasLimit(simulationResult + blobEvaluationGas), }, { blobs: encodedData.blobs.map(b => b.dataWithZeros), From d51c6995ec3537e61db95643d46bfbfb3732b0d2 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 12:25:59 +0000 Subject: [PATCH 37/57] ErrorsAbi --- yarn-project/ethereum/src/utils.ts | 9 ++++++--- yarn-project/l1-artifacts/scripts/generate-artifacts.sh | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/yarn-project/ethereum/src/utils.ts b/yarn-project/ethereum/src/utils.ts index 94e69f100a6..9f0f1ba5018 100644 --- a/yarn-project/ethereum/src/utils.ts +++ b/yarn-project/ethereum/src/utils.ts @@ -1,6 +1,6 @@ import { type Fr } from '@aztec/foundation/fields'; import { type Logger } from '@aztec/foundation/log'; -import { RollupAbi } from '@aztec/l1-artifacts'; +import { ErrorsAbi } from '@aztec/l1-artifacts'; import { type Abi, @@ -98,7 +98,7 @@ export function prettyLogViemErrorMsg(err: any) { * @param abi - The ABI to use for decoding. * @returns A FormattedViemError instance. */ -export function formatViemError(error: any, abi: Abi = RollupAbi): FormattedViemError { +export function formatViemError(error: any, abi: Abi = ErrorsAbi): FormattedViemError { // First try to decode as a custom error using the ABI try { if (error?.data) { @@ -116,7 +116,10 @@ export function formatViemError(error: any, abi: Abi = RollupAbi): FormattedViem if (error instanceof BaseError) { const revertError = error.walk(err => err instanceof ContractFunctionRevertedError); if (revertError instanceof ContractFunctionRevertedError) { - const errorName = revertError.data?.errorName ?? ''; + let errorName = revertError.data?.errorName; + if (!errorName) { + errorName = revertError.signature ?? ''; + } const args = revertError.metaMessages && revertError.metaMessages?.length > 1 ? revertError.metaMessages[1].trimStart() diff --git a/yarn-project/l1-artifacts/scripts/generate-artifacts.sh b/yarn-project/l1-artifacts/scripts/generate-artifacts.sh index fd3825893f6..62a417a8928 100755 --- a/yarn-project/l1-artifacts/scripts/generate-artifacts.sh +++ b/yarn-project/l1-artifacts/scripts/generate-artifacts.sh @@ -49,6 +49,12 @@ mkdir -p "$target_dir"; echo -ne "// Auto generated module\n" > "$target_dir/index.ts"; +# Generate Errors ABI artifact +echo -ne "/**\n * Combined Errors ABI.\n */\nexport const ErrorsAbi = " > "$target_dir/ErrorsAbi.ts"; +echo -n "$COMBINED_ERRORS" >> "$target_dir/ErrorsAbi.ts"; +echo -n " as const;" >> "$target_dir/ErrorsAbi.ts"; +echo -ne "export * from './ErrorsAbi.js';\n" >> "$target_dir/index.ts"; + for E in "${CONTRACTS[@]}"; do ARR=(${E//:/ }) ROOT="${ARR[0]}"; From a50e728fd32d4ebc5b8232d484b500f8f617660e Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 13:52:03 +0000 Subject: [PATCH 38/57] throw error on simulation instead of -1n --- yarn-project/ethereum/src/l1_tx_utils.ts | 2 - .../src/publisher/l1-publisher.ts | 118 ++++++++++-------- 2 files changed, 63 insertions(+), 57 deletions(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index 2c33aa977b3..6b91f89ca5f 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -614,9 +614,7 @@ export class L1TxUtils { return result[0].gasUsed; } catch (err) { if (err instanceof MethodNotFoundRpcError || err instanceof MethodNotSupportedRpcError) { - // Node doesn't support simulation, return -1n gas estimate this.logger?.error('Node does not support simulation API'); - return -1n; } throw err; } diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 8a3ddd07f62..87850b74bb6 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -49,6 +49,8 @@ import { type GetContractReturnType, type Hex, type HttpTransport, + MethodNotFoundRpcError, + MethodNotSupportedRpcError, type PrivateKeyAccount, type PublicActions, type PublicClient, @@ -982,13 +984,6 @@ export class L1Publisher { }, ); - // @note We perform this guesstimate instead of the usual `gasEstimate` since - // viem will use the current state to simulate against, which means that - // we will fail estimation in the case where we are simulating for the - // first ethereum block within our slot (as current time is not in the - // slot yet). - // const gasGuesstimate = blobEvaluationGas + L1Publisher.PROPOSE_GAS_GUESS; - const attestations = encodedData.attestations ? encodedData.attestations.map(attest => attest.toViemSignature()) : []; @@ -1060,31 +1055,39 @@ export class L1Publisher { functionName: 'propose', args, }); - let simulationResult = await this.l1TxUtils.simulateGasUsed( - { - to: this.rollupContract.address, - data, - }, - { - time: timestamp + 1n, - }, - [ + + let simulationResult: bigint; + try { + simulationResult = await this.l1TxUtils.simulateGasUsed( { - address: this.rollupContract.address, - // @note we override checkBlob to false since blobs are not part simulate() - stateDiff: [ - { - slot: toHex(9n, true), - value: toHex(0n, true), - }, - ], + to: this.rollupContract.address, + data, }, - ], - ); - - if (simulationResult === -1n) { - this.log.warn('Node does not support simulation API. Using gas guesstimate'); - simulationResult = L1Publisher.PROPOSE_GAS_GUESS; + { + // @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp + time: timestamp + 1n, + }, + [ + { + address: this.rollupContract.address, + // @note we override checkBlob to false since blobs are not part simulate() + stateDiff: [ + { + slot: toHex(9n, true), + value: toHex(0n, true), + }, + ], + }, + ], + ); + } catch (simErr) { + if (simErr instanceof MethodNotFoundRpcError || simErr instanceof MethodNotSupportedRpcError) { + // @note node doesn't support simulation API, we will use gas guesstimate + this.log.warn('Using gas guesstimate'); + simulationResult = L1Publisher.PROPOSE_GAS_GUESS; + } else { + throw simErr; + } } const result = await this.l1TxUtils.sendAndMonitorTransaction( @@ -1128,6 +1131,7 @@ export class L1Publisher { if (this.interrupted) { return undefined; } + let simulationResult: bigint; try { const kzg = Blob.getViemKzgInstance(); const { args, blobEvaluationGas } = await this.prepareProposeTx(encodedData); @@ -1136,34 +1140,38 @@ export class L1Publisher { functionName: 'proposeAndClaim', args: [...args, quote.toViemArgs()], }); - - let simulationResult = await this.l1TxUtils.simulateGasUsed( - { - to: this.rollupContract.address, - data, - }, - { - time: timestamp + 1n, - }, - [ + try { + simulationResult = await this.l1TxUtils.simulateGasUsed( { - address: this.rollupContract.address, - // @note we override checkBlob to false since blobs are not part simulate() - stateDiff: [ - { - slot: toHex(9n, true), - value: toHex(0n, true), - }, - ], + to: this.rollupContract.address, + data, }, - ], - ); - - if (simulationResult === -1n) { - this.log.warn('Node does not support simulation API. Using gas guesstimate'); - simulationResult = L1Publisher.PROPOSE_GAS_GUESS; + { + // @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp + time: timestamp + 1n, + }, + [ + { + address: this.rollupContract.address, + // @note we override checkBlob to false since blobs are not part simulate() + stateDiff: [ + { + slot: toHex(9n, true), + value: toHex(0n, true), + }, + ], + }, + ], + ); + } catch (simErr) { + if (simErr instanceof MethodNotFoundRpcError || simErr instanceof MethodNotSupportedRpcError) { + // @note node doesn't support simulation API, we will use gas guesstimate + this.log.warn('Using gas guesstimate'); + simulationResult = L1Publisher.PROPOSE_GAS_GUESS; + } else { + throw simErr; + } } - const result = await this.l1TxUtils.sendAndMonitorTransaction( { to: this.rollupContract.address, From b694bfc8e169ceeadae4a3f50f7725897acfd17d Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 14:08:02 +0000 Subject: [PATCH 39/57] some more log clarifications for L1 --- yarn-project/ethereum/src/l1_tx_utils.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index f7ab2b3c004..0d25fafb52c 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -251,7 +251,7 @@ export class L1TxUtils { return { txHash, gasLimit, gasPrice }; } catch (err: any) { const { message, metaMessages } = formatViemError(err); - this.logger?.error(`Failed to send transaction`, message, { metaMessages }); + this.logger?.error(`Failed to send L1 transaction`, message, { metaMessages }); throw { ...err, message, metaMessages }; } } @@ -388,7 +388,7 @@ export class L1TxUtils { await sleep(gasConfig.checkIntervalMs!); } catch (err: any) { const { message, ...error } = formatViemError(err); - this.logger?.warn(`Error monitoring tx ${currentTxHash}:`, message); + this.logger?.warn(`Error monitoring L1 transaction ${currentTxHash}:`, message); if (err.message?.includes('reverted')) { throw { ...error, message }; } @@ -434,9 +434,9 @@ export class L1TxUtils { try { const blobBaseFeeHex = await this.publicClient.request({ method: 'eth_blobBaseFee' }); blobBaseFee = BigInt(blobBaseFeeHex); - this.logger?.debug('Blob base fee:', { blobBaseFee: formatGwei(blobBaseFee) }); + this.logger?.debug('L1 Blob base fee:', { blobBaseFee: formatGwei(blobBaseFee) }); } catch { - this.logger?.warn('Failed to get blob base fee', attempt); + this.logger?.warn('Failed to get L1 blob base fee', attempt); } let priorityFee: bigint; @@ -558,10 +558,10 @@ export class L1TxUtils { maxFeePerBlobGas: gasPrice.maxFeePerBlobGas!, }) )?.gas; - this.logger?.debug('Gas used in estimateGas by blob tx', { gas: initialEstimate }); + this.logger?.debug('L1 gas used in estimateGas by blob tx', { gas: initialEstimate }); } else { initialEstimate = await this.publicClient.estimateGas({ account, ...request }); - this.logger?.debug('Gas used in estimateGas by non-blob tx', { gas: initialEstimate }); + this.logger?.debug('L1 gas used in estimateGas by non-blob tx', { gas: initialEstimate }); } // Add buffer based on either fixed amount or percentage @@ -602,19 +602,19 @@ export class L1TxUtils { }, ], }); - this.logger?.debug(`Gas used in simulation: ${result[0].calls[0].gasUsed}`, { + this.logger?.debug(`L1 gas used in simulation: ${result[0].calls[0].gasUsed}`, { result, }); if (result[0].calls[0].status === 'failure') { - this.logger?.error('Simulation failed', { + this.logger?.error('L1 transaction Simulation failed', { error: result[0].calls[0].error, }); - throw new Error(`Simulation failed with error: ${result[0].calls[0].error.message}`); + throw new Error(`L1 transaction simulation failed with error: ${result[0].calls[0].error.message}`); } return result[0].gasUsed; } catch (err) { if (err instanceof MethodNotFoundRpcError || err instanceof MethodNotSupportedRpcError) { - this.logger?.error('Node does not support simulation API'); + this.logger?.error('Node does not support eth_simulateV1 API'); } throw err; } From 4bd5f1f92f826f4e0d349a69a2e757d72313c416 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 14:19:32 +0000 Subject: [PATCH 40/57] handle regular ol' errors --- yarn-project/ethereum/src/utils.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/yarn-project/ethereum/src/utils.ts b/yarn-project/ethereum/src/utils.ts index 9f0f1ba5018..36be166ecad 100644 --- a/yarn-project/ethereum/src/utils.ts +++ b/yarn-project/ethereum/src/utils.ts @@ -99,6 +99,11 @@ export function prettyLogViemErrorMsg(err: any) { * @returns A FormattedViemError instance. */ export function formatViemError(error: any, abi: Abi = ErrorsAbi): FormattedViemError { + // If error is already a FormattedViemError, return it as is + if (error instanceof FormattedViemError) { + return error; + } + // First try to decode as a custom error using the ABI try { if (error?.data) { @@ -131,6 +136,11 @@ export function formatViemError(error: any, abi: Abi = ErrorsAbi): FormattedViem // If decoding fails, we fall back to the original formatting } + // If it's a regular Error instance, return it with its message + if (error instanceof Error) { + return new FormattedViemError(error.message); + } + // Original formatting logic for non-custom errors const truncateHex = (hex: string, length = 100) => { if (!hex || typeof hex !== 'string') { From abb34ff3adb45ef9b41c6518055f8b19daba710e Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 16:15:04 +0000 Subject: [PATCH 41/57] update test --- .../sequencer-client/src/publisher/l1-publisher.test.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts index bc9c6153712..f39bcf2962c 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts @@ -155,6 +155,7 @@ describe('L1Publisher', () => { }); (l1TxUtils as any).estimateGas.mockResolvedValue(GAS_GUESS); (l1TxUtils as any).simulateGasUsed.mockResolvedValue(1_000_000n); + (l1TxUtils as any).bumpGasLimit.mockImplementation((val: bigint) => val + (val * 20n) / 100n); }); const closeServer = (server: Server): Promise => { @@ -198,7 +199,7 @@ describe('L1Publisher', () => { }); }; - it('publishes and propose l2 block to l1', async () => { + it.only('publishes and propose l2 block to l1', async () => { rollupContractRead.archive.mockResolvedValue(l2Block.header.lastArchive.root.toString() as `0x${string}`); rollupContractWrite.propose.mockResolvedValueOnce(proposeTxHash); @@ -238,8 +239,8 @@ describe('L1Publisher', () => { to: mockRollupAddress, data: encodeFunctionData({ abi: rollupContract.abi, functionName: 'propose', args }), }, - // 1_000_000 is the gas used by the returned by simulateGasUsed & GAS_GUESS is the gas returned by estimateGas for the blob evaluation - { gasLimit: 1_000_000n + GAS_GUESS }, + // val + (val * 20n) / 100n + { gasLimit: 1_000_000n + GAS_GUESS + ((1_000_000n + GAS_GUESS) * 20n) / 100n }, { blobs: expectedBlobs.map(b => b.dataWithZeros), kzg }, ); From 33b6e403cc2d5f9006ebb21ab828d60c45921095 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 16:50:22 +0000 Subject: [PATCH 42/57] fix waitForEthereum --- spartan/aztec-network/templates/_helpers.tpl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spartan/aztec-network/templates/_helpers.tpl b/spartan/aztec-network/templates/_helpers.tpl index 9e23dc5ffdb..43870ab671d 100644 --- a/spartan/aztec-network/templates/_helpers.tpl +++ b/spartan/aztec-network/templates/_helpers.tpl @@ -192,6 +192,9 @@ nodeSelector: {{- end -}} {{- define "aztec-network.waitForEthereum" -}} +if [ -n "${EXTERNAL_ETHEREUM_HOST}" ]; then + export ETHEREUM_HOST="${EXTERNAL_ETHEREUM_HOST}" +fi echo "Awaiting ethereum node at ${ETHEREUM_HOST}" until curl -s -X POST -H 'Content-Type: application/json' \ -d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":67}' \ From 5f782c8dfbf19e0c569a45541d3640210e1c494e Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 17:23:43 +0000 Subject: [PATCH 43/57] add gasLimit to blockOverride (thx reth) --- yarn-project/ethereum/src/l1_tx_utils.ts | 4 ++-- yarn-project/sequencer-client/src/publisher/l1-publisher.ts | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index 0d25fafb52c..9314ad00241 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -571,7 +571,7 @@ export class L1TxUtils { } public async simulateGasUsed( - request: L1TxRequest, + request: L1TxRequest & { gas?: bigint }, blockOverrides: BlockOverrides = {}, stateOverrides: StateOverride = [], _gasConfig?: L1TxUtilsConfig, @@ -595,7 +595,7 @@ export class L1TxUtils { data: request.data, maxFeePerGas: gasPrice.maxFeePerGas, maxPriorityFeePerGas: gasPrice.maxPriorityFeePerGas, - gas: 12_000_000n, + gas: request.gas ?? 10_000_000n, nonce, }, ], diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 87850b74bb6..8a36cceba70 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -1062,10 +1062,13 @@ export class L1Publisher { { to: this.rollupContract.address, data, + gas: L1Publisher.PROPOSE_GAS_GUESS, }, { // @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp time: timestamp + 1n, + // @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit + gasLimit: L1Publisher.PROPOSE_GAS_GUESS * 2n, }, [ { @@ -1145,10 +1148,13 @@ export class L1Publisher { { to: this.rollupContract.address, data, + gas: L1Publisher.PROPOSE_AND_CLAIM_GAS_GUESS, }, { // @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp time: timestamp + 1n, + // @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit + gasLimit: L1Publisher.PROPOSE_AND_CLAIM_GAS_GUESS * 2n, }, [ { From 30f8648f930a4e6b17a9a8489d8e21e5dd2d80bf Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 17:25:10 +0000 Subject: [PATCH 44/57] remove .only --- .../sequencer-client/src/publisher/l1-publisher.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts index f39bcf2962c..a1990c3c638 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts @@ -199,7 +199,7 @@ describe('L1Publisher', () => { }); }; - it.only('publishes and propose l2 block to l1', async () => { + it('publishes and propose l2 block to l1', async () => { rollupContractRead.archive.mockResolvedValue(l2Block.header.lastArchive.root.toString() as `0x${string}`); rollupContractWrite.propose.mockResolvedValueOnce(proposeTxHash); From 5a9177e4ed2251d6a1de786d0a80f8514d2abe7b Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 17:37:29 +0000 Subject: [PATCH 45/57] fix sepolia values yaml & tf --- .../values/sepolia-48-validators-with-metrics.yaml | 3 ++- spartan/terraform/deploy-release/main.tf | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml b/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml index 04cfc6fd267..4b08967f01b 100644 --- a/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml +++ b/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml @@ -9,9 +9,10 @@ network: public: false ethereum: - externalHost: chainId: "11155111" deployL1ContractsPrivateKey: + execution: + externalHost: validator: l1FixedPriorityFeePerGas: 1 diff --git a/spartan/terraform/deploy-release/main.tf b/spartan/terraform/deploy-release/main.tf index 70967493b00..deef6d1a1a1 100644 --- a/spartan/terraform/deploy-release/main.tf +++ b/spartan/terraform/deploy-release/main.tf @@ -90,7 +90,7 @@ resource "helm_release" "aztec-gke-cluster" { dynamic "set" { for_each = var.ETHEREUM_EXTERNAL_HOST != "" ? toset(["iterate"]) : toset([]) content { - name = "ethereum.externalHost" + name = "ethereum.execution.externalHost" value = var.ETHEREUM_EXTERNAL_HOST } } From 730d1208391f986135fd28d6d9d28bb7da2b2866 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 17:47:50 +0000 Subject: [PATCH 46/57] just ethereum.externalHost --- spartan/aztec-network/templates/_helpers.tpl | 2 +- spartan/aztec-network/values.yaml | 3 +-- spartan/terraform/deploy-release/main.tf | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/spartan/aztec-network/templates/_helpers.tpl b/spartan/aztec-network/templates/_helpers.tpl index 43870ab671d..9f11457e714 100644 --- a/spartan/aztec-network/templates/_helpers.tpl +++ b/spartan/aztec-network/templates/_helpers.tpl @@ -142,7 +142,7 @@ Service Address Setup Container - name: OTEL_COLLECTOR_ENDPOINT value: "{{ .Values.telemetry.otelCollectorEndpoint }}" - name: EXTERNAL_ETHEREUM_HOST - value: "{{ .Values.ethereum.execution.externalHost }}" + value: "{{ .Values.ethereum.externalHost }}" - name: ETHEREUM_PORT value: "{{ .Values.ethereum.execution.service.port }}" - name: EXTERNAL_BOOT_NODE_HOST diff --git a/spartan/aztec-network/values.yaml b/spartan/aztec-network/values.yaml index 16f198d6223..382e90fefd8 100644 --- a/spartan/aztec-network/values.yaml +++ b/spartan/aztec-network/values.yaml @@ -231,8 +231,8 @@ ethereum: # 10 times the default of 131072 maxTxInputSizeBytes: "1310720" args: "" + externalHost: "" execution: - externalHost: "" service: port: 8545 targetPort: 8545 @@ -243,7 +243,6 @@ ethereum: cpu: "1" storageSize: "80Gi" beacon: - externalHost: "" service: port: 5052 targetPort: 5052 diff --git a/spartan/terraform/deploy-release/main.tf b/spartan/terraform/deploy-release/main.tf index deef6d1a1a1..70967493b00 100644 --- a/spartan/terraform/deploy-release/main.tf +++ b/spartan/terraform/deploy-release/main.tf @@ -90,7 +90,7 @@ resource "helm_release" "aztec-gke-cluster" { dynamic "set" { for_each = var.ETHEREUM_EXTERNAL_HOST != "" ? toset(["iterate"]) : toset([]) content { - name = "ethereum.execution.externalHost" + name = "ethereum.externalHost" value = var.ETHEREUM_EXTERNAL_HOST } } From acba1b04f54c128b76e9380479316f9da7473ac6 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 18:00:34 +0000 Subject: [PATCH 47/57] update 48 vals yaml too --- .../values/sepolia-48-validators-with-metrics.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml b/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml index 4b08967f01b..d841d512672 100644 --- a/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml +++ b/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml @@ -11,8 +11,7 @@ network: ethereum: chainId: "11155111" deployL1ContractsPrivateKey: - execution: - externalHost: + externalHost: validator: l1FixedPriorityFeePerGas: 1 From ab9ce345756a851a9f652112963e050735dd501f Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 18:03:41 +0000 Subject: [PATCH 48/57] nuke validateHeader --- l1-contracts/src/core/Rollup.sol | 32 --------- l1-contracts/src/core/interfaces/IRollup.sol | 9 --- .../src/publisher/l1-publisher.test.ts | 15 +--- .../src/publisher/l1-publisher.ts | 71 ++----------------- 4 files changed, 8 insertions(+), 119 deletions(-) diff --git a/l1-contracts/src/core/Rollup.sol b/l1-contracts/src/core/Rollup.sol index 7a97711b2cc..6c82db95604 100644 --- a/l1-contracts/src/core/Rollup.sol +++ b/l1-contracts/src/core/Rollup.sol @@ -401,38 +401,6 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes return (slot, pendingBlockNumber + 1); } - /** - * @notice Validate a header for submission - * - * @dev This is a convenience function that can be used by the sequencer to validate a "partial" header - * without having to deal with viem or anvil for simulating timestamps in the future. - * - * @param _header - The header to validate - * @param _signatures - The signatures to validate - * @param _digest - The digest to validate - * @param _currentTime - The current time - * @param _blobsHash - The blobs hash for this block - * @param _flags - The flags to validate - */ - function validateHeader( - bytes calldata _header, - Signature[] memory _signatures, - bytes32 _digest, - Timestamp _currentTime, - bytes32 _blobsHash, - DataStructures.ExecutionFlags memory _flags - ) external view override(IRollup) { - _validateHeader( - ExtRollupLib.decodeHeader(_header), - _signatures, - _digest, - _currentTime, - getManaBaseFeeAt(_currentTime, true), - _blobsHash, - _flags - ); - } - /** * @notice Validate blob transactions against given inputs. * @dev Only exists here for gas estimation. diff --git a/l1-contracts/src/core/interfaces/IRollup.sol b/l1-contracts/src/core/interfaces/IRollup.sol index 44fd7963cdc..93bf9643628 100644 --- a/l1-contracts/src/core/interfaces/IRollup.sol +++ b/l1-contracts/src/core/interfaces/IRollup.sol @@ -112,15 +112,6 @@ interface IRollup { function canProposeAtTime(Timestamp _ts, bytes32 _archive) external view returns (Slot, uint256); - function validateHeader( - bytes calldata _header, - Signature[] memory _signatures, - bytes32 _digest, - Timestamp _currentTime, - bytes32 _blobsHash, - DataStructures.ExecutionFlags memory _flags - ) external view; - // solhint-disable-next-line func-name-mixedcase function INBOX() external view returns (IInbox); diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts index 4c296d88e81..650735f75bf 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts @@ -54,15 +54,6 @@ interface MockRollupContractWrite { interface MockRollupContractRead { archive: () => Promise<`0x${string}`>; getCurrentSlot(): Promise; - validateHeader: ( - args: readonly [ - `0x${string}`, - ViemSignature[], - `0x${string}`, - bigint, - { ignoreDA: boolean; ignoreSignatures: boolean }, - ], - ) => Promise; } class MockRollupContract { @@ -264,11 +255,11 @@ describe('L1Publisher', () => { it('does not retry if simulating a publish and propose tx fails', async () => { rollupContractRead.archive.mockResolvedValue(l2Block.header.lastArchive.root.toString() as `0x${string}`); - rollupContractRead.validateHeader.mockRejectedValueOnce(new Error('Test error')); + (l1TxUtils as any).simulateGasUsed.mockResolvedValue(new Error()); - await expect(publisher.proposeL2Block(l2Block)).rejects.toThrow(); + const result = await publisher.proposeL2Block(l2Block); - expect(rollupContractRead.validateHeader).toHaveBeenCalledTimes(1); + expect(result).toEqual(false); }); it('does not retry if sending a publish and propose tx fails', async () => { diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 8a36cceba70..72b8cedb98f 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -9,13 +9,7 @@ import { getHashedSignaturePayload, } from '@aztec/circuit-types'; import { type L1PublishBlockStats, type L1PublishProofStats, type L1PublishStats } from '@aztec/circuit-types/stats'; -import { - AGGREGATION_OBJECT_LENGTH, - AZTEC_MAX_EPOCH_DURATION, - type BlockHeader, - EthAddress, - type Proof, -} from '@aztec/circuits.js'; +import { AGGREGATION_OBJECT_LENGTH, AZTEC_MAX_EPOCH_DURATION, EthAddress, type Proof } from '@aztec/circuits.js'; import { type FeeRecipient, type RootRollupPublicInputs } from '@aztec/circuits.js/rollup'; import { type EthereumChain, @@ -45,12 +39,12 @@ import { type Chain, type Client, type ContractFunctionExecutionError, - ContractFunctionRevertedError, + type ContractFunctionRevertedError, type GetContractReturnType, type Hex, type HttpTransport, - MethodNotFoundRpcError, - MethodNotSupportedRpcError, + type MethodNotFoundRpcError, + type MethodNotSupportedRpcError, type PrivateKeyAccount, type PublicActions, type PublicClient, @@ -404,49 +398,6 @@ export class L1Publisher { return quote; } - /** - * @notice Will call `validateHeader` to make sure that it is possible to propose - * - * @dev Throws if unable to propose - * - * @param header - The header to propose - * @param digest - The digest that attestations are signing over - * - */ - public async validateBlockForSubmission( - header: BlockHeader, - attestationData: { digest: Buffer; signatures: Signature[] } = { - digest: Buffer.alloc(32), - signatures: [], - }, - ): Promise { - const ts = BigInt((await this.publicClient.getBlock()).timestamp + this.ethereumSlotDuration); - - const formattedSignatures = attestationData.signatures.map(attest => attest.toViemSignature()); - const flags = { ignoreDA: true, ignoreSignatures: formattedSignatures.length == 0 }; - - const args = [ - `0x${header.toBuffer().toString('hex')}`, - formattedSignatures, - `0x${attestationData.digest.toString('hex')}`, - ts, - `0x${header.contentCommitment.blobsHash.toString('hex')}`, - flags, - ] as const; - - try { - await this.rollupContract.read.validateHeader(args, { account: this.account }); - } catch (error: unknown) { - // Specify the type of error - if (error instanceof ContractFunctionRevertedError) { - const err = error as ContractFunctionRevertedError; - this.log.debug(`Validation failed: ${err.message}`, err.data); - } - throw error; - } - return ts; - } - public async getCurrentEpochCommittee(): Promise { const committee = await this.rollupContract.read.getCurrentEpochCommittee(); return committee.map(EthAddress.fromString); @@ -586,10 +537,6 @@ export class L1Publisher { blockHash: block.hash().toString(), }; - const consensusPayload = new ConsensusPayload(block.header, block.archive.root, txHashes ?? []); - - const digest = getHashedSignaturePayload(consensusPayload, SignatureDomainSeparator.blockAttestation); - const blobs = Blob.getBlobs(block.body.toBlobFields()); const proposeTxArgs = { header: block.header.toBuffer(), @@ -609,16 +556,8 @@ export class L1Publisher { const timer = new Timer(); - // @note This will make sure that we are passing the checks for our header ASSUMING that the data is also made available - // This means that we can avoid the simulation issues in later checks. - // By simulation issue, I mean the fact that the block.timestamp is equal to the last block, not the next, which - // make time consistency checks break. - const ts = await this.validateBlockForSubmission(block.header, { - digest: digest.toBuffer(), - signatures: attestations ?? [], - }); - this.log.debug(`Submitting propose transaction`); + const ts = BigInt((await this.publicClient.getBlock()).timestamp + this.ethereumSlotDuration); const result = proofQuote ? await this.sendProposeAndClaimTx(proposeTxArgs, proofQuote, opts, ts) : await this.sendProposeTx(proposeTxArgs, opts, ts); From d50ba48f9fc18f4ac240fdd81cbdbac4655bdcc7 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 18:11:19 +0000 Subject: [PATCH 49/57] fix imports --- .../sequencer-client/src/publisher/l1-publisher.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 72b8cedb98f..9d509b6b647 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -1,13 +1,5 @@ import { type BlobSinkClientInterface, createBlobSinkClient } from '@aztec/blob-sink/client'; -import { - ConsensusPayload, - type EpochProofClaim, - type EpochProofQuote, - type L2Block, - SignatureDomainSeparator, - type TxHash, - getHashedSignaturePayload, -} from '@aztec/circuit-types'; +import { type EpochProofClaim, type EpochProofQuote, type L2Block, type TxHash } from '@aztec/circuit-types'; import { type L1PublishBlockStats, type L1PublishProofStats, type L1PublishStats } from '@aztec/circuit-types/stats'; import { AGGREGATION_OBJECT_LENGTH, AZTEC_MAX_EPOCH_DURATION, EthAddress, type Proof } from '@aztec/circuits.js'; import { type FeeRecipient, type RootRollupPublicInputs } from '@aztec/circuits.js/rollup'; @@ -43,8 +35,8 @@ import { type GetContractReturnType, type Hex, type HttpTransport, - type MethodNotFoundRpcError, - type MethodNotSupportedRpcError, + MethodNotFoundRpcError, + MethodNotSupportedRpcError, type PrivateKeyAccount, type PublicActions, type PublicClient, From d432d46fc9c1711f423fea300b2a8b2c840dd830 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 18:30:44 +0000 Subject: [PATCH 50/57] Revert "nuke validateHeader" This reverts commit ab9ce345756a851a9f652112963e050735dd501f. --- l1-contracts/src/core/Rollup.sol | 32 +++++++++ l1-contracts/src/core/interfaces/IRollup.sol | 9 +++ .../src/publisher/l1-publisher.test.ts | 15 ++++- .../src/publisher/l1-publisher.ts | 67 ++++++++++++++++++- 4 files changed, 117 insertions(+), 6 deletions(-) diff --git a/l1-contracts/src/core/Rollup.sol b/l1-contracts/src/core/Rollup.sol index 6c82db95604..7a97711b2cc 100644 --- a/l1-contracts/src/core/Rollup.sol +++ b/l1-contracts/src/core/Rollup.sol @@ -401,6 +401,38 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes return (slot, pendingBlockNumber + 1); } + /** + * @notice Validate a header for submission + * + * @dev This is a convenience function that can be used by the sequencer to validate a "partial" header + * without having to deal with viem or anvil for simulating timestamps in the future. + * + * @param _header - The header to validate + * @param _signatures - The signatures to validate + * @param _digest - The digest to validate + * @param _currentTime - The current time + * @param _blobsHash - The blobs hash for this block + * @param _flags - The flags to validate + */ + function validateHeader( + bytes calldata _header, + Signature[] memory _signatures, + bytes32 _digest, + Timestamp _currentTime, + bytes32 _blobsHash, + DataStructures.ExecutionFlags memory _flags + ) external view override(IRollup) { + _validateHeader( + ExtRollupLib.decodeHeader(_header), + _signatures, + _digest, + _currentTime, + getManaBaseFeeAt(_currentTime, true), + _blobsHash, + _flags + ); + } + /** * @notice Validate blob transactions against given inputs. * @dev Only exists here for gas estimation. diff --git a/l1-contracts/src/core/interfaces/IRollup.sol b/l1-contracts/src/core/interfaces/IRollup.sol index 93bf9643628..44fd7963cdc 100644 --- a/l1-contracts/src/core/interfaces/IRollup.sol +++ b/l1-contracts/src/core/interfaces/IRollup.sol @@ -112,6 +112,15 @@ interface IRollup { function canProposeAtTime(Timestamp _ts, bytes32 _archive) external view returns (Slot, uint256); + function validateHeader( + bytes calldata _header, + Signature[] memory _signatures, + bytes32 _digest, + Timestamp _currentTime, + bytes32 _blobsHash, + DataStructures.ExecutionFlags memory _flags + ) external view; + // solhint-disable-next-line func-name-mixedcase function INBOX() external view returns (IInbox); diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts index 650735f75bf..4c296d88e81 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts @@ -54,6 +54,15 @@ interface MockRollupContractWrite { interface MockRollupContractRead { archive: () => Promise<`0x${string}`>; getCurrentSlot(): Promise; + validateHeader: ( + args: readonly [ + `0x${string}`, + ViemSignature[], + `0x${string}`, + bigint, + { ignoreDA: boolean; ignoreSignatures: boolean }, + ], + ) => Promise; } class MockRollupContract { @@ -255,11 +264,11 @@ describe('L1Publisher', () => { it('does not retry if simulating a publish and propose tx fails', async () => { rollupContractRead.archive.mockResolvedValue(l2Block.header.lastArchive.root.toString() as `0x${string}`); - (l1TxUtils as any).simulateGasUsed.mockResolvedValue(new Error()); + rollupContractRead.validateHeader.mockRejectedValueOnce(new Error('Test error')); - const result = await publisher.proposeL2Block(l2Block); + await expect(publisher.proposeL2Block(l2Block)).rejects.toThrow(); - expect(result).toEqual(false); + expect(rollupContractRead.validateHeader).toHaveBeenCalledTimes(1); }); it('does not retry if sending a publish and propose tx fails', async () => { diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 9d509b6b647..73b3c65f49d 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -1,7 +1,13 @@ import { type BlobSinkClientInterface, createBlobSinkClient } from '@aztec/blob-sink/client'; import { type EpochProofClaim, type EpochProofQuote, type L2Block, type TxHash } from '@aztec/circuit-types'; import { type L1PublishBlockStats, type L1PublishProofStats, type L1PublishStats } from '@aztec/circuit-types/stats'; -import { AGGREGATION_OBJECT_LENGTH, AZTEC_MAX_EPOCH_DURATION, EthAddress, type Proof } from '@aztec/circuits.js'; +import { + AGGREGATION_OBJECT_LENGTH, + AZTEC_MAX_EPOCH_DURATION, + type BlockHeader, + EthAddress, + type Proof, +} from '@aztec/circuits.js'; import { type FeeRecipient, type RootRollupPublicInputs } from '@aztec/circuits.js/rollup'; import { type EthereumChain, @@ -31,7 +37,7 @@ import { type Chain, type Client, type ContractFunctionExecutionError, - type ContractFunctionRevertedError, + ContractFunctionRevertedError, type GetContractReturnType, type Hex, type HttpTransport, @@ -390,6 +396,49 @@ export class L1Publisher { return quote; } + /** + * @notice Will call `validateHeader` to make sure that it is possible to propose + * + * @dev Throws if unable to propose + * + * @param header - The header to propose + * @param digest - The digest that attestations are signing over + * + */ + public async validateBlockForSubmission( + header: BlockHeader, + attestationData: { digest: Buffer; signatures: Signature[] } = { + digest: Buffer.alloc(32), + signatures: [], + }, + ): Promise { + const ts = BigInt((await this.publicClient.getBlock()).timestamp + this.ethereumSlotDuration); + + const formattedSignatures = attestationData.signatures.map(attest => attest.toViemSignature()); + const flags = { ignoreDA: true, ignoreSignatures: formattedSignatures.length == 0 }; + + const args = [ + `0x${header.toBuffer().toString('hex')}`, + formattedSignatures, + `0x${attestationData.digest.toString('hex')}`, + ts, + `0x${header.contentCommitment.blobsHash.toString('hex')}`, + flags, + ] as const; + + try { + await this.rollupContract.read.validateHeader(args, { account: this.account }); + } catch (error: unknown) { + // Specify the type of error + if (error instanceof ContractFunctionRevertedError) { + const err = error as ContractFunctionRevertedError; + this.log.debug(`Validation failed: ${err.message}`, err.data); + } + throw error; + } + return ts; + } + public async getCurrentEpochCommittee(): Promise { const committee = await this.rollupContract.read.getCurrentEpochCommittee(); return committee.map(EthAddress.fromString); @@ -529,6 +578,10 @@ export class L1Publisher { blockHash: block.hash().toString(), }; + const consensusPayload = new ConsensusPayload(block.header, block.archive.root, txHashes ?? []); + + const digest = getHashedSignaturePayload(consensusPayload, SignatureDomainSeparator.blockAttestation); + const blobs = Blob.getBlobs(block.body.toBlobFields()); const proposeTxArgs = { header: block.header.toBuffer(), @@ -548,8 +601,16 @@ export class L1Publisher { const timer = new Timer(); + // @note This will make sure that we are passing the checks for our header ASSUMING that the data is also made available + // This means that we can avoid the simulation issues in later checks. + // By simulation issue, I mean the fact that the block.timestamp is equal to the last block, not the next, which + // make time consistency checks break. + const ts = await this.validateBlockForSubmission(block.header, { + digest: digest.toBuffer(), + signatures: attestations ?? [], + }); + this.log.debug(`Submitting propose transaction`); - const ts = BigInt((await this.publicClient.getBlock()).timestamp + this.ethereumSlotDuration); const result = proofQuote ? await this.sendProposeAndClaimTx(proposeTxArgs, proofQuote, opts, ts) : await this.sendProposeTx(proposeTxArgs, opts, ts); From 63fd6e995ab7116b6bc9fae98e2d20354f6c868f Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 21 Jan 2025 19:12:55 +0000 Subject: [PATCH 51/57] re-instate imports --- .../src/publisher/l1-publisher.ts | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 73b3c65f49d..7fbff1a824b 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -1,5 +1,13 @@ import { type BlobSinkClientInterface, createBlobSinkClient } from '@aztec/blob-sink/client'; -import { type EpochProofClaim, type EpochProofQuote, type L2Block, type TxHash } from '@aztec/circuit-types'; +import { + ConsensusPayload, + type EpochProofClaim, + type EpochProofQuote, + type L2Block, + SignatureDomainSeparator, + type TxHash, + getHashedSignaturePayload, +} from '@aztec/circuit-types'; import { type L1PublishBlockStats, type L1PublishProofStats, type L1PublishStats } from '@aztec/circuit-types/stats'; import { AGGREGATION_OBJECT_LENGTH, @@ -685,9 +693,17 @@ export class L1Publisher { }), }); } catch (err) { - this.log.error(`Failed to claim epoch proof right`, err, { - proofQuote: proofQuote.toInspect(), - }); + if (err instanceof FormattedViemError) { + const { message, metaMessages } = err; + this.log.error(`Failed to claim epoch proof right`, message, { + metaMessages, + proofQuote: proofQuote.toInspect(), + }); + } else { + this.log.error(`Failed to claim epoch proof right`, err, { + proofQuote: proofQuote.toInspect(), + }); + } return false; } From 7e9c3ced657cacf249cca39193c59d581fd3aa03 Mon Sep 17 00:00:00 2001 From: spypsy Date: Wed, 22 Jan 2025 09:11:21 +0000 Subject: [PATCH 52/57] formatting --- yarn-project/archiver/src/archiver/archiver.test.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/yarn-project/archiver/src/archiver/archiver.test.ts b/yarn-project/archiver/src/archiver/archiver.test.ts index 75c679116cb..bd21698f8d2 100644 --- a/yarn-project/archiver/src/archiver/archiver.test.ts +++ b/yarn-project/archiver/src/archiver/archiver.test.ts @@ -141,10 +141,9 @@ describe('Archiver', () => { Promise.resolve(blocks[Number(args[0] - 1n)].archive.root.toString()), ); mockRollupEvents = mock(); - mockRollupEvents.L2BlockProposed.mockImplementation((filter: any, { fromBlock, toBlock }) => - Promise.resolve( - l2BlockProposedLogs.filter(log => log.blockNumber! >= fromBlock && log.blockNumber! <= toBlock), - )); + mockRollupEvents.L2BlockProposed.mockImplementation((filter: any, { fromBlock, toBlock }) => + Promise.resolve(l2BlockProposedLogs.filter(log => log.blockNumber! >= fromBlock && log.blockNumber! <= toBlock)), + ); mockRollup = { read: mockRollupRead, getEvents: mockRollupEvents, From 4c9ffc24f9a0d9cbe24189ecac663788b4acddd8 Mon Sep 17 00:00:00 2001 From: spypsy Date: Wed, 22 Jan 2025 15:18:20 +0000 Subject: [PATCH 53/57] add logging to timed out tx, reduce bot tx interval --- .../values/sepolia-48-validators-with-metrics.yaml | 2 +- yarn-project/ethereum/src/l1_tx_utils.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml b/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml index d841d512672..269c188b29a 100644 --- a/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml +++ b/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml @@ -77,4 +77,4 @@ proverNode: proverPublisherPrivateKey: bot: - txIntervalSeconds: 5 + txIntervalSeconds: 0 diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index 9314ad00241..5b2e08f5bf7 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -397,6 +397,10 @@ export class L1TxUtils { // Check if tx has timed out. txTimedOut = isTimedOut(); } + this.logger?.error(`L1 transaction ${currentTxHash} timed out`, { + txHash: currentTxHash, + ...tx, + }); throw new Error(`L1 transaction ${currentTxHash} timed out`); } From 7e0771368c38fada9f386f3be41d08179a3e0056 Mon Sep 17 00:00:00 2001 From: spypsy Date: Wed, 22 Jan 2025 16:11:48 +0000 Subject: [PATCH 54/57] tweak gas config --- .../values/sepolia-48-validators-with-metrics.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml b/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml index 269c188b29a..a3937f09aaa 100644 --- a/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml +++ b/spartan/aztec-network/values/sepolia-48-validators-with-metrics.yaml @@ -14,8 +14,8 @@ ethereum: externalHost: validator: - l1FixedPriorityFeePerGas: 1 - l1GasLimitBufferPercentage: 5 + l1FixedPriorityFeePerGas: 2 + l1GasLimitBufferPercentage: 15 replicas: 48 validatorKeys: validatorAddresses: From 5ed87e88e317d486c2bb30ec9344bae19147c8f2 Mon Sep 17 00:00:00 2001 From: spypsy Date: Thu, 23 Jan 2025 14:12:01 +0000 Subject: [PATCH 55/57] Update yarn-project/ethereum/src/l1_tx_utils.test.ts Co-authored-by: Santiago Palladino --- yarn-project/ethereum/src/l1_tx_utils.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.test.ts b/yarn-project/ethereum/src/l1_tx_utils.test.ts index 2484e20792c..2d1998902e0 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.test.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.test.ts @@ -376,7 +376,6 @@ describe('GasUtils', () => { fail('Should have thrown'); } catch (err: any) { const res = err; - // console.log('res', res); const { message } = res; // Verify the error contains actual newlines, not escaped \n expect(message).not.toContain('\\n'); From 9ff3659d2f4a3d88cde47bd771e32e6d1a12e244 Mon Sep 17 00:00:00 2001 From: spypsy Date: Thu, 23 Jan 2025 14:46:01 +0000 Subject: [PATCH 56/57] PR Fixes --- yarn-project/ethereum/src/l1_tx_utils.ts | 20 +-- .../src/publisher/l1-publisher.ts | 124 ++++++++---------- 2 files changed, 68 insertions(+), 76 deletions(-) diff --git a/yarn-project/ethereum/src/l1_tx_utils.ts b/yarn-project/ethereum/src/l1_tx_utils.ts index 5b2e08f5bf7..3122609fec2 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.ts @@ -250,9 +250,9 @@ export class L1TxUtils { return { txHash, gasLimit, gasPrice }; } catch (err: any) { - const { message, metaMessages } = formatViemError(err); - this.logger?.error(`Failed to send L1 transaction`, message, { metaMessages }); - throw { ...err, message, metaMessages }; + const viemError = formatViemError(err); + this.logger?.error(`Failed to send L1 transaction`, viemError.message, { metaMessages: viemError.metaMessages }); + throw viemError; } } @@ -387,10 +387,10 @@ export class L1TxUtils { } await sleep(gasConfig.checkIntervalMs!); } catch (err: any) { - const { message, ...error } = formatViemError(err); - this.logger?.warn(`Error monitoring L1 transaction ${currentTxHash}:`, message); - if (err.message?.includes('reverted')) { - throw { ...error, message }; + const viemError = formatViemError(err); + this.logger?.warn(`Error monitoring L1 transaction ${currentTxHash}:`, viemError.message); + if (viemError.message?.includes('reverted')) { + throw viemError; } await sleep(gasConfig.checkIntervalMs!); } @@ -578,7 +578,7 @@ export class L1TxUtils { request: L1TxRequest & { gas?: bigint }, blockOverrides: BlockOverrides = {}, stateOverrides: StateOverride = [], - _gasConfig?: L1TxUtilsConfig, + _gasConfig?: L1TxUtilsConfig & { fallbackGasEstimate?: bigint }, ): Promise { const gasConfig = { ...this.config, ..._gasConfig }; const gasPrice = await this.getGasPrice(gasConfig, false); @@ -619,6 +619,10 @@ export class L1TxUtils { } catch (err) { if (err instanceof MethodNotFoundRpcError || err instanceof MethodNotSupportedRpcError) { this.logger?.error('Node does not support eth_simulateV1 API'); + if (gasConfig.fallbackGasEstimate) { + this.logger?.debug(`Using fallback gas estimate: ${gasConfig.fallbackGasEstimate}`); + return gasConfig.fallbackGasEstimate; + } } throw err; } diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 7fbff1a824b..3ce845caf3e 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -1064,42 +1064,35 @@ export class L1Publisher { args, }); - let simulationResult: bigint; - try { - simulationResult = await this.l1TxUtils.simulateGasUsed( - { - to: this.rollupContract.address, - data, - gas: L1Publisher.PROPOSE_GAS_GUESS, - }, + const simulationResult = await this.l1TxUtils.simulateGasUsed( + { + to: this.rollupContract.address, + data, + gas: L1Publisher.PROPOSE_GAS_GUESS, + }, + { + // @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp + time: timestamp + 1n, + // @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit + gasLimit: L1Publisher.PROPOSE_GAS_GUESS * 2n, + }, + [ { - // @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp - time: timestamp + 1n, - // @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit - gasLimit: L1Publisher.PROPOSE_GAS_GUESS * 2n, + address: this.rollupContract.address, + // @note we override checkBlob to false since blobs are not part simulate() + stateDiff: [ + { + slot: toHex(9n, true), + value: toHex(0n, true), + }, + ], }, - [ - { - address: this.rollupContract.address, - // @note we override checkBlob to false since blobs are not part simulate() - stateDiff: [ - { - slot: toHex(9n, true), - value: toHex(0n, true), - }, - ], - }, - ], - ); - } catch (simErr) { - if (simErr instanceof MethodNotFoundRpcError || simErr instanceof MethodNotSupportedRpcError) { - // @note node doesn't support simulation API, we will use gas guesstimate - this.log.warn('Using gas guesstimate'); - simulationResult = L1Publisher.PROPOSE_GAS_GUESS; - } else { - throw simErr; - } - } + ], + { + // @note fallback gas estimate to use if the node doesn't support simulation API + fallbackGasEstimate: L1Publisher.PROPOSE_GAS_GUESS, + }, + ); const result = await this.l1TxUtils.sendAndMonitorTransaction( { @@ -1142,7 +1135,7 @@ export class L1Publisher { if (this.interrupted) { return undefined; } - let simulationResult: bigint; + try { const kzg = Blob.getViemKzgInstance(); const { args, blobEvaluationGas } = await this.prepareProposeTx(encodedData); @@ -1151,41 +1144,36 @@ export class L1Publisher { functionName: 'proposeAndClaim', args: [...args, quote.toViemArgs()], }); - try { - simulationResult = await this.l1TxUtils.simulateGasUsed( - { - to: this.rollupContract.address, - data, - gas: L1Publisher.PROPOSE_AND_CLAIM_GAS_GUESS, - }, + + const simulationResult = await this.l1TxUtils.simulateGasUsed( + { + to: this.rollupContract.address, + data, + gas: L1Publisher.PROPOSE_AND_CLAIM_GAS_GUESS, + }, + { + // @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp + time: timestamp + 1n, + // @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit + gasLimit: L1Publisher.PROPOSE_AND_CLAIM_GAS_GUESS * 2n, + }, + [ { - // @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp - time: timestamp + 1n, - // @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit - gasLimit: L1Publisher.PROPOSE_AND_CLAIM_GAS_GUESS * 2n, + address: this.rollupContract.address, + // @note we override checkBlob to false since blobs are not part simulate() + stateDiff: [ + { + slot: toHex(9n, true), + value: toHex(0n, true), + }, + ], }, - [ - { - address: this.rollupContract.address, - // @note we override checkBlob to false since blobs are not part simulate() - stateDiff: [ - { - slot: toHex(9n, true), - value: toHex(0n, true), - }, - ], - }, - ], - ); - } catch (simErr) { - if (simErr instanceof MethodNotFoundRpcError || simErr instanceof MethodNotSupportedRpcError) { - // @note node doesn't support simulation API, we will use gas guesstimate - this.log.warn('Using gas guesstimate'); - simulationResult = L1Publisher.PROPOSE_GAS_GUESS; - } else { - throw simErr; - } - } + ], + { + // @note fallback gas estimate to use if the node doesn't support simulation API + fallbackGasEstimate: L1Publisher.PROPOSE_AND_CLAIM_GAS_GUESS, + }, + ); const result = await this.l1TxUtils.sendAndMonitorTransaction( { to: this.rollupContract.address, From 901c8e3a3812b94620888a72abbbff7af7be67d5 Mon Sep 17 00:00:00 2001 From: spypsy Date: Thu, 23 Jan 2025 15:10:27 +0000 Subject: [PATCH 57/57] rm unused imports --- yarn-project/sequencer-client/src/publisher/l1-publisher.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 3ce845caf3e..2252458fc95 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -49,8 +49,6 @@ import { type GetContractReturnType, type Hex, type HttpTransport, - MethodNotFoundRpcError, - MethodNotSupportedRpcError, type PrivateKeyAccount, type PublicActions, type PublicClient,