-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[Feature]: state modifier for testing #18706
Comments
It would be great to provide a similar feature to the hardhat fork, dumping full data requires enormous works. |
What I've seen so far, is teams will write Python or similar scripts to achieve this. However, such an approach still requires to load the entire genesis into memory, which might be a no go. So if you could stream the genesis to load the exact module you want into memory, that would help a lot. From there, you can modify that module's state in memory and then write it back to the genesis file. |
why not modify it on disk? this way we avoid the need for streaming out and then back in? |
Maybe I'm missing something, but how do you modify anything w/o loading it in memory? I imagine any valuable state transition function will be dependent in some input. |
from my understanding, the state transition is a kind of streaming with the specific flags ? |
the idea i had is you write a state transition function and execute it directly on the database instead of loading anything into memory. there wouldnt be a need to extract the data from the database, maybe store loads it into cache but would be the same way we load things during execution |
Instead of syncing from genesis, I have been able to run osmosis mainnet tests by downloading a snapshot (https://quicksync.io) and syncing from there. That felt reasonable, but did require some manual work. For a chain that's been through multiple state-machine breaking upgrades and binaries, it is very difficult (today) to sync from genesis because of the need to collect many legacy binaries right? If that's true I think I agree with @cool-develope that streamlining state sync is a good direction, for testing non state breaking changes.
This and the points below it seem to be pointing at a way of streamlining forking a new testnet from mainnet head, am I understanding that right? |
the testing used here is when users like osmosis and gaia export genesis modify genesis then start a local testnet to test upgrades or other things. Its a bit different than our use case of testing. Im not sure what state streaming would add here? we would need to export all state into the file system, find the file which has the staking values, modify them, then import them back into a node. Is that what you mean @cool-develope |
personally, I like what hardhat fork is doing, it doesn't need the entire state. so it would be great the SDK provides some streaming or API to get the specific storage data or the minimum state for testing. |
Maybe, I misunderstand your point, should we need the full state to test the local testnet and upgrades? |
correct, the goal is to be able to take a snapshot of mainnet, modify state, then run that locally. This is how much of the ecosystem is doing chain upgrade testing today, except they export into genesis, modify then import |
I can't imagine any meaningful or useful state transition function w/o any dependent input, which must be loaded into memory. Now certainly you can blindly overwrite keys with some data, in which case no input is required. But I would argue that is only a small subset of the total set of state transition functions. E.g. consider the example where you want a single account to have the balance of all other accounts. This requires you loading some or all balances into memory. |
Summary
Today, if a chain would like to use their mainnet state to run tests on, they need to:
These steps are heavy in nature due to how we keep all genesis in memory until the end.
We should offer a simpler approach in which an application dev writes a state transition in a module, or outside in which it modifies all state to have the state they need to start the chain.
Problem Definition
Export and Importing of state is a large burden due to resource contraints
Proposed Feature
I see two options, but there may be more:
I tend to like two more since its separate from the main binary and can be distributed separately in the case of disaster recovery
To test, we should be able to take the cosmos hub mainnet database modify it to be a single validator and start the chain.
Its unclear how this will work with cometbft's database, we may need to modify their state as well if initchain doesnt do it all
The text was updated successfully, but these errors were encountered: