Skip to content

Commit

Permalink
Merge pull request #937 from iotaledger/fix/request-attestations-when…
Browse files Browse the repository at this point in the history
…-ready

Fix: Only request Attestations when parent of forking point is verified
  • Loading branch information
alexsporn authored Apr 25, 2024
2 parents 52cc42b + c3b481b commit 80baf80
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
7 changes: 0 additions & 7 deletions pkg/protocol/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ type Chain struct {
// IsEvicted contains a flag that indicates whether this chain was evicted.
IsEvicted reactive.Event

// IsSolid contains a flag that indicates whether this chain is solid (has a continuous connection to the root).
IsSolid reactive.Event

// shouldEvict contains a flag that indicates whether this chain should be evicted.
shouldEvict reactive.Event

Expand Down Expand Up @@ -89,7 +86,6 @@ func newChain(chains *Chains) *Chain {
StartEngine: reactive.NewVariable[bool](),
Engine: reactive.NewVariable[*engine.Engine](),
IsEvicted: reactive.NewEvent(),
IsSolid: reactive.NewEvent(),
shouldEvict: reactive.NewEvent(),

chains: chains,
Expand Down Expand Up @@ -213,7 +209,6 @@ func (c *Chain) initLogger() (shutdown func()) {
c.StartEngine.LogUpdates(c, log.LevelDebug, "StartEngine"),
c.Engine.LogUpdates(c, log.LevelTrace, "Engine", (*engine.Engine).LogName),
c.IsEvicted.LogUpdates(c, log.LevelTrace, "IsEvicted"),
c.IsSolid.LogUpdates(c, log.LevelTrace, "IsSolid"),
c.shouldEvict.LogUpdates(c, log.LevelTrace, "shouldEvict"),

c.Logger.Shutdown,
Expand All @@ -237,8 +232,6 @@ func (c *Chain) initDerivedProperties() (shutdown func()) {
c.deriveShouldEvict(forkingPoint, parentChain),
)
}),

c.IsSolid.InheritFrom(forkingPoint.IsSolid),
)
}),
),
Expand Down
8 changes: 6 additions & 2 deletions pkg/protocol/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,12 @@ func (c *Chains) initChainSwitching() (shutdown func()) {

return lo.BatchReverse(
c.HeaviestClaimedCandidate.WithNonEmptyValue(func(heaviestClaimedCandidate *Chain) (shutdown func()) {
return heaviestClaimedCandidate.IsSolid.WithNonEmptyValue(func(_ bool) (teardown func()) {
return heaviestClaimedCandidate.RequestAttestations.ToggleValue(true)
return heaviestClaimedCandidate.ForkingPoint.WithNonEmptyValue(func(forkingPoint *Commitment) (teardown func()) {
return forkingPoint.Parent.WithNonEmptyValue(func(parentOfForkingPoint *Commitment) (teardown func()) {
return parentOfForkingPoint.IsVerified.WithNonEmptyValue(func(_ bool) (teardown func()) {
return heaviestClaimedCandidate.RequestAttestations.ToggleValue(true)
})
})
})
}),

Expand Down
9 changes: 0 additions & 9 deletions pkg/protocol/commitment.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ type Commitment struct {
// IsRoot contains a flag indicating if this Commitment is the root of the Chain.
IsRoot reactive.Event

// IsSolid contains a flag indicating if this Commitment is solid (has all the commitments in its past cone until
// the RootCommitment).
IsSolid reactive.Event

// IsAttested contains a flag indicating if we have received attestations for this Commitment.
IsAttested reactive.Event

Expand Down Expand Up @@ -112,7 +108,6 @@ func newCommitment(commitments *Commitments, model *model.Commitment) *Commitmen
CumulativeAttestedWeight: reactive.NewVariable[uint64](),
CumulativeVerifiedWeight: reactive.NewVariable[uint64](),
IsRoot: reactive.NewEvent(),
IsSolid: reactive.NewEvent(),
IsAttested: reactive.NewEvent(),
IsSynced: reactive.NewEvent(),
IsCommittable: reactive.NewEvent(),
Expand Down Expand Up @@ -224,7 +219,6 @@ func (c *Commitment) initLogger() (shutdown func()) {
c.CumulativeAttestedWeight.LogUpdates(c, log.LevelTrace, "CumulativeAttestedWeight"),
c.CumulativeVerifiedWeight.LogUpdates(c, log.LevelTrace, "CumulativeVerifiedWeight"),
c.IsRoot.LogUpdates(c, log.LevelTrace, "IsRoot"),
c.IsSolid.LogUpdates(c, log.LevelTrace, "IsSolid"),
c.IsAttested.LogUpdates(c, log.LevelTrace, "IsAttested"),
c.IsSynced.LogUpdates(c, log.LevelTrace, "IsSynced"),
c.IsCommittable.LogUpdates(c, log.LevelTrace, "IsCommittable"),
Expand All @@ -241,7 +235,6 @@ func (c *Commitment) initDerivedProperties() (shutdown func()) {
return lo.BatchReverse(
// mark commitments that are marked as root as verified
c.IsVerified.InheritFrom(c.IsRoot),
c.IsSolid.InheritFrom(c.IsRoot),

c.IsRoot.OnTrigger(func() {
c.CumulativeAttestedWeight.Set(c.Commitment.CumulativeWeight())
Expand Down Expand Up @@ -277,8 +270,6 @@ func (c *Commitment) initDerivedProperties() (shutdown func()) {
}),
)
}),

c.IsSolid.InheritFrom(parent.IsSolid),
)
}),

Expand Down

0 comments on commit 80baf80

Please sign in to comment.