Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions cmd/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
34 changes: 17 additions & 17 deletions model/flow/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
26 changes: 15 additions & 11 deletions model/flow/epoch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion model/flow/service_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
6 changes: 3 additions & 3 deletions storage/store/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions utils/unittest/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
for _, apply := range opts {
apply(commit)
Expand Down
Loading