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

fetcher: provide api to fetch objects without validating if they are available in db #4927

Open
dshulyak opened this issue Aug 30, 2023 · 1 comment

Comments

@dshulyak
Copy link
Contributor

existing api always tries to lookup if object exists in the database, this is both inefficient and not robust.

as an example ballot validation

image

in fact all this objects are available in memory in the tortoise, so there is absolutely no reason to waste resources on doing this database lookups.

another concern is that this is not robust, if tortoise doesn't have dependency when dependant object is processed - it will fail validation and it will retry hopefully in some future.

to address both of those concern component that maintain state should be able to provide information about missing objects (for example as an error), and fetcher should do request based on missing object, regardless of that is stored in the database. after fetching complete validation should be re-done. in other words it should be up to handler to check that data is available, some handlers may do it using database, but in some places we already have all necessary data in memory.

@countvonzero

@dshulyak
Copy link
Contributor Author

image

bors bot pushed a commit that referenced this issue Sep 1, 2023
related: #4927

this change eliminates database lookups on ballot validation path, with an exception of when lru cache is not sufficient to hold
vrf nonces and activations. in that case we will have to load them from db, that can be optimized later by fitting more in lru cache #4935 or reusing tortoise dataset as well

- fetcher will be asked for ballots only if we don't have them in memory
- reference ballots for eligibility validation will be fetched from tortoise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant