Skip to content

Commit

Permalink
feat: add custom max gas for block for sim config (backport cosmos#16656
Browse files Browse the repository at this point in the history
) (cosmos#16731)

Co-authored-by: mmsqe <[email protected]>
Co-authored-by: marbar3778 <[email protected]>
  • Loading branch information
3 people authored and JeancarloBarrios committed Sep 28, 2024
1 parent e7b445a commit d545254
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

### Features

* (sims) [#16656](https://github.com/cosmos/cosmos-sdk/pull/16656) Add custom max gas for block for sim config with unlimited as default.

### Improvements

* (deps) [#16553](https://github.com/cosmos/cosmos-sdk/pull/16553) Bump CometBFT to [v0.34.29](https://github.com/cometbft/cometbft/blob/v0.34.29/CHANGELOG.md#v03429).
Expand Down
10 changes: 2 additions & 8 deletions types/simulation/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ func (c Config) shallowCopy() Config {
return c
}

// With sets the values of t, seed, and fuzzSeed in a copy of the Config and returns the copy.
func (c Config) With(tb testing.TB, seed int64, fuzzSeed []byte) Config {
tb.Helper()
r := c.shallowCopy()
r.TB = tb
r.Seed = seed
r.FuzzSeed = fuzzSeed
return r
DBBackend string // custom db backend type
BlockMaxGas int64 // custom max gas for block
}
2 changes: 1 addition & 1 deletion x/simulation/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (w WeightedProposalContent) ContentSimulatorFn() simulation.ContentSimulato
// Consensus Params

// randomConsensusParams returns random simulation consensus parameters, it extracts the Evidence from the Staking genesis state.
func randomConsensusParams(r *rand.Rand, appState json.RawMessage, cdc codec.JSONCodec) *abci.ConsensusParams {
func randomConsensusParams(r *rand.Rand, appState json.RawMessage, cdc codec.JSONCodec, maxGas int64) *abci.ConsensusParams {
var genesisState map[string]json.RawMessage
err := json.Unmarshal(appState, &genesisState)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion x/simulation/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ func initChain(
config simulation.Config,
cdc codec.JSONCodec,
) (mockValidators, time.Time, []simulation.Account, string) {
blockMaxGas := int64(-1)
if config.BlockMaxGas > 0 {
blockMaxGas = config.BlockMaxGas
}
appState, accounts, chainID, genesisTimestamp := appStateFn(r, accounts, config)
consensusParams := randomConsensusParams(r, appState, cdc)
consensusParams := randomConsensusParams(r, appState, cdc, blockMaxGas)
req := abci.RequestInitChain{
AppStateBytes: appState,
ChainId: chainID,
Expand Down

0 comments on commit d545254

Please sign in to comment.