Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add batch denylist check #166

Merged
merged 3 commits into from
Jun 27, 2023
Merged

feat: add batch denylist check #166

merged 3 commits into from
Jun 27, 2023

Conversation

olizilla
Copy link
Contributor

@olizilla olizilla commented Jun 21, 2023

Send an array of CID strings to check if they are on the denylist. Response is the subset of the array that is on the denylist.

POST /
Content-Type: application/json

["cid1","cid2"]

This will be used by e-ipfs to check a batch of cids at once, see: elastic-ipfs/bitswap-peer#215

License: MIT

Send an array of CID strings to check if they are on the denylist. Reponse is the subset of the array that is on the denylist.

```http
POST /
Content-Type: application/json

["cid1","cid2"]
```

License: MIT
Signed-off-by: Oli Evans <oli@protocol.ai>
License: MIT
Signed-off-by: Oli Evans <oli@protocol.ai>
* @param {import('./env').Env} env
*/
export async function denylistPost (request, env) {
if (!request.json) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK this is not undefined if content-type is not json...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes, right, i was following the itty-route request type which defines .json as optional, but isn't want i want to test for here. Fixing!

Copy link
Contributor

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

License: MIT
Signed-off-by: Oli Evans <oli@protocol.ai>
@olizilla olizilla merged commit 407aecb into main Jun 27, 2023
6 checks passed
@olizilla olizilla deleted the batch-denylist branch June 27, 2023 10:53
olizilla added a commit to elastic-ipfs/bitswap-peer that referenced this pull request Jul 5, 2023
- cap the max number of cids we'll accept in a single message. 
- We're seeing 20k spikes in our `bitswap-pending-entries` metrics per
node, so I'm putting in a hard cap of 500 wanted cids per message that
we'll process. The caller can ask again if they need more. This also
means i can put a sensible cap on how many cids the denylist service
should handle in a batch.
- check batches of cids against our denylist api.
- cache entries that are on the denylist; they are rarely removed.
- use cache to avoid asking about items we already know, and as a
fallback if denylist service cannot be reached.
- add `bitswap-denied` counter metric to see how many CIDs we skip due
to being on the denylist


see: batch endpoint for denylist api –
storacha/reads#166
see: set DENYLIST_URL in env -
elastic-ipfs/bitswap-peer-deployment#99

License: MIT

---------

Signed-off-by: Oli Evans <oli@protocol.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants