Skip to content

Commit

Permalink
Fix: fixing bugs WIPWIP
Browse files Browse the repository at this point in the history
  • Loading branch information
hmoog committed Oct 4, 2023
1 parent 8ec344f commit ef2e6da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pkg/protocol/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions pkg/tests/protocol_startup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")...)
Expand Down

0 comments on commit ef2e6da

Please sign in to comment.