This repository was archived by the owner on Jan 20, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathconfig.go
More file actions
117 lines (95 loc) · 4.45 KB
/
config.go
File metadata and controls
117 lines (95 loc) · 4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package config
const (
DefaultSnapshotInterval = 10000
DefaultSnapshotKeepRecent = 0 // set to 0 to only keep one current snapshot
DefaultAsyncCommitBuffer = 100
DefaultCacheSize = 100000
DefaultSSKeepRecent = 100000
DefaultSSPruneInterval = 600
DefaultSSImportWorkers = 1
DefaultSSAsyncBuffer = 100
DefaultSSHashRange = 1000000
)
type StateCommitConfig struct {
// Enable defines if the state-commit should be enabled.
// If true, it will replace the existing IAVL db backend with memIAVL.
// defaults to false.
Enable bool `mapstructure:"enable"`
// Directory defines the state-commit store directory
// If not explicitly set, default to application home directory
Directory string `mapstructure:"directory"`
// ZeroCopy defines if the memiavl should return slices pointing to mmap-ed buffers directly (zero-copy),
// the zero-copied slices must not be retained beyond current block's execution.
// the sdk address cache will be disabled if zero-copy is enabled.
// defaults to false.
ZeroCopy bool `mapstructure:"zero-copy"`
// AsyncCommitBuffer defines the size of asynchronous commit queue
// this greatly improve block catching-up performance, <= 0 means synchronous commit.
// defaults to 100
AsyncCommitBuffer int `mapstructure:"async-commit-buffer"`
// SnapshotKeepRecent defines what many old snapshots (excluding the latest one) to keep
// defaults to 0 to only keep one current snapshot
SnapshotKeepRecent uint32 `mapstructure:"snapshot-keep-recent"`
// SnapshotInterval defines the block interval the memiavl snapshot is taken, default to 10000.
SnapshotInterval uint32 `mapstructure:"snapshot-interval"`
// SnapshotWriterLimit defines the concurrency for taking commit store snapshot
SnapshotWriterLimit int `mapstructure:"snapshot-writer-limit"`
// CacheSize defines the size of the cache for each memiavl store.
// Deprecated: this is removed, we will just rely on mmap page cache
CacheSize int `mapstructure:"cache-size"`
// OnlyAllowExportOnSnapshotVersion defines whether we only allow state sync
// snapshot creation happens after the memiavl snapshot is created
OnlyAllowExportOnSnapshotVersion bool `mapstructure:"only-allow-export-on-snapshot-version"`
}
type StateStoreConfig struct {
// Enable defines if the state-store should be enabled for historical queries.
Enable bool `mapstructure:"enable"`
// DBDirectory defines the directory to store the state store db files
// If not explicitly set, default to application home directory
// default to empty
DBDirectory string `mapstructure:"db-directory"`
// Backend defines the backend database used for state-store
// Supported backends: pebbledb, rocksdb
// defaults to pebbledb
Backend string `mapstructure:"backend"`
// AsyncWriteBuffer defines the async queue length for commits to be applied to State Store
// Set <= 0 for synchronous writes, which means commits also need to wait for data to be persisted in State Store.
// defaults to 100
AsyncWriteBuffer int `mapstructure:"async-write-buffer"`
// KeepRecent defines the number of versions to keep in state store
// Setting it to 0 means keep everything.
// Default to keep the last 100,000 blocks
KeepRecent int `mapstructure:"keep-recent"`
// PruneIntervalSeconds defines the interval in seconds to trigger pruning
// default to every 600 seconds
PruneIntervalSeconds int `mapstructure:"prune-interval-seconds"`
// ImportNumWorkers defines the number of goroutines used during import
// defaults to 1
ImportNumWorkers int `mapstructure:"import-num-workers"`
// Whether to keep last version of a key during pruning or delete
// defaults to true
KeepLastVersion bool `mapstructure:"keep-last-version"`
// Range of blocks after which a XOR hash is computed and stored
// defaults to 1,000,000 blocks
HashRange int64 `json:"hash_range"`
}
func DefaultStateCommitConfig() StateCommitConfig {
return StateCommitConfig{
Enable: true,
AsyncCommitBuffer: DefaultAsyncCommitBuffer,
SnapshotInterval: DefaultSnapshotInterval,
SnapshotKeepRecent: DefaultSnapshotKeepRecent,
}
}
func DefaultStateStoreConfig() StateStoreConfig {
return StateStoreConfig{
Enable: true,
Backend: "pebbledb",
AsyncWriteBuffer: DefaultSSAsyncBuffer,
KeepRecent: DefaultSSKeepRecent,
PruneIntervalSeconds: DefaultSSPruneInterval,
ImportNumWorkers: DefaultSSImportWorkers,
KeepLastVersion: true,
HashRange: DefaultSSHashRange,
}
}