From ddc65ede027f33688a8d437fa5c02672d3e2ad89 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 24 Dec 2024 17:39:05 +1000 Subject: [PATCH 1/2] Fall back to the confirmed state if the agreed state is nil. This way, the block validators will get updates even for non-staked nodes. Fixes NIT-3009 --- staker/bold/bold_staker.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index 1a8eed80fa..539eb80abf 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -260,6 +260,13 @@ func (b *BOLDStaker) Start(ctxIn context.Context) { } if confirmedGlobalState != nil { + if agreedGlobalState == nil { + // If we don't have a latest agreed global state, we should fall back to + // using the latest confirmed global state. + for _, notifier := range b.stakedNotifiers { + notifier.UpdateLatestStaked(confirmedMsgCount, *confirmedGlobalState) + } + } for _, notifier := range b.confirmedNotifiers { notifier.UpdateLatestConfirmed(confirmedMsgCount, *confirmedGlobalState) } From 2fe54e77860edc5d3dc1293cbbecc04332c5e3d5 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Mon, 30 Dec 2024 10:20:46 +0900 Subject: [PATCH 2/2] Rearrange the order of agreed and confirmed This way, the behavior of falling back to the confirmed state is more readable. --- staker/bold/bold_staker.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index 539eb80abf..063f7b9719 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -244,29 +244,29 @@ func (b *BOLDStaker) Start(ctxIn context.Context) { if err != nil { log.Warn("error updating latest wasm module root", "err", err) } + confirmedMsgCount, confirmedGlobalState, err := b.getLatestState(ctx, true) + if err != nil { + log.Error("staker: error checking latest confirmed", "err", err) + } + agreedMsgCount, agreedGlobalState, err := b.getLatestState(ctx, false) if err != nil { log.Error("staker: error checking latest agreed", "err", err) } + if agreedGlobalState == nil { + // If we don't have a latest agreed global state, we should fall back to + // using the latest confirmed global state. + agreedGlobalState = confirmedGlobalState + agreedMsgCount = confirmedMsgCount + } if agreedGlobalState != nil { for _, notifier := range b.stakedNotifiers { notifier.UpdateLatestStaked(agreedMsgCount, *agreedGlobalState) } } - confirmedMsgCount, confirmedGlobalState, err := b.getLatestState(ctx, true) - if err != nil { - log.Error("staker: error checking latest confirmed", "err", err) - } if confirmedGlobalState != nil { - if agreedGlobalState == nil { - // If we don't have a latest agreed global state, we should fall back to - // using the latest confirmed global state. - for _, notifier := range b.stakedNotifiers { - notifier.UpdateLatestStaked(confirmedMsgCount, *confirmedGlobalState) - } - } for _, notifier := range b.confirmedNotifiers { notifier.UpdateLatestConfirmed(confirmedMsgCount, *confirmedGlobalState) }