Skip to content

Commit 6b4ea83

Browse files
authored
chore: Run ValidateOrRevokeMessages job once a month for an fid (#1900)
## Motivation - The ValidateOrRevoke messages job is normally run if the signers change, but we also run once a month for backup (used to be 14 days) - Run the job during low-traffic time ## Merge Checklist _Choose all relevant options below by adding an `x` now or at any time before submitting for review_ - [X] PR title adheres to the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) standard - [X] PR has a [changeset](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#35-adding-changesets) - [ ] PR has been tagged with a change label(s) (i.e. documentation, feature, bugfix, or chore) - [ ] PR includes [documentation](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#32-writing-docs) if necessary. - [X] All [commits have been signed](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#22-signing-commits) <!-- start pr-codex --> --- ## PR-Codex overview This PR updates the `validateOrRevokeMessagesJob` to run once a month instead of every day, and adjusts the fid calculation to check 1/28th instead of 1/14th. ### Detailed summary - Updated cron schedule to run `validateOrRevokeMessagesJob` once a month. - Changed fid calculation to check 1/28th of the FIDs. - Updated test to reflect fid % 28 matching. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent f1ffdd7 commit 6b4ea83

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

.changeset/fair-lions-compete.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@farcaster/hubble": patch
3+
---
4+
5+
chore: Run validateOrRevoke once a month

apps/hubble/src/storage/jobs/validateOrRevokeMessagesJob.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe("ValidateOrRevokeMessagesJob", () => {
9595
expect(result2._unsafeUnwrap()).toBe(1);
9696
});
9797

98-
test("doJobForFid checks message when fid % 14 matches", async () => {
98+
test("doJobForFid checks message when fid % 28 matches", async () => {
9999
const engine2 = new Engine(db, network, undefined, publicClient);
100100
const job2 = new ValidateOrRevokeMessagesJobScheduler(db, engine2);
101101
await engine2.start();

apps/hubble/src/storage/jobs/validateOrRevokeMessagesJob.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { statsd } from "../../utils/statsd.js";
1010
import { getHubState, putHubState } from "../../storage/db/hubState.js";
1111
import { sleep } from "../../utils/crypto.js";
1212

13-
export const DEFAULT_VALIDATE_AND_REVOKE_MESSAGES_CRON = "10 8 * * *"; // Every day at 8:10 UTC (00:10 am PST)
13+
export const DEFAULT_VALIDATE_AND_REVOKE_MESSAGES_CRON = "10 20 * * *"; // Every day at 20:10 UTC (00:10 pm PST)
1414

1515
// How much time to allocate to validating and revoking each fid.
16-
// 50 fids per second, which translates to 1/14th of the FIDs will be checked in just over 2 hours.
16+
// 50 fids per second, which translates to 1/28th of the FIDs will be checked in just over 2 hours.
1717
const TIME_SCHEDULED_PER_FID_MS = 1000 / 50;
1818

1919
const log = logger.child({
@@ -189,7 +189,7 @@ export class ValidateOrRevokeMessagesJobScheduler {
189189
).unwrapOr(0);
190190

191191
// Every 14 days, we do a full scan of all messages for this FID, to make sure we don't miss anything
192-
const doFullScanForFid = this._checkAllFids && fid % 14 === new Date(Date.now()).getDate() % 14;
192+
const doFullScanForFid = this._checkAllFids && fid % 28 === new Date(Date.now()).getDate() % 28;
193193

194194
if (!doFullScanForFid && latestSignerEventTs < lastJobTimestamp) {
195195
return ok(0);

0 commit comments

Comments
 (0)