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

Commit db66666

Browse files
committed
Merge branch 'develop' of github.com:iotaledger/iota-core into test-scenario
2 parents 0d93eea + cd5b582 commit db66666

File tree

109 files changed

+2282
-943
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+2282
-943
lines changed

Diff for: .github/workflows/build_tools.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424

2525
- name: Build genesis-snapshot tool
2626
working-directory: tools/genesis-snapshot
27-
run: go mod tidy && go build .
27+
run: go build .

Diff for: .github/workflows/feature-network-deploy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444

4545
- uses: actions/setup-go@v5
4646
with:
47-
go-version-file: 'tools/genesis-snapshot/go.mod'
47+
go-version-file: 'go.mod'
4848
cache: false
4949

5050
- name: Print Go version

Diff for: .github/workflows/golangci-lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Checkout custom linter
1919
uses: actions/checkout@v4
2020
with:
21-
repository: karimodm/typegroupingcheck
21+
repository: muxxer/typegroupingcheck
2222
path: typegroupingcheck
2323

2424
- name: Setup go

Diff for: .github/workflows/unit-test-nightly.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Unit tests nightly
2+
3+
on:
4+
schedule:
5+
- cron: '0 5 * * *' # Runs every day at 5 AM
6+
workflow_dispatch:
7+
8+
jobs:
9+
unit-tests-with-log:
10+
name: Unit tests with log nightly
11+
runs-on: self-hosted
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- uses: actions/setup-go@v5
17+
with:
18+
go-version-file: 'go.mod'
19+
cache: false
20+
21+
- name: Print Go version
22+
run: go version
23+
24+
- name: Run unit tests with logger (level trace)
25+
run: |
26+
CI_UNIT_TESTS_LOG_LEVEL=trace go test ./... -tags rocksdb -count=5 -race -short -timeout 120m
27+
28+
unit-tests-without-log:
29+
name: Unit tests without log nightly
30+
runs-on: self-hosted
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
35+
- uses: actions/setup-go@v5
36+
with:
37+
go-version-file: 'go.mod'
38+
cache: false
39+
40+
- name: Print Go version
41+
run: go version
42+
43+
- name: Run unit tests without logger
44+
run: |
45+
CI_UNIT_NO_LOG=1 go test ./... -tags rocksdb -count=5 -race -short -timeout 120m

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ IOTA-Core is the node software for the upcoming IOTA 2.0 protocol.
88
![GitHub License](https://img.shields.io/github/license/iotaledger/iota-core?branch=develop)
99
---
1010
[![unit-test](https://github.com/iotaledger/iota-core/actions/workflows/unit-test.yml/badge.svg?branch=develop)](https://github.com/iotaledger/iota-core/actions/workflows/unit-test.yml)
11+
[![unit-test-nightly](https://github.com/iotaledger/iota-core/actions/workflows/unit-test-nightly.yml/badge.svg?branch=develop)](https://github.com/iotaledger/iota-core/actions/workflows/unit-test-nightly.yml)
1112
[![build_docker](https://github.com/iotaledger/iota-core/actions/workflows/build_docker.yml/badge.svg?branch=develop)](https://github.com/iotaledger/iota-core/actions/workflows/build_docker.yml)
1213
[![docker-network-health](https://github.com/iotaledger/iota-core/actions/workflows/docker-network-health.yml/badge.svg?branch=develop)](https://github.com/iotaledger/iota-core/actions/workflows/docker-network-health.yml)
1314
[![docker-network-tests-nightly](https://github.com/iotaledger/iota-core/actions/workflows/docker-network-tests-nightly.yml/badge.svg?branch=develop)](https://github.com/iotaledger/iota-core/actions/workflows/docker-network-tests-nightly.yml)

Diff for: components/app/app.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var (
2525
Name = "iota-core"
2626

2727
// Version of the app.
28-
Version = "1.0.0-alpha.3"
28+
Version = "1.0.0-alpha.6"
2929
)
3030

3131
func App() *app.App {

Diff for: components/debugapi/commitment.go

+30-9
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,22 @@ func prepareCommitmentGraph(g *graphviz.Graphviz, rootCommitment *protocol.Commi
6969
return nil, parentErr
7070
}
7171

72-
if err = parentCommitment.Children.ForEach(func(childCommitment *protocol.Commitment) error {
73-
child, childErr := createNode(graph, childCommitment)
74-
if childErr != nil {
75-
return childErr
76-
}
72+
// TODO: this should be removed once eviction of commitments is properly implemented
73+
if parentCommitment.Children.IsEmpty() {
74+
if childCommitment, exists := parentCommitment.Chain.Get().Commitment(parentCommitment.Slot() + 1); exists {
75+
if err = renderChild(childCommitment, graph, parentCommitment, parent); err != nil {
76+
return nil, err
77+
}
7778

78-
if childCommitment.Chain.Get() == deps.Protocol.Chains.Main.Get() {
79-
child.SetColor("green")
79+
commitmentWalker.Push(childCommitment)
80+
81+
continue
8082
}
83+
}
8184

82-
if _, edgeErr := graph.CreateEdge(fmt.Sprintf("%s -> %s", parentCommitment.ID().String()[:8], childCommitment.ID().String()[:8]), parent, child); edgeErr != nil {
83-
return ierrors.Wrapf(edgeErr, "could not create edge %s -> %s", parentCommitment.ID().String()[:8], childCommitment.ID().String()[:8])
85+
if err = parentCommitment.Children.ForEach(func(childCommitment *protocol.Commitment) error {
86+
if err = renderChild(childCommitment, graph, parentCommitment, parent); err != nil {
87+
return err
8488
}
8589

8690
commitmentWalker.Push(childCommitment)
@@ -94,6 +98,23 @@ func prepareCommitmentGraph(g *graphviz.Graphviz, rootCommitment *protocol.Commi
9498
return graph, nil
9599
}
96100

101+
func renderChild(childCommitment *protocol.Commitment, graph *cgraph.Graph, parentCommitment *protocol.Commitment, parent *cgraph.Node) error {
102+
child, err := createNode(graph, childCommitment)
103+
if err != nil {
104+
return err
105+
}
106+
107+
if childCommitment.Chain.Get() == deps.Protocol.Chains.Main.Get() {
108+
child.SetColor("green")
109+
}
110+
111+
if _, edgeErr := graph.CreateEdge(fmt.Sprintf("%s -> %s", parentCommitment.ID().String()[:8], childCommitment.ID().String()[:8]), parent, child); edgeErr != nil {
112+
return ierrors.Wrapf(edgeErr, "could not create edge %s -> %s", parentCommitment.ID().String()[:8], childCommitment.ID().String()[:8])
113+
}
114+
115+
return nil
116+
}
117+
97118
func createNode(graph *cgraph.Graph, commitment *protocol.Commitment) (*cgraph.Node, error) {
98119
node, err := graph.CreateNode(fmt.Sprintf("%d-%s", commitment.ID().Slot(), commitment.ID().Identifier().String()[:8]))
99120
if err != nil {

Diff for: components/debugapi/component.go

+10-7
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func init() {
4848
DepsFunc: func(cDeps dependencies) { deps = cDeps },
4949
Configure: configure,
5050
Params: params,
51-
IsEnabled: func(c *dig.Container) bool {
51+
IsEnabled: func(_ *dig.Container) bool {
5252
return restapi.ParamsRestAPI.Enabled && ParamsDebugAPI.Enabled
5353
},
5454
}
@@ -90,11 +90,13 @@ func configure() error {
9090

9191
routeGroup := deps.RestRouteManager.AddRoute("debug/v2")
9292

93+
debugAPIWorkerPool := workerpool.NewGroup("DebugAPI").CreatePool("DebugAPI", workerpool.WithWorkerCount(1))
94+
9395
deps.Protocol.Events.Engine.BlockDAG.BlockAttached.Hook(func(block *blocks.Block) {
9496
blocksPerSlot.Set(block.ID().Slot(), append(lo.Return1(blocksPerSlot.GetOrCreate(block.ID().Slot(), func() []*blocks.Block {
9597
return make([]*blocks.Block, 0)
9698
})), block))
97-
})
99+
}, event.WithWorkerPool(debugAPIWorkerPool))
98100

99101
deps.Protocol.Events.Engine.SlotGadget.SlotFinalized.Hook(func(index iotago.SlotIndex) {
100102
epoch := deps.Protocol.APIForSlot(index).TimeProvider().EpochFromSlot(index)
@@ -113,23 +115,24 @@ func configure() error {
113115
}
114116
}
115117

116-
}, event.WithWorkerPool(workerpool.NewGroup("DebugAPI").CreatePool("PruneDebugAPI", workerpool.WithWorkerCount(1))))
118+
}, event.WithWorkerPool(debugAPIWorkerPool))
117119

118120
deps.Protocol.Events.Engine.Notarization.SlotCommitted.Hook(func(scd *notarization.SlotCommittedDetails) {
119121
if err := storeTransactionsPerSlot(scd); err != nil {
120122
Component.LogWarnf(">> DebugAPI Error: %s\n", err)
121123
}
122-
})
124+
}, event.WithWorkerPool(debugAPIWorkerPool))
123125

124-
deps.Protocol.Events.Engine.EvictionState.SlotEvicted.Hook(func(index iotago.SlotIndex) {
126+
deps.Protocol.Events.Engine.Evict.Hook(func(index iotago.SlotIndex) {
125127
blocksInSlot, exists := blocksPerSlot.Get(index)
126128
if !exists {
127129
return
128130
}
129131

130132
for _, block := range blocksInSlot {
131133
if block.ProtocolBlock() == nil {
132-
Component.LogInfof("block is a root block", block.ID())
134+
Component.LogInfof("block is a root block %s", block.ID())
135+
133136
continue
134137
}
135138

@@ -146,7 +149,7 @@ func configure() error {
146149
}
147150

148151
blocksPerSlot.Delete(index)
149-
})
152+
}, event.WithWorkerPool(debugAPIWorkerPool))
150153

151154
routeGroup.GET(RouteBlockMetadata, func(c echo.Context) error {
152155
blockID, err := httpserver.ParseBlockIDParam(c, api.ParameterBlockID)

Diff for: components/debugapi/transactions.go

+11-14
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"github.com/iotaledger/hive.go/ads"
55
"github.com/iotaledger/hive.go/ierrors"
66
"github.com/iotaledger/hive.go/kvstore/mapdb"
7-
"github.com/iotaledger/iota-core/pkg/protocol/engine/mempool"
87
"github.com/iotaledger/iota-core/pkg/protocol/engine/notarization"
98
iotago "github.com/iotaledger/iota.go/v4"
109
)
@@ -17,10 +16,7 @@ func init() {
1716

1817
func storeTransactionsPerSlot(scd *notarization.SlotCommittedDetails) error {
1918
slot := scd.Commitment.Slot()
20-
stateDiff, err := deps.Protocol.Engines.Main.Get().Ledger.MemPool().StateDiff(slot)
21-
if err != nil {
22-
return ierrors.Wrapf(err, "failed to retrieve state diff for slot %d", slot)
23-
}
19+
2420
mutationsTree := ads.NewSet[iotago.Identifier](
2521
mapdb.NewMapDB(),
2622
iotago.Identifier.Bytes,
@@ -33,23 +29,24 @@ func storeTransactionsPerSlot(scd *notarization.SlotCommittedDetails) error {
3329
IncludedTransactions: make([]string, 0),
3430
}
3531

36-
var innerErr error
37-
stateDiff.ExecutedTransactions().ForEach(func(_ iotago.TransactionID, txMeta mempool.TransactionMetadata) bool {
38-
tcs.IncludedTransactions = append(tcs.IncludedTransactions, txMeta.ID().String())
39-
if err := mutationsTree.Add(txMeta.ID()); err != nil {
40-
innerErr = ierrors.Wrapf(err, "failed to add transaction to mutations tree, txID: %s", txMeta.ID())
32+
for _, transaction := range scd.Mutations {
33+
txID, err := transaction.ID()
34+
if err != nil {
35+
return ierrors.Wrapf(err, "failed to calculate transactionID")
36+
}
4137

42-
return false
38+
tcs.IncludedTransactions = append(tcs.IncludedTransactions, txID.String())
39+
if err = mutationsTree.Add(txID); err != nil {
40+
return ierrors.Wrapf(err, "failed to add transaction to mutations tree, txID: %s", txID)
4341
}
4442

45-
return true
46-
})
43+
}
4744

4845
tcs.MutationsRoot = mutationsTree.Root().String()
4946

5047
transactionsPerSlot[slot] = tcs
5148

52-
return innerErr
49+
return nil
5350
}
5451

5552
func getSlotTransactionIDs(slot iotago.SlotIndex) (*TransactionsChangesResponse, error) {

Diff for: components/inx/component.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func init() {
1919
Name: "INX",
2020
DepsFunc: func(cDeps dependencies) { deps = cDeps },
2121
Params: params,
22-
IsEnabled: func(c *dig.Container) bool {
22+
IsEnabled: func(_ *dig.Container) bool {
2323
return ParamsINX.Enabled
2424
},
2525
Provide: provide,

Diff for: components/metricstracker/component.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func init() {
2121
Params: params,
2222
Provide: provide,
2323
Run: run,
24-
IsEnabled: func(c *dig.Container) bool {
24+
IsEnabled: func(_ *dig.Container) bool {
2525
return ParamsMetricsTracker.Enabled
2626
},
2727
}
@@ -63,13 +63,13 @@ func run() error {
6363
Component.LogInfo("Starting Metrics Tracker ... done")
6464

6565
unhook := lo.Batch(
66-
deps.Protocol.Events.Engine.BlockDAG.BlockAttached.Hook(func(b *blocks.Block) {
66+
deps.Protocol.Events.Engine.BlockDAG.BlockAttached.Hook(func(_ *blocks.Block) {
6767
deps.MetricsTracker.metrics.Blocks.Inc()
6868
}, event.WithWorkerPool(Component.WorkerPool)).Unhook,
6969
deps.Protocol.Events.Engine.Notarization.SlotCommitted.Hook(func(_ *notarization.SlotCommittedDetails) {
7070
deps.MetricsTracker.measure()
7171
}, event.WithWorkerPool(Component.WorkerPool)).Unhook,
72-
deps.Protocol.Events.Engine.BlockGadget.BlockConfirmed.Hook(func(b *blocks.Block) {
72+
deps.Protocol.Events.Engine.BlockGadget.BlockConfirmed.Hook(func(_ *blocks.Block) {
7373
deps.MetricsTracker.metrics.ConfirmedBlocks.Inc()
7474
}, event.WithWorkerPool(Component.WorkerPool)).Unhook,
7575
)

Diff for: components/prometheus/metrics_commitments.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,28 @@ var CommitmentsMetrics = collector.NewCollection(commitmentsNamespace,
5959
collector.WithHelp("Number of accepted blocks by the node per slot."),
6060
collector.WithLabels("slot"),
6161
collector.WithPruningDelay(10*time.Minute),
62-
collector.WithResetBeforeCollecting(true),
6362
collector.WithInitFunc(func() {
6463
deps.Protocol.Events.Engine.Notarization.SlotCommitted.Hook(func(details *notarization.SlotCommittedDetails) {
6564
deps.Collector.Update(commitmentsNamespace, acceptedBlocks, float64(details.AcceptedBlocks.Size()), strconv.Itoa(int(details.Commitment.Slot())))
6665
}, event.WithWorkerPool(Component.WorkerPool))
6766
}),
6867
)),
68+
collector.WithMetric(collector.NewMetric(transactions,
69+
collector.WithType(collector.Gauge),
70+
collector.WithHelp("Number of accepted transactions by the node per slot."),
71+
collector.WithLabels("slot"),
72+
collector.WithPruningDelay(10*time.Minute),
73+
collector.WithInitFunc(func() {
74+
deps.Protocol.Events.Engine.Notarization.SlotCommitted.Hook(func(details *notarization.SlotCommittedDetails) {
75+
deps.Collector.Update(commitmentsNamespace, transactions, float64(len(details.Mutations)), strconv.Itoa(int(details.Commitment.Slot())))
76+
}, event.WithWorkerPool(Component.WorkerPool))
77+
}),
78+
)),
6979
collector.WithMetric(collector.NewMetric(validators,
7080
collector.WithType(collector.Gauge),
7181
collector.WithHelp("Number of active validators per slot."),
7282
collector.WithLabels("slot"),
7383
collector.WithPruningDelay(10*time.Minute),
74-
collector.WithResetBeforeCollecting(true),
7584
collector.WithInitFunc(func() {
7685
deps.Protocol.Events.Engine.Notarization.SlotCommitted.Hook(func(details *notarization.SlotCommittedDetails) {
7786
deps.Collector.Update(commitmentsNamespace, validators, float64(details.ActiveValidatorsCount), strconv.Itoa(int(details.Commitment.Slot())))

Diff for: components/prometheus/metrics_conflicts.go

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ var ConflictMetrics = collector.NewCollection(conflictNamespace,
3737
collector.WithType(collector.Counter),
3838
collector.WithHelp("Number of resolved (accepted) conflicts"),
3939
collector.WithInitFunc(func() {
40+
//nolint:revive
4041
deps.Protocol.Events.Engine.SpendDAG.SpenderAccepted.Hook(func(spendID iotago.TransactionID) {
4142
deps.Collector.Increment(conflictNamespace, resolvedConflictCount)
4243
}, event.WithWorkerPool(Component.WorkerPool))
@@ -46,6 +47,7 @@ var ConflictMetrics = collector.NewCollection(conflictNamespace,
4647
collector.WithType(collector.Counter),
4748
collector.WithHelp("Number of created conflicts"),
4849
collector.WithInitFunc(func() {
50+
//nolint:revive
4951
deps.Protocol.Events.Engine.SpendDAG.SpenderCreated.Hook(func(spendID iotago.TransactionID) {
5052
deps.Collector.Increment(conflictNamespace, allConflictCounts)
5153
}, event.WithWorkerPool(Component.WorkerPool))

Diff for: components/prometheus/metrics_scheduler.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,22 @@ var SchedulerMetrics = collector.NewCollection(schedulerNamespace,
140140
collector.WithLabels("state"),
141141
collector.WithHelp("Number of blocks processed by the scheduler."),
142142
collector.WithInitFunc(func() {
143-
deps.Protocol.Events.Engine.Scheduler.BlockEnqueued.Hook(func(block *blocks.Block) {
143+
deps.Protocol.Events.Engine.Scheduler.BlockEnqueued.Hook(func(_ *blocks.Block) {
144144
deps.Collector.Increment(schedulerNamespace, schedulerProcessedBlocks, enqueuedBlockLabel)
145145

146146
}, event.WithWorkerPool(Component.WorkerPool))
147147

148-
deps.Protocol.Events.Engine.Scheduler.BlockDropped.Hook(func(block *blocks.Block, _ error) {
148+
deps.Protocol.Events.Engine.Scheduler.BlockDropped.Hook(func(_ *blocks.Block, _ error) {
149149
deps.Collector.Increment(schedulerNamespace, schedulerProcessedBlocks, droppedBlockLabel)
150150

151151
}, event.WithWorkerPool(Component.WorkerPool))
152152

153-
deps.Protocol.Events.Engine.Scheduler.BlockSkipped.Hook(func(block *blocks.Block) {
153+
deps.Protocol.Events.Engine.Scheduler.BlockSkipped.Hook(func(_ *blocks.Block) {
154154
deps.Collector.Increment(schedulerNamespace, schedulerProcessedBlocks, skippedBlockLabel)
155155

156156
}, event.WithWorkerPool(Component.WorkerPool))
157157

158-
deps.Protocol.Events.Engine.Scheduler.BlockScheduled.Hook(func(block *blocks.Block) {
158+
deps.Protocol.Events.Engine.Scheduler.BlockScheduled.Hook(func(_ *blocks.Block) {
159159
deps.Collector.Increment(schedulerNamespace, schedulerProcessedBlocks, scheduledBlockLabel)
160160

161161
}, event.WithWorkerPool(Component.WorkerPool))

Diff for: components/prometheus/metrics_slots.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ var SlotMetrics = collector.NewCollection(slotNamespace,
5757
collector.WithPruningDelay(10*time.Minute),
5858
collector.WithHelp("Number of invalid blocks in a slot."),
5959
collector.WithInitFunc(func() {
60-
deps.Protocol.Events.Engine.BlockDAG.BlockInvalid.Hook(func(block *blocks.Block, err error) {
60+
deps.Protocol.Events.Engine.BlockDAG.BlockInvalid.Hook(func(block *blocks.Block, _ error) {
6161
eventSlot := int(block.ID().Slot())
6262
deps.Collector.Increment(slotNamespace, invalidBlocks, strconv.Itoa(eventSlot))
6363
}, event.WithWorkerPool(Component.WorkerPool))

Diff for: components/protocol/component.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func provide(c *dig.Container) error {
177177
}
178178

179179
func configure() error {
180-
deps.Protocol.Network.OnBlockReceived(func(block *model.Block, source peer.ID) {
180+
deps.Protocol.Network.OnBlockReceived(func(block *model.Block, _ peer.ID) {
181181
Component.LogDebugf("BlockReceived: %s", block.ID())
182182
})
183183

@@ -269,11 +269,11 @@ func configure() error {
269269
Component.LogDebugf("BlockSkipped, blockID: %s", block.ID())
270270
})
271271

272-
deps.Protocol.Network.OnCommitmentRequestReceived(func(commitmentID iotago.CommitmentID, id peer.ID) {
272+
deps.Protocol.Network.OnCommitmentRequestReceived(func(commitmentID iotago.CommitmentID, _ peer.ID) {
273273
Component.LogDebugf("SlotCommitmentRequestReceived: %s", commitmentID)
274274
})
275275

276-
deps.Protocol.Network.OnCommitmentReceived(func(commitment *model.Commitment, id peer.ID) {
276+
deps.Protocol.Network.OnCommitmentReceived(func(commitment *model.Commitment, _ peer.ID) {
277277
Component.LogDebugf("SlotCommitmentReceived: %s", commitment.ID())
278278
})
279279

0 commit comments

Comments
 (0)