@@ -268,7 +268,6 @@ var (
268268	StateSchemeFlag  =  & cli.StringFlag {
269269		Name :     "state.scheme" ,
270270		Usage :    "Scheme to use for storing ethereum state ('hash' or 'path')" ,
271- 		Value :    rawdb .HashScheme ,
272271		Category : flags .StateCategory ,
273272	}
274273	StateHistoryFlag  =  & cli.Uint64Flag {
@@ -1721,15 +1720,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
17211720	if  ctx .IsSet (StateHistoryFlag .Name ) {
17221721		cfg .StateHistory  =  ctx .Uint64 (StateHistoryFlag .Name )
17231722	}
1724- 	// Parse state scheme, abort the process if it's not compatible. 
1725- 	chaindb  :=  tryMakeReadOnlyDatabase (ctx , stack )
1726- 	scheme , err  :=  ParseStateScheme (ctx , chaindb )
1727- 	chaindb .Close ()
1728- 	if  err  !=  nil  {
1729- 		Fatalf ("%v" , err )
1723+ 	if  ctx .IsSet (StateSchemeFlag .Name ) {
1724+ 		cfg .StateScheme  =  ctx .String (StateSchemeFlag .Name )
17301725	}
1731- 	cfg .StateScheme  =  scheme 
1732- 
17331726	// Parse transaction history flag, if user is still using legacy config 
17341727	// file with 'TxLookupLimit' configured, copy the value to 'TransactionHistory'. 
17351728	if  cfg .TransactionHistory  ==  ethconfig .Defaults .TransactionHistory  &&  cfg .TxLookupLimit  !=  ethconfig .Defaults .TxLookupLimit  {
@@ -2165,7 +2158,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
21652158	if  gcmode  :=  ctx .String (GCModeFlag .Name ); gcmode  !=  "full"  &&  gcmode  !=  "archive"  {
21662159		Fatalf ("--%s must be either 'full' or 'archive'" , GCModeFlag .Name )
21672160	}
2168- 	scheme , err  :=  ParseStateScheme (ctx , chainDb )
2161+ 	scheme , err  :=  rawdb . ParseStateScheme (ctx . String ( StateSchemeFlag . Name ) , chainDb )
21692162	if  err  !=  nil  {
21702163		Fatalf ("%v" , err )
21712164	}
@@ -2224,47 +2217,12 @@ func MakeConsolePreloads(ctx *cli.Context) []string {
22242217	return  preloads 
22252218}
22262219
2227- // ParseStateScheme resolves scheme identifier from CLI flag. If the provided 
2228- // state scheme is not compatible with the one of persistent scheme, an error 
2229- // will be returned. 
2230- // 
2231- //   - none: use the scheme consistent with persistent state, or fallback 
2232- //     to hash-based scheme if state is empty. 
2233- //   - hash: use hash-based scheme or error out if not compatible with 
2234- //     persistent state scheme. 
2235- //   - path: use path-based scheme or error out if not compatible with 
2236- //     persistent state scheme. 
2237- func  ParseStateScheme (ctx  * cli.Context , disk  ethdb.Database ) (string , error ) {
2238- 	// If state scheme is not specified, use the scheme consistent 
2239- 	// with persistent state, or fallback to hash mode if database 
2240- 	// is empty. 
2241- 	stored  :=  rawdb .ReadStateScheme (disk )
2242- 	if  ! ctx .IsSet (StateSchemeFlag .Name ) {
2243- 		if  stored  ==  ""  {
2244- 			// use default scheme for empty database, flip it when 
2245- 			// path mode is chosen as default 
2246- 			log .Info ("State schema set to default" , "scheme" , "hash" )
2247- 			return  rawdb .HashScheme , nil 
2248- 		}
2249- 		log .Info ("State scheme set to already existing" , "scheme" , stored )
2250- 		return  stored , nil  // reuse scheme of persistent scheme 
2251- 	}
2252- 	// If state scheme is specified, ensure it's compatible with 
2253- 	// persistent state. 
2254- 	scheme  :=  ctx .String (StateSchemeFlag .Name )
2255- 	if  stored  ==  ""  ||  scheme  ==  stored  {
2256- 		log .Info ("State scheme set by user" , "scheme" , scheme )
2257- 		return  scheme , nil 
2258- 	}
2259- 	return  "" , fmt .Errorf ("incompatible state scheme, stored: %s, provided: %s" , stored , scheme )
2260- }
2261- 
22622220// MakeTrieDatabase constructs a trie database based on the configured scheme. 
22632221func  MakeTrieDatabase (ctx  * cli.Context , disk  ethdb.Database , preimage  bool , readOnly  bool ) * trie.Database  {
22642222	config  :=  & trie.Config {
22652223		Preimages : preimage ,
22662224	}
2267- 	scheme , err  :=  ParseStateScheme (ctx , disk )
2225+ 	scheme , err  :=  rawdb . ParseStateScheme (ctx . String ( StateSchemeFlag . Name ) , disk )
22682226	if  err  !=  nil  {
22692227		Fatalf ("%v" , err )
22702228	}
0 commit comments