Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit 2704038

Browse files
committed
Align structure of database config parameters to hornet
1 parent fb81362 commit 2704038

File tree

8 files changed

+109
-73
lines changed

8 files changed

+109
-73
lines changed

components/debugapi/component.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ func configure() error {
7979
blocksPerSlot = shrinkingmap.New[iotago.SlotIndex, []*blocks.Block]()
8080
blocksPrunableStorage = prunable.NewBucketManager(database.Config{
8181
Engine: hivedb.EngineRocksDB,
82-
Directory: ParamsDebugAPI.Path,
82+
Directory: ParamsDebugAPI.Database.Path,
8383

8484
Version: 1,
8585
PrefixHealth: []byte{debugPrefixHealth},
8686
}, func(err error) {
8787
Component.LogWarnf(">> DebugAPI Error: %s\n", err)
88-
}, prunable.WithMaxOpenDBs(ParamsDebugAPI.MaxOpenDBs),
88+
}, prunable.WithMaxOpenDBs(ParamsDebugAPI.Database.MaxOpenDBs),
8989
)
9090

9191
routeGroup := deps.RestRouteManager.AddRoute("debug/v2")
@@ -98,7 +98,7 @@ func configure() error {
9898

9999
deps.Protocol.Events.Engine.SlotGadget.SlotFinalized.Hook(func(index iotago.SlotIndex) {
100100
epoch := deps.Protocol.APIForSlot(index).TimeProvider().EpochFromSlot(index)
101-
if epoch < iotago.EpochIndex(ParamsDebugAPI.PruningThreshold) {
101+
if epoch < iotago.EpochIndex(ParamsDebugAPI.Database.Pruning.Threshold) {
102102
return
103103
}
104104

@@ -107,7 +107,7 @@ func configure() error {
107107
lastPruned++
108108
}
109109

110-
for i := lastPruned; i < epoch-iotago.EpochIndex(ParamsDebugAPI.PruningThreshold); i++ {
110+
for i := lastPruned; i < epoch-iotago.EpochIndex(ParamsDebugAPI.Database.Pruning.Threshold); i++ {
111111
if err := blocksPrunableStorage.Prune(i); err != nil {
112112
Component.LogWarnf(">> DebugAPI Error: %s\n", err)
113113
}

components/debugapi/params.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ type ParametersDebugAPI struct {
99
// Enabled whether the DebugAPI component is enabled.
1010
Enabled bool `default:"true" usage:"whether the DebugAPI component is enabled"`
1111

12-
Path string `default:"testnet/debug" usage:"the path to the database folder"`
13-
MaxOpenDBs int `default:"2" usage:"maximum number of open database instances"`
14-
PruningThreshold uint64 `default:"1" usage:"how many epochs should be retained"`
15-
DBGranularity int64 `default:"100" usage:"how many slots should be contained in a single DB instance"`
12+
Database struct {
13+
Path string `default:"testnet/debug" usage:"the path to the database folder"`
14+
MaxOpenDBs int `default:"2" usage:"maximum number of open database instances"`
15+
Granularity int64 `default:"100" usage:"how many slots should be contained in a single DB instance"`
16+
Pruning struct {
17+
Threshold uint64 `default:"1" usage:"how many epochs should be retained"`
18+
}
19+
} `name:"db"`
1620
}
1721

1822
// ParamsDebugAPI is the default configuration parameters for the DebugAPI component.

components/protocol/component.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ func provide(c *dig.Container) error {
128128
}
129129

130130
return c.Provide(func(deps protocolDeps) *protocol.Protocol {
131-
pruningSizeEnabled := ParamsDatabase.Size.Enabled
132-
pruningTargetDatabaseSizeBytes, err := bytes.Parse(ParamsDatabase.Size.TargetSize)
131+
pruningSizeEnabled := ParamsDatabase.Pruning.Size.Enabled
132+
pruningTargetDatabaseSizeBytes, err := bytes.Parse(ParamsDatabase.Pruning.Size.TargetSize)
133133
if err != nil {
134-
Component.LogPanicf("parameter %s invalid", Component.App().Config().GetParameterPath(&(ParamsDatabase.Size.TargetSize)))
134+
Component.LogPanicf("parameter %s invalid", Component.App().Config().GetParameterPath(&(ParamsDatabase.Pruning.Size.TargetSize)))
135135
}
136136

137137
if pruningSizeEnabled && pruningTargetDatabaseSizeBytes == 0 {
138-
Component.LogPanicf("%s has to be specified if %s is enabled", Component.App().Config().GetParameterPath(&(ParamsDatabase.Size.TargetSize)), Component.App().Config().GetParameterPath(&(ParamsDatabase.Size.Enabled)))
138+
Component.LogPanicf("%s has to be specified if %s is enabled", Component.App().Config().GetParameterPath(&(ParamsDatabase.Pruning.Size.TargetSize)), Component.App().Config().GetParameterPath(&(ParamsDatabase.Pruning.Size.Enabled)))
139139
}
140140

141141
return protocol.New(
@@ -145,11 +145,11 @@ func provide(c *dig.Container) error {
145145
protocol.WithBaseDirectory(ParamsDatabase.Path),
146146
protocol.WithStorageOptions(
147147
storage.WithDBEngine(deps.DatabaseEngine),
148-
storage.WithPruningDelay(iotago.EpochIndex(ParamsDatabase.PruningThreshold)),
149-
storage.WithPruningSizeEnable(ParamsDatabase.Size.Enabled),
148+
storage.WithPruningDelay(iotago.EpochIndex(ParamsDatabase.Pruning.Threshold)),
149+
storage.WithPruningSizeEnable(ParamsDatabase.Pruning.Size.Enabled),
150150
storage.WithPruningSizeMaxTargetSizeBytes(pruningTargetDatabaseSizeBytes),
151-
storage.WithPruningSizeReductionPercentage(ParamsDatabase.Size.ReductionPercentage),
152-
storage.WithPruningSizeCooldownTime(ParamsDatabase.Size.CooldownTime),
151+
storage.WithPruningSizeReductionPercentage(ParamsDatabase.Pruning.Size.ReductionPercentage),
152+
storage.WithPruningSizeCooldownTime(ParamsDatabase.Pruning.Size.CooldownTime),
153153
storage.WithBucketManagerOptions(
154154
prunable.WithMaxOpenDBs(ParamsDatabase.MaxOpenDBs),
155155
),

components/protocol/params.go

+16-14
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,22 @@ type BaseToken struct {
4141

4242
// ParametersDatabase contains the definition of configuration parameters used by the storage layer.
4343
type ParametersDatabase struct {
44-
Engine string `default:"rocksdb" usage:"the used database engine (rocksdb/mapdb)"`
45-
Path string `default:"testnet/database" usage:"the path to the database folder"`
46-
MaxOpenDBs int `default:"5" usage:"maximum number of open database instances"`
47-
PruningThreshold uint64 `default:"30" usage:"how many finalized epochs should be retained"`
44+
Engine string `default:"rocksdb" usage:"the used database engine (rocksdb/mapdb)"`
45+
Path string `default:"testnet/database" usage:"the path to the database folder"`
46+
MaxOpenDBs int `default:"5" usage:"maximum number of open database instances"`
4847

49-
Size struct {
50-
// Enabled defines whether to delete old block data from the database based on maximum database size
51-
Enabled bool `default:"true" usage:"whether to delete old block data from the database based on maximum database size"`
52-
// TargetSize defines the target size of the database
53-
TargetSize string `default:"30GB" usage:"target size of the database"`
54-
// ReductionPercentage defines the percentage the database size gets reduced if the target size is reached
55-
ReductionPercentage float64 `default:"10.0" usage:"the percentage the database size gets reduced if the target size is reached"`
56-
// CooldownTime defines the cooldown time between two pruning by database size events
57-
CooldownTime time.Duration `default:"5m" usage:"cooldown time between two pruning by database size events"`
48+
Pruning struct {
49+
Threshold uint64 `default:"30" usage:"how many finalized epochs should be retained"`
50+
Size struct {
51+
// Enabled defines whether to delete old block data from the database based on maximum database size
52+
Enabled bool `default:"true" usage:"whether to delete old block data from the database based on maximum database size"`
53+
// TargetSize defines the target size of the database
54+
TargetSize string `default:"30GB" usage:"target size of the database"`
55+
// ReductionPercentage defines the percentage the database size gets reduced if the target size is reached
56+
ReductionPercentage float64 `default:"10.0" usage:"the percentage the database size gets reduced if the target size is reached"`
57+
// CooldownTime defines the cooldown time between two pruning by database size events
58+
CooldownTime time.Duration `default:"5m" usage:"cooldown time between two pruning by database size events"`
59+
}
5860
}
5961
}
6062

@@ -67,6 +69,6 @@ var ParamsDatabase = &ParametersDatabase{}
6769
var params = &app.ComponentParams{
6870
Params: map[string]any{
6971
"protocol": ParamsProtocol,
70-
"database": ParamsDatabase,
72+
"db": ParamsDatabase,
7173
},
7274
}

config_defaults.json

+17-11
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,30 @@
7272
},
7373
"debugAPI": {
7474
"enabled": true,
75-
"path": "testnet/debug",
76-
"maxOpenDBs": 2,
77-
"pruningThreshold": 1,
78-
"dbGranularity": 100
75+
"db": {
76+
"path": "testnet/debug",
77+
"maxOpenDBs": 2,
78+
"granularity": 100,
79+
"pruning": {
80+
"threshold": 1
81+
}
82+
}
7983
},
8084
"metricsTracker": {
8185
"enabled": true
8286
},
83-
"database": {
87+
"db": {
8488
"engine": "rocksdb",
8589
"path": "testnet/database",
8690
"maxOpenDBs": 5,
87-
"pruningThreshold": 30,
88-
"size": {
89-
"enabled": true,
90-
"targetSize": "30GB",
91-
"reductionPercentage": 10,
92-
"cooldownTime": "5m"
91+
"pruning": {
92+
"threshold": 30,
93+
"size": {
94+
"enabled": true,
95+
"targetSize": "30GB",
96+
"reductionPercentage": 10,
97+
"cooldownTime": "5m"
98+
}
9399
}
94100
},
95101
"protocol": {

deploy/ansible/roles/iota-core-node/templates/docker-compose-iota-core.yml.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ services:
4646
--profiling.enabled=true
4747
--profiling.bindAddress=0.0.0.0:6061
4848
--restAPI.bindAddress=0.0.0.0:14265
49-
--database.path=/app/data/database
49+
--db.path=/app/data/database
5050
--protocol.snapshot.path=/app/data/snapshot.bin
5151
--dashboard.bindAddress=0.0.0.0:8081
5252
--prometheus.bindAddress=iota-core:9311

documentation/configuration.md

+54-30
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Example:
9595

9696
| Name | Description | Type | Default value |
9797
| ------------------------------------------- | ------------------------------------------------------------- | ------ | -------------------------------------------- |
98-
| bindMultiAddresses | The bind multi addresses for p2p connections | array | /ip4/0.0.0.0/tcp/14666<br/>/ip6/::/tcp/14666 |
98+
| bindMultiAddresses | The bind multi addresses for p2p connections | array | /ip4/0.0.0.0/tcp/15600<br/>/ip6/::/tcp/15600 |
9999
| [connectionManager](#p2p_connectionmanager) | Configuration for connectionManager | object | |
100100
| externalMultiAddresses | External reacheable multi addresses advertised to the network | array | |
101101
| identityPrivateKey | Private key used to derive the node identity (optional) | string | "" |
@@ -120,8 +120,8 @@ Example:
120120
{
121121
"p2p": {
122122
"bindMultiAddresses": [
123-
"/ip4/0.0.0.0/tcp/14666",
124-
"/ip6/::/tcp/14666"
123+
"/ip4/0.0.0.0/tcp/15600",
124+
"/ip6/::/tcp/15600"
125125
],
126126
"connectionManager": {
127127
"highWatermark": 10,
@@ -225,24 +225,40 @@ Example:
225225

226226
## <a id="debugapi"></a> 6. DebugAPI
227227

228-
| Name | Description | Type | Default value |
229-
| ---------------- | ---------------------------------------------------------- | ------- | --------------- |
230-
| enabled | Whether the DebugAPI component is enabled | boolean | true |
231-
| path | The path to the database folder | string | "testnet/debug" |
232-
| maxOpenDBs | Maximum number of open database instances | int | 2 |
233-
| pruningThreshold | How many epochs should be retained | uint | 1 |
234-
| dbGranularity | How many slots should be contained in a single DB instance | int | 100 |
228+
| Name | Description | Type | Default value |
229+
| ------------------ | ----------------------------------------- | ------- | ------------- |
230+
| enabled | Whether the DebugAPI component is enabled | boolean | true |
231+
| [db](#debugapi_db) | Configuration for db | object | |
232+
233+
### <a id="debugapi_db"></a> Db
234+
235+
| Name | Description | Type | Default value |
236+
| ------------------------------- | ---------------------------------------------------------- | ------ | --------------- |
237+
| path | The path to the database folder | string | "testnet/debug" |
238+
| maxOpenDBs | Maximum number of open database instances | int | 2 |
239+
| granularity | How many slots should be contained in a single DB instance | int | 100 |
240+
| [pruning](#debugapi_db_pruning) | Configuration for pruning | object | |
241+
242+
### <a id="debugapi_db_pruning"></a> Pruning
243+
244+
| Name | Description | Type | Default value |
245+
| --------- | ---------------------------------- | ---- | ------------- |
246+
| threshold | How many epochs should be retained | uint | 1 |
235247

236248
Example:
237249

238250
```json
239251
{
240252
"debugAPI": {
241253
"enabled": true,
242-
"path": "testnet/debug",
243-
"maxOpenDBs": 2,
244-
"pruningThreshold": 1,
245-
"dbGranularity": 100
254+
"db": {
255+
"path": "testnet/debug",
256+
"maxOpenDBs": 2,
257+
"granularity": 100,
258+
"pruning": {
259+
"threshold": 1
260+
}
261+
}
246262
}
247263
}
248264
```
@@ -263,17 +279,23 @@ Example:
263279
}
264280
```
265281

266-
## <a id="database"></a> 8. Database
282+
## <a id="db"></a> 8. Db
283+
284+
| Name | Description | Type | Default value |
285+
| ---------------------- | ----------------------------------------- | ------ | ------------------ |
286+
| engine | The used database engine (rocksdb/mapdb) | string | "rocksdb" |
287+
| path | The path to the database folder | string | "testnet/database" |
288+
| maxOpenDBs | Maximum number of open database instances | int | 5 |
289+
| [pruning](#db_pruning) | Configuration for pruning | object | |
290+
291+
### <a id="db_pruning"></a> Pruning
267292

268-
| Name | Description | Type | Default value |
269-
| ---------------------- | -------------------------------------------- | ------ | ------------------ |
270-
| engine | The used database engine (rocksdb/mapdb) | string | "rocksdb" |
271-
| path | The path to the database folder | string | "testnet/database" |
272-
| maxOpenDBs | Maximum number of open database instances | int | 5 |
273-
| pruningThreshold | How many finalized epochs should be retained | uint | 30 |
274-
| [size](#database_size) | Configuration for size | object | |
293+
| Name | Description | Type | Default value |
294+
| ------------------------ | -------------------------------------------- | ------ | ------------- |
295+
| threshold | How many finalized epochs should be retained | uint | 30 |
296+
| [size](#db_pruning_size) | Configuration for size | object | |
275297

276-
### <a id="database_size"></a> Size
298+
### <a id="db_pruning_size"></a> Size
277299

278300
| Name | Description | Type | Default value |
279301
| ------------------- | --------------------------------------------------------------------------------- | ------- | ------------- |
@@ -286,16 +308,18 @@ Example:
286308

287309
```json
288310
{
289-
"database": {
311+
"db": {
290312
"engine": "rocksdb",
291313
"path": "testnet/database",
292314
"maxOpenDBs": 5,
293-
"pruningThreshold": 30,
294-
"size": {
295-
"enabled": true,
296-
"targetSize": "30GB",
297-
"reductionPercentage": 10,
298-
"cooldownTime": "5m"
315+
"pruning": {
316+
"threshold": 30,
317+
"size": {
318+
"enabled": true,
319+
"targetSize": "30GB",
320+
"reductionPercentage": 10,
321+
"cooldownTime": "5m"
322+
}
299323
}
300324
}
301325
}

tools/docker-network/.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ COMMON_CONFIG="
55
--p2p.db.path=/app/data/peerdb
66
--profiling.enabled=true
77
--profiling.bindAddress=0.0.0.0:6061
8-
--database.path=/app/data/database
8+
--db.path=/app/data/database
99
--protocol.snapshot.path=/app/data/snapshot.bin
1010
"
1111

0 commit comments

Comments
 (0)