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 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
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 @@ -88,6 +89,7 @@ func init() {
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)")
flag.Uint64Var(&numViewsPerSecond, "target-view-rate", 1, "target number of views per second")
flag.BoolVar(&profiler, "profiler", DefaultProfiler, "whether to enable the auto-profiler")
flag.BoolVar(&profileUploader, "profile-uploader", DefaultProfileUploader, "whether to upload profiles to the cloud")
flag.BoolVar(&tracing, "tracing", DefaultTracing, "whether to enable low-overhead tracing in flow")
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
16 changes: 14 additions & 2 deletions 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 @@ -1160,6 +1169,9 @@ func BootstrapNetwork(networkConf NetworkConfig, bootstrapDir string, chainID fl

dkgOffsetView := rootHeader.View + networkConf.ViewsInStakingAuction - 1

// target number of seconds in epoch
targetDuration := networkConf.ViewsInEpoch / networkConf.ViewsPerSecond

// generate epoch service events
epochSetup := &flow.EpochSetup{
Counter: epochCounter,
Expand All @@ -1171,8 +1183,8 @@ func BootstrapNetwork(networkConf NetworkConfig, bootstrapDir string, chainID fl
Participants: participants.ToSkeleton(),
Assignments: clusterAssignments,
RandomSource: randomSource,
TargetDuration: networkConf.ViewsInEpoch, // 1view/s
TargetEndTime: uint64(time.Now().Unix()) + networkConf.ViewsInEpoch,
TargetDuration: targetDuration,
TargetEndTime: uint64(time.Now().Unix()) + targetDuration,
}

epochCommit := &flow.EpochCommit{
Expand Down
Loading