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

Commit

Permalink
Merge branch 'develop' into test-scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrvivian committed Jan 18, 2024
2 parents a29a425 + 6d2857a commit 3b843f6
Show file tree
Hide file tree
Showing 38 changed files with 198 additions and 171 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/feature-network-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ on:
branches:
- develop
workflow_dispatch:
inputs:
snapshotUrl:
description: 'Custom snapshot URL:'
required: false
default: ""

concurrency:
group: feature-network-deploy-group
Expand Down Expand Up @@ -62,13 +57,6 @@ jobs:
working-directory: tools/genesis-snapshot
run: go run -tags=rocksdb . --config feature --seed 7R1itJx5hVuo9w9hjg5cwKFmek4HMSoBDgJZN8hKGxih --filename genesis-snapshot.bin

- name: Upload snapshot
id: upload-snapshot
run: |
SNAPSHOT_URL=$(curl -T ./tools/genesis-snapshot/genesis-snapshot.bin https://transfer.sh)
echo "Snapshot URL: $SNAPSHOT_URL"
echo "snapshot_url=$SNAPSHOT_URL" >> $GITHUB_OUTPUT
- # Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
Expand All @@ -92,8 +80,6 @@ jobs:
- name: Ansible deploy
env:
CUSTOM_SNAPSHOT_URL: '${{ github.event.inputs.snapshotUrl }}'
DEFAULT_SNAPSHOT_URL: '${{ steps.upload-snapshot.outputs.snapshot_url }}'
NETWORK_ENVIRONMENT: '${{ secrets.NETWORK_ENVIRONMENT }}'
IOTA_CORE_DOCKER_IMAGE_REPO: 'iotaledger/iota-core'
IOTA_CORE_DOCKER_IMAGE_TAG: 'feature'
Expand Down
6 changes: 3 additions & 3 deletions components/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
dashboardmetrics "github.com/iotaledger/iota-core/components/dashboard_metrics"
"github.com/iotaledger/iota-core/components/debugapi"
"github.com/iotaledger/iota-core/components/inx"
"github.com/iotaledger/iota-core/components/metrics"
"github.com/iotaledger/iota-core/components/metricstracker"
"github.com/iotaledger/iota-core/components/p2p"
"github.com/iotaledger/iota-core/components/prometheus"
"github.com/iotaledger/iota-core/components/protocol"
"github.com/iotaledger/iota-core/components/restapi"
coreapi "github.com/iotaledger/iota-core/components/restapi/core"
Expand All @@ -25,7 +25,7 @@ var (
Name = "iota-core"

// Version of the app.
Version = "1.0.0-alpha.1"
Version = "1.0.0-alpha.2"
)

func App() *app.App {
Expand All @@ -49,7 +49,7 @@ Command line flags:
protocol.Component,
dashboardmetrics.Component,
dashboard.Component,
metrics.Component,
prometheus.Component,
inx.Component,
),
)
Expand Down
8 changes: 4 additions & 4 deletions components/debugapi/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ func configure() error {
blocksPerSlot = shrinkingmap.New[iotago.SlotIndex, []*blocks.Block]()
blocksPrunableStorage = prunable.NewBucketManager(database.Config{
Engine: hivedb.EngineRocksDB,
Directory: ParamsDebugAPI.Path,
Directory: ParamsDebugAPI.Database.Path,

Version: 1,
PrefixHealth: []byte{debugPrefixHealth},
}, func(err error) {
Component.LogWarnf(">> DebugAPI Error: %s\n", err)
}, prunable.WithMaxOpenDBs(ParamsDebugAPI.MaxOpenDBs),
}, prunable.WithMaxOpenDBs(ParamsDebugAPI.Database.MaxOpenDBs),
)

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

deps.Protocol.Events.Engine.SlotGadget.SlotFinalized.Hook(func(index iotago.SlotIndex) {
epoch := deps.Protocol.APIForSlot(index).TimeProvider().EpochFromSlot(index)
if epoch < iotago.EpochIndex(ParamsDebugAPI.PruningThreshold) {
if epoch < iotago.EpochIndex(ParamsDebugAPI.Database.Pruning.Threshold) {
return
}

Expand All @@ -107,7 +107,7 @@ func configure() error {
lastPruned++
}

for i := lastPruned; i < epoch-iotago.EpochIndex(ParamsDebugAPI.PruningThreshold); i++ {
for i := lastPruned; i < epoch-iotago.EpochIndex(ParamsDebugAPI.Database.Pruning.Threshold); i++ {
if err := blocksPrunableStorage.Prune(i); err != nil {
Component.LogWarnf(">> DebugAPI Error: %s\n", err)
}
Expand Down
12 changes: 8 additions & 4 deletions components/debugapi/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ type ParametersDebugAPI struct {
// Enabled whether the DebugAPI component is enabled.
Enabled bool `default:"true" usage:"whether the DebugAPI component is enabled"`

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

// ParamsDebugAPI is the default configuration parameters for the DebugAPI component.
Expand Down
2 changes: 1 addition & 1 deletion components/p2p/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
// ParametersP2P contains the definition of configuration parameters used by the p2p plugin.
type ParametersP2P struct {
// BindAddress defines on which multi addresses the p2p service should listen on.
BindMultiAddresses []string `default:"/ip4/0.0.0.0/tcp/14666,/ip6/::/tcp/14666" usage:"the bind multi addresses for p2p connections"`
BindMultiAddresses []string `default:"/ip4/0.0.0.0/tcp/15600,/ip6/::/tcp/15600" usage:"the bind multi addresses for p2p connections"`

ConnectionManager struct {
// Defines the high watermark to use within the connection manager.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package metrics
package prometheus

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

"github.com/iotaledger/hive.go/app"
"github.com/iotaledger/hive.go/ierrors"
"github.com/iotaledger/iota-core/components/metrics/collector"
"github.com/iotaledger/iota-core/components/prometheus/collector"
"github.com/iotaledger/iota-core/pkg/daemon"
"github.com/iotaledger/iota-core/pkg/protocol"
)

func init() {
Component = &app.Component{
Name: "Metrics",
Name: "Prometheus",
DepsFunc: func(cDeps dependencies) { deps = cDeps },
Params: params,
Run: run,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package metrics
package prometheus

import (
"time"

"github.com/iotaledger/hive.go/runtime/event"
"github.com/iotaledger/iota-core/components/metrics/collector"
"github.com/iotaledger/iota-core/components/prometheus/collector"
"github.com/iotaledger/iota-core/pkg/protocol/engine/blocks"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package metrics
package prometheus

import (
"strconv"
"time"

"github.com/iotaledger/hive.go/runtime/event"
"github.com/iotaledger/iota-core/components/metrics/collector"
"github.com/iotaledger/iota-core/components/prometheus/collector"
"github.com/iotaledger/iota-core/pkg/protocol"
"github.com/iotaledger/iota-core/pkg/protocol/engine/notarization"
iotago "github.com/iotaledger/iota.go/v4"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package metrics
package prometheus

import (
"time"

"github.com/iotaledger/hive.go/runtime/event"
"github.com/iotaledger/iota-core/components/metrics/collector"
"github.com/iotaledger/iota-core/components/prometheus/collector"
iotago "github.com/iotaledger/iota.go/v4"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package metrics
package prometheus

import (
"github.com/iotaledger/iota-core/components/metrics/collector"
"github.com/iotaledger/iota-core/components/prometheus/collector"
)

const (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package metrics
package prometheus

import (
"runtime"
"strconv"
"time"

"github.com/iotaledger/iota-core/components/metrics/collector"
"github.com/iotaledger/iota-core/components/prometheus/collector"
)

const (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//nolint:gosec // false positive on constants
package metrics
package prometheus

import (
"time"

"github.com/iotaledger/hive.go/ierrors"
"github.com/iotaledger/hive.go/runtime/event"
"github.com/iotaledger/iota-core/components/metrics/collector"
"github.com/iotaledger/iota-core/components/prometheus/collector"
"github.com/iotaledger/iota-core/pkg/protocol/engine/blocks"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package metrics
package prometheus

import (
"strconv"
"time"

"github.com/iotaledger/hive.go/runtime/event"
"github.com/iotaledger/iota-core/components/metrics/collector"
"github.com/iotaledger/iota-core/components/prometheus/collector"
"github.com/iotaledger/iota-core/pkg/protocol/engine/blocks"
"github.com/iotaledger/iota-core/pkg/protocol/engine/mempool"
iotago "github.com/iotaledger/iota.go/v4"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package metrics
package prometheus

import (
"github.com/iotaledger/hive.go/runtime/event"
"github.com/iotaledger/iota-core/components/metrics/collector"
"github.com/iotaledger/iota-core/components/prometheus/collector"
"github.com/iotaledger/iota-core/pkg/protocol/engine/blocks"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package metrics
package prometheus

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

var params = &app.ComponentParams{
Params: map[string]any{
"metrics": ParamsMetrics,
"prometheus": ParamsMetrics,
},
}
16 changes: 8 additions & 8 deletions components/protocol/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ func provide(c *dig.Container) error {
}

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

if pruningSizeEnabled && pruningTargetDatabaseSizeBytes == 0 {
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)))
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)))
}

return protocol.New(
Expand All @@ -145,11 +145,11 @@ func provide(c *dig.Container) error {
protocol.WithBaseDirectory(ParamsDatabase.Path),
protocol.WithStorageOptions(
storage.WithDBEngine(deps.DatabaseEngine),
storage.WithPruningDelay(iotago.EpochIndex(ParamsDatabase.PruningThreshold)),
storage.WithPruningSizeEnable(ParamsDatabase.Size.Enabled),
storage.WithPruningDelay(iotago.EpochIndex(ParamsDatabase.Pruning.Threshold)),
storage.WithPruningSizeEnable(ParamsDatabase.Pruning.Size.Enabled),
storage.WithPruningSizeMaxTargetSizeBytes(pruningTargetDatabaseSizeBytes),
storage.WithPruningSizeReductionPercentage(ParamsDatabase.Size.ReductionPercentage),
storage.WithPruningSizeCooldownTime(ParamsDatabase.Size.CooldownTime),
storage.WithPruningSizeReductionPercentage(ParamsDatabase.Pruning.Size.ReductionPercentage),
storage.WithPruningSizeCooldownTime(ParamsDatabase.Pruning.Size.CooldownTime),
storage.WithBucketManagerOptions(
prunable.WithMaxOpenDBs(ParamsDatabase.MaxOpenDBs),
),
Expand Down
30 changes: 16 additions & 14 deletions components/protocol/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,22 @@ type BaseToken struct {

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

Size struct {
// Enabled defines whether to delete old block data from the database based on maximum database size
Enabled bool `default:"true" usage:"whether to delete old block data from the database based on maximum database size"`
// TargetSize defines the target size of the database
TargetSize string `default:"30GB" usage:"target size of the database"`
// ReductionPercentage defines the percentage the database size gets reduced if the target size is reached
ReductionPercentage float64 `default:"10.0" usage:"the percentage the database size gets reduced if the target size is reached"`
// CooldownTime defines the cooldown time between two pruning by database size events
CooldownTime time.Duration `default:"5m" usage:"cooldown time between two pruning by database size events"`
Pruning struct {
Threshold uint64 `default:"30" usage:"how many finalized epochs should be retained"`
Size struct {
// Enabled defines whether to delete old block data from the database based on maximum database size
Enabled bool `default:"true" usage:"whether to delete old block data from the database based on maximum database size"`
// TargetSize defines the target size of the database
TargetSize string `default:"30GB" usage:"target size of the database"`
// ReductionPercentage defines the percentage the database size gets reduced if the target size is reached
ReductionPercentage float64 `default:"10.0" usage:"the percentage the database size gets reduced if the target size is reached"`
// CooldownTime defines the cooldown time between two pruning by database size events
CooldownTime time.Duration `default:"5m" usage:"cooldown time between two pruning by database size events"`
}
}
}

Expand All @@ -67,6 +69,6 @@ var ParamsDatabase = &ParametersDatabase{}
var params = &app.ComponentParams{
Params: map[string]any{
"protocol": ParamsProtocol,
"database": ParamsDatabase,
"db": ParamsDatabase,
},
}
Loading

0 comments on commit 3b843f6

Please sign in to comment.