Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Benchnet] Allow configuring view times faster than 1s #6446

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions integration/localnet/builder/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ var (
numViewsInStakingPhase uint64
numViewsInDKGPhase uint64
numViewsEpoch uint64
numViewsPerSecond uint64
epochCommitSafetyThreshold uint64
profiler bool
profileUploader bool
Expand All @@ -85,6 +86,7 @@ func init() {
flag.IntVar(&testExecutionCount, "test-execution", DefaultTestExecutionCount, "number of test execution")
flag.UintVar(&nClusters, "nclusters", DefaultNClusters, "number of collector clusters")
flag.Uint64Var(&numViewsEpoch, "epoch-length", 10000, "number of views in epoch")
flag.Uint64Var(&numViewsPerSecond, "epoch-view-rate", 1, "number of views per second")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to call this target-view-rate because its describes a property of the network across all epochs (in comparison, the other parameters epoch-* usually specify something for one epoch, like the views within one epoch)

flag.Uint64Var(&numViewsInStakingPhase, "epoch-staking-phase-length", 2000, "number of views in epoch staking phase")
flag.Uint64Var(&numViewsInDKGPhase, "epoch-dkg-phase-length", 2000, "number of views in epoch dkg phase")
flag.Uint64Var(&epochCommitSafetyThreshold, "epoch-commit-safety-threshold", 1000, "number of views for safety threshold T (assume: one finalization occurs within T blocks)")
Expand Down Expand Up @@ -127,6 +129,9 @@ func main() {
if numViewsEpoch != 0 {
flowNetworkOpts = append(flowNetworkOpts, testnet.WithViewsInEpoch(numViewsEpoch))
}
if numViewsPerSecond != 0 {
flowNetworkOpts = append(flowNetworkOpts, testnet.WithViewsPerSecond(numViewsPerSecond))
}
if numViewsInStakingPhase != 0 {
flowNetworkOpts = append(flowNetworkOpts, testnet.WithViewsInStakingAuction(numViewsInStakingPhase))
}
Expand Down
11 changes: 10 additions & 1 deletion integration/testnet/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const (
DefaultViewsInStakingAuction uint64 = 5
DefaultViewsInDKGPhase uint64 = 50
DefaultViewsInEpoch uint64 = 200
DefaultViewsPerSecond uint64 = 1
DefaultEpochCommitSafetyThreshold uint64 = 20
DefaultEpochExtensionViewCount uint64 = 50

Expand Down Expand Up @@ -429,6 +430,7 @@ type NetworkConfig struct {
ViewsInDKGPhase uint64
ViewsInStakingAuction uint64
ViewsInEpoch uint64
ViewsPerSecond uint64
EpochCommitSafetyThreshold uint64
KVStoreFactory func(epochStateID flow.Identifier) (protocol_state.KVStoreAPI, error)
}
Expand All @@ -443,6 +445,7 @@ func NewNetworkConfig(name string, nodes NodeConfigs, opts ...NetworkConfigOpt)
ViewsInStakingAuction: DefaultViewsInStakingAuction,
ViewsInDKGPhase: DefaultViewsInDKGPhase,
ViewsInEpoch: DefaultViewsInEpoch,
ViewsPerSecond: DefaultViewsPerSecond,
EpochCommitSafetyThreshold: DefaultEpochCommitSafetyThreshold,
KVStoreFactory: func(epochStateID flow.Identifier) (protocol_state.KVStoreAPI, error) {
return kvstore.NewDefaultKVStore(DefaultEpochCommitSafetyThreshold, DefaultEpochExtensionViewCount, epochStateID)
Expand Down Expand Up @@ -482,6 +485,12 @@ func WithViewsInEpoch(views uint64) func(*NetworkConfig) {
}
}

func WithViewsPerSecond(views uint64) func(*NetworkConfig) {
return func(config *NetworkConfig) {
config.ViewsPerSecond = views
}
}

func WithViewsInDKGPhase(views uint64) func(*NetworkConfig) {
return func(config *NetworkConfig) {
config.ViewsInDKGPhase = views
Expand Down Expand Up @@ -1171,7 +1180,7 @@ func BootstrapNetwork(networkConf NetworkConfig, bootstrapDir string, chainID fl
Participants: participants.ToSkeleton(),
Assignments: clusterAssignments,
RandomSource: randomSource,
TargetDuration: networkConf.ViewsInEpoch, // 1view/s
TargetDuration: networkConf.ViewsInEpoch / networkConf.ViewsPerSecond,
TargetEndTime: uint64(time.Now().Unix()) + networkConf.ViewsInEpoch,
}

Expand Down
Loading