-
Notifications
You must be signed in to change notification settings - Fork 7
add client filtering flag #75
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Ignacio Hagopian <[email protected]>
@@ -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 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gist of PR.
t.Run("accept-any-client-address", func(t *testing.T) { | ||
require.Empty(t, s.filterAuction(auction)) | ||
}) |
There was a problem hiding this comment.
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.
s.auctionFilters.ClientAddressWhitelist = []string{"f144zep4gitj73rrujd3jw6iprljicx6vl4wbeavi"} | ||
t.Run("reject-single-client-address", func(t *testing.T) { | ||
require.Contains(t, s.filterAuction(auction), "f2kb4izxsxu2jyyslzwmv2sfbrgpld56efedgru5i") | ||
}) |
There was a problem hiding this comment.
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.
auction.ClientAddress = s.auctionFilters.ClientAddressWhitelist[0] | ||
t.Run("accept-single-client-address", func(t *testing.T) { | ||
require.Empty(t, s.filterAuction(auction)) | ||
}) |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
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: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.