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 Throttled Handler implementation to SDK #1906

Merged
merged 35 commits into from
Aug 30, 2023
Merged

Conversation

joshua-kim
Copy link
Contributor

Why this should be merged

Adds a throttled app handler implementation to the SDK

How this works

All incoming requests need to clear a throttler

How this was tested

Added unit test

@joshua-kim joshua-kim changed the base branch from master to sdk-throttler August 23, 2023 18:17
@danlaine danlaine added the sdk This involves SDK tooling or frameworks label Aug 23, 2023
joshua-kim and others added 2 commits August 28, 2023 12:40
Co-authored-by: Ceyhun Onur <ceyhun.onur@avalabs.org>
Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
joshua-kim and others added 3 commits August 28, 2023 23:43
Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>

func (t ThrottledHandler) AppGossip(ctx context.Context, nodeID ids.NodeID, gossipBytes []byte) error {
if !t.Throttler.Handle(nodeID) {
return fmt.Errorf("dropping message from %s: %w", nodeID, ErrThrottled)
Copy link
Contributor

Choose a reason for hiding this comment

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

q: should we really return an error when throttling? How about logging a warn and return nil. Not sure how AppGossip errors are handled by consensus engine

Copy link
Contributor Author

@joshua-kim joshua-kim Aug 29, 2023

Choose a reason for hiding this comment

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

This is dropped and logged by the p2p.responder that wraps all p2p.Handler instances. Currently we log, but in the future we'll implement application-level errors in #1889 where we'll make a custom p2p.AppError type that the sdk will interpret as an error.

Not sure how AppGossip errors are handled by consensus engine

Any AppHandler error will fatal consensus which is why they are logged, learned this when making the SDK. 😓

@StephenButtolph StephenButtolph added this to the v1.10.10 milestone Aug 29, 2023
Base automatically changed from sdk-throttler to dev August 30, 2023 06:27
@StephenButtolph StephenButtolph merged commit 0944233 into dev Aug 30, 2023
16 checks passed
@StephenButtolph StephenButtolph deleted the sdk-throttler-handler branch August 30, 2023 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sdk This involves SDK tooling or frameworks
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants