Skip to content

Conversation

geoff-vball
Copy link
Contributor

@geoff-vball geoff-vball commented Aug 13, 2025

Why this should be merged

Closes #4239 (comment)

How this works

Creates a new grpc method GetAllValidatorSets that returns all validators for all subnets.

Creates a caching wrapper for validator State that overrides GetValidatorSet to check the cache for the validator set. If it is missing, then call GetAllValidatorSets and cache all the results.

TODO check grpc max message size
Using current three fields returned the size of the serialized message remains under the default 4MB limit with the maximum 20k L1 validators each validating a separate subnet and an additional 20k primary network validators. Additionally we override/disable the maximum gRPC message size when dialing already.

How this was tested

Need to be documented in RELEASES.md?

@geoff-vball geoff-vball force-pushed the cache-validator-sets branch from 78aad7c to ac137d6 Compare August 13, 2025 17:21
@joshua-kim joshua-kim moved this to Backlog 🧊 in avalanchego Aug 18, 2025
return validatorSets, nil
}

func (c *CachedState) GetValidatorSet(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the case that the State is a wrapped state like tracedState, this doesn't actually call the underlying GetValidatorSet method - will that cause any problems for us?

Copy link
Contributor

Choose a reason for hiding this comment

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

tracedState is a wrapper that needs access to a different state implementation which would presumably make the relevant calls itself at a level no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think in the case you wrap CachedState -> TracedState -> State, if you call GetValidatorSet the trace would be tagged with GetAllValidatorSets because that would be what you'd be calling under the hood.

If you wrapped TracedState -> CachedState -> State then the trace would be tagged (correctly?) with GetValidatorSet

Don't think it's a big deal either way though

@geoff-vball geoff-vball marked this pull request as ready for review September 11, 2025 15:11
@geoff-vball geoff-vball requested review from a team and maru-ava and removed request for a team September 11, 2025 15:29
@@ -1115,6 +1115,9 @@ func (m *manager) createSnowmanChain(
return nil, fmt.Errorf("expected validators.State but got %T", vm)
}

// Wrap the validator state with a cached state
m.validatorState = validators.NewCachedState(m.validatorState)
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be valState or else it just gets overridden below it seems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog 🧊
Development

Successfully merging this pull request may close these issues.

Create GetValidatorSets caching library
3 participants