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

Minimal state rollovers #433

Closed
hdevalence opened this issue Feb 15, 2022 · 4 comments
Closed

Minimal state rollovers #433

hdevalence opened this issue Feb 15, 2022 · 4 comments

Comments

@hdevalence
Copy link
Member

Currently, each of our testnets has a completely fresh state, independent of any state from a previous testnet. This has worked well enough for development so far, but now that we have more users interested in the project, it would be friendlier not to erase their state. It would also be useful to start working on having a meaningful upgrade path.

In the long term, it would be ideal to be able to faithfully serialize the entire application state into the genesis.json file for a new chain, but in the short term (today and tomorrow, before launching the Orthosie testnet) it would be useful to figure out the bare minimum viable state rollover needed to preserve users' balances.

Because users should be able to sync their state from the chain, this means that we have to make (a minimal subset of) the old chain data available for syncing.

I think this looks like:

  • a list of StateFragments recording every existing note;
  • a list of nullifiers recording which of them have been spent;
  • a list of denominations (asset id preimages).

Clients would need to scan through this data to sync the chain.

As an MVP, we could potentially just insert all of the existing notes and nullifiers into the application state when processing the genesis file. With no other changes, this would mean that the first CompactBlock received during chain scanning would have a summary of the entire previous chain state.

I think this would be fine for now, since we have relatively little data (I checked this morning[^1] and there are only 55k notes; multiplying by ~200 bytes per state fragment gives ~10MB, which is on the upper end of reasonable), but in the longer term we might want to explore other options.

Three that come to mind:

  1. Queue up the old state fragments somehow and slot them into blocks of the new chain as it runs forward (e.g., replaying 1000 at a time or something);
  2. Cut them into chunks (say 1000 at a time or something), creating "phantom blocks" that only the app knows about, and reporting the next height as the initial height of the new chain.
  3. While exporting, attach the heights to the notes and nullifiers, and then use the data in the genesis file to create phantom blocks mirroring the old chain, reporting the initial height of the new chain as the highest height of any of the rolled-over data.

I don't really like either of those, since they both feel kind of hacky. We ideally don't want to be creating a bunch of phantom chain data that doesn't come from a (Tendermint) block (Related: #374).

@hdevalence hdevalence added this to the Testnet #6: Orthosie milestone Feb 15, 2022
@hdevalence
Copy link
Member Author

From the Tendermint docs:

initial_height: Height at which Tendermint should begin. If a blockchain is conducting a network upgrade, starting from the stopped height brings uniqueness to previous heights.

We use this with approach (3) to ensure that the historical blocks don't conflict with new blocks.

@hdevalence hdevalence removed this from the Testnet #7: Herse milestone Apr 4, 2022
@hdevalence
Copy link
Member Author

We should do this before going to mainnet, but there's no particular rush to do it, and it may be better to wait, since we won't have to update the state rollover code as we evolve our state, if we don't have any state rollover code.

@zbuc zbuc moved this to Future in Testnets Mar 24, 2023
@hdevalence
Copy link
Member Author

@erwanor Is this issue duplicated by the issues that are part of the upgrades work? Can we close it out?

@erwanor
Copy link
Member

erwanor commented Oct 25, 2023

Superseded by #1804 and in particular #3081

@erwanor erwanor closed this as completed Oct 25, 2023
@github-project-automation github-project-automation bot moved this from Future to Testnet 63: Rhea (Web Wallet) in Testnets Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Testnet 63: Rhea (Web Wallet)
Development

No branches or pull requests

2 participants