Skip to content

Commit

Permalink
Fix: fixed bug with erroneous transition rule
Browse files Browse the repository at this point in the history
  • Loading branch information
hmoog committed Oct 31, 2023
1 parent 647d023 commit 0b3ba89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion pkg/protocol/commitment.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,14 @@ func NewCommitment(commitment *model.Commitment, protocol *Protocol) *Commitment
c.IsRoot.OnTrigger(func() {
c.IsAttested.Set(true)
c.IsVerified.Set(true)
c.IsSolid.Set(true)
})

c.Logger = protocol.NewEntityLogger(fmt.Sprintf("Slot%d.", commitment.Slot()), c.IsEvicted, func(entityLogger log.Logger) {
c.IsSolid.LogUpdates(entityLogger, log.LevelTrace, "IsSolid")
c.Chain.LogUpdates(entityLogger, log.LevelTrace, "Chain", (*Chain).LogName)
c.IsVerified.LogUpdates(entityLogger, log.LevelTrace, "IsVerified")
c.InSyncRange.LogUpdates(entityLogger, log.LevelTrace, "InSyncRange")
c.WarpSync.LogUpdates(entityLogger, log.LevelTrace, "WarpSync")
c.Weight.LogUpdates(entityLogger, log.LevelTrace, "Weight")
c.AttestedWeight.LogUpdates(entityLogger, log.LevelTrace, "AttestedWeight")
Expand All @@ -132,7 +137,7 @@ func NewCommitment(commitment *model.Commitment, protocol *Protocol) *Commitment

func (c *Commitment) isAboveLatestVerifiedCommitment(parent *Commitment) reactive.DerivedVariable[bool] {
return reactive.NewDerivedVariable3(func(parentAboveLatestVerifiedCommitment, parentIsVerified, isVerified bool) bool {
return parentAboveLatestVerifiedCommitment || (parentIsVerified && isVerified)
return parentAboveLatestVerifiedCommitment || (parentIsVerified && !isVerified)
}, parent.IsAboveLatestVerifiedCommitment, parent.IsVerified, c.IsVerified)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/testsuite/mock/blockissuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (i *BlockIssuer) IssueValidationBlock(ctx context.Context, alias string, no

validationBlock, _ := block.ValidationBlock()

node.Protocol.MainEngine.Get().LogTrace("issued validation block", "block", validationBlock, "blockID", block.ID(), "slot", block.ID().Slot(), "commitment", block.SlotCommitmentID(), "latestFinalizedSlot", block.ProtocolBlock().LatestFinalizedSlot, "version", block.ProtocolBlock().ProtocolVersion, "highestSupportedVersion", validationBlock.HighestSupportedVersion, "hash", validationBlock.ProtocolParametersHash)
node.Protocol.MainEngine.Get().LogTrace("issued validation block", "blockID", block.ID(), "slot", block.ID().Slot(), "commitment", block.SlotCommitmentID(), "latestFinalizedSlot", block.ProtocolBlock().LatestFinalizedSlot, "version", block.ProtocolBlock().ProtocolVersion, "highestSupportedVersion", validationBlock.HighestSupportedVersion, "hash", validationBlock.ProtocolParametersHash)

return block
}
Expand Down Expand Up @@ -283,7 +283,7 @@ func (i *BlockIssuer) IssueBasicBlock(ctx context.Context, alias string, node *N

require.NoErrorf(i.Testing, i.IssueBlock(block.ModelBlock(), node), "%s > failed to issue block with alias %s", i.Name, alias)

node.Protocol.LogTrace("issued block", "block", block, "blockID", block.ID(), "slot", block.ID().Slot(), "commitment", block.SlotCommitmentID(), "latestFinalizedSlot", block.ProtocolBlock().LatestFinalizedSlot, "version", block.ProtocolBlock().ProtocolVersion)
node.Protocol.LogTrace("issued block", "blockID", block.ID(), "slot", block.ID().Slot(), "commitment", block.SlotCommitmentID(), "latestFinalizedSlot", block.ProtocolBlock().LatestFinalizedSlot, "version", block.ProtocolBlock().ProtocolVersion)

return block
}
Expand Down

0 comments on commit 0b3ba89

Please sign in to comment.