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

feat: route to nodes even if slightly behind max height #68

Merged
merged 4 commits into from
Oct 4, 2022

Conversation

IvanVergiliev
Copy link
Contributor

Description

We want to be able to tolerate some lag in certain situations. For example, we might want to favour our own node over a node provider even if we're slightly behind head. This PR keeps routing to nodes as long as they are within 10 blocks of the max height.

Type of change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • 😎 New feature (non-breaking change which adds functionality)
  • ⁉️ Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • ⚒️ Refactor (no functional changes)
  • 📖 Documentation (updating or adding docs)

How Has This Been Tested?

Added unit tests for new filter.

Copy link
Member

@dianwen dianwen left a comment

Choose a reason for hiding this comment

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

I love how easy this change is

@@ -6,6 +6,10 @@ import (
"github.com/satsuma-data/node-gateway/internal/metadata"
)

const (
MaxAllowedBlocksBehindHead = 10
Copy link
Member

Choose a reason for hiding this comment

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

If we want to guarantee clients will have access to data no staler than some amount of time, we probably want this configurable because of how different the block production times are. The plan is to run one gateway per chain right now, so having this configurable globally would be ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done - added a new Routing session of the config so that I can pass that into the filter factory and have it be responsible for that part of the config (e.g. handling defaults).

Base automatically changed from end-to-end-tests to main October 4, 2022 07:02
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.

3 participants