Commit Graph

668 Commits

Author SHA1 Message Date
Sanjay
f5960584bf Release shuttle 0.5.8 (#2216)
## Why is this change needed?

Release shuttle 0.5.8 with validate message changes

## 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)
- [x] 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.


<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates versions in `hub-nodejs` and `shuttle` packages. Focus
is on upgrading `grpc-js` in `hub-nodejs` to 1.11 and bumping versions
for both packages.

### Detailed summary
- Updated `hub-nodejs` version to 0.11.22 with `grpc-js` upgrade
- Updated `shuttle` version to 0.5.8
- Removed message validation in `shuttle`
- Updated dependencies in `shuttle`
- Updated `hub-nodejs` dependency version in `shuttle`

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-27 00:19:33 +00:00
Sanjay
2fa29ad4cb fix: Upgrade grpc-js to 1.11 (#2214)
## Why is this change needed?

Latest version grpc-js has some fixes that might help with the
RST_STREAM issues in hubs.

## 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)
- [x] 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.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR upgrades `grpc-js` to version 1.11, fixes stream handling in
`bufferedStreamWriter.ts`, and adds a `destroyStream` function in
`server.ts`.

### Detailed summary
- Upgraded `grpc-js` to version 1.11
- Improved stream handling in `bufferedStreamWriter.ts`
- Added `destroyStream` function in `server.ts`

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-26 17:27:24 +00:00
Sanjay
4f40c19b06 fix: Do not validate messages in shuttle by default (#2213)
## Why is this change needed?

This should significantly improve performance. This was originally
intended as additional protection when listening to untrusted hubs. But
given most users are listening to their own or trusted hub providers, no
need to enable this by default.

## 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)
- [x] 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.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR disables message validation by default in `shuttle`. 

### Detailed summary
- Shuttle now does not validate messages by default
- Added environment variable to enable message validation
- Updated message processing logic in `hubEventProcessor.ts`

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-25 17:10:25 -07:00
Sanjay
f1d80deb01 chore: Release 1.14 (#2208)
## Why is this change needed?

Release 1.14

## 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)
- [x] 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.


<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the version of `@farcaster/hubble` to `1.14.0`,
introduces minor and patch changes, and updates the `FARCASTER_VERSION`
constant in `hubble.ts`.

### Detailed summary
- Updated `@farcaster/hubble` version to `1.14.0`
- Minor and patch changes in `CHANGELOG.md`
- Updated `FARCASTER_VERSION` constant in `hubble.ts`

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-24 15:29:50 -07:00
Cassandra Heart
d1dce89fc9 fix: do not let deleted fname events allow old fname events to be re-added (#2203)
## Why is this change needed?

The fname events are not coming through correctly for a few names, and
by consequence we're seeing a few old fname events being endlessly
replayed. The deletion of the fname record (when fid = 0 in proof)
completely removes the record rather than its association with a fid,
and by consequence replaying the older event re-adds the fname. This
resolves the hub side of the behavior by correctly holding on to the new
fname event, but deleting the association with a fid.

## 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)
- [x] PR has been tagged with a change label(s) (i.e. documentation,
feature, bugfix, or chore)
- [x] PR includes
[documentation](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#32-writing-docs)
if necessary.

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to enhance the `hubble` app by fixing issues
related to username proof handling and syncing historical events.

### Detailed summary
- Fixed issue where deleted fname events allowed re-adding old fname
events
- Improved syncing historical events in `syncEngine.ts`
- Updated `mergeUserNameProof` functionality in tests
- Added `rsGetUserNameProof` import in `nameRegistryEvent.ts`
- Enhanced `UserDataStore` functionality in `user_data_store.rs`

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-24 14:48:28 -07:00
Sanjay
a5f867fbcb fix: Fix incorrect target fid check for link messages older than the compact state (#2207)
## Why is this change needed?

We were checking for the message creator's fid instead of the target fid
and therefore rejecting valid messages older than the compact state

## 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)
- [x] 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.


<!-- start pr-codex -->

---

## PR-Codex overview
This PR fixes an issue with target fid check for link messages older
than the compact state in the `store.rs` file and adds tests in
`linkStoreCompactState.test.ts`.

### Detailed summary
- Fixed incorrect target fid check for link messages in `store.rs`
- Added tests for merging link add messages in
`linkStoreCompactState.test.ts`

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-24 14:35:37 -07:00
Sanjay
554d82a45b [fix] Fix race condition with earliest ts hash calculation (#2204)
## Why is this change needed?

It was possible to trigger race conditions when calculating
earliest_ts_hash, this led to hubs have different values which meant
that stores would become out of sync. Migrate the cache to rust and
prevent race conditions.


## 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)
- [x] 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.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR migrates the storage cache to Rust and addresses a race
condition.

### Detailed summary
- Migrated storage cache to Rust for efficiency
- Fixed a race condition in the storage cache
- Added `PRIMARY_KEY_LENGTH` constant in `message.rs`
- Updated `storage_cache` exports in `store/mod.rs`
- Added functions to interact with storage cache in `utils.rs`
- Updated `lib.rs` to include `StorageCache`
- Updated `storeEventHandler.ts` to handle `StorageCache`
- Updated tests to use `StorageCache` in `storeEventHandler.test.ts`
- Implemented `StorageCache` in `store_event_handler.rs`
- Added Rust bindings for `StorageCache` in `rustfunctions.ts`

> The following files were skipped due to too many changes:
`apps/hubble/src/storage/stores/storageCache.ts`,
`apps/hubble/src/storage/stores/storageCache.test.ts`,
`apps/hubble/src/addon/src/store/storage_cache.rs`

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-23 20:50:30 -07:00
Cassandra Heart
be54d20352 fix: full state events should not include deletes (#2124)
## Why is this change needed?

The current processing of full state events results in an unbounded
number of deleted messages, making event consumption downstream
unpredictable and prone to getting stuck on singular large events.
Because merge events historically applied to deltas, and deltas were
generally small in effect size, this was a reasonable consideration, but
for full state (compact) messages, it is implicit on what is added
(everything in it) and what is not (everything not in it), making the
deleted messages something implicitly handled by downstream consumers.

## 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)
- [x] PR has been tagged with a change label(s) (i.e. documentation,
feature, bugfix, or chore)
- [x] PR includes
[documentation](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#32-writing-docs)
if necessary.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on fixing the behavior of full state events in the
`store.rs` file and test cases related to compact state messages in the
`linkStoreCompactState.test.ts`.

### Detailed summary
- Fixed full state events to exclude deleted messages in `store.rs`
- Updated test cases to reflect changes in handling deleted messages for
compact state messages in `linkStoreCompactState.test.ts`

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-19 12:36:25 -05:00
Wasif Iqbal
3746a4847a chore: release 1.13.8 (#2199)
## Why is this change needed?

- release 1.13.8

## 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)
- [x] 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.


<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to update version numbers and dependencies
across various packages.

### Detailed summary
- Updated version to `0.14.19` in `@farcaster/core`
- Updated version to `0.11.21` in `@farcaster/hub-nodejs`
- Updated version to `0.5.7` in `@farcaster/shuttle`
- Updated version to `1.13.8` in `@farcaster/hubble`
- Added event id functions in `@farcaster/core`
- Fixed conflict criteria issue in `@farcaster/shuttle`
- Upgraded libp2p to `0.44.0` in `@farcaster/hubble`
- Increased hub storage requirement to `200 GB` in `@farcaster/hubble`

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-18 16:14:32 -05:00
Cassandra Heart
ee0947ec4b fix: on conflict criteria is ambiguous and cannot be used for upsert (#2197)
## Why is this change needed?

Shuttle defines the messages table with two unique constraints, one for
the hash, another for the triple of hash, fid and type. Postgres does
not allow multiple ON CONFLICT criteria, and ambiguous conflicts are
essentially surfaced as uniqueness violation failures in spite of ON
CONFLICT criteria given. This change alters the merge to instead attempt
insert, doing nothing on any conflict, then resolving with an update if
necessary and the original conflict resolution criteria is satisfied.

Addresses Issue #2167 

## 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)
- [x] PR has been tagged with a change label(s) (i.e. documentation,
feature, bugfix, or chore)
- [x] PR includes
[documentation](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#32-writing-docs)
if necessary.


<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the conflict resolution logic in `MessageProcessor` to
fix ambiguity issues during upsert operations.

### Detailed summary
- Updated conflict resolution logic to use `doNothing()` method instead
of complex conditions
- Improved handling of conflict criteria for upsert operations

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-18 12:36:56 -05:00
Varun Srinivasan
e2b1c7c681 chore: upgrade libp2p to 0.44.0 (#2191)
## Why is this change needed?

Upgrades libp2p one minor version up ([Release
Notes](https://github.com/libp2p/js-libp2p/releases/tag/v0.44.0) |
[Migration
Guide](https://github.com/libp2p/js-libp2p/blob/main/doc/migrations/v0.43-v0.44.md))

### Breaking Change in Autodial + Connection Manager Behavior

libp2p's ConnectionManager now has a default minConnection threshold of
50. If the number of active connections is < this number, it will
attempt to redial peers that are in the store.

Since we only disconnect peers and do not remove them from our store,
the naive upgrade causes us to reconnect immediately to peers
unexpectedly. We now set the threshold explicitly to 0 to prevent this.
We should consider also removing peers from the peer store in a future
upgrade.


## 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
- [ ] PR has a
[changeset](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#35-adding-changesets)
- [x] 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.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR upgrades `libp2p` to version 0.44.0, updates
`@chainsafe/libp2p-gossipsub` to 6.2.0, and introduces
`@libp2p/interface-connection-gater` version 2.0.1.

### Detailed summary
- Upgraded `libp2p` to 0.44.0
- Updated `@chainsafe/libp2p-gossipsub` to 6.2.0
- Added `@libp2p/interface-connection-gater` version 2.0.1

> The following files were skipped due to too many changes: `yarn.lock`

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-18 02:42:53 +00:00
Sanjay
76ad1ac2a2 feat: Expose event id functions (#2195)
## Why is this change needed?

Make timestamp to event id converstion function publicly accessible

## 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)
- [x] 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.


<!-- start pr-codex -->

---

## PR-Codex overview
This PR adds new event ID functions and refactors timestamp handling in
the `core` and `hubble` packages.

### Detailed summary
- Added `extractEventTimestamp` and `makeEventId` functions in `core`
- Updated `console.ts` and `storeEventHandler.ts` to use the new
functions
- Refactored timestamp handling for event IDs

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-17 02:09:34 +00:00
Wasif Iqbal
97d0a7ea3a fix: update hub storage requirement to 200 GB (#2194)
## Why is this change needed?

- update hub storage requirement to 200 GB

## 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)
- [x] 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.


<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the storage requirement for the Hubble app to 200 GB and
adjusts related documentation to reflect the change.

### Detailed summary
- Updated Hubble app storage requirement to 200 GB
- Adjusted disk size in GCP tutorial to 200 GB
- Updated storage requirement in installation guide to 200 GB

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-16 15:47:23 -05:00
Wasif Iqbal
9ad23d5074 chore: release 1.13.7 (#2188)
## Why is this change needed?

- hub 1.13.7
- core 0.14.18
- hub-nodejs 0.11.20

## 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)
- [x] 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.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR increases version numbers for various packages and dependencies.
It also includes changes related to extending frame message URL max
length and assigning shards using a hashing algorithm.

### Detailed summary
- Increased version numbers for packages and dependencies
- Extended frame message URL max length
- Assigned shards using jump consistent hashing algorithm

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-15 16:14:43 -05:00
Shane da Silva
6bf952601f chore(shuttle): Release 0.5.6 (#2186)
## Why is this change needed?

Includes some performance improvements.

## Merge Checklist

- [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)
- [x] 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.


<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the version of `@farcaster/shuttle` to `0.5.6` and
includes improvements related to stream trimming and recording size.

### Detailed summary
- Updated version to `0.5.6`
- Trim stream at regular interval
- Stop recording stream size
- Updated `@farcaster/hub-nodejs` to `0.11.20`

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-15 19:39:48 +00:00
Shane da Silva
e5760da0d3 perf(shuttle): Trim stream at regular intervals instead of every iteration (#2185)
## Why is this change needed?

Performance profiling indicates that we're spending a non-trivial amount
of time (5-10% of wall clock time) trimming the stream. This doesn't
need to happen as frequently as it's currently happening, so switch to
an interval timer so that we're not slowing down general processing in
any meaningful way.

## Merge Checklist

- [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)
- [x] 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.


<!-- start pr-codex -->

---

## PR-Codex overview
This PR optimizes the event stream processing in
`HubEventStreamConsumer` by adding a regular interval to trim old events
efficiently.

### Detailed summary
- Added `interval` property to schedule event processing at regular
intervals
- Implemented interval logic to clear old events and process stale
events
- Updated `stop` method to clear the interval
- Simplified event processing logic in the message loop

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-15 19:28:13 +00:00
Shane da Silva
fc67ccf043 chore(shuttle): Stop recording stream size (#2183)
## Why is this change needed?

Looking at profiling data, this actually takes up a non-trivial amount
of wall clock time (10% of total time). Since the stream is
automatically trimmed, recording the size isn't particularly useful
except as perhaps an early warning on memory, but there are generally
other metrics one could use (number of events processed, etc.) to infer
that there is a slowdown in processing.

## Merge Checklist

- [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)
- [x] 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.


<!-- start pr-codex -->

---

## PR-Codex overview
This PR stops recording stream size in the `eventStream.ts` file of the
`@farcaster/shuttle` package.

### Detailed summary
- Removed recording stream size in eventStream.ts
- Removed statsd gauge and timing metrics for stream size and time
calculations

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-15 18:56:35 +00:00
Shane da Silva
63f29f1aca chore(shuttle): Release 0.5.5 (#2179)
## Why is this change needed?

To ensure this remains efficient at higher loads, perform before/after
hook processing in batches.

## Merge Checklist

- [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.


<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the version of `@farcaster/shuttle` to `0.5.5`. It
includes efficiency improvements in before/after hooks and updates to
`@farcaster/hub-nodejs`.

### Detailed summary
- Updated version to `0.5.5`
- Efficiency improvements in before/after hooks
- Updated dependency `@farcaster/hub-nodejs` to `0.11.20`

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-12 22:34:34 -07:00
Shane da Silva
27e3c7ae0c fix(shuttle): Switch before/after processing hooks to use batches (#2178)
## Why is this change needed?

This will be much more efficient at high loads.

## Merge Checklist

- [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)
- [x] 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.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR optimizes event processing efficiency in `@farcaster/shuttle` by
switching before/after hooks to work with batches.

### Detailed summary
- Updated `PreProcessHandler` and `PostProcessHandler` signatures to
work with batches
- Refactored event processing logic to handle batches efficiently
- Improved event processing performance by processing events in batches

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-12 22:30:37 -07:00
Shane da Silva
b09009f508 chore: Release 0.5.4 (#2177)
## Why is this change needed?

We want to allow users to add pre-post processing logic when processing
hub events using Shuttle.

## Merge Checklist

- [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.


<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the version of the `@farcaster/shuttle` package to
`0.5.4` and adds support for running before/after hooks when processing
events.

### Detailed summary
- Updated `@farcaster/shuttle` package version to `0.5.4`
- Added support for running before/after hooks when processing events

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-13 04:01:34 +00:00
Shane da Silva
41f32cd0fa feat(shuttle): Support running before/after hooks when processing events (#2176)
## Why is this change needed?

We want the ability to provide custom pre/post-processing logic when
processing events. Expose optional hooks that can be specified. This has
the added benefit that the `beforeProcess` hook can be used to skip
processing of an event.

## Merge Checklist

- [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)
- [x] PR includes
[documentation](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#32-writing-docs)
if necessary.


<!-- start pr-codex -->

---

## PR-Codex overview
This PR enhances the `@farcaster/shuttle` package by adding support for
running before/after hooks when processing events.

### Detailed summary
- Added `beforeProcess` and `afterProcess` handlers to
`EventStreamHubSubscriber` and `HubEventStreamConsumer`
- Implemented handling of preprocess and postprocess actions for event
processing
- Introduced `EventStreamHubSubscriberOptions` and
`EventStreamConsumerOptions` interfaces
- Updated `HubEventStreamConsumer` to extend `TypedEmitter` for custom
event tracking

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-12 18:28:26 -07:00
horsefacts
fb0a083aef feat: increase frame message URL max length (#2174)
## Why is this change needed?

Describe why this issue should be fixed and link to any relevant design
docs, issues or other relevant items.

## 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)
- [x] 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.


<!-- start pr-codex -->

---

## PR-Codex overview
This PR extends the maximum length of the frame message URL to 1024
characters for better validation accuracy.

### Detailed summary
- Increased maximum URL length validation from 256 to 1024 characters
- Updated test case with longer URL length for validation testing

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-12 18:26:42 -04:00
Shane da Silva
312340d210 feat: Assign shards using jump consistent hashing (#2171)
## Why is this change needed?

While modulo-based arithmetic for assigning shards is simple and works
fine, it does not work well when the number of shards changes.

For example, when increasing the number of shards from 3 → 4 using
modulo-based shard assignment, ~83% of FIDs will be assigned to a
different shard. With consistent hashing, only ~25% will be assigned to
a different shard.

Jump consistent hashing is a particular approach to consistent hashing
that is stateless (requires no additional tracking of shard
assignments), which is ideal for hubs, since we don't want hubs to have
to manage per-client tracking of shards.

## Merge Checklist

- [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)
- [x] PR has been tagged with a change label(s) (i.e. documentation,
feature, bugfix, or chore)
- [x] PR includes
[documentation](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#32-writing-docs)
if necessary.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on implementing the jump consistent hashing algorithm
for shard assignment in the Hubble app.

### Detailed summary
- Implemented `jumpConsistentHash` algorithm for shard assignment based
on FID
- Updated shard assignment logic in `Server` class
- Updated tests in `eventService.test.ts` for shard-based event handling

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-12 12:24:41 -07:00
Shane da Silva
3ac4e39c71 chore(shuttle): Release 0.5.2 (#2168)
## Why is this change needed?

Includeds some minor fixes that others are looking to use.

## Merge Checklist

- [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)
- [x] 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.


<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the version of `@farcaster/shuttle` package to `0.5.2`
and includes enhancements for message processing and PostgreSQL schema
customization.

### Detailed summary
- Updated `@farcaster/shuttle` package version to `0.5.2`
- Added feature to handle removals for compact state explicitly and warn
on mismatching deletes
- Added feature to enable shuttle and its example-app to use a
PostgreSQL schema other than "public"

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-12 17:11:21 +00:00
Cassandra Heart
a8b69a077c feat: make message processor handle removals for compact state explicitly, warn on mismatching deletes (#2141)
## Why is this change needed?

Follow up from review of #2124, we want to confirm first that moving the
responsibility of message processing marking messages as deleted for the
set difference from full-state-bearing messages is a no-op, and while
we're at it, might as well combine the potential thousands of SQL
updates into a single query.

## 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)
- [x] PR has been tagged with a change label(s) (i.e. documentation,
feature, bugfix, or chore)
- [x] PR includes
[documentation](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#32-writing-docs)
if necessary.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR introduces explicit handling of message removals for compact
state in the message processor, along with warnings for mismatching
deletes.

### Detailed summary
- Added handling for removals of compact state messages
- Warns on mismatching deletes
- Introduced new methods for processing compact state messages

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-11 23:09:13 -05:00
Ty Book
cc357b4b5c feat(shuttle): Make shuttle and example-app capable of using postgres schema other than "public" (#2149)
## Why is this change needed?

This allows using shuttle to target e.g. multi-tenant dbs. Shouldn't be
a breaking change because new parameters on public functions are
optional.

## 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)
- [x] PR includes
[documentation](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#32-writing-docs)
if necessary.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR enables `shuttle` and its `example-app` to use a custom
PostgreSQL schema.

### Detailed summary
- Added support for custom PostgreSQL schema in shuttle and example-app
- Updated migrations to create functions with `CREATE OR REPLACE`
- Updated dependencies in `package.json`
- Added dotenv package for environment variables
- Updated README with installation instructions for node 21
- Modified database client creation to include schema parameter
- Updated table row count estimation function to include schema
parameter

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-10 21:09:03 -07:00
Wasif Iqbal
17a81b7aaa chore: release 1.13.6 (#2146)
## Why is this change needed?

Release 1.13.6

## 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)
- [x] 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.


<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the version of `@farcaster/hubble` to `1.13.6` and
includes various patches and features related to message delays,
snapshot bandwidth, hub service agreements, peer maps, clock skew
validation, and Rust extension updates.

### Detailed summary
- Added stats for bundle message delays and stale contact info
- Increased message threshold to reduce snapshot bandwidth usage
- Fixed cli arguments order issue in docker-compose.yml
- Added hub service agreement: no rewards for running a hub
- Added unique peer map to sync engine for active peers
- Validated gossip message for clock skew
- Updated Rust extension to curve25519-dalek 4.1.3

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-09 19:17:57 -05:00
Sanjay
fa5eef4058 fix: Increase message threshold to reduce snapshot bandwidth usage (#2145)
## Why is this change needed?

Snapshots are using too much bandwitdh, increase the threshold to about
10% of current messages (~470M)

## 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)
- [x] 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.
2024-07-10 00:09:14 +00:00
Wasif Iqbal
b5ff774a9c feat: add hub service agreement - there will be no rewards for running a hub (#2142)
## Why is this change needed?

⚠️ THERE WILL BE NO REWARDS FOR RUNNING A HUB

## 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)
- [x] 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.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR adds a hub service agreement feature to the Hubble script,
requiring hub operators to agree to terms before starting the hub.

### Detailed summary
- Added function `prompt_for_hub_operator_agreement` to prompt hub
operators to agree to terms
- Prompt displays a warning about no rewards for running the hub
- Operators must type "Yes" to proceed
- Implemented input validation for agreement
- Integration of agreement prompt before starting or upgrading the hub

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-09 18:50:56 -05:00
Shane da Silva
6b037f48c0 chore(shuttle): Release 0.4.4 (#2140)
## Why is this change needed?

Includes a fix allowing Redis Clusters to be used with the `RedisClient`
class.

## Merge Checklist

- [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)
- [x] 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.


<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the version of `@farcaster/shuttle` package to `0.4.4`
and introduces a new feature allowing the Redis client to be a cluster
instance.

### Detailed summary
- Updated `@farcaster/shuttle` package version to `0.4.4`
- Added feature: Redis client can now be a cluster instance

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-09 14:35:07 -07:00
Shane da Silva
864261b798 feat(shuttle): Allow RedisClient's client to be a cluster instance (#2139)
## Why is this change needed?

We were artificially limiting the accepted type to a `Redis` instance,
when a `Cluster` instance would also work fine.

## Merge Checklist

- [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.


<!-- start pr-codex -->

---

## PR-Codex overview
This PR adds support for Redis cluster instances in the `shuttle`
package.

### Detailed summary
- Added support for Redis cluster instances in `shuttle/redis.ts`
- Updated `RedisClient` constructor to accept either `Redis` or
`Cluster` client
- Updated `create` method to handle Redis cluster instances

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-09 14:21:06 -07:00
Shane da Silva
fcb76cd9ad chore(shuttle) Release 0.4.3 (#2136)
## Why is this change needed?

Releases a bug fix that is affecting Shuttle users.

## Merge Checklist

- [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.


<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the version of `@farcaster/shuttle` package to `0.4.3`
and includes a patch to handle "no such key" error when querying group
on first start.

### Detailed summary
- Updated package version to `0.4.3`
- Patched to handle "no such key" error when querying group on first
start

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-08 18:59:58 -07:00
Shane da Silva
2bae6fb98b chore: Update curve25519-dalek from 4.1.1 to 4.1.3 in Rust extension (#2134)
## Motivation

This addresses a vulnerability.

## Change Summary

Update

## Merge Checklist

- [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 `curve25519-dalek` package in the Rust extension of
the `@farcaster/hubble` addon from version 4.1.1 to 4.1.3.

### Detailed summary
- Updated `curve25519-dalek` package version from 4.1.1 to 4.1.3
- Removed `platforms` package
- Updated checksum for `curve25519-dalek` package

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-08 23:16:00 +00:00
aquatic
795815afbe fix(hubble): hub operator fid is not set docker compose (#2129)
## Motivation

Fixes #2088 #2117 

There is likely an underlying issue with the commander configuration but
this is a quick change that gets this working for those having trouble
getting the container up and running.

## Change Summary

Reordered CLI arguments in docker-compose.yml.

## 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)
- [x] 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)

## Additional Context

If this is a relatively large or complex change, provide more details
here that will help reviewers


<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the `docker-compose.yml` file for the
`@farcaster/hubble` app to fix an issue with CLI arguments order
affecting the hub operator FID.

### Detailed summary
- Added `--hub-operator-fid ${HUB_OPERATOR_FID:-0}` to fix unset hub
operator FID in docker-compose.yml.
- Rearranged CLI arguments to ensure correct order and parameter
assignment.

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-08 23:10:07 +00:00
Shane da Silva
4518058412 fix(shuttle): Handle missing group key (#2133)
## Motivation

We didn't handle the case where the group key wasn't already created.

## Change Summary

Handle it.

## Merge Checklist

- [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)
- [x] 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 focuses on gracefully handling "no such key" errors when
querying a group on the first start in the `shuttle` package.

### Detailed summary
- Added error handling for "no such key" scenario
- Skips group creation if key doesn't exist
- Improved robustness in handling ReplyError

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->

---------

Co-authored-by: Ken Goldfarb <hello@kengoldfarb.com>
2024-07-08 23:04:24 +00:00
Wasif Iqbal
2a82b3dcd6 feat: add unique peer map to sync engine to represent current active peers (#2120)
## Motivation

- Current peer store keeps track of all hubs that successfully connected
- However, peers may connect and never be seen again due to churn or
change in Peer ID
- We add TTL Map of peers that only adds peers, never deletes, and
expires any peer that hasn't gossiped updates in 24 hours

## Change Summary

- add unique peer map to sync engine to represent current active peers

## 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)
- [x] 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)

## Additional Context

If this is a relatively large or complex change, provide more details
here that will help reviewers

<!-- start pr-codex -->

---

## PR-Codex overview
This PR introduces a unique peer map to track active peers in the sync
engine of the Hubble app. It also adds a high-performance TTLMap for
efficient entry expiration management.

### Detailed summary
- Added unique peer map for active peers in the sync engine
- Implemented TTLMap for automatic expiration of entries
- Updated handling of peer discovery events
- Enhanced peer contact management in the sync engine

> The following files were skipped due to too many changes:
`apps/hubble/src/utils/ttl_map.ts`

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-03 11:48:57 -05:00
Wasif Iqbal
aa02a48db4 fix: validate gossip message for clock skew (#2119)
## Motivation

- Messages were found in gossip with very high timestamps that would be
very far in the future

## Change Summary

- Reject gossip messages that are more than 10 minutes in the future 

## 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)
- [x] 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)

## Additional Context

If this is a relatively large or complex change, provide more details
here that will help reviewers


<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on fixing clock skew validation for gossip messages in
the `@farcaster/hubble` module.

### Detailed summary
- Added validation for clock skew in gossip messages
- Introduced `ALLOWED_CLOCK_SKEW_SECONDS` constant
- Improved error handling for future timestamps in gossip messages

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-02 21:03:18 -05:00
Wasif Iqbal
fdcc3b5228 chore: add stats for bundle message delays, stale contact info (#2118)
## Motivation

- Need better visibility into message delays and disambiguate between
bundle delay and message delay
- Ensure stale contacts aren't disseminating through the network

## Change Summary

- Add statsd metrics for earliest and latest message timestamp in bundle
and bundle creation timestamp. All timestamps are in farcaster time
- Add statsd metric for old contact info being gossiped

## 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)
- [x] 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)

## Additional Context

If this is a relatively large or complex change, provide more details
here that will help reviewers


<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on enhancing message bundle submission in the Hubble
application by adding stats for message delays and contact info
staleness.

### Detailed summary
- Added stats for bundle message delays and stale contact info
- Updated `submitMessageBundle` method parameters in multiple files
- Updated `submitMessageBundle` method in `Hub` class to include
additional stats and parameters

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-07-02 19:05:18 -05:00
Wasif Iqbal
59bcfe7fba chore: release 1.13.5 (#2114)
## Motivation

- Reduce network bandwidth with gossip improvements
- Support experimental sync APIs (note: may be removed or significantly
altered in the future)

## Change Summary

- Update p2p gossip to reduce unnecessary contact updates
- Add experimental sync control APIs

## 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)
- [x] PR has been tagged with a change label(s) (i.e. documentation,
feature, bugfix, or chore)
- [x] 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)

## Additional Context

If this is a relatively large or complex change, provide more details
here that will help reviewers


<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates versions and adds endpoints for sync control in
`hub-web` and `hub-nodejs`, and includes various improvements and fixes
in the `hubble` app.

### Detailed summary
- Updated `hub-web` version to 0.8.12
- Updated `hub-nodejs` version to 0.11.19
- Added endpoints for sync control
- Improved gossip contact info frequency in `hubble` app
- Added experimental HTTP APIs for sync control in `hubble` app

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-06-30 17:05:49 -05:00
Wasif Iqbal
224e75fa6b fix: contact info updates (#2113)
## Motivation

Contact info gossip is causing undue burden on network 

## Change Summary

fix: gossip contact info every 30 minutes instead of every minute, avoid
gossiping contact info on peer connect, skip contact info updates that
happen too frequently

## 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)
- [x] 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)

## Additional Context

If this is a relatively large or complex change, provide more details
here that will help reviewers


<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on optimizing contact info gossiping in the Hubble app
by reducing frequency and skipping recent updates.

### Detailed summary
- Changed gossip contact info frequency to every 30 minutes
- Skipped gossiping contact info on peer connect
- Added a threshold to skip contact info updates happening too
frequently

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-06-30 15:03:42 -05:00
Wasif Iqbal
667a5b304c feat: add experimental HTTP APIs to control sync (#2111)
## Motivation

Add HTTP APIs to force sync with a particular peer id and to interrupt
current sync.

NOTE: This is experimental, these endpoints may be removed or
significantly altered in the future.

## Change Summary

### GET /v1/syncStatus

```
{
  "isSyncing": true,
  "syncStatus": [
    {
      "peerId": "12D3KooWDgi3EZGdsghsuyk17QUJUm81WdypjUfUpQFMv1KHqFPg",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 452062847,
      "ourMessages": 449266923,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooWBeHgpW1YJer1exohYJmBugcCxw6nPivDWPinc7GzZwtW",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 452193687,
      "ourMessages": 449266923,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooWBM99sMoBfWZdA8eDMbU6z2awAKvnpwPWfsrJEkK6gE82",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 452066054,
      "ourMessages": 449266923,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooWAd4CS8JrFzhavbX8VYoqZgYvixq92SKoMwkKSmEYn3ji",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 451854112,
      "ourMessages": 449263973,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooWAceovMknjAkFVxsazdq1zFsBA1FdQcd9quq8szhmi4YG",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 452123129,
      "ourMessages": 449263973,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooW9zRXheJk13bPxxGzsDqK9WjienqoeQTpZq1kh3hbi8vs",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 452386192,
      "ourMessages": 449266923,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooWAiWjWtt29EgQtANUPtZLmXrwermBf1PFvHtSkrkfWuVN",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 451970452,
      "ourMessages": 449266923,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooWET8RWKH5nRGmGn7FWMkSP5p8E48ipSoqC8CdCrCKekhh",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 452125619,
      "ourMessages": 449263973,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooWEFY9y65Su3LFd68BuJ3GLD37KxczMxxJ2h3QX3FsrTMw",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 452009411,
      "ourMessages": 449263973,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooWAg56TGduGdNjCtuXEdLkiyuTQykjBsKLmnBhKx2WvMgU",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 452250942,
      "ourMessages": 449266923,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooWCw6zzXy2zeXgHj1jhPruUaqjfbNxK8Gp6hGoaA17ReYf",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 452077312,
      "ourMessages": 449266923,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooWELYvHd5MkDYaT1BXCEVn61PuznAj15mUmQn1ioLVQC1h",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 452160134,
      "ourMessages": 449266923,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooWDvzJMYFAzdJ4NPtHfm4Ygoz9JSWXgi346q5VAE6stnSm",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 452012326,
      "ourMessages": 449266923,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooWBCbzwWTYkU7hzQHo8dN2PTYtoom8Eo3heP1QtuuaYbPy",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 452241704,
      "ourMessages": 449266923,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooWC4LJ62SHpTVoSvyzA63jBHXeTNm1vboKUygR83d8EH5X",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 452097420,
      "ourMessages": 449266923,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooWBuS8TUiqeabs9YKTz17vQRD2csVA4PDUqFFmKDyCGepq",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 451996803,
      "ourMessages": 449264141,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooWMRrDr4JmWFnxusb5S9nsrkxBAXqWf7BymJtgQRsJMVQ2",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 452267236,
      "ourMessages": 449264141,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooWB8uy9VxTpipGoRjEc2BFoswXKgyGS6rhNTd1ofD9JXLG",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 452081457,
      "ourMessages": 449267092,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooWDrDvLLvRNaUiqmrA9YvRp41gZaEmoatqVAdJwzopdgBN",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 452128777,
      "ourMessages": 449264141,
      "lastBadSync": -1,
      "score": 0
    },
    {
      "peerId": "12D3KooWBfPafShMrDwmVwM1qGqajyyYnfsr4K2MznKRfnxx6giU",
      "inSync": "false",
      "shouldSync": false,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 451763652,
      "ourMessages": 449264184,
      "lastBadSync": -1,
      "score": 0
    }
  ],
  "engineStarted": true
}
```

### POST /v1/stopSync
```
{
  "isSyncing": false,
  "syncStatus": [],
  "engineStarted": true
}
```

### POST /v1/forceSync?peer_id=${PEER_ID_HERE}
```
{
  "isSyncing": true,
  "syncStatus": [
    {
      "peerId": "12D3KooWRnSZUxjVJjbSHhVKpXtvibMarSfLSKDBeMpfVaNm1Joo",
      "inSync": "false",
      "shouldSync": true,
      "divergencePrefix": "",
      "divergenceSecondsAgo": 0,
      "theirMessages": 448940578,
      "ourMessages": 449276683,
      "lastBadSync": -1,
      "score": 0
    }
  ],
  "engineStarted": true
}
```

## 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)
- [x] PR has been tagged with a change label(s) (i.e. documentation,
feature, bugfix, or chore)
- [x] 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)

## Additional Context

If this is a relatively large or complex change, provide more details
here that will help reviewers


<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to add experimental HTTP APIs for controlling
synchronization in the `@farcaster/hubble` app.

### Detailed summary
- Added experimental HTTP APIs for controlling sync: `stopSync`,
`syncStatus`, `forceSync`
- Implemented corresponding API endpoints in `httpServer.ts`
- Updated documentation with examples and responses for each API

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-06-29 01:37:30 -05:00
Sanjay
c723f655ff feat: add endpoints to control sync (#2110) 2024-06-28 17:30:45 -07:00
Shane da Silva
e67f8cb0dd chore(shuttle): Release 0.4.2 (#2108)
## Motivation

Release latest fix.

## Change Summary

Updates version to 0.4.2

## Merge Checklist

- [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 version of `@farcaster/shuttle` package to `0.4.2`
and includes a more efficient switch clause implementation.

### Detailed summary
- Updated version to `0.4.2` in `packages/shuttle/package.json`
- Improved efficiency of switch clause in the code

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-06-27 13:31:10 -07:00
Shane da Silva
fad0f17916 fix(shuttle): Use more efficient lookup to avoid errors (#2107)
## Motivation

We were seeing errors due to the number of message hashes in the `IN`
clause, resulting in a different prepared statement for each different
number of hashes.

## Change Summary

Switch to using the `= any([...])` form so that the same prepared
statement is always used.

## Merge Checklist

- [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)
- [x] 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 focuses on optimizing the `shuttle` package by updating
dependencies and improving query efficiency.

### Detailed summary
- Updated `pg` dependency to `8.12.0`
- Switched `where` clause in `MessageReconciliation` for more efficiency
- Added `sql` import in `shuttle/db.ts`

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-06-27 13:21:11 -07:00
Sanjay
00d88c6f7f chore: Release 1.13.4 (#2104)
## Motivation

Release performance fixes for gossip

## Change Summary

Describe the changes being made in 1-2 concise sentences.

## 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)
- [x] 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)

## Additional Context

If this is a relatively large or complex change, provide more details
here that will help reviewers


<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the version of `@farcaster/hubble` to `1.13.4` in the
package.json and includes patch changes related to fixing issues with
mainnet bootstrap peers and gossip worker.

### Detailed summary
- Updated version to `1.13.4`
- Removed `nemes` from mainnet bootstrap peers
- Fixed gossip worker spending too much time iterating peer store

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-06-26 16:00:11 -07:00
Sanjay
366ce95c31 fix: Fix gossip worker spending too much time iterating peer store (#2103)
## Motivation

```
 [Bottom up (heavy) profile]:
  Note: percentage shows a share of a particular caller in the total
  amount of its parent calls.
  Callers occupying less than 1.0% are not shown.

   ticks parent  name
  1460430   43.7%  /home/sanjay/.nvm/versions/node/v18.15.0/bin/node
  795879   54.5%    /home/sanjay/.nvm/versions/node/v18.15.0/bin/node
  224383   28.2%      LazyCompile: *peerIdFromBytes file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-id/dist/src/index.js:153:32
  224365  100.0%        LazyCompile: *all file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/dist/src/store.js:170:15
  224365  100.0%          /home/sanjay/.nvm/versions/node/v18.15.0/bin/node
  174182   21.9%      LazyCompile: *load file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/dist/src/store.js:35:15
  174145  100.0%        /home/sanjay/.nvm/versions/node/v18.15.0/bin/node
  90942   11.4%      LazyCompile: *decode file:///home/sanjay/hubble_dev/node_modules/multiformats/src/bases/base.js:343:12
  90931  100.0%        LazyCompile: *all file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/dist/src/store.js:170:15
  90931  100.0%          /home/sanjay/.nvm/versions/node/v18.15.0/bin/node
  79173    9.9%      /home/sanjay/.nvm/versions/node/v18.15.0/bin/node
  27262   34.4%        LazyCompile: *cleanPath file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/codec.js:165:26
  27252  100.0%          LazyCompile: *bytesToMultiaddrParts file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/codec.js:56:38
  27235   99.9%            LazyCompile: *load file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/dist/src/store.js:35:15
  15786   19.9%        LazyCompile: *all file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/dist/src/store.js:170:15
  15786  100.0%          /home/sanjay/.nvm/versions/node/v18.15.0/bin/node
    879    5.6%            LazyCompile: *forEach file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/dist/src/index.js:24:18
  12903   16.3%        LazyCompile: *format file:///home/sanjay/hubble_dev/node_modules/multiformats/src/cid.js:20:23
  12886   99.9%          LazyCompile: *all file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/dist/src/store.js:170:15
  12886  100.0%            /home/sanjay/.nvm/versions/node/v18.15.0/bin/node
  10342   13.1%        LazyCompile: *peerIdFromBytes file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-id/dist/src/index.js:153:32
  10341  100.0%          LazyCompile: *all file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/dist/src/store.js:170:15
  10341  100.0%            /home/sanjay/.nvm/versions/node/v18.15.0/bin/node
   7094    9.0%        LazyCompile: *bytesToMultiaddrParts file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/codec.js:56:38
   7092  100.0%          LazyCompile: *load file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/dist/src/store.js:35:15
   7092  100.0%            /home/sanjay/.nvm/versions/node/v18.15.0/bin/node
   3885    4.9%        LazyCompile: *_peerIdToDatastoreKey file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/dist/src/store.js:21:26
   3883   99.9%          LazyCompile: *all file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/dist/src/store.js:170:15
   3883  100.0%            /home/sanjay/.nvm/versions/node/v18.15.0/bin/node
  38786    4.9%      LazyCompile: *fromString file:///home/sanjay/hubble_dev/node_modules/uint8arrays/dist/src/from-string.js:10:27
  24315   62.7%        LazyCompile: *Key file:///home/sanjay/hubble_dev/node_modules/interface-datastore/dist/src/key.js:29:16
  24275   99.8%          LazyCompile: *all file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/dist/src/store.js:170:15
  24275  100.0%            /home/sanjay/.nvm/versions/node/v18.15.0/bin/node
   7340   18.9%        LazyCompile: *_peerIdToDatastoreKey file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/dist/src/store.js:21:26
   7338  100.0%          LazyCompile: *all file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/dist/src/store.js:170:15
   7338  100.0%            /home/sanjay/.nvm/versions/node/v18.15.0/bin/node
   7110   18.3%        LazyCompile: *_allKeys file:///home/sanjay/hubble_dev/node_modules/datastore-core/dist/src/memory.js:32:14
   7110  100.0%          /home/sanjay/.nvm/versions/node/v18.15.0/bin/node
   7010   98.6%            LazyCompile: *next file:///home/sanjay/hubble_dev/node_modules/it-peekable/dist/src/index.js:17:15
     98    1.4%            Function: ^next file:///home/sanjay/hubble_dev/node_modules/it-peekable/dist/src/index.js:17:15
  25814    3.2%      LazyCompile: *toString file:///home/sanjay/hubble_dev/node_modules/uint8arrays/dist/src/to-string.js:9:25
  24662   95.5%        LazyCompile: *bytes2mh file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/convert.js:188:18
  24661  100.0%          LazyCompile: *bytesToMultiaddrParts file:///home/sanjay/hubble_dev/node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/codec.js:56:38

```

## Change Summary

Describe the changes being made in 1-2 concise sentences.

## 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)
- [x] 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)

## Additional Context

If this is a relatively large or complex change, provide more details
here that will help reviewers


<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on optimizing the performance of the `peerStoreCount`
function in the `gossipNodeWorker.ts` file by addressing the issue of
blocking the event loop.

### Detailed summary
- Added a comment highlighting the performance-intensive nature of
`peerStoreCount` function
- Removed redundant `statsd().gauge` call in `handleContactInfo` method

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-06-26 15:32:49 -07:00
Wasif Iqbal
3f0fb85c15 fix: remove nemes from mainnet bootstrap peers (#2102) 2024-06-26 14:53:53 -05:00
Sanjay
2bf0959f2e chore: Release 1.13.3 (#2091)
## Motivation

Release 1.13.3

## Change Summary

Describe the changes being made in 1-2 concise sentences.

## 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)
- [x] 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)

## Additional Context

If this is a relatively large or complex change, provide more details
here that will help reviewers
2024-06-24 23:49:12 +00:00
Sanjay
b150e90001 fix: Use stricter socket timeout for gossip (#2090)
## Motivation

Gossip metrics indicate the worker sometimes stalls for 5 mins before
receiving messages in a burst. Likely due to one or more bad peers. The
default socket timeout is 5 mins, set this to 30seconds to see if it
helps.

## Change Summary

Describe the changes being made in 1-2 concise sentences.

## 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)
- [x] 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)

## Additional Context

If this is a relatively large or complex change, provide more details
here that will help reviewers


<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the `hubble` package to use a stricter socket timeout
for gossip communication in the `gossipNodeWorker.ts` file.

### Detailed summary
- Updated the socket timeout for gossip communication to be stricter (30
seconds).
- Modified the `transports` configuration to include the new socket
timeout settings.

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-06-24 16:17:56 -07:00
Wasif Iqbal
eacf29c98c fix: return better error message (#2077)
## Motivation

Parameters that contained invalid cast URLs with valid cast URL prefixes
were surfacing database error instead of not found error. The url itself
did not contain parent casts, but because it contained a valid prefix,
the database lookups were returning errors.
For example, a valid URL may be:
"https://warpcast.com/~/channel/japan777iine"
An invalid URL may be: "https://warpcast.com/~/chanel-makeup"

Since both URLs contain same prefix, _part_ of the invalid param gets
processed. That "prefix" then yields an error when entries aren't found
in the database. However, no entries found is expected, because the URL
is garbage.

Instead of surfacing the database error, we now correctly surface not
found error. This should fix #2067

- Certain queries to Hub API caused db errors to surface, e.g:
```
{
  "code": 2,
  "details": "db.internal_error/could not get message with key: [1, 129, 11, 134, 0, 1, 111, 110, 101, 6, 78, 209, 172, 203, 162, 11, 104, 228, 239, 164, 151, 212, 243, 3, 81, 109, 55, 199, 100, 32]",
  "metadata": {
    "errcode": [
      null
    ]
  }
}
```

## Change Summary

**Empty URL**
```
{
  "errCode": "bad_request.invalid_param",
  "presentable": false,
  "name": "HubError",
  "code": 3,
  "details": "url < 1 byte",
  "metadata": {
    "errcode": [
      "bad_request.invalid_param"
    ]
  }
}
```

**Invalid URL**
```
{
  "errCode": "not_found",
  "presentable": false,
  "name": "HubError",
  "code": 2,
  "details": "could not get message with key: [1, 129, 11, 134, 0, 1, 111, 110, 101, 6, 78, 209, 172, 203, 162, 11, 104, 228, 239, 164, 151, 212, 243, 3, 81, 109, 55, 199, 100, 32]",
  "metadata": {
    "errcode": [
      "not_found"
    ]
  }
}
```

## 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
- [ ] PR has a
[changeset](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#35-adding-changesets)
- [x] 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)

## Additional Context

If this is a relatively large or complex change, provide more details
here that will help reviewers

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to fix the issue where the HTTP endpoint returns
"not found" instead of an internal database error.

### Detailed summary
- Fixed the issue in the `cast_store.rs` file related to generating
message primary key
- Updated error handling in `message.rs` and `store.rs` files
- Added a new function `not_found` in `store.rs`
- Modified error conversion logic in `server.ts` to handle Rust errors

>  Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
2024-06-21 18:59:23 -05:00