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

refactor(share/shrex-nd): blacklist peers that send invalid data #2231

Merged
merged 4 commits into from May 25, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion share/getters/shrex.go
Expand Up @@ -217,7 +217,16 @@ func (sg *ShrexGetter) GetSharesByNamespace(
nd, getErr := sg.ndClient.RequestND(reqCtx, root, id, peer)
cancel()
switch {
case getErr == nil, errors.Is(getErr, share.ErrNamespaceNotFound):
case getErr == nil:
if getErr = nd.Verify(root, id); getErr != nil {
setStatus(peers.ResultBlacklistPeer)
break
}
setStatus(peers.ResultNoop)
sg.metrics.recordNDAttempt(ctx, attempt, true)
renaynay marked this conversation as resolved.
Show resolved Hide resolved
return nd, getErr
case errors.Is(getErr, share.ErrNamespaceNotFound):
// TODO: will be merged with first case once non-inclusion proofs are ready
setStatus(peers.ResultNoop)
sg.metrics.recordNDAttempt(ctx, attempt, true)
return nd, getErr
Expand Down
6 changes: 0 additions & 6 deletions share/p2p/shrexnd/client.go
Expand Up @@ -127,12 +127,6 @@ func (c *Client) doRequest(
if err != nil {
return nil, fmt.Errorf("client-nd: converting response to shares: %w", err)
}

err = shares.Verify(root, nID)
if err != nil {
return nil, fmt.Errorf("client-nd: verifying response: %w", err)
}

return shares, nil
}

Expand Down