Skip to content

Commit ba0c30b

Browse files
durkmurderjordanschalm
authored andcommitted
Implemented a fallback for DecodeSignerIDs when IdentitiesByEpoch fails with sentinel
1 parent d352e86 commit ba0c30b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

consensus/hotstuff/signature/block_signer_decoder.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,19 @@ func (b *BlockSignerDecoder) DecodeSignerIDs(header *flow.Header) (flow.Identifi
3636
return []flow.Identifier{}, nil
3737
}
3838

39+
// we will use IdentitiesByEpoch since it's a faster call and avoids DB lookup
3940
members, err := b.IdentitiesByEpoch(header.ParentView)
4041
if err != nil {
4142
if errors.Is(err, model.ErrViewForUnknownEpoch) {
42-
return nil, fmt.Errorf("could not retrieve consensus participants for view %d: %w", header.ParentView, err)
43+
// possibly, we request epoch which is far behind in the past, in this case we won't have it in cache.
44+
// try asking by parent ID
45+
members, err = b.IdentitiesByBlock(header.ParentID)
46+
if err != nil {
47+
return nil, fmt.Errorf("could not retrieve identities for block %x with QC view %d for parent %x: %w", header.ID(), header.ParentView, header.ParentID, err)
48+
}
49+
} else {
50+
return nil, fmt.Errorf("unexpected error retrieving identities for block %v: %w", header.ID(), err)
4351
}
44-
return nil, fmt.Errorf("unexpected error retrieving identities for block %v: %w", header.ID(), err)
4552
}
4653
signerIDs, err := signature.DecodeSignerIndicesToIdentifiers(members.NodeIDs(), header.ParentVoterIndices)
4754
if err != nil {

consensus/hotstuff/signature/block_signer_decoder_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/onflow/flow-go/model/flow"
1414
"github.com/onflow/flow-go/model/flow/order"
1515
"github.com/onflow/flow-go/module/signature"
16+
"github.com/onflow/flow-go/state"
1617
"github.com/onflow/flow-go/utils/unittest"
1718
)
1819

0 commit comments

Comments
 (0)