Skip to content

Commit 3627865

Browse files
author
AztecBot
committed
Merge branch 'next' into merge-train/barretenberg
2 parents 04d5631 + 8cd0d2e commit 3627865

File tree

8 files changed

+127
-30
lines changed

8 files changed

+127
-30
lines changed

yarn-project/node-keystore/examples/everything.json

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,17 @@
6969
"mnemonic": "test test test test test test test test test test test junk",
7070
"addressCount": 1
7171
},
72-
[
73-
"0x5555555555555555555555555555555555555555555555555555555555555555",
74-
"0x6666666666666666666666666666666666666666",
75-
{
76-
"address": "0x7777777777777777777777777777777777777777",
77-
"remoteSignerUrl": "https://localhost:9300",
78-
"certPath": "/path/to/prover-cert.pem"
79-
},
80-
{
81-
"path": "/tmp/prover-publishers",
82-
"password": "prover-pass"
83-
}
84-
]
72+
"0x5555555555555555555555555555555555555555555555555555555555555555",
73+
"0x6666666666666666666666666666666666666666",
74+
{
75+
"address": "0x7777777777777777777777777777777777777777",
76+
"remoteSignerUrl": "https://localhost:9300",
77+
"certPath": "/path/to/prover-cert.pem"
78+
},
79+
{
80+
"path": "/tmp/prover-publishers",
81+
"password": "prover-pass"
82+
}
8583
]
8684
}
8785
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"schemaVersion": 1,
3+
"prover": {
4+
"id": "0x1234567890123456789012345678901234567890",
5+
"publisher": "0x1234567890123456789012345678901234567890123456789012345678901234"
6+
}
7+
}

yarn-project/node-keystore/src/keystore_manager.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,10 @@ export class KeystoreManager {
218218
};
219219
}
220220

221-
// Handle complex prover case with id and publishers
222-
const proverConfig = this.keystore.prover;
223-
const signers: EthSigner[] = [];
224-
225-
for (const publisherAccounts of proverConfig.publisher) {
226-
const publisherSigners = this.createSignersFromEthAccounts(publisherAccounts, this.keystore.remoteSigner);
227-
signers.push(...publisherSigners);
228-
}
221+
const id = EthAddress.fromString(this.keystore.prover.id);
222+
const signers = this.createSignersFromEthAccounts(this.keystore.prover.publisher, this.keystore.remoteSigner);
229223

230-
return {
231-
id: EthAddress.fromString(proverConfig.id),
232-
signers,
233-
};
224+
return { id, signers };
234225
}
235226

236227
/**

yarn-project/node-keystore/src/schemas.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ describe('Keystore Schema Validation', () => {
5757
expect((parsed.prover as any).publisher).toHaveLength(2);
5858
});
5959

60+
it('should validate prover with single publisher example', () => {
61+
const keystore = loadExample('prover-with-single-publisher.json');
62+
expect(() => keystoreSchema.parse(keystore)).not.toThrow();
63+
64+
const parsed = keystoreSchema.parse(keystore);
65+
expect(parsed.schemaVersion).toBe(1);
66+
expect(typeof parsed.prover).toBe('object');
67+
expect((parsed.prover as any).id).toBe('0x1234567890123456789012345678901234567890');
68+
expect((parsed.prover as any).publisher).toBe('0x1234567890123456789012345678901234567890123456789012345678901234');
69+
});
70+
6071
it('should reject keystore with invalid schema version', () => {
6172
const keystore = {
6273
schemaVersion: 2, // Invalid

yarn-project/node-keystore/src/schemas.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,22 @@ const mnemonicConfigSchema = z.object({
5151
});
5252

5353
// EthAccount schema
54-
const ethAccountSchema = z.union([ethPrivateKeySchema, remoteSignerAccountSchema, jsonKeyFileV3Schema]);
54+
const ethAccountSchema = z.union([
55+
ethPrivateKeySchema,
56+
remoteSignerAccountSchema,
57+
jsonKeyFileV3Schema,
58+
mnemonicConfigSchema,
59+
]);
5560

5661
// EthAccounts schema
57-
const ethAccountsSchema = z.union([ethAccountSchema, z.array(ethAccountSchema), mnemonicConfigSchema]);
62+
const ethAccountsSchema = z.union([ethAccountSchema, z.array(ethAccountSchema)]);
5863

5964
// Prover keystore schema
6065
const proverKeyStoreSchema = z.union([
6166
ethAccountSchema,
6267
z.object({
6368
id: ethAddressSchema,
64-
publisher: z.array(ethAccountsSchema),
69+
publisher: ethAccountsSchema,
6570
}),
6671
]);
6772

yarn-project/node-keystore/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export type ProverKeyStore =
6868
/** Address that identifies the prover. This address will receive the rewards. */
6969
id: EthAddressHex;
7070
/** One or more EOAs used for sending proof L1 txs. */
71-
publisher: EthAccounts[];
71+
publisher: EthAccounts;
7272
}
7373
| EthAccount;
7474

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)