From 248bfabee4bdbfb1e752f998a9d6b54a1b7ed8c2 Mon Sep 17 00:00:00 2001 From: Diego Date: Fri, 6 Dec 2024 20:47:43 +0900 Subject: [PATCH] Fix apply only forced changes --- dot/sync/block_importer.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dot/sync/block_importer.go b/dot/sync/block_importer.go index f00b9316d5..bbfa3d7853 100644 --- a/dot/sync/block_importer.go +++ b/dot/sync/block_importer.go @@ -117,21 +117,24 @@ func (b *blockImporter) checkAndApplyForcedAuthChanges(blockData types.BlockData for i := range consensusDigests { digest := consensusDigests[i] - switch digest.ConsensusEngineID { - case types.GrandpaEngineID: + if digest.ConsensusEngineID == types.GrandpaEngineID { data := types.NewGrandpaConsensusDigest() err := scale.Unmarshal(digest.Data, &data) if err != nil { return fmt.Errorf("unmarshaling grandpa consensus digest: %w", err) } - err = b.grandpaState.HandleGRANDPADigest(header, data) + digestValue, err := data.Value() if err != nil { - return fmt.Errorf("handling grandpa digest: %w", err) + return fmt.Errorf("getting digest value: %w", err) + } + + if _, ok := digestValue.(types.GrandpaForcedChange); ok { + err = b.grandpaState.HandleGRANDPADigest(header, data) + if err != nil { + return fmt.Errorf("handling grandpa digest: %w", err) + } } - default: - // Will be handle by the block importer - continue } }