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

Improve TState #1834

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Improve TState #1834

wants to merge 6 commits into from

Conversation

RodrigoVillar
Copy link
Contributor

@RodrigoVillar RodrigoVillar commented Dec 16, 2024

This PR makes the following improvements related to TState:

  • fetcher now takes just the database keys that it needs to fetch, rather than state keys (i.e. database keys + it's permissions) as fetcher is not and should not be responsible for permission validation
  • Both the state keys and storage mapping that were previously passed into TState have been replaced by a Scope interface which implements both reads and permission validation requests (i.e. Has()).
    • TStateRecorder has been replaced by SimulatedScope
  • dbtest has been moved into its own package, following the convention in AvalancheGo.

@@ -142,12 +150,16 @@ func TestFetchSameKeysSlow(t *testing.T) {
stateKeys.Add(keyBase+strconv.Itoa(k), state.Read)
}
txID := ids.GenerateTestID()
keys := make([]string, 0, len(stateKeys))
Copy link
Contributor

Choose a reason for hiding this comment

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

converting the state keys map into a keys slice seems to be a common usage pattern; do you think it would make sense to create a function that would encapsulate that ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the tests, we can switch to generating database keys instead of generating state keys + immediately stripping their permissions. But agree that we should add a function that converts state keys into a keys slice.

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

@RodrigoVillar RodrigoVillar marked this pull request as ready for review December 16, 2024 15:50
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