Skip to content

Commit 5e3219a

Browse files
authored
feat: Add funding account to key store schema (#16785)
This PR updates the keystore schema to include funding accounts as per the updated design doc AztecProtocol/engineering-designs#81. The functionality of automatically funding publisher accounts is still outstanding.
2 parents e53d3d9 + 6116d1c commit 5e3219a

File tree

6 files changed

+23
-5
lines changed

6 files changed

+23
-5
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
"accountCount": 2,
6060
"addressCount": 1
6161
},
62-
"feeRecipient": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcd"
62+
"feeRecipient": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcd",
63+
"fundingAccount": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
6364
}
6465
],
6566
"prover": {
@@ -81,5 +82,6 @@
8182
"password": "prover-pass"
8283
}
8384
]
84-
}
85+
},
86+
"fundingAccount": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
8587
}

yarn-project/node-keystore/examples/prover-with-publishers.json renamed to yarn-project/node-keystore/examples/prover-with-publishers-and-funding-account.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"0x1234567890123456789012345678901234567890123456789012345678901234",
77
"0x1234567890123456789012345678901234567890123456789012345678901234"
88
]
9-
}
9+
},
10+
"fundingAccount": "0xdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
1011
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@ describe('Keystore Schema Validation', () => {
4747
});
4848

4949
it('should validate prover with publishers example', () => {
50-
const keystore = loadExample('prover-with-publishers.json');
50+
const keystore = loadExample('prover-with-publishers-and-funding-account.json');
5151
expect(() => keystoreSchema.parse(keystore)).not.toThrow();
5252

5353
const parsed = keystoreSchema.parse(keystore);
5454
expect(parsed.schemaVersion).toBe(1);
5555
expect(typeof parsed.prover).toBe('object');
5656
expect((parsed.prover as any).id).toBe('0x1234567890123456789012345678901234567890');
5757
expect((parsed.prover as any).publisher).toHaveLength(2);
58+
expect(parsed.fundingAccount).toBe('0xdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd');
5859
});
5960

6061
it('should validate prover with single publisher example', () => {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const validatorKeyStoreSchema = z.object({
7777
publisher: ethAccountsSchema.nullish(),
7878
feeRecipient: aztecAddressSchema,
7979
remoteSigner: remoteSignerConfigSchema.nullish(),
80+
fundingAccount: ethAccountSchema.nullish(),
8081
});
8182

8283
// Main keystore schema
@@ -87,6 +88,7 @@ export const keystoreSchema = z
8788
slasher: ethAccountsSchema.nullish(),
8889
remoteSigner: remoteSignerConfigSchema.nullish(),
8990
prover: proverKeyStoreSchema.nullish(),
91+
fundingAccount: ethAccountSchema.nullish(),
9092
})
9193
.refine(data => data.validators || data.prover, {
9294
message: 'Keystore must have at least validators or prover configuration',

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ export type ValidatorKeyStore = {
9696
* Default remote signer for all accounts in this block.
9797
*/
9898
remoteSigner?: EthRemoteSignerConfig;
99+
/**
100+
* Used for automatically funding publisher accounts in this block.
101+
*/
102+
fundingAccount?: EthAccount;
99103
};
100104

101105
export type KeyStore = {
@@ -109,4 +113,6 @@ export type KeyStore = {
109113
remoteSigner?: EthRemoteSignerConfig;
110114
/** Prover configuration. Only one prover configuration is allowed. */
111115
prover?: ProverKeyStore;
116+
/** Used for automatically funding publisher accounts if there is none defined in the corresponding ValidatorKeyStore*/
117+
fundingAccount?: EthAccount;
112118
};

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ describe('Keystore Duplication Validation', () => {
166166
'simple-validator.json',
167167
'multiple-validators-remote.json',
168168
'simple-prover.json',
169-
'prover-with-publishers.json',
169+
'prover-with-publishers-and-funding-account.json',
170170
'everything.json',
171171
];
172172

@@ -191,6 +191,10 @@ describe('Keystore Duplication Validation', () => {
191191
// File-level remote signer
192192
expect(ks.remoteSigner).toBeDefined();
193193

194+
// File-level funding account
195+
expect(ks.fundingAccount).toBeDefined();
196+
expect(ks.fundingAccount).toBe('0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
197+
194198
// Slasher: array with mixed account types (private key, address, remote signer account, mnemonic)
195199
expect(ks.slasher).toBeDefined();
196200
expect(Array.isArray(ks.slasher)).toBe(true);
@@ -214,6 +218,8 @@ describe('Keystore Duplication Validation', () => {
214218
expect(Array.isArray(v1.attester)).toBe(true);
215219
expect(v1.publisher).toBeDefined(); // mnemonic config
216220
expect(v1.feeRecipient).toMatch(/^0x[0-9a-fA-F]{64}$/);
221+
expect(v1.fundingAccount).toBeDefined();
222+
expect(v1.fundingAccount).toBe('0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
217223

218224
// Prover complex type
219225
expect(ks.prover).toBeDefined();

0 commit comments

Comments
 (0)