Skip to content

Commit

Permalink
Merge branch 'develop' into feat/inx-mqtt
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrvivian committed Sep 18, 2023
2 parents 82e543c + 83057da commit 456ba64
Show file tree
Hide file tree
Showing 28 changed files with 864 additions and 260 deletions.
109 changes: 80 additions & 29 deletions components/metrics/metrics_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@ import (
const (
schedulerNamespace = "scheduler"

queueSizePerNodeWork = "queue_size_per_node_work" //nolint:gosec
queueSizePerNodeCount = "queue_size_per_node_count"
schedulerProcessedBlocks = "processed_blocks"
manaAmountPerNode = "mana_per_node"
scheduledBlockLabel = "scheduled"
skippedBlockLabel = "skipped"
droppedBlockLabel = "dropped"
enqueuedBlockLabel = "enqueued"
bufferReadyBlockCount = "buffer_ready_block_total" //nolint:gosec
bufferTotalSize = "buffer_size_block_total"
bufferMaxSize = "buffer_max_size"
rate = "rate"
queueSizePerNodeWork = "queue_size_per_node_work" //nolint:gosec
queueSizePerNodeCount = "queue_size_per_node_count"
validatorQueueSizePerNodeCount = "validator_queue_size_per_node_count"
schedulerProcessedBlocks = "processed_blocks"
manaAmountPerNode = "mana_per_node"
scheduledBlockLabel = "scheduled"
skippedBlockLabel = "skipped"
droppedBlockLabel = "dropped"
enqueuedBlockLabel = "enqueued"
basicBufferReadyBlockCount = "buffer_ready_block_total" //nolint:gosec
basicBufferTotalSize = "buffer_size_block_total"
basicBufferMaxSize = "buffer_max_size"
rate = "rate"
validatorBufferTotalSize = "validator_buffer_size_block_total"
validatorQueueMaxSize = "validator_buffer_max_size"
)

var SchedulerMetrics = collector.NewCollection(schedulerNamespace,
Expand Down Expand Up @@ -55,31 +58,65 @@ var SchedulerMetrics = collector.NewCollection(schedulerNamespace,
}, event.WithWorkerPool(Component.WorkerPool))
}),
)),

collector.WithMetric(collector.NewMetric(queueSizePerNodeCount,
collector.WithType(collector.Gauge),
collector.WithLabels("issuer_id"),
collector.WithPruningDelay(10*time.Minute),
collector.WithHelp("Current size of each node's queue (as block count)."),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.Scheduler.BlockEnqueued.Hook(func(block *blocks.Block) {
deps.Collector.Update(schedulerNamespace, queueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())

if _, isBasic := block.BasicBlock(); isBasic {
deps.Collector.Update(schedulerNamespace, queueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
}
}, event.WithWorkerPool(Component.WorkerPool))

deps.Protocol.Events.Engine.Scheduler.BlockSkipped.Hook(func(block *blocks.Block) {
deps.Collector.Update(schedulerNamespace, queueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())

if _, isBasic := block.BasicBlock(); isBasic {
deps.Collector.Update(schedulerNamespace, queueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
}
}, event.WithWorkerPool(Component.WorkerPool))

deps.Protocol.Events.Engine.Scheduler.BlockDropped.Hook(func(block *blocks.Block, _ error) {
deps.Collector.Update(schedulerNamespace, queueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())

if _, isBasic := block.BasicBlock(); isBasic {
deps.Collector.Update(schedulerNamespace, queueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
}
}, event.WithWorkerPool(Component.WorkerPool))

deps.Protocol.Events.Engine.Scheduler.BlockScheduled.Hook(func(block *blocks.Block) {
deps.Collector.Update(schedulerNamespace, queueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
if _, isBasic := block.BasicBlock(); isBasic {
deps.Collector.Update(schedulerNamespace, queueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
}
}, event.WithWorkerPool(Component.WorkerPool))
}),
)),
collector.WithMetric(collector.NewMetric(validatorQueueSizePerNodeCount,
collector.WithType(collector.Gauge),
collector.WithLabels("issuer_id"),
collector.WithPruningDelay(10*time.Minute),
collector.WithHelp("Current number of validation blocks in each validator's queue."),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.Scheduler.BlockEnqueued.Hook(func(block *blocks.Block) {
if _, isValidation := block.ValidationBlock(); isValidation {
deps.Collector.Update(schedulerNamespace, validatorQueueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.ValidatorQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
}
}, event.WithWorkerPool(Component.WorkerPool))

deps.Protocol.Events.Engine.Scheduler.BlockSkipped.Hook(func(block *blocks.Block) {
if _, isValidation := block.ValidationBlock(); isValidation {
deps.Collector.Update(schedulerNamespace, validatorQueueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.ValidatorQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
}
}, event.WithWorkerPool(Component.WorkerPool))

deps.Protocol.Events.Engine.Scheduler.BlockDropped.Hook(func(block *blocks.Block, _ error) {
if _, isValidation := block.ValidationBlock(); isValidation {
deps.Collector.Update(schedulerNamespace, validatorQueueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.ValidatorQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
}
}, event.WithWorkerPool(Component.WorkerPool))

deps.Protocol.Events.Engine.Scheduler.BlockScheduled.Hook(func(block *blocks.Block) {
if _, isValidation := block.ValidationBlock(); isValidation {
deps.Collector.Update(schedulerNamespace, validatorQueueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.ValidatorQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
}
}, event.WithWorkerPool(Component.WorkerPool))
}),
)),
Expand Down Expand Up @@ -127,32 +164,46 @@ var SchedulerMetrics = collector.NewCollection(schedulerNamespace,
}, event.WithWorkerPool(Component.WorkerPool))
}),
)),
collector.WithMetric(collector.NewMetric(bufferMaxSize,
collector.WithMetric(collector.NewMetric(basicBufferMaxSize,
collector.WithType(collector.Gauge),
collector.WithHelp("Maximum number of blocks that can be stored in the buffer."),
collector.WithHelp("Maximum number of basic blocks that can be stored in the buffer."),
collector.WithCollectFunc(func() (float64, []string) {
return float64(deps.Protocol.MainEngineInstance().Scheduler.MaxBufferSize()), []string{}
return float64(deps.Protocol.MainEngineInstance().CurrentAPI().ProtocolParameters().CongestionControlParameters().MaxBufferSize), []string{}
}),
)),
collector.WithMetric(collector.NewMetric(bufferReadyBlockCount,
collector.WithMetric(collector.NewMetric(basicBufferReadyBlockCount,
collector.WithType(collector.Gauge),
collector.WithHelp("Number of ready blocks in the scheduler buffer."),
collector.WithCollectFunc(func() (float64, []string) {
return float64(deps.Protocol.MainEngineInstance().Scheduler.ReadyBlocksCount()), []string{}
}),
)),
collector.WithMetric(collector.NewMetric(bufferTotalSize,
collector.WithMetric(collector.NewMetric(basicBufferTotalSize,
collector.WithType(collector.Gauge),
collector.WithHelp("Current size of the scheduler buffer (in bytes)."),
collector.WithHelp("Current number of basic blocks in the scheduler buffer."),
collector.WithCollectFunc(func() (float64, []string) {
return float64(deps.Protocol.MainEngineInstance().Scheduler.BufferSize()), []string{}
return float64(deps.Protocol.MainEngineInstance().Scheduler.BasicBufferSize()), []string{}
}),
)),
collector.WithMetric(collector.NewMetric(rate,
collector.WithType(collector.Gauge),
collector.WithHelp("Current rate of the scheduler."),
collector.WithHelp("Current scheduling rate of basic blocks."),
collector.WithCollectFunc(func() (float64, []string) {
return float64(deps.Protocol.MainEngineInstance().CurrentAPI().ProtocolParameters().CongestionControlParameters().SchedulerRate), []string{}
}),
)),
collector.WithMetric(collector.NewMetric(validatorBufferTotalSize,
collector.WithType(collector.Gauge),
collector.WithHelp("Current number of validation blocks in the scheduling buffer."),
collector.WithCollectFunc(func() (float64, []string) {
return float64(deps.Protocol.MainEngineInstance().Scheduler.ValidatorBufferSize()), []string{}
}),
)),
collector.WithMetric(collector.NewMetric(validatorQueueMaxSize,
collector.WithType(collector.Gauge),
collector.WithHelp("Maximum number of validation blocks that can be stored in each validator queue."),
collector.WithCollectFunc(func() (float64, []string) {
return float64(deps.Protocol.MainEngineInstance().Scheduler.Rate()), []string{}
return float64(deps.Protocol.MainEngineInstance().CurrentAPI().ProtocolParameters().CongestionControlParameters().MaxValidationBufferSize), []string{}
}),
)),
)
2 changes: 1 addition & 1 deletion components/validator/issuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ func issueValidatorBlock(ctx context.Context) {
return
}

Component.LogDebug("Issued validator block: %s - commitment %s %d - latest finalized slot %d", modelBlock.ID(), modelBlock.ProtocolBlock().SlotCommitmentID, modelBlock.ProtocolBlock().SlotCommitmentID.Index(), modelBlock.ProtocolBlock().LatestFinalizedSlot)
Component.LogDebugf("Issued validator block: %s - commitment %s %d - latest finalized slot %d", modelBlock.ID(), modelBlock.ProtocolBlock().SlotCommitmentID, modelBlock.ProtocolBlock().SlotCommitmentID.Index(), modelBlock.ProtocolBlock().LatestFinalizedSlot)

}
1 change: 1 addition & 0 deletions config_defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"filter": {
"maxAllowedClockDrift": "5s"
},
"protocolParametersPath": "testnet/protocol_parameters.json",
"baseToken": {
"name": "Shimmer",
"tickerSymbol": "SMR",
Expand Down
12 changes: 7 additions & 5 deletions documentation/docs/references/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,12 @@ Example:

## <a id="protocol"></a> 9. Protocol

| Name | Description | Type | Default value |
| -------------------------------- | --------------------------- | ------ | ------------- |
| [snapshot](#protocol_snapshot) | Configuration for snapshot | object | |
| [filter](#protocol_filter) | Configuration for filter | object | |
| [baseToken](#protocol_basetoken) | Configuration for baseToken | object | |
| Name | Description | Type | Default value |
| -------------------------------- | ---------------------------------------- | ------ | ---------------------------------- |
| [snapshot](#protocol_snapshot) | Configuration for snapshot | object | |
| [filter](#protocol_filter) | Configuration for filter | object | |
| protocolParametersPath | The path of the protocol parameters file | string | "testnet/protocol_parameters.json" |
| [baseToken](#protocol_basetoken) | Configuration for baseToken | object | |

### <a id="protocol_snapshot"></a> Snapshot

Expand Down Expand Up @@ -366,6 +367,7 @@ Example:
"filter": {
"maxAllowedClockDrift": "5s"
},
"protocolParametersPath": "testnet/protocol_parameters.json",
"baseToken": {
"name": "Shimmer",
"tickerSymbol": "SMR",
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ require (
github.com/iotaledger/hive.go/lo v0.0.0-20230906114834-b50190b9f9c2
github.com/iotaledger/hive.go/logger v0.0.0-20230906114834-b50190b9f9c2
github.com/iotaledger/hive.go/runtime v0.0.0-20230906114834-b50190b9f9c2
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230906114834-b50190b9f9c2
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230912111751-d84fba02bb7c
github.com/iotaledger/hive.go/stringify v0.0.0-20230906114834-b50190b9f9c2
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230908143946-e15613b4af95
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230908142450-d259cfb4153d
github.com/iotaledger/iota.go/v4 v4.0.0-20230911110046-2c50729c4ea0
github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d
github.com/labstack/echo/v4 v4.11.1
github.com/labstack/gommon v0.4.0
github.com/libp2p/go-libp2p v0.30.0
Expand Down Expand Up @@ -58,7 +58,7 @@ require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/eclipse/paho.mqtt.golang v1.4.3 // indirect
github.com/elastic/gosigar v0.14.2 // indirect
github.com/ethereum/go-ethereum v1.12.2 // indirect
github.com/ethereum/go-ethereum v1.13.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/felixge/fgprof v0.9.3 // indirect
github.com/fjl/memsize v0.0.2 // indirect
Expand All @@ -83,7 +83,7 @@ require (
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/holiman/uint256 v1.2.3 // indirect
github.com/huin/goupnp v1.2.0 // indirect
github.com/huin/goupnp v1.3.0 // indirect
github.com/iancoleman/orderedmap v0.3.0 // indirect
github.com/iotaledger/grocksdb v1.7.5-0.20230220105546-5162e18885c7 // indirect
github.com/ipfs/boxo v0.10.0 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum/go-ethereum v1.12.2 h1:eGHJ4ij7oyVqUQn48LBz3B7pvQ8sV0wGJiIE6gDq/6Y=
github.com/ethereum/go-ethereum v1.12.2/go.mod h1:1cRAEV+rp/xX0zraSCBnu9Py3HQ+geRMj3HdR+k0wfI=
github.com/ethereum/go-ethereum v1.13.0 h1:dZALM0PlDTtNITTECPiqSrFo0iEYVDfby+mSVc0LxIs=
github.com/ethereum/go-ethereum v1.13.0/go.mod h1:0TDsBNJ7j8jR01vKpk4j2zfVKyAbQuKzy6wLwb5ZMuU=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
Expand Down Expand Up @@ -270,8 +270,8 @@ github.com/hjson/hjson-go/v4 v4.0.0 h1:wlm6IYYqHjOdXH1gHev4VoXCaW20HdQAGCxdOEEg2
github.com/hjson/hjson-go/v4 v4.0.0/go.mod h1:KaYt3bTw3zhBjYqnXkYywcYctk0A2nxeEFTse3rH13E=
github.com/holiman/uint256 v1.2.3 h1:K8UWO1HUJpRMXBxbmaY1Y8IAMZC/RsKB+ArEnnK4l5o=
github.com/holiman/uint256 v1.2.3/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw=
github.com/huin/goupnp v1.2.0 h1:uOKW26NG1hsSSbXIZ1IR7XP9Gjd1U8pnLaCMgntmkmY=
github.com/huin/goupnp v1.2.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc=
github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE=
github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
Expand Down Expand Up @@ -299,16 +299,16 @@ github.com/iotaledger/hive.go/logger v0.0.0-20230906114834-b50190b9f9c2 h1:vVs4Z
github.com/iotaledger/hive.go/logger v0.0.0-20230906114834-b50190b9f9c2/go.mod h1:sxqWRdZ1OOxwkxVczuGcW034Mpt2vFh5ebJHO++ZYeI=
github.com/iotaledger/hive.go/runtime v0.0.0-20230906114834-b50190b9f9c2 h1:jpX2K+d9+FaCngP3dTjSIabm+OIxThc/AQPKvp2d23c=
github.com/iotaledger/hive.go/runtime v0.0.0-20230906114834-b50190b9f9c2/go.mod h1:fXVyQ1MAwxe/EmjAnG8WcQqbzGk9EW/FsJ/n16H/f/w=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230906114834-b50190b9f9c2 h1:kEakiZRk/LUb2CxQvSOsdTgUXK1Ee4BNec9ps40+iXQ=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230906114834-b50190b9f9c2/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230912111751-d84fba02bb7c h1:dijcFDsCtbUIGxeC5XiWIl1azYHb3x/zGJZ3P+9mABY=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230912111751-d84fba02bb7c/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I=
github.com/iotaledger/hive.go/stringify v0.0.0-20230906114834-b50190b9f9c2 h1:exATYMLT/d8fgMuVNO6kMDsFn9DUJEcyCuoBv9sP13g=
github.com/iotaledger/hive.go/stringify v0.0.0-20230906114834-b50190b9f9c2/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230908143946-e15613b4af95 h1:l+e3MJjKPp8PfCnMP1cbssUwvvwjeenr20q4TupoSYw=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230908143946-e15613b4af95/go.mod h1:vZYattpu7STOa6cBUQviSyBkV0EsGDmNwAfhLi8DZ+s=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230908142450-d259cfb4153d h1:ymchSf0Dx5tXnvl+uorFHwfHf66MC2o82aCK0KEFDoQ=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230908142450-d259cfb4153d/go.mod h1:B7gyJP6GshCSlEmY3CxEk5TZdsMs3UNz5U92hkFDdMs=
github.com/iotaledger/iota.go/v4 v4.0.0-20230911110046-2c50729c4ea0 h1:eBVGnr/WkqF3+tlCE23uDxPvmkD/r7StkIoUerwLEqw=
github.com/iotaledger/iota.go/v4 v4.0.0-20230911110046-2c50729c4ea0/go.mod h1:MM3RLtTEsfT6Wh0EhpgmzVO/HM0/NOw+E7+mnGTnyA0=
github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d h1:p9IchKq6kft758XDlnN/tAEXJMXGlmQPmbdxolba1gs=
github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo=
github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY=
github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM=
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
Expand Down
Loading

0 comments on commit 456ba64

Please sign in to comment.