@@ -42,6 +42,9 @@ type StorageConfig struct {
4242 RollbackWindow uint64 `mapstructure:"rollback_window"`
4343 // LookbackWindow is how many queryable blocks are kept below the rollback window; -1 keeps all.
4444 LookbackWindow int64 `mapstructure:"lookback_window"`
45+ // StateStoreBackend is how the state store keeps its history: "pebbledb" stores every version of
46+ // every key, "undolog" the value each block replaced, over the current state.
47+ StateStoreBackend string `mapstructure:"state_store_backend"`
4548 // PruneInterval is how often the storage garbage collector runs.
4649 PruneInterval time.Duration `mapstructure:"prune_interval"`
4750 // CheckpointTimeInterval is the wall-clock gap between state-commit checkpoints.
@@ -90,6 +93,7 @@ func defaultStorageConfig() StorageConfig {
9093 Receipts : true ,
9194 RollbackWindow : gc .RollbackWindow ,
9295 LookbackWindow : gc .LookbackWindow ,
96+ StateStoreBackend : seidbconfig .DefaultSSBackend ,
9397 PruneInterval : gc .PruneInterval ,
9498 CheckpointTimeInterval : cp .TimeInterval ,
9599 CheckpointBlockInterval : cp .BlockInterval ,
@@ -102,6 +106,7 @@ const (
102106 FlagStorageReceipts = "giga.storage.receipts"
103107 FlagStorageRollbackWindow = "giga.storage.rollback_window"
104108 FlagStorageLookbackWindow = "giga.storage.lookback_window"
109+ FlagStorageStateStoreBackend = "giga.storage.state_store_backend"
105110 FlagStoragePruneInterval = "giga.storage.prune_interval"
106111 FlagStorageCheckpointTimeInterval = "giga.storage.checkpoint_time_interval"
107112 FlagStorageCheckpointBlockInterval = "giga.storage.checkpoint_block_interval"
@@ -137,6 +142,11 @@ func ReadConfig(opts AppOptions) (Config, error) {
137142 return cfg , fmt .Errorf ("%s: %w" , FlagStorageLookbackWindow , err )
138143 }
139144 }
145+ if v := opts .Get (FlagStorageStateStoreBackend ); v != nil {
146+ if cfg .Storage .StateStoreBackend , err = cast .ToStringE (v ); err != nil {
147+ return cfg , fmt .Errorf ("%s: %w" , FlagStorageStateStoreBackend , err )
148+ }
149+ }
140150 if v := opts .Get (FlagStoragePruneInterval ); v != nil {
141151 if cfg .Storage .PruneInterval , err = cast .ToDurationE (v ); err != nil {
142152 return cfg , fmt .Errorf ("%s: %w" , FlagStoragePruneInterval , err )
@@ -197,6 +207,12 @@ func (c Config) Validate() error {
197207 return fmt .Errorf ("%s: must be >= 0, or -1 to keep all history, got %d" , FlagStorageLookbackWindow ,
198208 c .Storage .LookbackWindow )
199209 }
210+ switch c .Storage .StateStoreBackend {
211+ case seidbconfig .PebbleDBBackend , seidbconfig .PebbleDBUndoBackend :
212+ default :
213+ return fmt .Errorf ("%s: %q is not %q or %q" , FlagStorageStateStoreBackend , c .Storage .StateStoreBackend ,
214+ seidbconfig .PebbleDBBackend , seidbconfig .PebbleDBUndoBackend )
215+ }
200216 if c .Storage .PruneInterval <= 0 {
201217 return fmt .Errorf ("%s: must be positive, got %s" , FlagStoragePruneInterval , c .Storage .PruneInterval )
202218 }
@@ -257,6 +273,11 @@ rollback_window = {{ .Giga.Storage.RollbackWindow }}
257273# -1 keeps all history.
258274lookback_window = {{ .Giga.Storage.LookbackWindow }}
259275
276+ # state_store_backend is how the state store keeps its history. "pebbledb" stores every version
277+ # of every key; "undolog" stores the value each block replaced, over the current state, and
278+ # drops expired history a bucket at a time.
279+ state_store_backend = "{{ .Giga.Storage.StateStoreBackend }}"
280+
260281# prune_interval is how often the storage garbage collector runs.
261282prune_interval = "{{ .Giga.Storage.PruneInterval }}"
262283
0 commit comments