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

Commit 928e923

Browse files
authored
Merge pull request #671 from iotaledger/feat/node-docker-setup
Align config structure and values to HORNET in preparation for node-docker-setup
2 parents 416433b + 2704038 commit 928e923

25 files changed

+157
-121
lines changed

Diff for: components/app/app.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
dashboardmetrics "github.com/iotaledger/iota-core/components/dashboard_metrics"
1212
"github.com/iotaledger/iota-core/components/debugapi"
1313
"github.com/iotaledger/iota-core/components/inx"
14-
"github.com/iotaledger/iota-core/components/metrics"
1514
"github.com/iotaledger/iota-core/components/metricstracker"
1615
"github.com/iotaledger/iota-core/components/p2p"
16+
"github.com/iotaledger/iota-core/components/prometheus"
1717
"github.com/iotaledger/iota-core/components/protocol"
1818
"github.com/iotaledger/iota-core/components/restapi"
1919
coreapi "github.com/iotaledger/iota-core/components/restapi/core"
@@ -49,7 +49,7 @@ Command line flags:
4949
protocol.Component,
5050
dashboardmetrics.Component,
5151
dashboard.Component,
52-
metrics.Component,
52+
prometheus.Component,
5353
inx.Component,
5454
),
5555
)

Diff for: 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
}

Diff for: 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.

Diff for: components/p2p/params.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const (
1313
// ParametersP2P contains the definition of configuration parameters used by the p2p plugin.
1414
type ParametersP2P struct {
1515
// BindAddress defines on which multi addresses the p2p service should listen on.
16-
BindMultiAddresses []string `default:"/ip4/0.0.0.0/tcp/14666,/ip6/::/tcp/14666" usage:"the bind multi addresses for p2p connections"`
16+
BindMultiAddresses []string `default:"/ip4/0.0.0.0/tcp/15600,/ip6/::/tcp/15600" usage:"the bind multi addresses for p2p connections"`
1717

1818
ConnectionManager struct {
1919
// Defines the high watermark to use within the connection manager.
File renamed without changes.

Diff for: components/metrics/component.go renamed to components/prometheus/component.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package metrics
1+
package prometheus
22

3-
// metrics is the plugin instance responsible for collection of prometheus metrics.
3+
// prometheus is the plugin instance responsible for collection of prometheus metrics.
44
// All metrics should be defined in metrics_namespace.go files with different namespace for each new collection.
55
// Metrics naming should follow the guidelines from: https://prometheus.io/docs/practices/naming/
66
// In short:
@@ -22,14 +22,14 @@ import (
2222

2323
"github.com/iotaledger/hive.go/app"
2424
"github.com/iotaledger/hive.go/ierrors"
25-
"github.com/iotaledger/iota-core/components/metrics/collector"
25+
"github.com/iotaledger/iota-core/components/prometheus/collector"
2626
"github.com/iotaledger/iota-core/pkg/daemon"
2727
"github.com/iotaledger/iota-core/pkg/protocol"
2828
)
2929

3030
func init() {
3131
Component = &app.Component{
32-
Name: "Metrics",
32+
Name: "Prometheus",
3333
DepsFunc: func(cDeps dependencies) { deps = cDeps },
3434
Params: params,
3535
Run: run,

Diff for: components/metrics/metrics_accounts.go renamed to components/prometheus/metrics_accounts.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
package metrics
1+
package prometheus
22

33
import (
44
"time"
55

66
"github.com/iotaledger/hive.go/runtime/event"
7-
"github.com/iotaledger/iota-core/components/metrics/collector"
7+
"github.com/iotaledger/iota-core/components/prometheus/collector"
88
"github.com/iotaledger/iota-core/pkg/protocol/engine/blocks"
99
)
1010

Diff for: components/metrics/metrics_commitments.go renamed to components/prometheus/metrics_commitments.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package metrics
1+
package prometheus
22

33
import (
44
"strconv"
55
"time"
66

77
"github.com/iotaledger/hive.go/runtime/event"
8-
"github.com/iotaledger/iota-core/components/metrics/collector"
8+
"github.com/iotaledger/iota-core/components/prometheus/collector"
99
"github.com/iotaledger/iota-core/pkg/protocol"
1010
"github.com/iotaledger/iota-core/pkg/protocol/engine/notarization"
1111
iotago "github.com/iotaledger/iota.go/v4"

Diff for: components/metrics/metrics_conflicts.go renamed to components/prometheus/metrics_conflicts.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
package metrics
1+
package prometheus
22

33
import (
44
"time"
55

66
"github.com/iotaledger/hive.go/runtime/event"
7-
"github.com/iotaledger/iota-core/components/metrics/collector"
7+
"github.com/iotaledger/iota-core/components/prometheus/collector"
88
iotago "github.com/iotaledger/iota.go/v4"
99
)
1010

Diff for: components/metrics/metrics_db.go renamed to components/prometheus/metrics_db.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package metrics
1+
package prometheus
22

33
import (
4-
"github.com/iotaledger/iota-core/components/metrics/collector"
4+
"github.com/iotaledger/iota-core/components/prometheus/collector"
55
)
66

77
const (

Diff for: components/metrics/metrics_info.go renamed to components/prometheus/metrics_info.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package metrics
1+
package prometheus
22

33
import (
44
"runtime"
55
"strconv"
66
"time"
77

8-
"github.com/iotaledger/iota-core/components/metrics/collector"
8+
"github.com/iotaledger/iota-core/components/prometheus/collector"
99
)
1010

1111
const (

Diff for: components/metrics/metrics_scheduler.go renamed to components/prometheus/metrics_scheduler.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//nolint:gosec // false positive on constants
2-
package metrics
2+
package prometheus
33

44
import (
55
"time"
66

77
"github.com/iotaledger/hive.go/ierrors"
88
"github.com/iotaledger/hive.go/runtime/event"
9-
"github.com/iotaledger/iota-core/components/metrics/collector"
9+
"github.com/iotaledger/iota-core/components/prometheus/collector"
1010
"github.com/iotaledger/iota-core/pkg/protocol/engine/blocks"
1111
)
1212

Diff for: components/metrics/metrics_slots.go renamed to components/prometheus/metrics_slots.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package metrics
1+
package prometheus
22

33
import (
44
"strconv"
55
"time"
66

77
"github.com/iotaledger/hive.go/runtime/event"
8-
"github.com/iotaledger/iota-core/components/metrics/collector"
8+
"github.com/iotaledger/iota-core/components/prometheus/collector"
99
"github.com/iotaledger/iota-core/pkg/protocol/engine/blocks"
1010
"github.com/iotaledger/iota-core/pkg/protocol/engine/mempool"
1111
iotago "github.com/iotaledger/iota.go/v4"

Diff for: components/metrics/metrics_tangle.go renamed to components/prometheus/metrics_tangle.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package metrics
1+
package prometheus
22

33
import (
44
"github.com/iotaledger/hive.go/runtime/event"
5-
"github.com/iotaledger/iota-core/components/metrics/collector"
5+
"github.com/iotaledger/iota-core/components/prometheus/collector"
66
"github.com/iotaledger/iota-core/pkg/protocol/engine/blocks"
77
)
88

Diff for: components/metrics/params.go renamed to components/prometheus/params.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package metrics
1+
package prometheus
22

33
import (
44
"github.com/iotaledger/hive.go/app"
@@ -23,6 +23,6 @@ var ParamsMetrics = &ParametersMetrics{}
2323

2424
var params = &app.ComponentParams{
2525
Params: map[string]any{
26-
"metrics": ParamsMetrics,
26+
"prometheus": ParamsMetrics,
2727
},
2828
}

Diff for: 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
),

Diff for: 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
}

Diff for: config_defaults.json

+20-14
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
},
2020
"p2p": {
2121
"bindMultiAddresses": [
22-
"/ip4/0.0.0.0/tcp/14666",
23-
"/ip6/::/tcp/14666"
22+
"/ip4/0.0.0.0/tcp/15600",
23+
"/ip6/::/tcp/15600"
2424
],
2525
"connectionManager": {
2626
"highWatermark": 10,
@@ -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": {
@@ -121,7 +127,7 @@
121127
"maxCount": 100
122128
}
123129
},
124-
"metrics": {
130+
"prometheus": {
125131
"enabled": true,
126132
"bindAddress": "0.0.0.0:9311",
127133
"goMetrics": false,

0 commit comments

Comments
 (0)