mirror of
https://github.com/farcasterxyz/hub-monorepo.git
synced 2026-04-18 03:00:22 -04:00
Add a flag to clear L2 events (#1439)
This commit is contained in:
5
.changeset/forty-cycles-cough.md
Normal file
5
.changeset/forty-cycles-cough.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@farcaster/hubble": patch
|
||||
---
|
||||
|
||||
feat: Add a flag to clear l2 events
|
||||
@@ -82,6 +82,7 @@ app
|
||||
.option("--l2-key-registry-address <address>", "The address of the L2 Farcaster Key Registry contract")
|
||||
.option("--l2-storage-registry-address <address>", "The address of the L2 Farcaster Storage Registry contract")
|
||||
.option("--l2-resync-events", "Resync events from the L2 Farcaster contracts before starting (default: disabled)")
|
||||
.option("--l2-clear-events", "Deletes all events from the L2 Farcaster contracts before starting (default: disabled)")
|
||||
.option(
|
||||
"--l2-first-block <number>",
|
||||
"The block number to begin syncing events from L2 Farcaster contracts",
|
||||
@@ -490,6 +491,7 @@ app
|
||||
l2ChunkSize: cliOptions.l2ChunkSize ?? hubConfig.l2ChunkSize,
|
||||
l2ChainId: cliOptions.l2ChainId ?? hubConfig.l2ChainId,
|
||||
l2ResyncEvents: cliOptions.l2ResyncEvents ?? hubConfig.l2ResyncEvents ?? false,
|
||||
l2ClearEvents: cliOptions.l2ClearEvents ?? hubConfig.l2ClearEvents ?? false,
|
||||
l2RentExpiryOverride: cliOptions.l2RentExpiryOverride ?? hubConfig.l2RentExpiryOverride,
|
||||
bootstrapAddrs,
|
||||
allowedPeers: cliOptions.allowedPeers ?? hubConfig.allowedPeers,
|
||||
|
||||
@@ -72,6 +72,7 @@ import axios from "axios";
|
||||
import { HttpAPIServer } from "./rpc/httpServer.js";
|
||||
import { SingleBar } from "cli-progress";
|
||||
import { exportToProtobuf } from "@libp2p/peer-id-factory";
|
||||
import OnChainEventStore from "./storage/stores/onChainEventStore.js";
|
||||
|
||||
export type HubSubmitSource = "gossip" | "rpc" | "eth-provider" | "l2-provider" | "sync" | "fname-registry";
|
||||
|
||||
@@ -192,6 +193,9 @@ export interface HubOptions {
|
||||
/** Resync l2 events */
|
||||
l2ResyncEvents?: boolean;
|
||||
|
||||
/** Clears all l2 events */
|
||||
l2ClearEvents?: boolean;
|
||||
|
||||
/** Resync fname events */
|
||||
resyncNameEvents?: boolean;
|
||||
|
||||
@@ -534,6 +538,12 @@ export class Hub implements HubInterface {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.options.l2ClearEvents === true) {
|
||||
log.info("clearing l2 events");
|
||||
await OnChainEventStore.clearEvents(this.rocksDB);
|
||||
log.info("l2 events cleared");
|
||||
}
|
||||
|
||||
// Get the Network ID from the DB
|
||||
const dbNetworkResult = await this.getDbNetwork();
|
||||
if (dbNetworkResult.isOk() && dbNetworkResult.value && dbNetworkResult.value !== this.options.network) {
|
||||
|
||||
@@ -46,6 +46,7 @@ L2 Options:
|
||||
--l2-key-registry-address <address> The address of the L2 Farcaster Key Registry contract
|
||||
--l2-storage-registry-address <address> The address of the L2 Farcaster Storage Registry contract
|
||||
--l2-resync-events Resync events from the L2 Farcaster contracts before starting (default: disabled)
|
||||
--l2-clear-events Deletes all L2 events before starting (default: disabled)
|
||||
--l2-first-block <number> The block number to begin syncing events from L2 Farcaster contracts
|
||||
--l2-chunk-size <number> The number of events to fetch from L2 Farcaster contracts at a time
|
||||
--l2-chain-id <number> The chain ID of the L2 Farcaster contracts are deployed to
|
||||
|
||||
Reference in New Issue
Block a user