Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit 80baf80

Browse files
authored
Merge pull request #937 from iotaledger/fix/request-attestations-when-ready
Fix: Only request Attestations when parent of forking point is verified
2 parents 52cc42b + c3b481b commit 80baf80

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

pkg/protocol/chain.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ type Chain struct {
5757
// IsEvicted contains a flag that indicates whether this chain was evicted.
5858
IsEvicted reactive.Event
5959

60-
// IsSolid contains a flag that indicates whether this chain is solid (has a continuous connection to the root).
61-
IsSolid reactive.Event
62-
6360
// shouldEvict contains a flag that indicates whether this chain should be evicted.
6461
shouldEvict reactive.Event
6562

@@ -89,7 +86,6 @@ func newChain(chains *Chains) *Chain {
8986
StartEngine: reactive.NewVariable[bool](),
9087
Engine: reactive.NewVariable[*engine.Engine](),
9188
IsEvicted: reactive.NewEvent(),
92-
IsSolid: reactive.NewEvent(),
9389
shouldEvict: reactive.NewEvent(),
9490

9591
chains: chains,
@@ -213,7 +209,6 @@ func (c *Chain) initLogger() (shutdown func()) {
213209
c.StartEngine.LogUpdates(c, log.LevelDebug, "StartEngine"),
214210
c.Engine.LogUpdates(c, log.LevelTrace, "Engine", (*engine.Engine).LogName),
215211
c.IsEvicted.LogUpdates(c, log.LevelTrace, "IsEvicted"),
216-
c.IsSolid.LogUpdates(c, log.LevelTrace, "IsSolid"),
217212
c.shouldEvict.LogUpdates(c, log.LevelTrace, "shouldEvict"),
218213

219214
c.Logger.Shutdown,
@@ -237,8 +232,6 @@ func (c *Chain) initDerivedProperties() (shutdown func()) {
237232
c.deriveShouldEvict(forkingPoint, parentChain),
238233
)
239234
}),
240-
241-
c.IsSolid.InheritFrom(forkingPoint.IsSolid),
242235
)
243236
}),
244237
),

pkg/protocol/chains.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,12 @@ func (c *Chains) initChainSwitching() (shutdown func()) {
323323

324324
return lo.BatchReverse(
325325
c.HeaviestClaimedCandidate.WithNonEmptyValue(func(heaviestClaimedCandidate *Chain) (shutdown func()) {
326-
return heaviestClaimedCandidate.IsSolid.WithNonEmptyValue(func(_ bool) (teardown func()) {
327-
return heaviestClaimedCandidate.RequestAttestations.ToggleValue(true)
326+
return heaviestClaimedCandidate.ForkingPoint.WithNonEmptyValue(func(forkingPoint *Commitment) (teardown func()) {
327+
return forkingPoint.Parent.WithNonEmptyValue(func(parentOfForkingPoint *Commitment) (teardown func()) {
328+
return parentOfForkingPoint.IsVerified.WithNonEmptyValue(func(_ bool) (teardown func()) {
329+
return heaviestClaimedCandidate.RequestAttestations.ToggleValue(true)
330+
})
331+
})
328332
})
329333
}),
330334

pkg/protocol/commitment.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ type Commitment struct {
6060
// IsRoot contains a flag indicating if this Commitment is the root of the Chain.
6161
IsRoot reactive.Event
6262

63-
// IsSolid contains a flag indicating if this Commitment is solid (has all the commitments in its past cone until
64-
// the RootCommitment).
65-
IsSolid reactive.Event
66-
6763
// IsAttested contains a flag indicating if we have received attestations for this Commitment.
6864
IsAttested reactive.Event
6965

@@ -112,7 +108,6 @@ func newCommitment(commitments *Commitments, model *model.Commitment) *Commitmen
112108
CumulativeAttestedWeight: reactive.NewVariable[uint64](),
113109
CumulativeVerifiedWeight: reactive.NewVariable[uint64](),
114110
IsRoot: reactive.NewEvent(),
115-
IsSolid: reactive.NewEvent(),
116111
IsAttested: reactive.NewEvent(),
117112
IsSynced: reactive.NewEvent(),
118113
IsCommittable: reactive.NewEvent(),
@@ -224,7 +219,6 @@ func (c *Commitment) initLogger() (shutdown func()) {
224219
c.CumulativeAttestedWeight.LogUpdates(c, log.LevelTrace, "CumulativeAttestedWeight"),
225220
c.CumulativeVerifiedWeight.LogUpdates(c, log.LevelTrace, "CumulativeVerifiedWeight"),
226221
c.IsRoot.LogUpdates(c, log.LevelTrace, "IsRoot"),
227-
c.IsSolid.LogUpdates(c, log.LevelTrace, "IsSolid"),
228222
c.IsAttested.LogUpdates(c, log.LevelTrace, "IsAttested"),
229223
c.IsSynced.LogUpdates(c, log.LevelTrace, "IsSynced"),
230224
c.IsCommittable.LogUpdates(c, log.LevelTrace, "IsCommittable"),
@@ -241,7 +235,6 @@ func (c *Commitment) initDerivedProperties() (shutdown func()) {
241235
return lo.BatchReverse(
242236
// mark commitments that are marked as root as verified
243237
c.IsVerified.InheritFrom(c.IsRoot),
244-
c.IsSolid.InheritFrom(c.IsRoot),
245238

246239
c.IsRoot.OnTrigger(func() {
247240
c.CumulativeAttestedWeight.Set(c.Commitment.CumulativeWeight())
@@ -277,8 +270,6 @@ func (c *Commitment) initDerivedProperties() (shutdown func()) {
277270
}),
278271
)
279272
}),
280-
281-
c.IsSolid.InheritFrom(parent.IsSolid),
282273
)
283274
}),
284275

0 commit comments

Comments
 (0)