diff --git a/cmd/scaffold.go b/cmd/scaffold.go index 142f2d55c6d..9e57ed37532 100644 --- a/cmd/scaffold.go +++ b/cmd/scaffold.go @@ -169,10 +169,6 @@ func (fnb *FlowNodeBuilder) BaseFlags() { fnb.flags.StringVarP(&fnb.BaseConfig.BootstrapDir, "bootstrapdir", "b", defaultConfig.BootstrapDir, "path to the bootstrap directory") fnb.flags.StringVarP(&fnb.BaseConfig.datadir, "datadir", "d", defaultConfig.datadir, "directory to store the protocol database") - var rejectPebbleDir rejectPebbleDirValue - fnb.flags.VarP(rejectPebbleDir, "pebble-dir", "", "DEPRECATED") - _ = fnb.flags.MarkHidden("pebble-dir") - fnb.flags.StringVar(&fnb.BaseConfig.pebbleCheckpointsDir, "pebble-checkpoints-dir", defaultConfig.pebbleCheckpointsDir, "directory to store the checkpoints for the public pebble database (protocol state)") fnb.flags.StringVar(&fnb.BaseConfig.secretsdir, "secretsdir", defaultConfig.secretsdir, "directory to store private database (secrets)") fnb.flags.StringVarP(&fnb.BaseConfig.level, "loglevel", "l", defaultConfig.level, "level for logging output") @@ -285,17 +281,6 @@ func (fnb *FlowNodeBuilder) BaseFlags() { "Disables calling the transaction fee deduction. This is only for testing purposes. To disable fees on a network it is better to set the fee price to 0.0 .") } -// TODO: remove after mainnet27 spork -// this struct is to reject the deprecated --pebble-dir flag -type rejectPebbleDirValue struct{} - -func (rejectPebbleDirValue) String() string { return "" } -func (rejectPebbleDirValue) Set(string) error { - return fmt.Errorf("the --pebble-dir flag is deprecated. Please remove the flag. " + - "Database will be stored in the location pointed by the --datadir flag which defaults to /data/protocol if not specified.") -} -func (rejectPebbleDirValue) Type() string { return "string" } - func (fnb *FlowNodeBuilder) EnqueuePingService() { fnb.Component("ping service", func(node *NodeConfig) (module.ReadyDoneAware, error) { pingLibP2PProtocolID := protocols.PingProtocolId(node.SporkID) diff --git a/model/flow/epoch.go b/model/flow/epoch.go index 41e12df481a..c8fca83ee1d 100644 --- a/model/flow/epoch.go +++ b/model/flow/epoch.go @@ -397,25 +397,25 @@ func NewEpochCommit(untrusted UntrustedEpochCommit) (*EpochCommit, error) { if len(untrusted.ClusterQCs) == 0 { return nil, fmt.Errorf("cluster QCs list must not be empty") } - // TODO(mainnet27): remove this conditional: https://github.com/onflow/flow-go/issues/6772 - if untrusted.DKGIndexMap != nil { - // enforce invariant: len(DKGParticipantKeys) == len(DKGIndexMap) - n := len(untrusted.DKGIndexMap) // size of the DKG committee - if len(untrusted.DKGParticipantKeys) != n { - return nil, fmt.Errorf("number of %d Random Beacon key shares is inconsistent with number of DKG participants (len=%d)", len(untrusted.DKGParticipantKeys), len(untrusted.DKGIndexMap)) - } + if untrusted.DKGIndexMap == nil { + return nil, fmt.Errorf("DKG index map must not be nil") + } + // enforce invariant: len(DKGParticipantKeys) == len(DKGIndexMap) + n := len(untrusted.DKGIndexMap) // size of the DKG committee + if len(untrusted.DKGParticipantKeys) != n { + return nil, fmt.Errorf("number of %d Random Beacon key shares is inconsistent with number of DKG participants (len=%d)", len(untrusted.DKGParticipantKeys), len(untrusted.DKGIndexMap)) + } - // enforce invariant: DKGIndexMap values form the set {0, 1, ..., n-1} where n=len(DKGParticipantKeys) - encounteredIndex := make([]bool, n) - for _, index := range untrusted.DKGIndexMap { - if index < 0 || index >= n { - return nil, fmt.Errorf("index %d is outside allowed range [0,n-1] for a DKG committee of size n=%d", index, n) - } - if encounteredIndex[index] { - return nil, fmt.Errorf("duplicated DKG index %d", index) - } - encounteredIndex[index] = true + // enforce invariant: DKGIndexMap values form the set {0, 1, ..., n-1} where n=len(DKGParticipantKeys) + encounteredIndex := make([]bool, n) + for _, index := range untrusted.DKGIndexMap { + if index < 0 || index >= n { + return nil, fmt.Errorf("index %d is outside allowed range [0,n-1] for a DKG committee of size n=%d", index, n) + } + if encounteredIndex[index] { + return nil, fmt.Errorf("duplicated DKG index %d", index) } + encounteredIndex[index] = true } return &EpochCommit{ diff --git a/model/flow/epoch_test.go b/model/flow/epoch_test.go index 815a8c5de6f..b1cae07b69e 100644 --- a/model/flow/epoch_test.go +++ b/model/flow/epoch_test.go @@ -16,21 +16,11 @@ func TestMalleability(t *testing.T) { t.Run("EpochSetup", func(t *testing.T) { unittest.RequireEntityNonMalleable(t, unittest.EpochSetupFixture()) }) - t.Run("EpochCommit with nil DKGIndexMap", func(t *testing.T) { - require.Nil(t, unittest.EpochCommitFixture().DKGIndexMap) // sanity check that the fixture has left `DKGIndexMap` nil - unittest.RequireEntityNonMalleable(t, unittest.EpochCommitFixture(), - // We pin the `DKGIndexMap` to the current value (nil), so `MalleabilityChecker` will not mutate this field: - unittest.WithPinnedField("DKGIndexMap"), - ) - }) - t.Run("EpochCommit with proper DKGIndexMap", func(t *testing.T) { checker := unittest.NewMalleabilityChecker(unittest.WithFieldGenerator("DKGIndexMap", func() flow.DKGIndexMap { return flow.DKGIndexMap{unittest.IdentifierFixture(): 0, unittest.IdentifierFixture(): 1} })) - err := checker.CheckEntity(unittest.EpochCommitFixture(func(commit *flow.EpochCommit) { - commit.DKGIndexMap = flow.DKGIndexMap{unittest.IdentifierFixture(): 0, unittest.IdentifierFixture(): 1} - })) + err := checker.CheckEntity(unittest.EpochCommitFixture()) require.NoError(t, err) }) t.Run("EpochRecover", func(t *testing.T) { @@ -671,6 +661,20 @@ func TestNewEpochCommit(t *testing.T) { require.Contains(t, err.Error(), "DKG group key must not be nil") }) + t.Run("nil DKGIndexMap", func(t *testing.T) { + untrusted := flow.UntrustedEpochCommit{ + Counter: 1, + ClusterQCs: validClusterQCs, + DKGGroupKey: validDKGGroupKey, + DKGParticipantKeys: make([]crypto.PublicKey, 0), + DKGIndexMap: nil, + } + commit, err := flow.NewEpochCommit(untrusted) + require.Error(t, err) + require.Nil(t, commit) + require.Contains(t, err.Error(), "DKG index map must not be nil") + }) + t.Run("empty list of cluster QCs", func(t *testing.T) { untrusted := flow.UntrustedEpochCommit{ Counter: 1, diff --git a/model/flow/service_event.go b/model/flow/service_event.go index 325665c7cd7..3602268dc7a 100644 --- a/model/flow/service_event.go +++ b/model/flow/service_event.go @@ -186,7 +186,7 @@ func (marshaller marshallerImpl) UnmarshalWithType(b []byte, eventType ServiceEv if err != nil { return ServiceEvent{}, fmt.Errorf( - "failed to unmarshal to service event ot type %s: %w", + "failed to unmarshal to service event of type %s: %w", eventType, err, ) diff --git a/storage/store/headers.go b/storage/store/headers.go index 8fd1210d76d..27967c2991b 100644 --- a/storage/store/headers.go +++ b/storage/store/headers.go @@ -234,10 +234,10 @@ func (h *Headers) ByParentID(parentID flow.Identifier) ([]*flow.Header, error) { } // BlockIDByView returns the block ID that is certified at the given view. It is an optimized -// version of `ByView` that skips retrieving the block. Expected errors during normal operations: -// - `[storage.ErrNotFound] if no certified block is known at given view. +// version of `ByView` that skips retrieving the block. // -// NOTE: this method is not available until next spork (mainnet27) or a migration that builds the index. +// Expected errors during normal operations: +// - [storage.ErrNotFound] if no certified block is known at given view. func (h *Headers) BlockIDByView(view uint64) (flow.Identifier, error) { blockID, err := h.viewCache.Get(h.db.Reader(), view) if err != nil { diff --git a/utils/unittest/fixtures.go b/utils/unittest/fixtures.go index fad9543eb5c..553c9e467be 100644 --- a/utils/unittest/fixtures.go +++ b/utils/unittest/fixtures.go @@ -2329,6 +2329,7 @@ func EpochCommitFixture(opts ...func(*flow.EpochCommit)) *flow.EpochCommit { ClusterQCs: flow.ClusterQCVoteDatasFromQCs(QuorumCertificatesWithSignerIDsFixtures(1)), DKGGroupKey: KeyFixture(crypto.BLSBLS12381).PublicKey(), DKGParticipantKeys: PublicKeysFixture(2, crypto.BLSBLS12381), + DKGIndexMap: flow.DKGIndexMap{IdentifierFixture(): 0, IdentifierFixture(): 1}, } for _, apply := range opts { apply(commit)