Skip to content

Commit 2fa9fc5

Browse files
committed
update expected ErrNotFound to ErrUnknownSnapshotReference
1 parent 01b9246 commit 2fa9fc5

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

access/validator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import (
55
"fmt"
66

77
"github.com/onflow/flow-go/crypto"
8+
"github.com/onflow/flow-go/state"
89

910
"github.com/onflow/cadence/runtime/parser"
1011

1112
"github.com/onflow/flow-go/model/flow"
1213
"github.com/onflow/flow-go/state/protocol"
13-
"github.com/onflow/flow-go/storage"
1414
)
1515

1616
type Blocks interface {
@@ -29,7 +29,7 @@ func NewProtocolStateBlocks(state protocol.State) *ProtocolStateBlocks {
2929
func (b *ProtocolStateBlocks) HeaderByID(id flow.Identifier) (*flow.Header, error) {
3030
header, err := b.state.AtBlockID(id).Head()
3131
if err != nil {
32-
if errors.Is(err, storage.ErrNotFound) {
32+
if errors.Is(err, state.ErrUnknownSnapshotReference) {
3333
return nil, nil
3434
}
3535

engine/consensus/ingestion/core.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/onflow/flow-go/module/metrics"
1919
"github.com/onflow/flow-go/module/signature"
2020
"github.com/onflow/flow-go/module/trace"
21+
"github.com/onflow/flow-go/state"
2122
"github.com/onflow/flow-go/state/protocol"
2223
"github.com/onflow/flow-go/storage"
2324
)
@@ -158,7 +159,7 @@ func (e *Core) validateGuarantors(guarantee *flow.CollectionGuarantee) error {
158159
snapshot := e.state.AtBlockID(guarantee.ReferenceBlockID)
159160
cluster, err := snapshot.Epochs().Current().ClusterByChainID(guarantee.ChainID)
160161
// reference block not found
161-
if errors.Is(err, storage.ErrNotFound) {
162+
if errors.Is(err, state.ErrUnknownSnapshotReference) {
162163
return engine.NewUnverifiableInputError(
163164
"could not get clusters with chainID %v for unknown reference block (id=%x): %w", guarantee.ChainID, guarantee.ReferenceBlockID, err)
164165
}
@@ -212,7 +213,7 @@ func (e *Core) validateOrigin(originID flow.Identifier, guarantee *flow.Collecti
212213
valid, err := protocol.IsNodeAuthorizedWithRoleAt(refState, originID, flow.RoleCollection)
213214
if err != nil {
214215
// collection with an unknown reference block is unverifiable
215-
if errors.Is(err, storage.ErrNotFound) {
216+
if errors.Is(err, state.ErrUnknownSnapshotReference) {
216217
return engine.NewUnverifiableInputError("could not get origin (id=%x) for unknown reference block (id=%x): %w", originID, guarantee.ReferenceBlockID, err)
217218
}
218219
return fmt.Errorf("unexpected error checking collection origin %x at reference block %x: %w", originID, guarantee.ReferenceBlockID, err)

module/validation/receipt_validator.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/onflow/flow-go/engine"
99
"github.com/onflow/flow-go/model/flow"
1010
"github.com/onflow/flow-go/module/signature"
11+
"github.com/onflow/flow-go/state"
1112
"github.com/onflow/flow-go/state/fork"
1213
"github.com/onflow/flow-go/state/protocol"
1314
"github.com/onflow/flow-go/storage"
@@ -108,7 +109,7 @@ func (v *receiptValidator) fetchResult(resultID flow.Identifier) (*flow.Executio
108109
func (v *receiptValidator) subgraphCheck(result *flow.ExecutionResult, prevResult *flow.ExecutionResult) error {
109110
block, err := v.state.AtBlockID(result.BlockID).Head()
110111
if err != nil {
111-
if errors.Is(err, storage.ErrNotFound) {
112+
if errors.Is(err, state.ErrUnknownSnapshotReference) {
112113
return engine.NewInvalidInputErrorf("no block found %v %w", result.BlockID, err)
113114
}
114115
return err

state/protocol/util.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func IsNodeAuthorizedAt(snapshot Snapshot, id flow.Identifier) (bool, error) {
2525
// IsNodeAuthorizedWithRoleAt returns whether the node with the given ID is a valid
2626
// un-ejected network participant with the specified role as of the given state snapshot.
2727
// Expected errors during normal operations:
28-
// - storage.ErrNotFound if snapshot references an unknown block
28+
// - state.ErrUnknownSnapshotReference if snapshot references an unknown block
2929
//
3030
// All other errors are unexpected and potential symptoms of internal state corruption.
3131
func IsNodeAuthorizedWithRoleAt(snapshot Snapshot, id flow.Identifier, role flow.Role) (bool, error) {
@@ -41,7 +41,7 @@ func IsNodeAuthorizedWithRoleAt(snapshot Snapshot, id flow.Identifier, role flow
4141
// CheckNodeStatusAt returns whether the node with the given ID is a valid identity at the given
4242
// state snapshot, and satisfies all checks.
4343
// Expected errors during normal operations:
44-
// - storage.ErrNotFound if snapshot references an unknown block
44+
// - state.ErrUnknownSnapshotReference if snapshot references an unknown block
4545
//
4646
// All other errors are unexpected and potential symptoms of internal state corruption.
4747
func CheckNodeStatusAt(snapshot Snapshot, id flow.Identifier, checks ...flow.IdentityFilter) (bool, error) {
@@ -93,7 +93,7 @@ func PreviousEpochExists(snap Snapshot) (bool, error) {
9393
// FindGuarantors decodes the signer indices from the guarantee, and finds the guarantor identifiers from protocol state
9494
// Expected Error returns during normal operations:
9595
// - signature.InvalidSignerIndicesError if `signerIndices` does not encode a valid set of collection guarantors
96-
// - storage.ErrNotFound if the guarantee's ReferenceBlockID is not found
96+
// - state.ErrUnknownSnapshotReference if guarantee references an unknown block
9797
// - protocol.ErrNextEpochNotCommitted if epoch has not been committed yet
9898
// - protocol.ErrClusterNotFound if cluster is not found by the given chainID
9999
func FindGuarantors(state State, guarantee *flow.CollectionGuarantee) ([]flow.Identifier, error) {

0 commit comments

Comments
 (0)