From 100f88800b02f79e04d1d6e4a47471077a6357eb Mon Sep 17 00:00:00 2001 From: ValarDragon Date: Mon, 29 Oct 2018 09:37:42 -0700 Subject: [PATCH] address bez's comments --- x/mock/simulation/random_simulate_blocks.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/x/mock/simulation/random_simulate_blocks.go b/x/mock/simulation/random_simulate_blocks.go index 78939698b6dc..7c3c38240dc8 100644 --- a/x/mock/simulation/random_simulate_blocks.go +++ b/x/mock/simulation/random_simulate_blocks.go @@ -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 @@ -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