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")...)