-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
R4R: Simulation improvements (logging fix, random genesis parameters) #2617
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4e44ddf
Print out initial update on every block
cwgoes 38ceea1
Randomize simulation parameters
cwgoes 4e48217
Randomize initial liveness weightings
cwgoes 46e6b40
Randomize genesis parameters
cwgoes 3884b13
Update PENDING.md
cwgoes 991573e
Avoid dividing-by-zero
cwgoes f5918db
More simulation seeds, more blocks in CI version
cwgoes e2aa3e9
Update cmd/gaia/app/sim_test.go
zmanian 01c235d
Update cmd/gaia/app/sim_test.go
zmanian f13f602
Update cmd/gaia/app/sim_test.go
zmanian 1868ee3
Merge remote-tracking branch 'origin/develop' into cwgoes/simulation-…
rigelrozanski a84cf4f
Merge tag 'v0.25.0' into develop
cwgoes fb0f4a4
Merge branch 'develop' into cwgoes/simulation-transubstantiated
cwgoes d9907cc
Address comments
cwgoes f695a66
Minimize variable passing
cwgoes 39165c9
fixed power store invariant
sunnya97 3cf6687
PENDING
sunnya97 42eb4e2
IterateValidatorsBonded -> IterateBondedValidatorsByPower
sunnya97 888c061
WriteValidators uses IterateLastValidators rather than IterateBondedV…
sunnya97 13d933f
fixed democoin interface
sunnya97 191a732
fixed comment
sunnya97 559ebb7
Merge PR #2671: Power Store Invariant
rigelrozanski 7b10ac4
Merge branch 'develop' into cwgoes/simulation-transubstantiated
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package simulation | ||
|
||
import ( | ||
"math/rand" | ||
) | ||
|
||
const ( | ||
// Minimum time per block | ||
minTimePerBlock int64 = 10000 / 2 | ||
|
||
// Maximum time per block | ||
maxTimePerBlock int64 = 10000 | ||
|
||
// TODO Remove in favor of binary search for invariant violation | ||
onOperation bool = false | ||
) | ||
|
||
var ( | ||
// Currently there are 3 different liveness types, fully online, spotty connection, offline. | ||
defaultLivenessTransitionMatrix, _ = CreateTransitionMatrix([][]int{ | ||
{90, 20, 1}, | ||
{10, 50, 5}, | ||
{0, 10, 1000}, | ||
}) | ||
|
||
// 3 states: rand in range [0, 4*provided blocksize], rand in range [0, 2 * provided blocksize], 0 | ||
defaultBlockSizeTransitionMatrix, _ = CreateTransitionMatrix([][]int{ | ||
{85, 5, 0}, | ||
{15, 92, 1}, | ||
{0, 3, 99}, | ||
}) | ||
) | ||
|
||
// Simulation parameters | ||
type Params struct { | ||
PastEvidenceFraction float64 | ||
NumKeys int | ||
EvidenceFraction float64 | ||
InitialLivenessWeightings []int | ||
LivenessTransitionMatrix TransitionMatrix | ||
BlockSizeTransitionMatrix TransitionMatrix | ||
} | ||
|
||
// Return default simulation parameters | ||
func DefaultParams() Params { | ||
return Params{ | ||
PastEvidenceFraction: 0.5, | ||
NumKeys: 250, | ||
EvidenceFraction: 0.5, | ||
InitialLivenessWeightings: []int{40, 5, 5}, | ||
LivenessTransitionMatrix: defaultLivenessTransitionMatrix, | ||
BlockSizeTransitionMatrix: defaultBlockSizeTransitionMatrix, | ||
} | ||
} | ||
|
||
// Return random simulation parameters | ||
func RandomParams(r *rand.Rand) Params { | ||
return Params{ | ||
PastEvidenceFraction: r.Float64(), | ||
NumKeys: r.Intn(250), | ||
EvidenceFraction: r.Float64(), | ||
InitialLivenessWeightings: []int{r.Intn(80), r.Intn(10), r.Intn(10)}, | ||
LivenessTransitionMatrix: defaultLivenessTransitionMatrix, | ||
BlockSizeTransitionMatrix: defaultBlockSizeTransitionMatrix, | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense for randomized genesis states to be defined within the module itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question. I think they may need to be dependent (e.g. the max evidence age for slashing should be the unbonding period), although in that case I wonder if we should just share the parameters themselves...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have that sort of requirement, they definitely should be dependent when being set or be the same variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets keep things here for a bit... we lose agility by organizing things too far, and simulation is an edge application, so I think it's fine as is for now.