@@ -268,7 +268,6 @@ var (
268
268
StateSchemeFlag = & cli.StringFlag {
269
269
Name : "state.scheme" ,
270
270
Usage : "Scheme to use for storing ethereum state ('hash' or 'path')" ,
271
- Value : rawdb .HashScheme ,
272
271
Category : flags .StateCategory ,
273
272
}
274
273
StateHistoryFlag = & cli.Uint64Flag {
@@ -1721,15 +1720,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
1721
1720
if ctx .IsSet (StateHistoryFlag .Name ) {
1722
1721
cfg .StateHistory = ctx .Uint64 (StateHistoryFlag .Name )
1723
1722
}
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 )
1730
1725
}
1731
- cfg .StateScheme = scheme
1732
-
1733
1726
// Parse transaction history flag, if user is still using legacy config
1734
1727
// file with 'TxLookupLimit' configured, copy the value to 'TransactionHistory'.
1735
1728
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
2165
2158
if gcmode := ctx .String (GCModeFlag .Name ); gcmode != "full" && gcmode != "archive" {
2166
2159
Fatalf ("--%s must be either 'full' or 'archive'" , GCModeFlag .Name )
2167
2160
}
2168
- scheme , err := ParseStateScheme (ctx , chainDb )
2161
+ scheme , err := rawdb . ParseStateScheme (ctx . String ( StateSchemeFlag . Name ) , chainDb )
2169
2162
if err != nil {
2170
2163
Fatalf ("%v" , err )
2171
2164
}
@@ -2224,47 +2217,12 @@ func MakeConsolePreloads(ctx *cli.Context) []string {
2224
2217
return preloads
2225
2218
}
2226
2219
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
-
2262
2220
// MakeTrieDatabase constructs a trie database based on the configured scheme.
2263
2221
func MakeTrieDatabase (ctx * cli.Context , disk ethdb.Database , preimage bool , readOnly bool ) * trie.Database {
2264
2222
config := & trie.Config {
2265
2223
Preimages : preimage ,
2266
2224
}
2267
- scheme , err := ParseStateScheme (ctx , disk )
2225
+ scheme , err := rawdb . ParseStateScheme (ctx . String ( StateSchemeFlag . Name ) , disk )
2268
2226
if err != nil {
2269
2227
Fatalf ("%v" , err )
2270
2228
}
0 commit comments