From ef2e6dabf232531396e189d4db921d311708d8b7 Mon Sep 17 00:00:00 2001 From: Hans Moog <3293976+hmoog@users.noreply.github.com> Date: Wed, 4 Oct 2023 16:14:14 +0200 Subject: [PATCH] Fix: fixing bugs WIPWIP --- pkg/protocol/chains.go | 11 +++++------ pkg/tests/protocol_startup_test.go | 3 +++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/protocol/chains.go b/pkg/protocol/chains.go index 5ad251147..828898b4b 100644 --- a/pkg/protocol/chains.go +++ b/pkg/protocol/chains.go @@ -290,13 +290,16 @@ func (c *Chains) publishEngineCommitments(chain *Chain) { panic(err) // this can never happen, but we panic to get a stack trace if it ever does } - publishedCommitment.promote(chain) publishedCommitment.AttestedWeight.Set(publishedCommitment.Weight.Get()) publishedCommitment.IsAttested.Trigger() publishedCommitment.IsVerified.Trigger() latestPublishedSlot = commitment.Slot() + if publishedCommitment.IsSolid.Get() { + publishedCommitment.promote(chain) + } + return publishedCommitment, published } @@ -305,17 +308,13 @@ func (c *Chains) publishEngineCommitments(chain *Chain) { chain.ForkingPoint.Set(rootCommitment) rootCommitment.IsRoot.Trigger() + rootCommitment.promote(chain) } } else { latestPublishedSlot = forkingPoint.Slot() - 1 } return engine.LatestCommitment.OnUpdate(func(_, latestModelCommitment *model.Commitment) { - if latestModelCommitment == nil { - // TODO: CHECK IF NECESSARY - return - } - for latestPublishedSlot < latestModelCommitment.Slot() { if commitmentToPublish, err := engine.Storage.Commitments().Load(latestPublishedSlot + 1); err != nil { panic(err) // this should never happen, but we panic to get a stack trace if it does diff --git a/pkg/tests/protocol_startup_test.go b/pkg/tests/protocol_startup_test.go index 03af7cc9b..8f9d4b6b0 100644 --- a/pkg/tests/protocol_startup_test.go +++ b/pkg/tests/protocol_startup_test.go @@ -10,6 +10,7 @@ import ( "github.com/iotaledger/hive.go/core/eventticker" "github.com/iotaledger/hive.go/ds/types" "github.com/iotaledger/hive.go/lo" + "github.com/iotaledger/hive.go/log" "github.com/iotaledger/hive.go/runtime/options" "github.com/iotaledger/iota-core/pkg/core/account" "github.com/iotaledger/iota-core/pkg/protocol" @@ -201,6 +202,8 @@ func Test_StartNodeFromSnapshotAndDisk(t *testing.T) { ) ts.Wait() + nodeC1.Protocol.SetLogLevel(log.LevelDebug) + // Everything that was accepted before shutting down should be available on disk (verifying that restoring the block cache from disk works). ts.AssertBlocksExist(ts.BlocksWithPrefixes("8", "9", "11", "12", "13.0", "13.1", "13.2", "13.3"), true, ts.Nodes("nodeC-restarted")...) ts.AssertStorageRootBlocks(expectedStorageRootBlocksFrom0, ts.Nodes("nodeC-restarted")...)