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

Commit 26f6f6a

Browse files
committed
Feat: stuff works
1 parent a22e54d commit 26f6f6a

File tree

12 files changed

+167
-210
lines changed

12 files changed

+167
-210
lines changed

go.mod

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ require (
1010
github.com/google/uuid v1.4.0
1111
github.com/gorilla/websocket v1.5.1
1212
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
13-
github.com/iotaledger/hive.go/ads v0.0.0-20240115215600-822f4326ef0e
14-
github.com/iotaledger/hive.go/app v0.0.0-20240115215600-822f4326ef0e
15-
github.com/iotaledger/hive.go/constraints v0.0.0-20240115215600-822f4326ef0e
16-
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240115215600-822f4326ef0e
17-
github.com/iotaledger/hive.go/crypto v0.0.0-20240115215600-822f4326ef0e
18-
github.com/iotaledger/hive.go/ds v0.0.0-20240115215600-822f4326ef0e
19-
github.com/iotaledger/hive.go/ierrors v0.0.0-20240115215600-822f4326ef0e
20-
github.com/iotaledger/hive.go/kvstore v0.0.0-20240115215600-822f4326ef0e
21-
github.com/iotaledger/hive.go/lo v0.0.0-20240115215600-822f4326ef0e
22-
github.com/iotaledger/hive.go/log v0.0.0-20240115215600-822f4326ef0e
23-
github.com/iotaledger/hive.go/runtime v0.0.0-20240115215600-822f4326ef0e
24-
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240115215600-822f4326ef0e
25-
github.com/iotaledger/hive.go/stringify v0.0.0-20240115215600-822f4326ef0e
13+
github.com/iotaledger/hive.go/ads v0.0.0-20240117095736-623cd3fb800b
14+
github.com/iotaledger/hive.go/app v0.0.0-20240117095736-623cd3fb800b
15+
github.com/iotaledger/hive.go/constraints v0.0.0-20240117095736-623cd3fb800b
16+
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240117095736-623cd3fb800b
17+
github.com/iotaledger/hive.go/crypto v0.0.0-20240117095736-623cd3fb800b
18+
github.com/iotaledger/hive.go/ds v0.0.0-20240117095736-623cd3fb800b
19+
github.com/iotaledger/hive.go/ierrors v0.0.0-20240117095736-623cd3fb800b
20+
github.com/iotaledger/hive.go/kvstore v0.0.0-20240117095736-623cd3fb800b
21+
github.com/iotaledger/hive.go/lo v0.0.0-20240117095736-623cd3fb800b
22+
github.com/iotaledger/hive.go/log v0.0.0-20240117095736-623cd3fb800b
23+
github.com/iotaledger/hive.go/runtime v0.0.0-20240117095736-623cd3fb800b
24+
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240117095736-623cd3fb800b
25+
github.com/iotaledger/hive.go/stringify v0.0.0-20240117095736-623cd3fb800b
2626
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240110125343-5c50e43b71fa
2727
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240110120225-05a4544ca1dd
2828
github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00

go.sum

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -277,32 +277,32 @@ github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJ
277277
github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
278278
github.com/iotaledger/grocksdb v1.7.5-0.20230220105546-5162e18885c7 h1:dTrD7X2PTNgli6EbS4tV9qu3QAm/kBU3XaYZV2xdzys=
279279
github.com/iotaledger/grocksdb v1.7.5-0.20230220105546-5162e18885c7/go.mod h1:ZRdPu684P0fQ1z8sXz4dj9H5LWHhz4a9oCtvjunkSrw=
280-
github.com/iotaledger/hive.go/ads v0.0.0-20240115215600-822f4326ef0e h1:31H89nWLZgrD5JJCXrncIKNWHgjlp7RjVYN1v94ADWM=
281-
github.com/iotaledger/hive.go/ads v0.0.0-20240115215600-822f4326ef0e/go.mod h1:+ysVYmX4esgKnGCeRo7Uhn7b6FrWrtJuZKvI0J4YXj4=
282-
github.com/iotaledger/hive.go/app v0.0.0-20240115215600-822f4326ef0e h1:QsoX8vdsy+vsNQHvFS+3VWaYynDwxCeRjcR3ujt8lB4=
283-
github.com/iotaledger/hive.go/app v0.0.0-20240115215600-822f4326ef0e/go.mod h1:EowdKxXnoe6QfJF315OssYyfX24LIcgAjTr78CqprMo=
284-
github.com/iotaledger/hive.go/constraints v0.0.0-20240115215600-822f4326ef0e h1:SjPTt9DIOONQE84eNARnrlegN6GDudXPowYIPZ/OzPU=
285-
github.com/iotaledger/hive.go/constraints v0.0.0-20240115215600-822f4326ef0e/go.mod h1:dOBOM2s4se3HcWefPe8sQLUalGXJ8yVXw58oK8jke3s=
286-
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240115215600-822f4326ef0e h1:NaLQmmNWRO4X9AdlBlGOs48uC6gR08RdimWmXKZX5Bk=
287-
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240115215600-822f4326ef0e/go.mod h1:Xaj//ZaRtBsr4xGJMh9ZCLhC2QkOhiLNTDhPXVHbi7Q=
288-
github.com/iotaledger/hive.go/crypto v0.0.0-20240115215600-822f4326ef0e h1:vJm5KNZrWJCvQAXRRftX+AyfQPbTEfqA/X40GbsCLLQ=
289-
github.com/iotaledger/hive.go/crypto v0.0.0-20240115215600-822f4326ef0e/go.mod h1:gsifUt12BCY+momgmC5QYhmG00ffuW0A5T5Sr72wyis=
290-
github.com/iotaledger/hive.go/ds v0.0.0-20240115215600-822f4326ef0e h1:pQRG2si9Xei+pifY3yfMlCRpQQuskOUvCzYjukiX0Vs=
291-
github.com/iotaledger/hive.go/ds v0.0.0-20240115215600-822f4326ef0e/go.mod h1:Ih+78nAgA5QALMvQk3a4SP94W/S/oNXHJTHmf4H9Rn4=
292-
github.com/iotaledger/hive.go/ierrors v0.0.0-20240115215600-822f4326ef0e h1:R6Ng2q2DZGbNg0H3m9ixnK2xnsX5c6XDzCTI+PbzBrE=
293-
github.com/iotaledger/hive.go/ierrors v0.0.0-20240115215600-822f4326ef0e/go.mod h1:HcE8B5lP96enc/OALTb2/rIIi+yOLouRoHOKRclKmC8=
294-
github.com/iotaledger/hive.go/kvstore v0.0.0-20240115215600-822f4326ef0e h1:z4adlmByGoYg4F81JaPYSuWtM7TGvkVnKvgIM1H6UUU=
295-
github.com/iotaledger/hive.go/kvstore v0.0.0-20240115215600-822f4326ef0e/go.mod h1:ET5O4JuZjsDdyO5DeumF8VKwLascBNdAlmyeXHigD8c=
296-
github.com/iotaledger/hive.go/lo v0.0.0-20240115215600-822f4326ef0e h1:AGwmCzMeHZvXnmVDObqOQDaF1u6CIUm4OlqYIccfDuw=
297-
github.com/iotaledger/hive.go/lo v0.0.0-20240115215600-822f4326ef0e/go.mod h1:w3abvs2FpXLd8rugaTq5YnT4KbniyulhePRU77F5pCg=
298-
github.com/iotaledger/hive.go/log v0.0.0-20240115215600-822f4326ef0e h1:5RIQlWqRGMUZakKUfh6TBqXNxY6cjb3Bu1PvSaBM4oA=
299-
github.com/iotaledger/hive.go/log v0.0.0-20240115215600-822f4326ef0e/go.mod h1:9QT/3ZQB/sNlRgBxw07iJeD4a9e7GIRwNIdanIccx+Q=
300-
github.com/iotaledger/hive.go/runtime v0.0.0-20240115215600-822f4326ef0e h1:u+2DTNjat/n5e/eQG9a7m1NLSxv6R5Bpku3as3w070c=
301-
github.com/iotaledger/hive.go/runtime v0.0.0-20240115215600-822f4326ef0e/go.mod h1:AzqO/YvIdFTZoK8r9UWHvxrqaWeWxDN+rFf+V7b/6gY=
302-
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240115215600-822f4326ef0e h1:nj3C0RL55gHXcb8R1Avj+ywsPlK9V/ooGpNKeYDJqnI=
303-
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240115215600-822f4326ef0e/go.mod h1:LkvNBG7PeoQgCCSB/eMNX8kSHTXtRN10kFciLdMvcgc=
304-
github.com/iotaledger/hive.go/stringify v0.0.0-20240115215600-822f4326ef0e h1:+BCgGnpJEyei7AT/eoZ0aZpF/lyEXK86idl7pa9iWZ8=
305-
github.com/iotaledger/hive.go/stringify v0.0.0-20240115215600-822f4326ef0e/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs=
280+
github.com/iotaledger/hive.go/ads v0.0.0-20240117095736-623cd3fb800b h1:F1WQo3OKQ6uTce+MAyjMQfJtPgiFvPcM9sJb0qtrVW0=
281+
github.com/iotaledger/hive.go/ads v0.0.0-20240117095736-623cd3fb800b/go.mod h1:+ysVYmX4esgKnGCeRo7Uhn7b6FrWrtJuZKvI0J4YXj4=
282+
github.com/iotaledger/hive.go/app v0.0.0-20240117095736-623cd3fb800b h1:EcWMovs0wZ4b0TZkoYihRw5ZzssxdoGdWg5R3FnMSvU=
283+
github.com/iotaledger/hive.go/app v0.0.0-20240117095736-623cd3fb800b/go.mod h1:EowdKxXnoe6QfJF315OssYyfX24LIcgAjTr78CqprMo=
284+
github.com/iotaledger/hive.go/constraints v0.0.0-20240117095736-623cd3fb800b h1:20PMzZNuCmsQuxvSiMTMOGgqxuBoelmxDrcObN71k8I=
285+
github.com/iotaledger/hive.go/constraints v0.0.0-20240117095736-623cd3fb800b/go.mod h1:dOBOM2s4se3HcWefPe8sQLUalGXJ8yVXw58oK8jke3s=
286+
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240117095736-623cd3fb800b h1:0+d7iDuMtK0tj/zc8JvwRB8gnb8xQerfvg6Xy8wSNTI=
287+
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240117095736-623cd3fb800b/go.mod h1:Xaj//ZaRtBsr4xGJMh9ZCLhC2QkOhiLNTDhPXVHbi7Q=
288+
github.com/iotaledger/hive.go/crypto v0.0.0-20240117095736-623cd3fb800b h1:1cvLu1wTCkAYj6EaLFRKhXRu8yvnBwn+5iwBBS1aSu4=
289+
github.com/iotaledger/hive.go/crypto v0.0.0-20240117095736-623cd3fb800b/go.mod h1:gsifUt12BCY+momgmC5QYhmG00ffuW0A5T5Sr72wyis=
290+
github.com/iotaledger/hive.go/ds v0.0.0-20240117095736-623cd3fb800b h1:BnUhY6BjzhGCrG/teG7es7RSoscIuW0jaj17CwWi6Rk=
291+
github.com/iotaledger/hive.go/ds v0.0.0-20240117095736-623cd3fb800b/go.mod h1:Ih+78nAgA5QALMvQk3a4SP94W/S/oNXHJTHmf4H9Rn4=
292+
github.com/iotaledger/hive.go/ierrors v0.0.0-20240117095736-623cd3fb800b h1:yRClpQVTOc6eZFF9cFkEoEtqqB1CfCV1KR5k2RP5TfE=
293+
github.com/iotaledger/hive.go/ierrors v0.0.0-20240117095736-623cd3fb800b/go.mod h1:HcE8B5lP96enc/OALTb2/rIIi+yOLouRoHOKRclKmC8=
294+
github.com/iotaledger/hive.go/kvstore v0.0.0-20240117095736-623cd3fb800b h1:qR/vWnnW/FKsbB7AKlWPMu6H7sH4y/Xo1gZVLJOvb30=
295+
github.com/iotaledger/hive.go/kvstore v0.0.0-20240117095736-623cd3fb800b/go.mod h1:ET5O4JuZjsDdyO5DeumF8VKwLascBNdAlmyeXHigD8c=
296+
github.com/iotaledger/hive.go/lo v0.0.0-20240117095736-623cd3fb800b h1:ySqaMG4CO48tSWtPXNfxR+SJ2NOP0J/DyCXmnh0STQk=
297+
github.com/iotaledger/hive.go/lo v0.0.0-20240117095736-623cd3fb800b/go.mod h1:w3abvs2FpXLd8rugaTq5YnT4KbniyulhePRU77F5pCg=
298+
github.com/iotaledger/hive.go/log v0.0.0-20240117095736-623cd3fb800b h1:7XjeQJX9jqBGfIDD7ntNrD9xKwOHJgq1VwHsifBQiCc=
299+
github.com/iotaledger/hive.go/log v0.0.0-20240117095736-623cd3fb800b/go.mod h1:9QT/3ZQB/sNlRgBxw07iJeD4a9e7GIRwNIdanIccx+Q=
300+
github.com/iotaledger/hive.go/runtime v0.0.0-20240117095736-623cd3fb800b h1:D2YC8ciz2DyWHWZ7fKtOLhPsoQKoKJJHjigcA22GUZk=
301+
github.com/iotaledger/hive.go/runtime v0.0.0-20240117095736-623cd3fb800b/go.mod h1:AzqO/YvIdFTZoK8r9UWHvxrqaWeWxDN+rFf+V7b/6gY=
302+
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240117095736-623cd3fb800b h1:PY+nQ8treIKcgEfwtFYZAG2cRPpvJq3Mjj8xx2nNPoY=
303+
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240117095736-623cd3fb800b/go.mod h1:LkvNBG7PeoQgCCSB/eMNX8kSHTXtRN10kFciLdMvcgc=
304+
github.com/iotaledger/hive.go/stringify v0.0.0-20240117095736-623cd3fb800b h1:Fxet0IIzHuA8daQxBxHOXR1YGuCSbzeBVvqdiMsPWG0=
305+
github.com/iotaledger/hive.go/stringify v0.0.0-20240117095736-623cd3fb800b/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs=
306306
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240110125343-5c50e43b71fa h1:/Czrql6nqnvQfUd0JEwM7Pt11Z55ZpiCI1fNiQ4ZmX4=
307307
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240110125343-5c50e43b71fa/go.mod h1:0QsQZN/hld/1Bi32QeHaDAtk8lTI/oSfE0G/8Aj8Znk=
308308
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240110120225-05a4544ca1dd h1:Fg4lm/P7f9ctJZ4HOlZt/R47aTYPse7hby0BFkjcpjM=

pkg/protocol/attestations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (a *Attestations) initRequester() (shutdown func()) {
7878
unsubscribeFromTicker := lo.Batch(
7979
a.protocol.Commitments.WithElements(func(commitment *Commitment) (shutdown func()) {
8080
return commitment.RequestAttestations.WithNonEmptyValue(func(_ bool) (teardown func()) {
81-
if commitment.CumulativeWeight() == 0 {
81+
if commitment.CumulativeWeight.Get() == 0 {
8282
commitment.IsAttested.Set(true)
8383

8484
return nil

pkg/protocol/chain.go

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,6 @@ type Chain struct {
3535
// corresponding blocks in the Engine.
3636
LatestProducedCommitment reactive.Variable[*Commitment]
3737

38-
// ClaimedWeight contains the claimed weight of this chain which is derived from the cumulative weight of the
39-
// LatestCommitment.
40-
ClaimedWeight reactive.Variable[uint64]
41-
42-
// AttestedWeight contains the attested weight of this chain which is derived from the cumulative weight of all
43-
// attestations up to the LatestAttestedCommitment.
44-
AttestedWeight reactive.Variable[uint64]
45-
46-
// VerifiedWeight contains the verified weight of this chain which is derived from the cumulative weight of the
47-
// latest verified commitment.
48-
VerifiedWeight reactive.Variable[uint64]
49-
5038
// WarpSyncMode contains a flag that indicates whether this chain is in warp sync mode.
5139
WarpSyncMode reactive.Variable[bool]
5240

@@ -90,9 +78,6 @@ func newChain(chains *Chains) *Chain {
9078
LatestCommitment: reactive.NewVariable[*Commitment](),
9179
LatestAttestedCommitment: reactive.NewVariable[*Commitment](),
9280
LatestProducedCommitment: reactive.NewVariable[*Commitment](),
93-
ClaimedWeight: reactive.NewVariable[uint64](),
94-
AttestedWeight: reactive.NewVariable[uint64](),
95-
VerifiedWeight: reactive.NewVariable[uint64](),
9681
WarpSyncMode: reactive.NewVariable[bool]().Init(true),
9782
LatestSyncedSlot: reactive.NewVariable[iotago.SlotIndex](),
9883
OutOfSyncThreshold: reactive.NewVariable[iotago.SlotIndex](),
@@ -191,9 +176,6 @@ func (c *Chain) initLogger() (shutdown func()) {
191176
c.LatestSyncedSlot.LogUpdates(c, log.LevelTrace, "LatestSyncedSlot"),
192177
c.OutOfSyncThreshold.LogUpdates(c, log.LevelTrace, "OutOfSyncThreshold"),
193178
c.ForkingPoint.LogUpdates(c, log.LevelTrace, "ForkingPoint", (*Commitment).LogName),
194-
c.ClaimedWeight.LogUpdates(c, log.LevelTrace, "ClaimedWeight"),
195-
c.AttestedWeight.LogUpdates(c, log.LevelTrace, "AttestedWeight"),
196-
c.VerifiedWeight.LogUpdates(c, log.LevelTrace, "VerifiedWeight"),
197179
c.LatestCommitment.LogUpdates(c, log.LevelTrace, "LatestCommitment", (*Commitment).LogName),
198180
c.LatestAttestedCommitment.LogUpdates(c, log.LevelTrace, "LatestAttestedCommitment", (*Commitment).LogName),
199181
c.LatestProducedCommitment.LogUpdates(c, log.LevelDebug, "LatestProducedCommitment", (*Commitment).LogName),
@@ -209,9 +191,6 @@ func (c *Chain) initLogger() (shutdown func()) {
209191
// initDerivedProperties initializes the behavior of this chain by setting up the relations between its properties.
210192
func (c *Chain) initDerivedProperties() (shutdown func()) {
211193
return lo.Batch(
212-
c.deriveClaimedWeight(),
213-
c.deriveVerifiedWeight(),
214-
c.deriveLatestAttestedWeight(),
215194
c.deriveWarpSyncMode(),
216195

217196
c.ForkingPoint.WithValue(c.deriveParentChain),
@@ -233,39 +212,6 @@ func (c *Chain) deriveWarpSyncMode() func() {
233212
}, c.LatestSyncedSlot, c.chains.LatestSeenSlot, c.OutOfSyncThreshold, c.WarpSyncMode.Get()))
234213
}
235214

236-
// deriveClaimedWeight defines how a chain determines its claimed weight (by setting the cumulative weight of the
237-
// latest commitment).
238-
func (c *Chain) deriveClaimedWeight() (shutdown func()) {
239-
return c.ClaimedWeight.DeriveValueFrom(reactive.NewDerivedVariable(func(_ uint64, latestCommitment *Commitment) uint64 {
240-
if latestCommitment == nil {
241-
return 0
242-
}
243-
244-
return latestCommitment.CumulativeWeight()
245-
}, c.LatestCommitment))
246-
}
247-
248-
// deriveLatestAttestedWeight defines how a chain determines its attested weight (by inheriting the cumulative attested
249-
// weight of the latest attested commitment). It uses inheritance instead of simply setting the value as the cumulative
250-
// attested weight can change over time depending on the attestations that are received.
251-
func (c *Chain) deriveLatestAttestedWeight() func() {
252-
return c.LatestAttestedCommitment.WithNonEmptyValue(func(latestAttestedCommitment *Commitment) (shutdown func()) {
253-
return c.AttestedWeight.InheritFrom(latestAttestedCommitment.CumulativeAttestedWeight)
254-
})
255-
}
256-
257-
// deriveVerifiedWeight defines how a chain determines its verified weight (by setting the cumulative weight of the
258-
// latest produced commitment).
259-
func (c *Chain) deriveVerifiedWeight() func() {
260-
return c.VerifiedWeight.DeriveValueFrom(reactive.NewDerivedVariable(func(_ uint64, latestProducedCommitment *Commitment) uint64 {
261-
if latestProducedCommitment == nil {
262-
return 0
263-
}
264-
265-
return latestProducedCommitment.CumulativeWeight()
266-
}, c.LatestProducedCommitment))
267-
}
268-
269215
// deriveChildChains defines how a chain determines its ChildChains (by adding each child to the set).
270216
func (c *Chain) deriveChildChains(child *Chain) func() {
271217
c.ChildChains.Add(child)
@@ -356,24 +302,6 @@ func (c *Chain) dispatchBlockToSpawnedEngine(block *model.Block, src peer.ID) (d
356302
return true
357303
}
358304

359-
// claimedWeight is a getter for the ClaimedWeight variable of this chain, which is internally used to be able to
360-
// "address" the variable across multiple chains in a generic way.
361-
func (c *Chain) claimedWeight() reactive.Variable[uint64] {
362-
return c.ClaimedWeight
363-
}
364-
365-
// verifiedWeight is a getter for the VerifiedWeight variable of this chain, which is internally used to be able to
366-
// "address" the variable across multiple chains in a generic way.
367-
func (c *Chain) verifiedWeight() reactive.Variable[uint64] {
368-
return c.VerifiedWeight
369-
}
370-
371-
// attestedWeight is a getter for the AttestedWeight variable of this chain, which is internally used to be able to
372-
// "address" the variable across multiple chains in a generic way.
373-
func (c *Chain) attestedWeight() reactive.Variable[uint64] {
374-
return c.AttestedWeight
375-
}
376-
377305
// winsTieBreak returns true if this chain wins the tie-break against the other chain (by comparing the IDs of the
378306
// commitments where both chains diverged), which is only used when two chains have exactly the same weight.
379307
func (c *Chain) winsTieBreak(other *Chain) bool {

pkg/protocol/chains.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ func newChains(protocol *Protocol) *Chains {
5050
protocol: protocol,
5151
}
5252

53-
c.HeaviestClaimedCandidate = newHeaviestChainCandidate((*Commitment).weightAddr, c.Main)
54-
c.HeaviestAttestedCandidate = newHeaviestChainCandidate((*Commitment).weightAddr, c.Main)
55-
c.HeaviestVerifiedCandidate = newHeaviestChainCandidate((*Commitment).weightAddr, c.Main)
53+
c.HeaviestClaimedCandidate = newHeaviestChainCandidate(c, (*Commitment).cumulativeWeightAddr)
54+
c.HeaviestAttestedCandidate = newHeaviestChainCandidate(c, (*Commitment).cumulativeAttestedWeightAddr)
55+
c.HeaviestVerifiedCandidate = newHeaviestChainCandidate(c, (*Commitment).cumulativeVerifiedWeightAddr)
5656

5757
shutdown := lo.Batch(
5858
c.initLogger(protocol.NewChildLogger("Chains")),
@@ -143,8 +143,10 @@ func (c *Chains) updateMeasuredSlot(latestSeenSlot iotago.SlotIndex) (teardown f
143143
func (c *Chains) deriveLatestSeenSlot(protocol *Protocol) func() {
144144
return protocol.Engines.Main.WithNonEmptyValue(func(mainEngine *engine.Engine) (shutdown func()) {
145145
return lo.Batch(
146-
mainEngine.Initialized.OnTrigger(func() {
147-
c.LatestSeenSlot.Set(mainEngine.LatestCommitment.Get().Slot())
146+
c.WithInitializedEngines(func(_ *Chain, engine *engine.Engine) (shutdown func()) {
147+
return engine.LatestCommitment.OnUpdate(func(_ *model.Commitment, latestCommitment *model.Commitment) {
148+
c.LatestSeenSlot.Set(latestCommitment.Slot())
149+
})
148150
}),
149151

150152
protocol.Network.OnBlockReceived(func(block *model.Block, src peer.ID) {
@@ -170,7 +172,7 @@ func increasing[T cmp.Ordered](currentValue T, newValue T) T {
170172
}
171173

172174
const (
173-
chainSwitchingThreshold iotago.SlotIndex = 10
175+
chainSwitchingThreshold iotago.SlotIndex = 3
174176

175177
chainSwitchingMeasurementOffset iotago.SlotIndex = 1
176178
)

0 commit comments

Comments
 (0)