Skip to content

Commit a40bb6b

Browse files
authored
fix: correctly handle prover reverted txs (#16654)
2 parents d0d5be1 + d6e7c15 commit a40bb6b

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed

yarn-project/prover-node/src/prover-node-publisher.test.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { BatchedBlob } from '@aztec/blob-lib';
22
import type { L1TxUtils, RollupContract } from '@aztec/ethereum';
33
import { SecretValue } from '@aztec/foundation/config';
4+
import { randomBytes } from '@aztec/foundation/crypto';
45
import { EthAddress } from '@aztec/foundation/eth-address';
56
import { Fr } from '@aztec/foundation/fields';
67
import type { PublisherConfig, TxSenderConfig } from '@aztec/sequencer-client';
78
import { Proof } from '@aztec/stdlib/proofs';
89
import { RootRollupPublicInputs } from '@aztec/stdlib/rollup';
910

11+
import { jest } from '@jest/globals';
1012
import { type MockProxy, mock } from 'jest-mock-extended';
1113

1214
import { ProverNodePublisher } from './prover-node-publisher.js';
@@ -193,4 +195,87 @@ describe('prover-node-publisher', () => {
193195
}
194196
},
195197
);
198+
199+
it('handles reverted txs correctly', async () => {
200+
const blocks = [RootRollupPublicInputs.random(), RootRollupPublicInputs.random()];
201+
202+
// Return the tips specified by the test
203+
rollup.getTips.mockResolvedValue({
204+
pendingBlockNumber: 2n,
205+
provenBlockNumber: 1n,
206+
});
207+
208+
// Return the requested block
209+
rollup.getBlock.mockImplementation((i: bigint) =>
210+
Promise.resolve({
211+
archive: blocks[Number(i) - 1].endArchiveRoot.toString(),
212+
attestationsHash: '0x', // unused,
213+
payloadDigest: '0x', // unused,
214+
headerHash: '0x', // unused,
215+
blobCommitmentsHash: '0x', // unused,
216+
slotNumber: 0n, // unused,
217+
feeHeader: {
218+
excessMana: 0n, // unused
219+
manaUsed: 0n, // unused
220+
feeAssetPriceNumerator: 0n, // unused
221+
congestionCost: 0n, // unused
222+
proverCost: 0n, // unused
223+
},
224+
}),
225+
);
226+
227+
// We have built a rollup proof of the range fromBlock - toBlock
228+
// so we need to set our archives and hashes accordingly
229+
const ourPublicInputs = RootRollupPublicInputs.random();
230+
ourPublicInputs.previousArchiveRoot = blocks[0].endArchiveRoot ?? Fr.ZERO;
231+
ourPublicInputs.endArchiveRoot = blocks[1].endArchiveRoot ?? Fr.ZERO;
232+
233+
const ourBatchedBlob = new BatchedBlob(
234+
ourPublicInputs.blobPublicInputs.blobCommitmentsHash,
235+
ourPublicInputs.blobPublicInputs.z,
236+
ourPublicInputs.blobPublicInputs.y,
237+
ourPublicInputs.blobPublicInputs.c,
238+
ourPublicInputs.blobPublicInputs.c.negate(), // Fill with dummy value
239+
);
240+
241+
// Return our public inputs
242+
const totalFields = ourPublicInputs.toFields();
243+
rollup.getEpochProofPublicInputs.mockResolvedValue(totalFields.map(x => x.toString()));
244+
245+
jest.spyOn(l1Utils, 'getSenderBalance').mockResolvedValue(42n);
246+
jest.spyOn(l1Utils, 'getSenderAddress').mockReturnValue(EthAddress.random());
247+
248+
jest.spyOn(l1Utils, 'sendAndMonitorTransaction').mockResolvedValue({
249+
gasPrice: {} as any,
250+
receipt: {
251+
status: 'reverted',
252+
effectiveGasPrice: 1n,
253+
gasUsed: 1n,
254+
transactionHash: `0x${randomBytes(32).toString('hex')}`,
255+
cumulativeGasUsed: 1n,
256+
blockNumber: 42n,
257+
blockHash: `0x${randomBytes(32).toString('hex')}`,
258+
from: EthAddress.random().toString(),
259+
} as any,
260+
});
261+
262+
jest.spyOn(l1Utils, 'getTransactionStats').mockResolvedValue({
263+
calldataGas: 1,
264+
calldataSize: 1,
265+
sender: EthAddress.random().toString(),
266+
transactionHash: `0x${randomBytes(32).toString('hex')}`,
267+
});
268+
269+
const result = await publisher.submitEpochProof({
270+
epochNumber: 2,
271+
fromBlock: 2,
272+
toBlock: 2,
273+
publicInputs: ourPublicInputs,
274+
proof: Proof.empty(),
275+
batchedBlobInputs: ourBatchedBlob,
276+
attestations: [],
277+
});
278+
279+
expect(result).toBe(false);
280+
});
196281
});

yarn-project/prover-node/src/prover-node-publisher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class ProverNodePublisher {
123123
}
124124

125125
// Tx was mined successfully
126-
if (txReceipt.status) {
126+
if (txReceipt.status === 'success') {
127127
const tx = await this.l1TxUtils.getTransactionStats(txReceipt.transactionHash);
128128
const stats: L1PublishProofStats = {
129129
gasPrice: txReceipt.effectiveGasPrice,

0 commit comments

Comments
 (0)