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

Lazy loading of State #4326

Closed
zmanian opened this issue May 10, 2019 · 10 comments
Closed

Lazy loading of State #4326

zmanian opened this issue May 10, 2019 · 10 comments

Comments

@zmanian
Copy link
Member

zmanian commented May 10, 2019

The original motivation for state pruning in the cosmos-sdk is that once we had stable testnets, restarting a blockchain node could take 10+ hours because we eagerly load all the unpruned states before the node starts serving requests.

At the time we talked about making it more convenient to run archive nodes by making it so gaia lazily loads old states on request when accessible on disk.

@alexanderbez
Copy link
Contributor

Is this more in regards to height and historical queries?

@zmanian
Copy link
Member Author

zmanian commented May 12, 2019

yes it enables historical queries but right now if you sync a node that can answer historical queries and then have to restart the node, restarting will take hours cause of eager state loading.

@alexanderbez
Copy link
Contributor

I see. What you suggest makes sense then.

ref: #4318

@alexanderbez alexanderbez self-assigned this May 12, 2019
@alexanderbez
Copy link
Contributor

Just to clarify what @zmanian is stating, whenever an application starts, the flow is as follows:

app.LoadLatestVersion(key) => BaseApp#LoadLatestVersion(key) => cms.LoadLatestVersion() => rs.LoadVersion(version) => (for each store) loadCommitStoreFromParams() => iavl.LoadStore() => tree.LoadVersion(version) => tree.ndb.getRoots()

So it seems each version (root) will be reloaded for each store when an application starts.

@alexanderbez
Copy link
Contributor

Taking a further look, I don't believe we can make the necessary changes from the SDK, but rather we must update iavl to provide this ability.

@zmanian
Copy link
Member Author

zmanian commented Jun 27, 2019

Can you explain what changes are needed @alexanderbez ?

@alexanderbez
Copy link
Contributor

I'll write a quick POC and submit a PR to the iavl repo.

@alexanderbez
Copy link
Contributor

alexanderbez commented Jun 27, 2019

Tested a working POC w/ cosmos/iavl#148 successfully. Also tested height queries successfully.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@tac0turtle
Copy link
Member

this has been done already in iavl v1

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

No branches or pull requests

3 participants