You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 30, 2023. It is now read-only.
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?
two storages: ledger, state. demo_app is currently using ledger slot number to determine if storage has been initialized or not
problem with this is, if for some reason after initializing the ledger, sync fails (eg:
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.
I think using
slot_number == 1
is not a good indication ofis 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
The text was updated successfully, but these errors were encountered: