Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

add client filtering flag #75

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

add client filtering flag #75

wants to merge 1 commit into from

Conversation

jsign
Copy link
Contributor

@jsign jsign commented Dec 17, 2021

Currently, bidbots can use cid-gravity for doing client filtering, but not everyone is using cid-gravity (in particular, miners in targeted-auctions).

This PR adds a new flag --client-address-whitelist to provide a whiltelist of client addresses for auctions:

  • If empty, it will have the current behavior: do not filter auctions depending on the client address.
  • If not empty, it will only bid in auctions if the client address is part of the client address whitelist.

The plan now is to share this PR with a storage provider that asked for this feature and allow them to test it.
If all looks good, we can merge it.

Signed-off-by: Ignacio Hagopian <[email protected]>
@jsign jsign self-assigned this Dec 17, 2021
@@ -29,11 +29,11 @@ $(BUF): $(BINGO_DIR)/buf.mod
@echo "(re)installing $(GOBIN)/buf-v0.41.0"
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=buf.mod -o=$(GOBIN)/buf-v0.41.0 "github.com/bufbuild/buf/cmd/buf"

GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.39.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just updating golangci-lint.

@@ -443,6 +451,19 @@ func (s *Service) filterAuction(auction *pb.Auction) (rejectReason string) {
s.auctionFilters.DealDuration.Max)
}

if len(s.auctionFilters.ClientAddressWhitelist) > 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gist of PR.

Comment on lines +36 to +38
t.Run("accept-any-client-address", func(t *testing.T) {
require.Empty(t, s.filterAuction(auction))
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test that if no whitelist is provided, we're accepting any auction.

Comment on lines +40 to +43
s.auctionFilters.ClientAddressWhitelist = []string{"f144zep4gitj73rrujd3jw6iprljicx6vl4wbeavi"}
t.Run("reject-single-client-address", func(t *testing.T) {
require.Contains(t, s.filterAuction(auction), "f2kb4izxsxu2jyyslzwmv2sfbrgpld56efedgru5i")
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test with a whitelist only containing f144zep4gitj73rrujd3jw6iprljicx6vl4wbeavi.

Then test if an auction from client f2kb4izxsxu2jyyslzwmv2sfbrgpld56efedgru5i (L33) will be rejected, since that must be the case.

The rejection message should be a string explaining the cause of rejection, which must say something about f2kb4izxsxu2jyyslzwmv2sfbrgpld56efedgru5i being rejected from not being in the whitelist. The logic in the code never have a strict interpretation of the returned string, its only using for logging; so took the liberty of avoiding type-erroring.

Comment on lines +45 to +48
auction.ClientAddress = s.auctionFilters.ClientAddressWhitelist[0]
t.Run("accept-single-client-address", func(t *testing.T) {
require.Empty(t, s.filterAuction(auction))
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test the case where the auction client address matches a value in the whitelist, and check that the auction isn't rejected.

@@ -95,6 +95,22 @@ func TestNew(t *testing.T) {
})
require.Error(t, err)

// Incorrect string representation of whitelisted client address.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Augment an existing test to check fast-fail in parsing a malformed client address in a whitelist.

@jsign jsign requested review from asutula and brunocalza December 17, 2021 15:22
@jsign jsign marked this pull request as ready for review December 17, 2021 15:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants