Skip to content
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

feat: clamp to consensus max gas #51

Closed
wants to merge 16 commits into from
176 changes: 58 additions & 118 deletions api/feemarket/feemarket/v1/params.pulsar.go

Large diffs are not rendered by default.

154 changes: 77 additions & 77 deletions api/feemarket/feemarket/v1/query.pulsar.go

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ require (
github.com/stretchr/testify v1.8.4
golang.org/x/tools v0.16.0
google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17
google.golang.org/grpc v1.59.0
google.golang.org/protobuf v1.31.0
google.golang.org/grpc v1.60.1
google.golang.org/protobuf v1.32.0
mvdan.cc/gofumpt v0.5.0
pgregory.net/rapid v1.1.0
)
Expand Down Expand Up @@ -299,14 +299,14 @@ require (
golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.143.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20231030173426-d783a09b4405 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
15 changes: 8 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1716,8 +1716,8 @@ golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1/go.mod h1:h4gKUeWbJ4rQPri
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A=
golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec=
golang.org/x/oauth2 v0.12.0 h1:smVPGxink+n1ZI5pkQa8y6fZT0RW0MgCO5bFpepy4B4=
golang.org/x/oauth2 v0.12.0/go.mod h1:A74bZ3aGXgCY0qaIC9Ahg6Lglin4AMAco8cIv9baba4=
golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY=
golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down Expand Up @@ -2026,8 +2026,9 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
Expand Down Expand Up @@ -2195,8 +2196,8 @@ google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCD
google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww=
google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g=
google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk=
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU=
google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
Expand All @@ -2214,8 +2215,8 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
16 changes: 7 additions & 9 deletions proto/feemarket/feemarket/v1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,18 @@ message Params {
(gogoproto.nullable) = false
];

// TargetBlockUtilization is the target block utilization.
// TargetBlockUtilization is the target block utilization (in units of gas).
// This value MUST be lower than the consensus max gas parameter.
uint64 target_block_utilization = 8;

// MaxBlockUtilization is the maximum block utilization.
uint64 max_block_utilization = 9;

// Window defines the window size for calculating an adaptive learning rate
// over a moving window of blocks.
uint64 window = 10;
// WindowSize defines the window size for calculating an adaptive learning
// rate over a moving window of blocks.
uint64 window_size = 9;

// FeeDenom is the denom that will be used for all fee payments.
string fee_denom = 11;
string fee_denom = 10;

// Enabled is a boolean that determines whether the EIP1559 fee market is
// enabled.
bool enabled = 12;
bool enabled = 11;
}
7 changes: 0 additions & 7 deletions tests/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import (
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
"github.com/cosmos/cosmos-sdk/x/consensus"
consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
"github.com/cosmos/cosmos-sdk/x/crisis"
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
distr "github.com/cosmos/cosmos-sdk/x/distribution"
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
"github.com/cosmos/cosmos-sdk/x/evidence"
Expand Down Expand Up @@ -96,7 +94,6 @@ var (
},
),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
feegrantmodule.AppModuleBasic{},
upgrade.AppModuleBasic{},
Expand Down Expand Up @@ -132,7 +129,6 @@ type TestApp struct {
MintKeeper mintkeeper.Keeper
DistrKeeper distrkeeper.Keeper
GovKeeper *govkeeper.Keeper
CrisisKeeper *crisiskeeper.Keeper
aljo242 marked this conversation as resolved.
Show resolved Hide resolved
UpgradeKeeper *upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
AuthzKeeper authzkeeper.Keeper
Expand Down Expand Up @@ -210,7 +206,6 @@ func New(
&app.MintKeeper,
&app.DistrKeeper,
&app.GovKeeper,
&app.CrisisKeeper,
&app.UpgradeKeeper,
&app.ParamsKeeper,
&app.AuthzKeeper,
Expand Down Expand Up @@ -292,8 +287,6 @@ func New(

/**** Module Options ****/

app.ModuleManager.RegisterInvariants(app.CrisisKeeper)

// RegisterUpgradeHandlers is used for registering any on-chain upgrades.
// app.RegisterUpgradeHandlers()

Expand Down
14 changes: 3 additions & 11 deletions tests/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
authzmodulev1 "cosmossdk.io/api/cosmos/authz/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
crisismodulev1 "cosmossdk.io/api/cosmos/crisis/module/v1"
distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1"
evidencemodulev1 "cosmossdk.io/api/cosmos/evidence/module/v1"
feegrantmodulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1"
Expand All @@ -30,7 +29,6 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
Expand All @@ -57,11 +55,11 @@ var (
// so that other modules that want to create or claim capabilities afterwards in InitChain
// can do so safely.
genesisModuleOrder = []string{
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, feemarkettypes.ModuleName,
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName,
distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName,
minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName,
minttypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName,
feegrant.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName,
vestingtypes.ModuleName, consensustypes.ModuleName,
vestingtypes.ModuleName, consensustypes.ModuleName, feemarkettypes.ModuleName,
}

// module account permissions
Expand Down Expand Up @@ -112,7 +110,6 @@ var (
authtypes.ModuleName,
banktypes.ModuleName,
govtypes.ModuleName,
crisistypes.ModuleName,
genutiltypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
Expand All @@ -122,7 +119,6 @@ var (
consensustypes.ModuleName,
},
EndBlockers: []string{
crisistypes.ModuleName,
govtypes.ModuleName,
feemarkettypes.ModuleName,
stakingtypes.ModuleName,
Expand Down Expand Up @@ -231,10 +227,6 @@ var (
Name: govtypes.ModuleName,
Config: appconfig.WrapAny(&govmodulev1.Module{}),
},
{
Name: crisistypes.ModuleName,
Config: appconfig.WrapAny(&crisismodulev1.Module{}),
},
{
Name: consensustypes.ModuleName,
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
Expand Down
3 changes: 0 additions & 3 deletions tests/app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ func (app *TestApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
allowedAddrsMap[addr] = true
}

/* Just to be safe, assert the invariants on current state. */
app.CrisisKeeper.AssertInvariants(ctx)

/* Handle fee distribution state. */

// withdraw all validator commission
Expand Down
7 changes: 4 additions & 3 deletions tests/app/feemarketd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
"github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand All @@ -31,6 +30,8 @@ import (
"github.com/skip-mev/feemarket/tests/app/params"
)

var flagCrisisDummy = "x-crisis-skip-assert-invariants" // dummy flag so that the crisis module does not need to be imported for security reasons

func NewRootCmd() *cobra.Command {
// we "pre"-instantiate the application for getting the injected/configured encoding configuration
simApp := app.New(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(app.DefaultNodeHome))
Expand Down Expand Up @@ -177,8 +178,8 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
)
}

func addModuleInitFlags(startCmd *cobra.Command) {
crisis.AddModuleInitFlags(startCmd)
func addModuleInitFlags(cmd *cobra.Command) {
cmd.Flags().Bool(flagCrisisDummy, true, "dummy flag for crisis module")
}

func genesisCommand(encodingConfig params.EncodingConfig, cmds ...*cobra.Command) *cobra.Command {
Expand Down
4 changes: 1 addition & 3 deletions tests/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func TestIntegrationTestSuite(t *testing.T) {

func (s *IntegrationTestSuite) SetupTest() {
s.encCfg = encoding.MakeTestEncodingConfig(app.ModuleBasics.RegisterInterfaces)

s.ctx, s.TestKeepers, s.TestMsgServers = testkeeper.NewTestSetup(s.T())
}

Expand Down Expand Up @@ -81,8 +80,7 @@ func (s *IntegrationTestSuite) TestParams() {
MinLearningRate: math.LegacyMustNewDecFromStr("0.1"),
MaxLearningRate: math.LegacyMustNewDecFromStr("0.1"),
TargetBlockUtilization: 5,
MaxBlockUtilization: 10,
Window: 1,
WindowSize: 1,
Enabled: true,
}

Expand Down
39 changes: 38 additions & 1 deletion testutils/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ package keeper
import (
"testing"

consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"

"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
testkeeper "github.com/skip-mev/chaintestutil/keeper"
"github.com/stretchr/testify/require"
Expand All @@ -22,6 +25,7 @@ import (
type TestKeepers struct {
testkeeper.TestKeepers
FeeMarketKeeper *feemarketkeeper.Keeper
ConsensusKeeper *consensuskeeper.Keeper
}

// TestMsgServers holds all message servers used during keeper tests for all modules
Expand All @@ -35,14 +39,25 @@ var additionalMaccPerms = map[string][]string{
feemarkettypes.FeeCollectorName: {authtypes.Burner},
}

var ConsensusParams = &tmproto.ConsensusParams{
Block: &tmproto.BlockParams{
MaxBytes: 1_000_000,
MaxGas: int64(feemarkettypes.DefaultMaxBlockUtilization),
},
Evidence: nil,
Validator: nil,
Version: nil,
}

// NewTestSetup returns initialized instances of all the keepers and message servers of the modules
func NewTestSetup(t testing.TB, options ...testkeeper.SetupOption) (sdk.Context, TestKeepers, TestMsgServers) {
options = append(options, testkeeper.WithAdditionalModuleAccounts(additionalMaccPerms))

_, tk, tms := testkeeper.NewTestSetup(t, options...)

// initialize extra keeper
feeMarketKeeper := FeeMarket(tk.Initializer, tk.AccountKeeper)
consensusKeeper := Consensus(tk.Initializer)
feeMarketKeeper := FeeMarket(tk.Initializer, tk.AccountKeeper, consensusKeeper)
require.NoError(t, tk.Initializer.LoadLatest())

// initialize msg servers
Expand All @@ -58,9 +73,13 @@ func NewTestSetup(t testing.TB, options ...testkeeper.SetupOption) (sdk.Context,
err = feeMarketKeeper.SetParams(ctx, feemarkettypes.DefaultParams())
require.NoError(t, err)

// init dummy consensus params
consensusKeeper.Set(ctx, ConsensusParams)
aljo242 marked this conversation as resolved.
Show resolved Hide resolved

testKeepers := TestKeepers{
TestKeepers: tk,
FeeMarketKeeper: feeMarketKeeper,
ConsensusKeeper: consensusKeeper,
}

testMsgServers := TestMsgServers{
Expand All @@ -71,10 +90,27 @@ func NewTestSetup(t testing.TB, options ...testkeeper.SetupOption) (sdk.Context,
return ctx, testKeepers, testMsgServers
}

// Consensus initializes the consensus params module using the testkeepers intializer.
func Consensus(
initializer *testkeeper.Initializer,
) *consensuskeeper.Keeper {
storeKey := sdk.NewKVStoreKey(consensustypes.StoreKey)
initializer.StateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, initializer.DB)

k := consensuskeeper.NewKeeper(
initializer.Codec,
storeKey,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

return &k
}
aljo242 marked this conversation as resolved.
Show resolved Hide resolved

// FeeMarket initializes the fee market module using the testkeepers intializer.
func FeeMarket(
initializer *testkeeper.Initializer,
authKeeper authkeeper.AccountKeeper,
consensusKeeper feemarkettypes.ConsensusKeeper,
) *feemarketkeeper.Keeper {
storeKey := sdk.NewKVStoreKey(feemarkettypes.StoreKey)
initializer.StateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, initializer.DB)
Expand All @@ -83,6 +119,7 @@ func FeeMarket(
initializer.Codec,
storeKey,
authKeeper,
consensusKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
}
18 changes: 18 additions & 0 deletions testutils/networksuite/networksuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ package networksuite
import (
"math/rand"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"

tmdb "github.com/cometbft/cometbft-db"
tmrand "github.com/cometbft/cometbft/libs/rand"
"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -44,6 +47,7 @@ type NetworkTestSuite struct {

Network *network.Network
FeeMarketState feemarkettypes.GenesisState
ConsensusState *tmproto.ConsensusParams
}

// SetupSuite setups the local network with a genesis state.
Expand All @@ -64,10 +68,24 @@ func (nts *NetworkTestSuite) SetupSuite() {
nts.FeeMarketState = populateFeeMarket(r, nts.FeeMarketState)
updateGenesisConfigState(feemarkettypes.ModuleName, &nts.FeeMarketState)

nts.ConsensusState = populateConsensus(r)
updateGenesisConfigState(consensustypes.ModuleName, nts.ConsensusState)

nts.Network = network.New(nts.T(), cfg)
}

func populateFeeMarket(_ *rand.Rand, feeMarketState feemarkettypes.GenesisState) feemarkettypes.GenesisState {
// TODO intercept and populate state randomly if desired
return feeMarketState
}

func populateConsensus(_ *rand.Rand) *tmproto.ConsensusParams {
consensusParams := new(tmproto.ConsensusParams)

consensusParams.Block = &tmproto.BlockParams{
MaxBytes: 1_000_000_000,
MaxGas: int64(feemarkettypes.DefaultMaxBlockUtilization),
}

return consensusParams
}
Loading
Loading