Skip to content

Commit

Permalink
Merge pull request #64 from dmkozh/high_traffic_mission
Browse files Browse the repository at this point in the history
Add new missions that trigger surge pricing/limiter at high volume traffic
  • Loading branch information
marta-lokhova authored Oct 3, 2022
2 parents 72aa4eb + 229190d commit 5884ad7
Show file tree
Hide file tree
Showing 14 changed files with 211 additions and 14 deletions.
4 changes: 4 additions & 0 deletions src/App/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ let main argv =
numTxs = 100000
spikeSize = 100000
spikeInterval = 0
maxFeeRate = Some(1000)
skipLowFeeTxs = false
numNodes = 3
namespaceProperty = ns
logLevels = ll
Expand Down Expand Up @@ -458,6 +460,8 @@ let main argv =
numTxs = mission.NumTxs
spikeSize = mission.SpikeSize
spikeInterval = mission.SpikeInterval
maxFeeRate = Some(1000)
skipLowFeeTxs = false
numNodes = mission.NumNodes
namespaceProperty = ns
logLevels = ll
Expand Down
2 changes: 2 additions & 0 deletions src/FSLibrary.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ let ctx : MissionContext =
numTxs = 1000
spikeSize = 1000
spikeInterval = 10
maxFeeRate = Some(1000)
skipLowFeeTxs = false
numNodes = 100
namespaceProperty = "stellar-supercluster"
logLevels = { LogDebugPartitions = []; LogTracePartitions = [] }
Expand Down
3 changes: 3 additions & 0 deletions src/FSLibrary/FSLibrary.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<Compile Include="MissionLoadGeneration.fs" />
<Compile Include="MissionInMemoryMode.fs" />
<Compile Include="MissionLoadGenerationWithSpikes.fs" />
<Compile Include="MissionLoadGenerationWithTxSetLimit.fs" />
<Compile Include="MissionBenchmarkBaseline.fs" />
<Compile Include="MissionBenchmarkConsensusOnly.fs" />
<Compile Include="MissionBenchmarkIncreaseTxRate.fs" />
Expand All @@ -53,11 +54,13 @@
<Compile Include="MissionHistoryTestnetMinimumCatchup.fs" />
<Compile Include="MissionHistoryTestnetParallelCatchup.fs" />
<Compile Include="MissionHistoryTestnetPerformance.fs" />
<Compile Include="MissionMixedImageLoadGeneration.fs" />
<Compile Include="MissionVersionMixConsensus.fs" />
<Compile Include="MissionVersionNewCatchupToOld.fs" />
<Compile Include="MissionVersionOldCatchupToNew.fs" />
<Compile Include="MissionProtocolUpgradeTestnet.fs" />
<Compile Include="MissionProtocolUpgradePubnet.fs" />
<Compile Include="MissionProtocolUpgradeWithLoad.fs" />
<Compile Include="MissionDatabaseInplaceUpgrade.fs" />
<Compile Include="MissionAcceptanceUnitTests.fs" />
<Compile Include="StellarMission.fs" />
Expand Down
4 changes: 3 additions & 1 deletion src/FSLibrary/MissionBenchmarkIncreaseTxRate.fs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ let benchmarkIncreaseTxRate (context: MissionContext) =
spikeinterval = context.spikeInterval
txrate = txRate
offset = 0
batchsize = 100 }
batchsize = 100
maxfeerate = None
skiplowfeetxs = false }

formation.RunLoadgen coreSet loadGen)
38 changes: 38 additions & 0 deletions src/FSLibrary/MissionLoadGenerationWithTxSetLimit.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2022 Stellar Development Foundation and contributors. Licensed
// under the Apache License, Version 2.0. See the COPYING file at the root
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0

module MissionLoadGenerationWithTxSetLimit

open StellarCoreSet
open StellarMissionContext
open StellarFormation
open StellarStatefulSets
open StellarSupercluster
open StellarCoreHTTP

let loadGenerationWithTxSetLimit (context: MissionContext) =
let coreSet =
MakeLiveCoreSet
"core"
{ CoreSetOptions.GetDefault context.image with
invariantChecks = AllInvariantsExceptBucketConsistencyChecks
dumpDatabase = false }

let context =
{ context with
numAccounts = 200
numTxs = 50000
txRate = 1000
skipLowFeeTxs = true }

context.Execute
[ coreSet ]
None
(fun (formation: StellarFormation) ->
formation.WaitUntilSynced [ coreSet ]
formation.UpgradeProtocolToLatest [ coreSet ]
formation.UpgradeMaxTxSetSize [ coreSet ] 1000

formation.RunLoadgen coreSet context.GenerateAccountCreationLoad
formation.RunLoadgen coreSet context.GeneratePaymentLoad)
76 changes: 76 additions & 0 deletions src/FSLibrary/MissionMixedImageLoadGeneration.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright 2022 Stellar Development Foundation and contributors. Licensed
// under the Apache License, Version 2.0. See the COPYING file at the root
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0

module MissionMixedImageLoadGeneration

open stellar_dotnet_sdk
open StellarCoreSet
open StellarMissionContext
open StellarFormation
open StellarStatefulSets
open StellarSupercluster
open StellarCoreHTTP

let mixedImageLoadGeneration (oldImageNodeCount: int) (context: MissionContext) =
let oldNodeCount = oldImageNodeCount
let newNodeCount = 3 - oldImageNodeCount

let newImage = context.image
let oldImage = GetOrDefault context.oldImage newImage

let oldName = "core-old"
let newName = "core-new"

// Allow 2/3 nodes consensus, so that one image version could fork the network
// in case of bugs.
let qSet =
CoreSetQuorumListWithThreshold(([ CoreSetName oldName; CoreSetName newName ], 51))

let oldCoreSet =
MakeLiveCoreSet
oldName
{ CoreSetOptions.GetDefault oldImage with
nodeCount = oldNodeCount
invariantChecks = AllInvariantsExceptBucketConsistencyChecks
dumpDatabase = false
quorumSet = qSet }

let newCoreSet =
MakeLiveCoreSet
newName
{ CoreSetOptions.GetDefault newImage with
nodeCount = newNodeCount
invariantChecks = AllInvariantsExceptBucketConsistencyChecks
dumpDatabase = false
quorumSet = qSet }

let context =
{ context with
numAccounts = 200
numTxs = 50000
txRate = 1000
skipLowFeeTxs = true }

// Put the version with majority of nodes in front of the set to let it generate
// the load and possibly leave the minority of nodes out of consensus in case of bugs.
let coreSets =
if oldNodeCount > newNodeCount then
[ oldCoreSet; newCoreSet ]
else
[ newCoreSet; oldCoreSet ]

context.Execute
coreSets
None
(fun (formation: StellarFormation) ->
formation.WaitUntilSynced coreSets
formation.UpgradeProtocolToLatest coreSets
formation.UpgradeMaxTxSetSize coreSets 1000

formation.RunLoadgen oldCoreSet context.GenerateAccountCreationLoad
formation.RunLoadgen oldCoreSet context.GeneratePaymentLoad)

let mixedImageLoadGenerationWithOldImageMajority (context: MissionContext) = mixedImageLoadGeneration 2 context

let mixedImageLoadGenerationWithNewImageMajority (context: MissionContext) = mixedImageLoadGeneration 1 context
44 changes: 44 additions & 0 deletions src/FSLibrary/MissionProtocolUpgradeWithLoad.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2022 Stellar Development Foundation and contributors. Licensed
// under the Apache License, Version 2.0. See the COPYING file at the root
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0

module MissionProtocolUpgradeWithLoad

open StellarCorePeer
open StellarCoreSet
open StellarMissionContext
open StellarFormation
open StellarStatefulSets
open StellarSupercluster
open StellarCoreHTTP

let protocolUpgradeWithLoad (context: MissionContext) =
let coreSet =
MakeLiveCoreSet
"core"
{ CoreSetOptions.GetDefault context.image with
invariantChecks = AllInvariantsExceptBucketConsistencyChecks
dumpDatabase = false }

let context =
{ context with
numAccounts = 200
numTxs = 50000
txRate = 1000
skipLowFeeTxs = true }

context.Execute
[ coreSet ]
None
(fun (formation: StellarFormation) ->
formation.WaitUntilSynced [ coreSet ]
let networkCfg = formation.NetworkCfg
let peer = networkCfg.GetPeer coreSet 0
let latestProtocol = peer.GetSupportedProtocolVersion()

formation.UpgradeProtocol [ coreSet ] (latestProtocol - 1)
formation.UpgradeMaxTxSetSize [ coreSet ] 1000
formation.RunLoadgen coreSet context.GenerateAccountCreationLoad

formation.ScheduleProtocolUpgrade [ coreSet ] latestProtocol (System.DateTime.Now.AddSeconds(20.0))
formation.RunLoadgen coreSet context.GeneratePaymentLoad)
4 changes: 3 additions & 1 deletion src/FSLibrary/MissionSimulatePubnetTier1Perf.fs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ let simulatePubnetTier1Perf (context: MissionContext) =
spikeinterval = context.spikeInterval
txrate = middle
offset = 0
batchsize = 100 }
batchsize = 100
maxfeerate = None
skiplowfeetxs = false }

formation.RunMultiLoadgen tier1 loadGen
formation.CheckNoErrorsAndPairwiseConsistency()
Expand Down
11 changes: 6 additions & 5 deletions src/FSLibrary/StellarCoreCfg.fs
Original file line number Diff line number Diff line change
Expand Up @@ -377,15 +377,16 @@ type NetworkCfg with
self.CoreSetList |> List.map processCoreSet |> List.concat |> Map.ofList

member self.QuorumSet(o: CoreSetOptions) : QuorumSet =
let ofNameKeyList (nks: (PeerShortName * KeyPair) array) : QuorumSet =
{ thresholdPercent = None
let ofNameKeyList (nks: (PeerShortName * KeyPair) array) (threshold: int option) : QuorumSet =
{ thresholdPercent = threshold
validators = Map.ofArray nks
innerQuorumSets = [||] }

match o.quorumSet with
| AllPeersQuorum -> ofNameKeyList (self.GetNameKeyListAll())
| CoreSetQuorum (ns) -> ofNameKeyList (self.GetNameKeyList [ ns ])
| CoreSetQuorumList (q) -> ofNameKeyList (self.GetNameKeyList q)
| AllPeersQuorum -> ofNameKeyList (self.GetNameKeyListAll()) None
| CoreSetQuorum (ns) -> ofNameKeyList (self.GetNameKeyList [ ns ]) None
| CoreSetQuorumList (q) -> ofNameKeyList (self.GetNameKeyList q) None
| CoreSetQuorumListWithThreshold (q, t) -> ofNameKeyList (self.GetNameKeyList q) (Some(t))
| ExplicitQuorum (e) -> e

member self.HistoryNodes(o: CoreSetOptions) : Map<PeerShortName, PeerDnsName> =
Expand Down
24 changes: 18 additions & 6 deletions src/FSLibrary/StellarCoreHTTP.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ type LoadGen =
spikeinterval: int
txrate: int
offset: int
batchsize: int }
batchsize: int
maxfeerate: int option
skiplowfeetxs: bool }

member self.ToQuery : (string * string) list =
[ ("mode", self.mode.ToString())
Expand All @@ -62,7 +64,9 @@ type LoadGen =
("spikesize", self.spikesize.ToString())
("spikeinterval", self.spikeinterval.ToString())
("batchsize", self.batchsize.ToString())
("offset", self.offset.ToString()) ]
("offset", self.offset.ToString())
("maxfeerate", (if self.maxfeerate.IsSome then self.maxfeerate.Value.ToString() else ""))
("skiplowfeetxs", (if self.skiplowfeetxs then "true" else "false")) ]

type MissionContext with

Expand All @@ -77,7 +81,9 @@ type MissionContext with
// Use conservative rate for account creation, as the network may quickly get overloaded
txrate = 5
offset = 0
batchsize = 100 }
batchsize = 100
maxfeerate = self.maxFeeRate
skiplowfeetxs = self.skipLowFeeTxs }

member self.GeneratePaymentLoad : LoadGen =
{ mode = GeneratePaymentLoad
Expand All @@ -87,7 +93,9 @@ type MissionContext with
spikesize = self.spikeSize
spikeinterval = self.spikeInterval
offset = 0
batchsize = 100 }
batchsize = 100
maxfeerate = self.maxFeeRate
skiplowfeetxs = self.skipLowFeeTxs }

member self.GeneratePretendLoad : LoadGen =
{ mode = GeneratePretendLoad
Expand All @@ -97,7 +105,9 @@ type MissionContext with
spikesize = self.spikeSize
spikeinterval = self.spikeInterval
offset = 0
batchsize = 100 }
batchsize = 100
maxfeerate = self.maxFeeRate
skiplowfeetxs = self.skipLowFeeTxs }


let DefaultAccountCreationLoadGen =
Expand All @@ -108,7 +118,9 @@ let DefaultAccountCreationLoadGen =
spikeinterval = 0
txrate = 10
offset = 0
batchsize = 100 }
batchsize = 100
maxfeerate = None
skiplowfeetxs = false }


type UpgradeParameters =
Expand Down
1 change: 1 addition & 0 deletions src/FSLibrary/StellarCoreSet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ type QuorumSet =
type QuorumSetSpec =
| CoreSetQuorum of CoreSetName
| CoreSetQuorumList of CoreSetName list
| CoreSetQuorumListWithThreshold of CoreSetName list * int
| ExplicitQuorum of QuorumSet
| AllPeersQuorum

Expand Down
9 changes: 8 additions & 1 deletion src/FSLibrary/StellarMission.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ module StellarMission
open MissionBootAndSync
open MissionSimplePayment
open MissionComplexTopology
open MissionLoadGeneration
open MissionInMemoryMode
open MissionLoadGeneration
open MissionLoadGenerationWithSpikes
open MissionLoadGenerationWithTxSetLimit
open MissionMixedImageLoadGeneration
open MissionBenchmarkBaseline
open MissionBenchmarkConsensusOnly
open MissionBenchmarkIncreaseTxRate
Expand All @@ -30,6 +32,7 @@ open MissionVersionMixNewCatchupToOld
open MissionVersionMixOldCatchupToNew
open MissionProtocolUpgradeTestnet
open MissionProtocolUpgradePubnet
open MissionProtocolUpgradeWithLoad
open MissionDatabaseInplaceUpgrade
open MissionAcceptanceUnitTests
open MissionSimulatePubnet
Expand All @@ -45,6 +48,9 @@ let allMissions : Map<string, Mission> =
("ComplexTopology", complexTopology)
("LoadGeneration", loadGeneration)
("LoadGenerationWithSpikes", loadGenerationWithSpikes)
("LoadGenerationWithTxSetLimit", loadGenerationWithTxSetLimit)
("MixedImageLoadGenerationWithOldImageMajority", mixedImageLoadGenerationWithOldImageMajority)
("MixedImageLoadGenerationWithNewImageMajority", mixedImageLoadGenerationWithNewImageMajority)
("InMemoryMode", runInMemoryMode)
("BenchmarkBaseline", benchmarkBaseline)
("BenchmarkConsensusOnly", benchmarkConsensusOnly)
Expand All @@ -66,6 +72,7 @@ let allMissions : Map<string, Mission> =
("VersionMixOldCatchupToNew", versionMixOldCatchupToNew)
("ProtocolUpgradeTestnet", protocolUpgradeTestnet)
("ProtocolUpgradePubnet", protocolUpgradePubnet)
("ProtocolUpgradeWithLoad", protocolUpgradeWithLoad)
("DatabaseInplaceUpgrade", databaseInplaceUpgrade)
("AcceptanceUnitTests", acceptanceUnitTests)
("SimulatePubnet", simulatePubnet)
Expand Down
2 changes: 2 additions & 0 deletions src/FSLibrary/StellarMissionContext.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type MissionContext =
numTxs: int
spikeSize: int
spikeInterval: int
maxFeeRate: int option
skipLowFeeTxs: bool
numNodes: int
namespaceProperty: string
logLevels: LogLevels
Expand Down
3 changes: 3 additions & 0 deletions src/FSLibrary/StellarStatefulSets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ type StellarFormation with
let peer = self.NetworkCfg.GetPeer coreSetList.[0] 0
peer.WaitForProtocol(version) |> ignore

member self.ScheduleProtocolUpgrade (coreSetList: CoreSet list) (version: int) (upgradeTime: System.DateTime) =
self.NetworkCfg.EachPeerInSets(coreSetList |> Array.ofList) (fun p -> p.UpgradeProtocol version upgradeTime)

member self.UpgradeProtocolToLatest(coreSetList: CoreSet list) =
let peer = self.NetworkCfg.GetPeer coreSetList.[0] 0
let latest = peer.GetSupportedProtocolVersion()
Expand Down

0 comments on commit 5884ad7

Please sign in to comment.