From 298612f51181fba91303d6ea2b252ae14d8a56d4 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 20 May 2024 19:54:55 -0300 Subject: [PATCH] gracefully fails if provided state scheme is incompatible with stored trie --- cmd/nitro/init.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/nitro/init.go b/cmd/nitro/init.go index c52c87732c8..6ce5b0145cf 100644 --- a/cmd/nitro/init.go +++ b/cmd/nitro/init.go @@ -187,6 +187,10 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo return nil, nil, err } chainDb := rawdb.WrapDatabaseWithWasm(chainData, wasmDb) + _, err = rawdb.ParseStateScheme(cacheConfig.StateScheme, chainDb) + if err != nil { + return nil, nil, err + } err = pruning.PruneChainDb(ctx, chainDb, stack, &config.Init, cacheConfig, l1Client, rollupAddrs, config.Node.ValidatorRequired()) if err != nil { return chainDb, nil, fmt.Errorf("error pruning: %w", err) @@ -244,6 +248,10 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo return nil, nil, err } chainDb := rawdb.WrapDatabaseWithWasm(chainData, wasmDb) + _, err = rawdb.ParseStateScheme(cacheConfig.StateScheme, chainDb) + if err != nil { + return nil, nil, err + } if config.Init.ImportFile != "" { initDataReader, err = statetransfer.NewJsonInitDataReader(config.Init.ImportFile)