From ea90be96ca42b63b9e4255849bd0720502537cbc Mon Sep 17 00:00:00 2001 From: Peter Argue <89119817+peterargue@users.noreply.github.com> Date: Fri, 6 Sep 2024 11:49:55 -0700 Subject: [PATCH 1/3] [Benchnet] Allow configuring view times faster than 1s --- integration/localnet/builder/bootstrap.go | 5 +++++ integration/testnet/network.go | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/integration/localnet/builder/bootstrap.go b/integration/localnet/builder/bootstrap.go index 200926bf83a..6f7d5f8fe24 100644 --- a/integration/localnet/builder/bootstrap.go +++ b/integration/localnet/builder/bootstrap.go @@ -62,6 +62,7 @@ var ( numViewsInStakingPhase uint64 numViewsInDKGPhase uint64 numViewsEpoch uint64 + numViewsPerSecond uint64 epochCommitSafetyThreshold uint64 profiler bool profileUploader bool @@ -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") 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)") @@ -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)) } diff --git a/integration/testnet/network.go b/integration/testnet/network.go index bc5fdc2f48b..dff06958049 100644 --- a/integration/testnet/network.go +++ b/integration/testnet/network.go @@ -118,6 +118,7 @@ const ( DefaultViewsInStakingAuction uint64 = 5 DefaultViewsInDKGPhase uint64 = 50 DefaultViewsInEpoch uint64 = 200 + DefaultViewsPerSecond uint64 = 1 DefaultEpochCommitSafetyThreshold uint64 = 20 DefaultEpochExtensionViewCount uint64 = 50 @@ -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) } @@ -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) @@ -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 @@ -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, } From 7bbeb6e4c6f2cfdc54428b35c932e810362104d7 Mon Sep 17 00:00:00 2001 From: Peter Argue <89119817+peterargue@users.noreply.github.com> Date: Fri, 6 Sep 2024 12:45:58 -0700 Subject: [PATCH 2/3] update flag name to target-view-rate --- integration/localnet/builder/bootstrap.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/localnet/builder/bootstrap.go b/integration/localnet/builder/bootstrap.go index 6f7d5f8fe24..42155923c54 100644 --- a/integration/localnet/builder/bootstrap.go +++ b/integration/localnet/builder/bootstrap.go @@ -86,10 +86,10 @@ 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") 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") From df3e47aa04efe9a2a78399616df9f78c34eaaea6 Mon Sep 17 00:00:00 2001 From: Peter Argue <89119817+peterargue@users.noreply.github.com> Date: Fri, 6 Sep 2024 13:21:16 -0700 Subject: [PATCH 3/3] fix end time calculation --- integration/testnet/network.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/integration/testnet/network.go b/integration/testnet/network.go index dff06958049..40c88295073 100644 --- a/integration/testnet/network.go +++ b/integration/testnet/network.go @@ -1169,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, @@ -1180,8 +1183,8 @@ func BootstrapNetwork(networkConf NetworkConfig, bootstrapDir string, chainID fl Participants: participants.ToSkeleton(), Assignments: clusterAssignments, RandomSource: randomSource, - TargetDuration: networkConf.ViewsInEpoch / networkConf.ViewsPerSecond, - TargetEndTime: uint64(time.Now().Unix()) + networkConf.ViewsInEpoch, + TargetDuration: targetDuration, + TargetEndTime: uint64(time.Now().Unix()) + targetDuration, } epochCommit := &flow.EpochCommit{