Skip to content

Commit

Permalink
address bez's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ValarDragon committed Oct 29, 2018
1 parent e4b5e2c commit 100f888
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions x/mock/simulation/random_simulate_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,13 @@ func SimulateFromSeed(tb testing.TB, app *baseapp.BaseApp,

// Returns a function to simulate blocks. Written like this to avoid constant parameters being passed everytime, to minimize
// memory overhead
func createBlockSimulator(testingMode bool, tb testing.TB, t *testing.T, event func(string), invariants []Invariant, ops []WeightedOperation, operationQueue map[int][]Operation, timeOperationQueue []FutureOperation, totalNumBlocks int, avgBlockSize int, displayLogs func()) func(
r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []Account, header abci.Header, logWriter func(string)) (opCount int) {
func createBlockSimulator(testingMode bool, tb testing.TB, t *testing.T,
event func(string), invariants []Invariant,
ops []WeightedOperation, operationQueue map[int][]Operation, timeOperationQueue []FutureOperation,
totalNumBlocks int, avgBlockSize int, displayLogs func()) func(
r *rand.Rand,
app *baseapp.BaseApp, ctx sdk.Context,
accounts []Account, header abci.Header, logWriter func(string)) (opCount int) {
var (
lastBlocksizeState = 0 // state for [4 * uniform distribution]
totalOpWeight = 0
Expand Down Expand Up @@ -258,6 +263,12 @@ func getTestingMode(tb testing.TB) (testingMode bool, t *testing.T, b *testing.B
return
}

/** getBlockSize returns a block size as determined from the transition matrix.
It targets making average block size the provided parameter.
The three states it moves between are:
* "over stuffed" blocks with average size of 2 * avgblocksize,
* normal sized blocks, hitting avgBlocksize on average,
* and empty blocks, with no txs / only txs scheduled from the past. */
func getBlockSize(r *rand.Rand, lastBlockSizeState, avgBlockSize int) (state, blocksize int) {
// TODO: Make blockSizeTransitionMatrix non-global
// TODO: Make default blocksize transitition matrix actually make the average blocksize equal to avgBlockSize
Expand Down

0 comments on commit 100f888

Please sign in to comment.