Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(vanity): count an aborted target's attempts so a budget-stopped run reports real throughput

nirholasf2bfcc2deb58
diff --git a/tests/vanity-grinder-batch.test.js b/tests/vanity-grinder-batch.test.js
index 9e3a4c2e6..9651fcf52 100644
--- a/tests/vanity-grinder-batch.test.js
+++ b/tests/vanity-grinder-batch.test.js
@@ -197,6 +197,33 @@ describe('batch vanity grinder end to end', () => {
expect(JSON.parse(readFileSync(join(dir, 'summary-quota.json'), 'utf8')).stopReason).toBe('max-found');
});
+ // The headline production failure: a shard that outlives its Cloud Run
+ // --task-timeout was killed and the whole execution reported FAILED, even
+ // though every key it had sealed was already in the DB. The grinder now stops
+ // itself first, and reports the work it really did.
+ it('winds down and exits 0 when MAX_RUNTIME_SEC expires mid-target', async () => {
+ const targets = join(dir, 'unreachable.json');
+ writeFileSync(targets, JSON.stringify([{ prefix: 'zzzzz', ignoreCase: false }]));
+ const summaryFile = join(dir, 'summary-budget.json');
+ const { stdout } = await runGrind(
+ {
+ TARGETS_FILE: targets,
+ OUTPUT_FILE: join(dir, 'budget.jsonl'),
+ CHECKPOINT_FILE: join(dir, 'checkpoint-budget.json'),
+ SUMMARY_FILE: summaryFile,
+ MAX_RUNTIME_SEC: '2',
+ },
+ { timeoutMs: 60_000 },
+ );
+ expect(stdout).toContain('runtime budget 2s reached');
+ const parsed = JSON.parse(readFileSync(summaryFile, 'utf8'));
+ expect(parsed.stopReason).toBe('runtime-budget');
+ // A budget stop is intentional, not a preemption needing a shard retry.
+ expect(parsed.preempted).toBe(false);
+ // Aborted targets still report the ed25519 work they actually did.
+ expect(parsed.totalAttempts).toBeGreaterThan(0);
+ });
+
it('shards the target list into disjoint slices that cover it exactly once', async () => {
const addresses = [];
for (const index of ['0', '1']) {
diff --git a/workers/vanity-grinder/grind.mjs b/workers/vanity-grinder/grind.mjs
index 1b42e5775..40a606dea 100644
--- a/workers/vanity-grinder/grind.mjs
+++ b/workers/vanity-grinder/grind.mjs
@@ -391,6 +391,10 @@ async function main() {
}
if (msg.type === 'aborted') {
// Preemption: leave the target un-completed so the next run retries it.
+ // Its attempts still count: they were real ed25519 work, and dropping
+ // them made every budget-terminated run report 0 keys/sec, which is
+ // exactly the shape of run MAX_RUNTIME_SEC makes routine.
+ stats.totalAttempts += msg.attempts || 0;
active -= 1;
maybeFinish();
}