Skip to content

Commit 6295a38

Browse files
authored
chore(port): forward-port v5-next cli/bot/docs backlog to next (#24934)
Forward-ports the small **cli / bot / docs** commits of the v5-next → next backlog, plus an owner checklist for the spartan-config and standard-contract-repin commits (both need an explicit v6 decision — see below). ## Applied (clean cherry-picks, chronological) - perf(bot): parallelize independent bot factory setup steps (#24581) - docs: revert threat model for node (#24465) (#24610) - feat(cli): support funding accounts in validator-keys new/set-funding-account (#24476) ## ⚠️ Needs owner conflict-resolution (conflict against reshaped `next`; not included here) Cherry-pick onto this branch and resolve: - [x] `git cherry-pick -x 38202d9` — chore(spartan): restore 7 day mainnet slash grace period (#24804) - [x] `git cherry-pick -x c3a2a85` — chore: re-pin handshake registry with owner-bound nullifiers (#24893) Part of the manual v5-next → next backlog sweep. Draft until conflicts are resolved and CI is green.
2 parents 2b932d6 + 093aa33 commit 6295a38

10 files changed

Lines changed: 664 additions & 456 deletions

File tree

yarn-project/THREAT_MODEL.md

Lines changed: 0 additions & 341 deletions
This file was deleted.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import { promiseWithResolvers } from '@aztec/foundation/promise';
2+
import type { AztecNode, AztecNodeAdmin, AztecNodeAdminConfig } from '@aztec/stdlib/interfaces/client';
3+
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
4+
5+
import { mock } from 'jest-mock-extended';
6+
7+
import { type BotConfig, getBotDefaultConfig } from './config.js';
8+
import { BotFactory } from './factory.js';
9+
import type { BotStore } from './store/index.js';
10+
11+
class TestBotFactory extends BotFactory {
12+
public override withNoMinTxsPerBlock<T>(fn: () => Promise<T>): Promise<T> {
13+
return super.withNoMinTxsPerBlock(fn);
14+
}
15+
}
16+
17+
describe('BotFactory.withNoMinTxsPerBlock', () => {
18+
let minTxsPerBlock: number | undefined;
19+
let setConfigCalls: (number | undefined)[];
20+
let factory: TestBotFactory;
21+
22+
beforeEach(() => {
23+
minTxsPerBlock = 3;
24+
setConfigCalls = [];
25+
26+
const aztecNodeAdmin = mock<AztecNodeAdmin>();
27+
aztecNodeAdmin.getConfig.mockImplementation(() => Promise.resolve({ minTxsPerBlock } as AztecNodeAdminConfig));
28+
aztecNodeAdmin.setConfig.mockImplementation(config => {
29+
setConfigCalls.push(config.minTxsPerBlock);
30+
minTxsPerBlock = config.minTxsPerBlock;
31+
return Promise.resolve();
32+
});
33+
34+
const config: BotConfig = { ...getBotDefaultConfig(), flushSetupTransactions: true };
35+
const wallet = mock<EmbeddedWallet>();
36+
factory = new TestBotFactory(config, wallet, mock<BotStore>(), mock<AztecNode>(), aztecNodeAdmin);
37+
});
38+
39+
it('zeroes minTxsPerBlock around a call and restores it after', async () => {
40+
await factory.withNoMinTxsPerBlock(() => {
41+
expect(minTxsPerBlock).toBe(0);
42+
return Promise.resolve();
43+
});
44+
45+
expect(setConfigCalls).toEqual([0, 3]);
46+
expect(minTxsPerBlock).toBe(3);
47+
});
48+
49+
it('zeroes once and restores once across overlapping calls', async () => {
50+
const gates = [promiseWithResolvers<void>(), promiseWithResolvers<void>(), promiseWithResolvers<void>()];
51+
const calls = gates.map(gate => factory.withNoMinTxsPerBlock(() => gate.promise));
52+
53+
gates[0].resolve();
54+
await calls[0];
55+
expect(minTxsPerBlock).toBe(0);
56+
57+
gates[1].resolve();
58+
await calls[1];
59+
expect(minTxsPerBlock).toBe(0);
60+
61+
gates[2].resolve();
62+
await calls[2];
63+
expect(setConfigCalls).toEqual([0, 3]);
64+
expect(minTxsPerBlock).toBe(3);
65+
});
66+
67+
it('restores minTxsPerBlock when the wrapped call fails', async () => {
68+
await expect(factory.withNoMinTxsPerBlock(() => Promise.reject(new Error('boom')))).rejects.toThrow('boom');
69+
70+
expect(setConfigCalls).toEqual([0, 3]);
71+
expect(minTxsPerBlock).toBe(3);
72+
});
73+
74+
it('restores minTxsPerBlock when one of several overlapping calls fails', async () => {
75+
const gate = promiseWithResolvers<void>();
76+
const failing = factory.withNoMinTxsPerBlock(() => Promise.reject(new Error('boom')));
77+
const succeeding = factory.withNoMinTxsPerBlock(() => gate.promise);
78+
79+
await expect(failing).rejects.toThrow('boom');
80+
expect(minTxsPerBlock).toBe(0);
81+
82+
gate.resolve();
83+
await succeeding;
84+
expect(setConfigCalls).toEqual([0, 3]);
85+
expect(minTxsPerBlock).toBe(3);
86+
});
87+
});

0 commit comments

Comments
 (0)