Skip to content

Commit

Permalink
feat: add custom max gas for block for sim config (#16656)
Browse files Browse the repository at this point in the history
(cherry picked from commit 9b2fd7b)

# Conflicts:
#	x/simulation/params.go
  • Loading branch information
mmsqe authored and mergify[bot] committed Jun 27, 2023
1 parent 56df2b2 commit 60db788
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,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
3 changes: 2 additions & 1 deletion types/simulation/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ type Config struct {
OnOperation bool // run slow invariants every operation
AllInvariants bool // print all failed invariants if a broken invariant is found

DBBackend string // custom db backend type
DBBackend string // custom db backend type
BlockMaxGas int64 // custom max gas for block
}
6 changes: 5 additions & 1 deletion x/simulation/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ func (w WeightedProposalContent) ContentSimulatorFn() simulation.ContentSimulato
// Param change proposals

// randomConsensusParams returns random simulation consensus parameters, it extracts the Evidence from the Staking genesis state.
<<<<<<< HEAD

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build (arm64)

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build (amd64)

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build (arm)

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / liveness-test

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (02)

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / golangci-lint

expected declaration, found '<<' (typecheck)

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (01)

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (01)

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (00)

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (00)

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (03)

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (03)

syntax error: non-declaration statement outside function body

Check failure on line 154 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / Analyze

syntax error: non-declaration statement outside function body
func randomConsensusParams(r *rand.Rand, appState json.RawMessage, cdc codec.JSONCodec) *abci.ConsensusParams {
=======

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build (arm64)

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build (amd64)

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build (arm)

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / liveness-test

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (02)

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (01)

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (01)

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (00)

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (00)

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (03)

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (03)

syntax error: unexpected ==, expecting }

Check failure on line 156 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / Analyze

syntax error: unexpected ==, expecting }
func randomConsensusParams(r *rand.Rand, appState json.RawMessage, cdc codec.JSONCodec, maxGas int64) *cmtproto.ConsensusParams {
>>>>>>> 9b2fd7bad (feat: add custom max gas for block for sim config (#16656))

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build (arm64)

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build (arm64)

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build (amd64)

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build (amd64)

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build (arm)

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build (arm)

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / liveness-test

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / liveness-test

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (02)

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (02)

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (02)

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / golangci-lint

illegal character U+0023 '#' (typecheck)

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (03)

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (03)

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (01)

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (01)

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (01)

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (01)

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (01)

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (01)

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (00)

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (00)

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (00)

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (00)

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (00)

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (00)

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (03)

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (03)

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (03)

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (03)

invalid character U+0023 '#'

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / Analyze

syntax error: unexpected >>, expecting }

Check failure on line 158 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / Analyze

invalid character U+0023 '#'
var genesisState map[string]json.RawMessage
err := json.Unmarshal(appState, &genesisState)

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build (arm64)

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build (amd64)

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build (arm)

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / build

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / liveness-test

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (02)

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / golangci-lint

expected declaration, found err (typecheck)

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (01)

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (01)

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (00)

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (00)

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (03)

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / test-race (03)

syntax error: non-declaration statement outside function body

Check failure on line 160 in x/simulation/params.go

View workflow job for this annotation

GitHub Actions / Analyze

syntax error: non-declaration statement outside function body
if err != nil {
Expand All @@ -162,7 +166,7 @@ func randomConsensusParams(r *rand.Rand, appState json.RawMessage, cdc codec.JSO
consensusParams := &abci.ConsensusParams{
Block: &abci.BlockParams{
MaxBytes: int64(simulation.RandIntBetween(r, 20000000, 30000000)),
MaxGas: -1,
MaxGas: maxGas,
},
Validator: &tmproto.ValidatorParams{
PubKeyTypes: []string{types.ABCIPubKeyTypeEd25519},
Expand Down
6 changes: 5 additions & 1 deletion x/simulation/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,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 60db788

Please sign in to comment.