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

Add support for IPLD prime's budgets feature in selectors #235

Merged
merged 3 commits into from
Oct 1, 2021

Conversation

hannahhoward
Copy link
Collaborator

Goals

Provide absolute limits on links traversed for incoming and outgoing requests

Implementation

  • use budget in Traverser utility (add logic to handle budget for first link load)
  • create options for MaxLinksPerOutgoingRequest & MaxLinksPerIncomingRequest
  • pass through and create traversak budgets as needed (0 vals = no max links)
  • add integration tests & unit tests of traverser behavior

add options to configure the maximum number of allowed links to traverse on the requestor and the
responder
@@ -27,7 +27,7 @@ require (
github.com/ipfs/go-peertaskqueue v0.2.0
github.com/ipfs/go-unixfs v0.2.4
github.com/ipld/go-codec-dagpb v1.3.0
github.com/ipld/go-ipld-prime v0.12.0
github.com/ipld/go-ipld-prime v0.12.3-0.20210929125341-05d5528bd84e
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we ask for a tag of this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will do on monday

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

before I commit go-graphsync v0.10.0 final

requestExecutor := executor.NewExecutor(requestManager, incomingBlockHooks, asyncLoader.AsyncLoad)
responseAssembler := responseassembler.New(ctx, peerManager)
peerTaskQueue := peertaskqueue.New()
responseManager := responsemanager.New(ctx, linkSystem, responseAssembler, peerTaskQueue, requestQueuedHooks, incomingRequestHooks, outgoingBlockHooks, requestUpdatedHooks, completedResponseListeners, requestorCancelledListeners, blockSentListeners, networkErrorListeners, gsConfig.maxInProgressIncomingRequests, network.ConnectionManager())
responseManager := responsemanager.New(ctx, linkSystem, responseAssembler, peerTaskQueue, requestQueuedHooks, incomingRequestHooks, outgoingBlockHooks, requestUpdatedHooks, completedResponseListeners, requestorCancelledListeners, blockSentListeners, networkErrorListeners, gsConfig.maxInProgressIncomingRequests, network.ConnectionManager(), gsConfig.maxLinksPerIncomingRequest)
Copy link
Collaborator

Choose a reason for hiding this comment

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

these have gotten pretty unwieldy. we probably want options or some other pattern for these constructors at some point

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

they're initialized by the code itself, so I'd probably lean towards a struct, but I also want to move this whole package to an internal directory :) but yes for later

Comment on lines 245 to 248
fmt.Println(responseMetadata)
if len(filteredResponses) > 0 {
fmt.Println(filteredResponses[0].Status())
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove debug fmt's?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

#oops

requestHooks RequestHooks
responseAssembler ResponseAssembler
linkSystem ipld.LinkSystem
maxLinksPerRequest uint64
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we be clear/consistent about whether 0 means fail immediately or no limit?
In this file it seems to mean 'no limit', but in the test in traverser_test "errors correctly, no budget" link budget is set to 0, and the traversal then fails due to being out of budget.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

in means no limit. The traverser test gets a nil value for the budget, meaning no budget, when this value is 0

Copy link
Collaborator

Choose a reason for hiding this comment

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

i think what i'm asking for is a comment to that effect :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added

termination from remote peers was not properly handling blocks included up to termination, and could
include unpredictable amounts in the response channel
@hannahhoward hannahhoward merged commit dc8c863 into main Oct 1, 2021
@dirkmc dirkmc mentioned this pull request Oct 5, 2021
@aschmahmann aschmahmann mentioned this pull request Dec 1, 2021
80 tasks
@mvdan mvdan deleted the feat/request-budgets branch December 15, 2021 14:18
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.

2 participants