diff --git a/integration/localnet/builder/bootstrap.go b/integration/localnet/builder/bootstrap.go index d1d63971d2b..27749a39f99 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 @@ -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") @@ -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 250e7eabe53..a84a3c529b0 100644 --- a/integration/testnet/network.go +++ b/integration/testnet/network.go @@ -119,6 +119,7 @@ const ( DefaultViewsInStakingAuction uint64 = 5 DefaultViewsInDKGPhase uint64 = 50 DefaultViewsInEpoch uint64 = 200 + DefaultViewsPerSecond uint64 = 1 DefaultEpochCommitSafetyThreshold uint64 = 20 DefaultEpochExtensionViewCount uint64 = 50 @@ -430,6 +431,7 @@ type NetworkConfig struct { ViewsInDKGPhase uint64 ViewsInStakingAuction uint64 ViewsInEpoch uint64 + ViewsPerSecond uint64 EpochCommitSafetyThreshold uint64 KVStoreFactory func(epochStateID flow.Identifier) (protocol_state.KVStoreAPI, error) } @@ -444,6 +446,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) @@ -483,6 +486,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 @@ -1161,6 +1170,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, @@ -1172,8 +1184,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{