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

Demo rollup and prover fails after restart #340

Closed
citizen-stig opened this issue May 25, 2023 · 0 comments · Fixed by #360
Closed

Demo rollup and prover fails after restart #340

citizen-stig opened this issue May 25, 2023 · 0 comments · Fixed by #360

Comments

@citizen-stig
Copy link
Member

citizen-stig commented May 25, 2023

Original issue: Sovereign-Labs/demo-rollup#9

two storages: ledger, state. demo_app is currently using ledger slot number to determine if storage has been initialized or not

let mut item_numbers = ledger_db.get_next_items_numbers();
    if item_numbers.slot_number == 1 {
        print!("No history detected. Initializing chain...");
        demo.init_chain(());
        println!("Done.");
    } else {
        println!("Chain is already initialized. Skipping initialization.");
    }

problem with this is, if for some reason after initializing the ledger, sync fails (eg:

  • due to incorrect authentication token,
  • or because the light client is not running, has crashed etc),
    slot number will remain at 1 and when the demo rollup tries to start again, it ends up attempting to re-initialize the db and panics.
No history detected. Initializing chain...initializing runtime
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ModuleError(Token address already exists)', 
sov-modules/sov-app-template/src/lib.rs:88:14

I think using slot_number == 1 is not a good indication of is chain initialized / do we need to run init_chain.
(a trivial case is to run init_chain and check slot number - and it's still 1!)

we need a better check to know that the state is "initialized" because there can be any number of failures once chain is initialized and before slot number advances. or we can make init_chain fail gracefully if its called multiple times, but this still requires some notion of knowing the chain has been "initialized"

in the shorter term, I can also just catch_unwind and detect the condition, or it can be as simple as adding "nuke the db" to the instructions, since that ends up working. a better solution is to have something queryable that tells us if both ledger and state have been "initialized". could also just be a boolean flag, but might be overkill?

@preston-evans98 lmk wyt

since this is just a demo, we can also just add instructions

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 a pull request may close this issue.

1 participant