diff --git a/.golangci.yml b/.golangci.yml index c0844c760..b18ea0c03 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,69 +1,66 @@ +version: "2" run: tests: true - timeout: 10m - sort-results: true allow-parallel-runners: true - exclude-dir: testutil/testdata - linters: - disable-all: true + default: none enable: - dogsled - - exportloopref - goconst - gocritic - - gofumpt - gosec - - gosimple - govet - ineffassign - misspell - nakedret - nolintlint - staticcheck - - stylecheck - thelper - - typecheck - unconvert - unused - + settings: + dogsled: + max-blank-identifiers: 3 + nolintlint: + require-explanation: false + require-specific: false + allow-unused: false + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + rules: + - linters: + - gosec + text: Use of weak random number generator + - linters: + - staticcheck + text: 'ST1003:' + - linters: + - staticcheck + text: 'ST1016:' + - linters: + - staticcheck + path: migrations + text: 'SA1019:' + paths: + - third_party$ + - builtin$ + - examples$ issues: - exclude-rules: - - text: "Use of weak random number generator" - linters: - - gosec - - text: "ST1003:" - linters: - - stylecheck - # FIXME: Disabled until golangci-lint updates stylecheck with this fix: - # https://github.com/dominikh/go-tools/issues/389 - - text: "ST1016:" - linters: - - stylecheck - - path: "migrations" - text: "SA1019:" - linters: - - staticcheck - - text: "leading space" - linters: - - nolintlint - max-issues-per-linter: 10000 max-same-issues: 10000 - -linters-settings: - gofumpt: - # Choose whether to use the extra rules. - module-path: github.com/notional-labs/composable-centauri - # Default: false - extra-rules: true - dogsled: - max-blank-identifiers: 3 - maligned: - # print struct with more effective memory layout or not, false by default - suggest-new: true - nolintlint: - allow-unused: false - allow-leading-space: true - require-explanation: false - require-specific: false +formatters: + enable: + - gofumpt + settings: + extra-rules: true + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/app/app.go b/app/app.go index f3f036fb6..96796240c 100644 --- a/app/app.go +++ b/app/app.go @@ -359,7 +359,7 @@ func NewComposableApp( app.mm = module.NewManager( genutil.NewAppModule( - app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx, + app.AccountKeeper, app.StakingKeeper, app.DeliverTx, encodingConfig.TxConfig, ), auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), @@ -692,12 +692,12 @@ func (app *ComposableApp) RegisterAPIRoutes(apiSvr *api.Server, _ config.APIConf // RegisterTxService implements the Application.RegisterTxService method. func (app *ComposableApp) RegisterTxService(clientCtx client.Context) { - authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) + authtx.RegisterTxService(app.GRPCQueryRouter(), clientCtx, app.Simulate, app.interfaceRegistry) } // RegisterTendermintService implements the Application.RegisterTendermintService method. func (app *ComposableApp) RegisterTendermintService(clientCtx client.Context) { - tmservice.RegisterTendermintService(clientCtx, app.BaseApp.GRPCQueryRouter(), app.interfaceRegistry, app.Query) + tmservice.RegisterTendermintService(clientCtx, app.GRPCQueryRouter(), app.interfaceRegistry, app.Query) } // RegisterNodeService registers the node gRPC Query service. diff --git a/app/export.go b/app/export.go index a33330220..c4685060d 100644 --- a/app/export.go +++ b/app/export.go @@ -43,7 +43,7 @@ func (app *ComposableApp) ExportAppStateAndValidators( AppState: appState, Validators: validators, Height: height, - ConsensusParams: app.BaseApp.GetConsensusParams(ctx), + ConsensusParams: app.GetConsensusParams(ctx), }, nil } @@ -52,12 +52,9 @@ func (app *ComposableApp) ExportAppStateAndValidators( // // in favour of export at a block height func (app *ComposableApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { - applyAllowedAddrs := false + applyAllowedAddrs := len(jailAllowedAddrs) > 0 // check if there is a allowed address list - if len(jailAllowedAddrs) > 0 { - applyAllowedAddrs = true - } allowedAddrsMap := make(map[string]bool) diff --git a/app/helpers/test_helpers.go b/app/helpers/test_helpers.go index 1646262fa..8056d9fbe 100644 --- a/app/helpers/test_helpers.go +++ b/app/helpers/test_helpers.go @@ -59,7 +59,7 @@ type EmptyAppOptions struct{} func (EmptyAppOptions) Get(_ string) interface{} { return nil } func NewContextForApp(app composable.ComposableApp) sdk.Context { - ctx := app.BaseApp.NewContext(false, tmproto.Header{ + ctx := app.NewContext(false, tmproto.Header{ ChainID: fmt.Sprintf("test-chain-%s", tmrand.Str(4)), Height: 1, }) diff --git a/app/ibctesting/chain.go b/app/ibctesting/chain.go index c2082b7b6..d8327b5eb 100644 --- a/app/ibctesting/chain.go +++ b/app/ibctesting/chain.go @@ -4,6 +4,7 @@ import ( "bytes" "crypto/sha256" "fmt" + "math" "os" "testing" "time" @@ -202,6 +203,10 @@ func (chain *TestChain) QueryProofAtHeight(key []byte, height int64) ([]byte, cl revision := clienttypes.ParseChainID(chain.ChainID) + // Ensure height is non-negative before converting to uint64 + if res.Height < 0 { + panic("negative height not allowed") + } // proof height + 1 is returned as the proof created corresponds to the height the proof // was created in the IAVL tree. Tendermint and subsequently the clients that rely on it // have heights 1 above the IAVL tree. Thus we return proof height + 1 @@ -211,6 +216,14 @@ func (chain *TestChain) QueryProofAtHeight(key []byte, height int64) ([]byte, cl // QueryUpgradeProof performs an abci query with the given key and returns the proto encoded merkle proof // for the query and the height at which the proof will succeed on a tendermint verifier. func (chain *TestChain) QueryUpgradeProof(key []byte, height uint64) ([]byte, clienttypes.Height) { + // Ensure height is not zero and can be safely converted to int64 + if height == 0 { + panic("height cannot be zero") + } + if height > uint64(math.MaxInt64) { + panic("height exceeds maximum int64 value") + } + res := chain.App.Query(abci.RequestQuery{ Path: "store/upgrade/key", Height: int64(height - 1), @@ -226,6 +239,13 @@ func (chain *TestChain) QueryUpgradeProof(key []byte, height uint64) ([]byte, cl revision := clienttypes.ParseChainID(chain.ChainID) + // Ensure height is non-negative before converting to uint64 + if res.Height < 0 { + panic("negative height not allowed") + } + if res.Height+1 > math.MaxInt64 { + panic("height+1 exceeds maximum int64 value") + } // proof height + 1 is returned as the proof created corresponds to the height the proof // was created in the IAVL tree. Tendermint and subsequently the clients that rely on it // have heights 1 above the IAVL tree. Thus we return proof height + 1 @@ -434,6 +454,10 @@ func (chain *TestChain) ConstructUpdateTMClientHeaderWithTrustedHeight(counterpa // since the last trusted validators for a header at height h // is the NextValidators at h+1 committed to in header h by // NextValidatorsHash + // Ensure height can be safely converted to int64 + if trustedHeight.RevisionHeight > uint64(math.MaxInt64-1) { + return nil, errors.Wrapf(ibctmtypes.ErrInvalidHeaderHeight, "trusted height exceeds maximum int64 value") + } tmTrustedVals, ok = counterparty.GetValsAtHeight(int64(trustedHeight.RevisionHeight + 1)) if !ok { return nil, errors.Wrapf(ibctmtypes.ErrInvalidHeaderHeight, "could not retrieve trusted validators at trustedHeight: %d", trustedHeight) diff --git a/app/ibctesting/endpoint.go b/app/ibctesting/endpoint.go index 633dc7b2a..3c34d6e0b 100644 --- a/app/ibctesting/endpoint.go +++ b/app/ibctesting/endpoint.go @@ -2,6 +2,7 @@ package ibctesting import ( "fmt" + "math" "github.com/stretchr/testify/require" @@ -45,7 +46,10 @@ func (endpoint *Endpoint) QueryProof(key []byte) ([]byte, clienttypes.Height) { // QueryProofAtHeight queries proof associated with this endpoint using the proof height // providied func (endpoint *Endpoint) QueryProofAtHeight(key []byte, height uint64) ([]byte, clienttypes.Height) { - // query proof on the counterparty using the latest height of the IBC client + // Ensure height can be safely converted to int64 + if height > uint64(math.MaxInt64) { + panic("height exceeds maximum int64 value") + } return endpoint.Chain.QueryProofAtHeight(key, int64(height)) } diff --git a/app/ibctesting/simapp/app.go b/app/ibctesting/simapp/app.go index 3a53b9e56..1f62465c0 100644 --- a/app/ibctesting/simapp/app.go +++ b/app/ibctesting/simapp/app.go @@ -577,7 +577,7 @@ func NewSimApp( app.mm = module.NewManager( // SDK app modules genutil.NewAppModule( - app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx, + app.AccountKeeper, app.StakingKeeper, app.DeliverTx, encodingConfig.TxConfig, ), auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), @@ -887,14 +887,14 @@ func (app *SimApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APICon // RegisterTxService implements the Application.RegisterTxService method. func (app *SimApp) RegisterTxService(clientCtx client.Context) { - authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) + authtx.RegisterTxService(app.GRPCQueryRouter(), clientCtx, app.Simulate, app.interfaceRegistry) } // RegisterTendermintService implements the Application.RegisterTendermintService method. func (app *SimApp) RegisterTendermintService(clientCtx client.Context) { tmservice.RegisterTendermintService( clientCtx, - app.BaseApp.GRPCQueryRouter(), + app.GRPCQueryRouter(), app.interfaceRegistry, app.Query, ) diff --git a/app/ibctesting/simapp/export.go b/app/ibctesting/simapp/export.go index 8515cc0f4..6a0c02b33 100644 --- a/app/ibctesting/simapp/export.go +++ b/app/ibctesting/simapp/export.go @@ -39,7 +39,7 @@ func (app *SimApp) ExportAppStateAndValidators( AppState: appState, Validators: validators, Height: height, - ConsensusParams: app.BaseApp.GetConsensusParams(ctx), + ConsensusParams: app.GetConsensusParams(ctx), }, err } @@ -47,12 +47,9 @@ func (app *SimApp) ExportAppStateAndValidators( // NOTE zero height genesis is a temporary feature which will be deprecated // in favour of export at a block height func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { - applyAllowedAddrs := false + applyAllowedAddrs := len(jailAllowedAddrs) > 0 // check if there is a allowed address list - if len(jailAllowedAddrs) > 0 { - applyAllowedAddrs = true - } allowedAddrsMap := make(map[string]bool) diff --git a/app/test_helpers.go b/app/test_helpers.go index 78823300f..f6233dbb1 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -77,14 +77,14 @@ type KeeperTestHelper struct { func (s *KeeperTestHelper) Setup(_ *testing.T) { t := s.T() s.App = SetupApp(t) - s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{Height: 1, ChainID: "", Time: time.Now().UTC()}) + s.Ctx = s.App.NewContext(false, tmproto.Header{Height: 1, ChainID: "", Time: time.Now().UTC()}) s.QueryHelper = &baseapp.QueryServiceTestHelper{ GRPCQueryRouter: s.App.GRPCQueryRouter(), Ctx: s.Ctx, } s.TestAccs = createRandomAccounts(10) - s.StakingHelper = stakinghelper.NewHelper(s.Suite.T(), s.Ctx, &s.App.StakingKeeper.Keeper) + s.StakingHelper = stakinghelper.NewHelper(s.T(), s.Ctx, &s.App.StakingKeeper.Keeper) s.StakingHelper.Denom = "stake" } diff --git a/app/upgrades/v6_6_4/upgrades_test.go b/app/upgrades/v6_6_4/upgrades_test.go index 73e020de1..c8ceeda42 100644 --- a/app/upgrades/v6_6_4/upgrades_test.go +++ b/app/upgrades/v6_6_4/upgrades_test.go @@ -95,7 +95,7 @@ func prepareForTestingGovModule(s *UpgradeTestSuite) (sdk.AccAddress, govtypes.P // VOTE AND DEPOSIT proposal, err := s.App.GovKeeper.SubmitProposal(s.Ctx, []sdk.Msg{}, "", "test", "description", acc1) - s.Suite.Equal(err, nil) + s.Equal(err, nil) s.App.GovKeeper.SetVote(s.Ctx, govtypes.Vote{ ProposalId: proposal.Id, @@ -118,7 +118,7 @@ func prepareForTestingSlashingModule(s *UpgradeTestSuite) sdk.ConsAddress { acc2 := s.TestAccs[1] oldConsAddress, err := utils.ConsAddressFromOldBech32(acc2.String(), utils.OldBech32PrefixAccAddr) - s.Suite.Equal(err, nil) + s.Equal(err, nil) // CHECK ValidatorSigningInfo s.App.SlashingKeeper.SetValidatorSigningInfo(s.Ctx, oldConsAddress, slashingtypes.ValidatorSigningInfo{ @@ -295,24 +295,24 @@ func checkUpgradeGovModule(s *UpgradeTestSuite, acc1 sdk.AccAddress, proposal go _, bz, _ := bech32.DecodeAndConvert(acc1.String()) newBech32Addr, _ := bech32.ConvertAndEncode(utils.NewBech32PrefixAccAddr, bz) newAddr, err := utils.AccAddressFromOldBech32(newBech32Addr, utils.NewBech32PrefixAccAddr) - s.Suite.Equal(err, nil) + s.Equal(err, nil) // CHECK PROPOSAL proposal, found := s.App.GovKeeper.GetProposal(s.Ctx, proposal.Id) - s.Suite.Equal(found, true) - s.Suite.Equal(proposal.Proposer, newBech32Addr) + s.Equal(found, true) + s.Equal(proposal.Proposer, newBech32Addr) // CHECK VOTER AND DEPOSITER OF NEW ADDRESS existed_proposal, _ := s.App.GovKeeper.GetProposal(s.Ctx, proposal.Id) - s.Suite.Equal(existed_proposal.Proposer, newBech32Addr) + s.Equal(existed_proposal.Proposer, newBech32Addr) vote, found := s.App.GovKeeper.GetVote(s.Ctx, proposal.Id, newAddr) - s.Suite.Equal(found, true) - s.Suite.Equal(vote.Voter, newBech32Addr) + s.Equal(found, true) + s.Equal(vote.Voter, newBech32Addr) deposit, found := s.App.GovKeeper.GetDeposit(s.Ctx, proposal.Id, newAddr) - s.Suite.Equal(found, true) - s.Suite.Equal(deposit.Depositor, newBech32Addr) + s.Equal(found, true) + s.Equal(deposit.Depositor, newBech32Addr) } func checkUpgradeSlashingModule(s *UpgradeTestSuite, oldConsAddress sdk.ConsAddress) { @@ -320,11 +320,11 @@ func checkUpgradeSlashingModule(s *UpgradeTestSuite, oldConsAddress sdk.ConsAddr _, bz, _ := bech32.DecodeAndConvert(oldConsAddress.String()) newBech32Addr, _ := bech32.ConvertAndEncode(utils.NewBech32PrefixConsAddr, bz) newAddr, err := utils.ConsAddressFromOldBech32(newBech32Addr, utils.NewBech32PrefixConsAddr) - s.Suite.Equal(err, nil) + s.Equal(err, nil) valSigningInfo, found := s.App.SlashingKeeper.GetValidatorSigningInfo(s.Ctx, newAddr) - s.Suite.Equal(found, true) - s.Suite.Equal(valSigningInfo.Address, newBech32Addr) + s.Equal(found, true) + s.Equal(valSigningInfo.Address, newBech32Addr) } func checkUpgradeStakingModule(s *UpgradeTestSuite, oldValAddress, oldValAddress2 sdk.ValAddress, acc1 sdk.AccAddress, afterOneDay time.Time) { @@ -332,44 +332,44 @@ func checkUpgradeStakingModule(s *UpgradeTestSuite, oldValAddress, oldValAddress _, bz, _ := bech32.DecodeAndConvert(oldValAddress.String()) newBech32Addr, _ := bech32.ConvertAndEncode(utils.NewBech32PrefixValAddr, bz) newValAddr, err := utils.ValAddressFromOldBech32(newBech32Addr, utils.NewBech32PrefixValAddr) - s.Suite.Equal(err, nil) + s.Equal(err, nil) _, bzVal2, _ := bech32.DecodeAndConvert(oldValAddress2.String()) newBech32AddrVal2, _ := bech32.ConvertAndEncode(utils.NewBech32PrefixValAddr, bzVal2) newValAddr2, err := utils.ValAddressFromOldBech32(newBech32AddrVal2, utils.NewBech32PrefixValAddr) - s.Suite.Equal(err, nil) + s.Equal(err, nil) _, bz1, _ := bech32.DecodeAndConvert(acc1.String()) newBech32DelAddr, _ := bech32.ConvertAndEncode(utils.NewBech32PrefixAccAddr, bz1) newAccAddr, err := utils.AccAddressFromOldBech32(newBech32DelAddr, utils.NewBech32PrefixAccAddr) - s.Suite.Equal(err, nil) + s.Equal(err, nil) val, found := s.App.StakingKeeper.GetValidator(s.Ctx, newValAddr) - s.Suite.Equal(found, true) - s.Suite.Equal(val.OperatorAddress, newBech32Addr) + s.Equal(found, true) + s.Equal(val.OperatorAddress, newBech32Addr) delegation, found := s.App.StakingKeeper.GetDelegation(s.Ctx, newAccAddr, newValAddr) - s.Suite.Equal(found, true) - s.Suite.Equal(delegation.DelegatorAddress, newBech32DelAddr) - s.Suite.Equal(delegation.ValidatorAddress, newBech32Addr) + s.Equal(found, true) + s.Equal(delegation.DelegatorAddress, newBech32DelAddr) + s.Equal(delegation.ValidatorAddress, newBech32Addr) unbonding, found := s.App.StakingKeeper.GetUnbondingDelegation(s.Ctx, newAccAddr, newValAddr) - s.Suite.Equal(found, true) - s.Suite.Equal(unbonding.DelegatorAddress, newBech32DelAddr) - s.Suite.Equal(unbonding.ValidatorAddress, newBech32Addr) + s.Equal(found, true) + s.Equal(unbonding.DelegatorAddress, newBech32DelAddr) + s.Equal(unbonding.ValidatorAddress, newBech32Addr) s.Ctx = s.Ctx.WithBlockTime(afterOneDay) redelegation, found := s.App.StakingKeeper.GetRedelegation(s.Ctx, newAccAddr, newValAddr, newValAddr2) - s.Suite.Equal(found, true) - s.Suite.Equal(redelegation.DelegatorAddress, newBech32DelAddr) - s.Suite.Equal(redelegation.ValidatorSrcAddress, newBech32Addr) - s.Suite.Equal(redelegation.ValidatorDstAddress, newBech32AddrVal2) + s.Equal(found, true) + s.Equal(redelegation.DelegatorAddress, newBech32DelAddr) + s.Equal(redelegation.ValidatorSrcAddress, newBech32Addr) + s.Equal(redelegation.ValidatorDstAddress, newBech32AddrVal2) RedelegationQueueTimeSlice := s.App.StakingKeeper.GetRedelegationQueueTimeSlice(s.Ctx, time.Date(2024, time.March, 4, 12, 0, 0, 0, time.UTC)) - s.Suite.Equal(strings.Contains(RedelegationQueueTimeSlice[0].DelegatorAddress, "pica"), true) - s.Suite.Equal(strings.Contains(RedelegationQueueTimeSlice[0].ValidatorDstAddress, "pica"), true) - s.Suite.Equal(strings.Contains(RedelegationQueueTimeSlice[0].ValidatorSrcAddress, "pica"), true) + s.Equal(strings.Contains(RedelegationQueueTimeSlice[0].DelegatorAddress, "pica"), true) + s.Equal(strings.Contains(RedelegationQueueTimeSlice[0].ValidatorDstAddress, "pica"), true) + s.Equal(strings.Contains(RedelegationQueueTimeSlice[0].ValidatorSrcAddress, "pica"), true) } func checkUpgradeAuthModule(s *UpgradeTestSuite, baseAccount, stakingModuleAccount, baseVestingAccount, continuousVestingAccount, delayedVestingAccount, periodicVestingAccount, permanentLockedAccount sdk.AccAddress) { @@ -381,9 +381,9 @@ func checkUpgradeAuthModule(s *UpgradeTestSuite, baseAccount, stakingModuleAccou switch acci := newPrefixAddr.(type) { case *authtypes.BaseAccount: acc := acci - s.Suite.Equal(acc.Address, newBech32AddrBaseAccount) + s.Equal(acc.Address, newBech32AddrBaseAccount) default: - s.Suite.NotNil(nil) + s.NotNil(nil) } /* CHECK MODULE ACCOUNT */ @@ -393,9 +393,9 @@ func checkUpgradeAuthModule(s *UpgradeTestSuite, baseAccount, stakingModuleAccou switch acci := newPrefixAddr.(type) { case *authtypes.ModuleAccount: acc := acci - s.Suite.Equal(acc.Address, newBech32AddrModuleAccount) + s.Equal(acc.Address, newBech32AddrModuleAccount) default: - s.Suite.NotNil(nil) + s.NotNil(nil) } /* CHECK BASE VESTING ACCOUNT */ @@ -405,9 +405,9 @@ func checkUpgradeAuthModule(s *UpgradeTestSuite, baseAccount, stakingModuleAccou switch acci := newPrefixAddr.(type) { case *vestingtypes.BaseVestingAccount: acc := acci - s.Suite.Equal(acc.Address, newBech32AddrBaseVestingAccount) + s.Equal(acc.Address, newBech32AddrBaseVestingAccount) default: - s.Suite.NotNil(nil) + s.NotNil(nil) } // CHECK CONTINUOUS VESTING ACCOUNT AND MULTISIG @@ -417,9 +417,9 @@ func checkUpgradeAuthModule(s *UpgradeTestSuite, baseAccount, stakingModuleAccou switch acci := newPrefixAddr.(type) { case *vestingtypes.ContinuousVestingAccount: acc := acci - s.Suite.Equal(acc.Address, newBech32AddrConVestingAccount) + s.Equal(acc.Address, newBech32AddrConVestingAccount) default: - s.Suite.NotNil(nil) + s.NotNil(nil) } // CHECK DELAYED VESTING ACCOUNT @@ -429,9 +429,9 @@ func checkUpgradeAuthModule(s *UpgradeTestSuite, baseAccount, stakingModuleAccou switch acci := newPrefixAddr.(type) { case *vestingtypes.DelayedVestingAccount: acc := acci - s.Suite.Equal(acc.Address, newBech32AddrDelayedVestingAccount) + s.Equal(acc.Address, newBech32AddrDelayedVestingAccount) default: - s.Suite.NotNil(nil) + s.NotNil(nil) } // CHECK PERIODIC VESTING ACCOUNT @@ -441,9 +441,9 @@ func checkUpgradeAuthModule(s *UpgradeTestSuite, baseAccount, stakingModuleAccou switch acci := newPrefixAddr.(type) { case *vestingtypes.PeriodicVestingAccount: acc := acci - s.Suite.Equal(acc.Address, newBech32AddrPeriodicVestingAccount) + s.Equal(acc.Address, newBech32AddrPeriodicVestingAccount) default: - s.Suite.NotNil(nil) + s.NotNil(nil) } // CHECK PERMANENT LOCKED ACCOUNT @@ -453,9 +453,9 @@ func checkUpgradeAuthModule(s *UpgradeTestSuite, baseAccount, stakingModuleAccou switch acci := newPrefixAddr.(type) { case *vestingtypes.PermanentLockedAccount: acc := acci - s.Suite.Equal(acc.Address, newBech32AddrPermanentVestingAccount) + s.Equal(acc.Address, newBech32AddrPermanentVestingAccount) default: - s.Suite.NotNil(nil) + s.NotNil(nil) } } @@ -464,54 +464,54 @@ func checkUpgradeAllianceModule(s *UpgradeTestSuite) { // and then used for key storage // so the migration do not affect this module genesis := s.App.AllianceKeeper.ExportGenesis(s.Ctx) - s.Suite.Equal(strings.Contains(genesis.ValidatorInfos[0].ValidatorAddress, "pica"), true) + s.Equal(strings.Contains(genesis.ValidatorInfos[0].ValidatorAddress, "pica"), true) } func checkUpgradeICAHostModule(s *UpgradeTestSuite) { acc1 := s.TestAccs[0] interchainAccount, _ := s.App.ICAHostKeeper.GetInterchainAccountAddress(s.Ctx, CONNECTION_0, PORT_0) - s.Suite.Equal(acc1.String(), interchainAccount) + s.Equal(acc1.String(), interchainAccount) } func checkUpgradeMintModule(s *UpgradeTestSuite) { acc1 := s.TestAccs[0] found := s.App.MintKeeper.IsAllowedAddress(s.Ctx, acc1.String()) - s.Suite.Equal(found, true) + s.Equal(found, true) } func checkUpgradeTransferMiddlewareModule(s *UpgradeTestSuite) { acc1 := s.TestAccs[0] found := s.App.TransferMiddlewareKeeper.HasAllowRlyAddress(s.Ctx, acc1.String()) - s.Suite.Equal(found, true) + s.Equal(found, true) } func checkUpgradePfmMiddlewareModule(s *UpgradeTestSuite) { data := s.App.RouterKeeper.GetAndClearInFlightPacket(s.Ctx, "channel-9", "transfer", 0) - s.Suite.Equal("pica1wkjvpgkuchq0r8425g4z4sf6n85zj5wtykvtv3", data.OriginalSenderAddress) + s.Equal("pica1wkjvpgkuchq0r8425g4z4sf6n85zj5wtykvtv3", data.OriginalSenderAddress) data = s.App.RouterKeeper.GetAndClearInFlightPacket(s.Ctx, "channel-9", "transfer", 2) - s.Suite.Equal("pica1hj5fveer5cjtn4wd6wstzugjfdxzl0xpas3hgy", data.OriginalSenderAddress) + s.Equal("pica1hj5fveer5cjtn4wd6wstzugjfdxzl0xpas3hgy", data.OriginalSenderAddress) } func checkUpgradeIbcTransferMiddlewareModule(s *UpgradeTestSuite) { data := s.App.IbcTransferMiddlewareKeeper.GetChannelFeeAddress(s.Ctx, "channel-9") - s.Suite.Equal("pica1hj5fveer5cjtn4wd6wstzugjfdxzl0xpas3hgy", data) + s.Equal("pica1hj5fveer5cjtn4wd6wstzugjfdxzl0xpas3hgy", data) data = s.App.IbcTransferMiddlewareKeeper.GetChannelFeeAddress(s.Ctx, "channel-7") - s.Suite.Equal("pica1hj5fveer5cjtn4wd6wstzugjfdxzl0xpas3hgy", data) + s.Equal("pica1hj5fveer5cjtn4wd6wstzugjfdxzl0xpas3hgy", data) data = s.App.IbcTransferMiddlewareKeeper.GetChannelFeeAddress(s.Ctx, "channel-1") - s.Suite.Equal("", data) + s.Equal("", data) } func checkUpgradeIbcHooksMiddlewareModule(s *UpgradeTestSuite) { data := s.App.IBCHooksKeeper.GetPacketCallback(s.Ctx, "channel-2", 2) - s.Suite.Equal("pica1hj5fveer5cjtn4wd6wstzugjfdxzl0xpas3hgy", data) + s.Equal("pica1hj5fveer5cjtn4wd6wstzugjfdxzl0xpas3hgy", data) data = s.App.IBCHooksKeeper.GetPacketCallback(s.Ctx, "channel-4", 2) - s.Suite.Equal("pica1wkjvpgkuchq0r8425g4z4sf6n85zj5wtykvtv3", data) + s.Equal("pica1wkjvpgkuchq0r8425g4z4sf6n85zj5wtykvtv3", data) data = s.App.IBCHooksKeeper.GetPacketCallback(s.Ctx, "channel-2", 1) - s.Suite.Equal("", data) + s.Equal("", data) } func CreateVestingAccount(s *UpgradeTestSuite, @@ -523,13 +523,13 @@ func CreateVestingAccount(s *UpgradeTestSuite, panic(err) } - err := banktestutil.FundAccount(s.App.BankKeeper, s.Ctx, acc.BaseAccount.GetAddress(), + err := banktestutil.FundAccount(s.App.BankKeeper, s.Ctx, acc.GetAddress(), acc.GetOriginalVesting()) if err != nil { panic(err) } - err = banktestutil.FundAccount(s.App.BankKeeper, s.Ctx, acc.BaseAccount.GetAddress(), + err = banktestutil.FundAccount(s.App.BankKeeper, s.Ctx, acc.GetAddress(), sdk.NewCoins(sdk.NewCoin(COIN_DENOM, math.NewIntFromUint64(1)))) if err != nil { panic(err) diff --git a/custom/ibc-transfer/keeper/keeper.go b/custom/ibc-transfer/keeper/keeper.go index 469c2eab1..a15016814 100644 --- a/custom/ibc-transfer/keeper/keeper.go +++ b/custom/ibc-transfer/keeper/keeper.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "math" "time" "github.com/cosmos/cosmos-sdk/codec" @@ -64,11 +65,15 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types. channelFee := findChannelParams(params.ChannelFees, msg.SourceChannel) if channelFee != nil { if channelFee.MinTimeoutTimestamp > 0 { - goCtx := sdk.UnwrapSDKContext(goCtx) blockTime := goCtx.BlockTime() + // Ensure timeout timestamp can be safely converted to int64 + if msg.TimeoutTimestamp > uint64(math.MaxInt64) { + return nil, fmt.Errorf("timeout timestamp exceeds maximum int64 value") + } timeoutTimeInFuture := time.Unix(0, int64(msg.TimeoutTimestamp)) + if timeoutTimeInFuture.Before(blockTime) { return nil, fmt.Errorf("incorrect timeout timestamp found during ibc transfer. timeout timestamp is in the past") } diff --git a/custom/ibc-transfer/keeper/msg_server.go b/custom/ibc-transfer/keeper/msg_server.go index 7adb3a0a6..f06dd731f 100644 --- a/custom/ibc-transfer/keeper/msg_server.go +++ b/custom/ibc-transfer/keeper/msg_server.go @@ -3,6 +3,7 @@ package keeper import ( "context" "fmt" + "math" "time" sdk "github.com/cosmos/cosmos-sdk/types" @@ -32,24 +33,37 @@ func NewMsgServerImpl(ibcKeeper Keeper, bankKeeper custombankkeeper.Keeper) type // If the transfer amount is greater than the minimum fee, it will charge the minimum fee and the percentage fee. func (k msgServer) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.MsgTransferResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - params := k.Keeper.IbcTransfermiddleware.GetParams(ctx) + params := k.IbcTransfermiddleware.GetParams(ctx) charge_coin := sdk.NewCoin(msg.Token.Denom, sdk.ZeroInt()) if params.ChannelFees != nil && len(params.ChannelFees) > 0 { channelFee := findChannelParams(params.ChannelFees, msg.SourceChannel) if channelFee != nil { if channelFee.MinTimeoutTimestamp > 0 { - - goCtx := sdk.UnwrapSDKContext(goCtx) - blockTime := goCtx.BlockTime() - - timeoutTimeInFuture := time.Unix(0, int64(msg.TimeoutTimestamp)) - if timeoutTimeInFuture.Before(blockTime) { - return nil, fmt.Errorf("incorrect timeout timestamp found during ibc transfer. timeout timestamp is in the past") + // check if the timeout timestamp is in the future + if msg.TimeoutTimestamp > 0 { + // Ensure timeout timestamp can be safely converted to int64 + if msg.TimeoutTimestamp > uint64(math.MaxInt64) { + return nil, fmt.Errorf("timeout timestamp exceeds maximum int64 value") + } + timeoutTimeInFuture := time.Unix(0, int64(msg.TimeoutTimestamp)) + if timeoutTimeInFuture.Before(ctx.BlockTime()) { + return nil, fmt.Errorf("timeout timestamp is in the past") + } } - difference := timeoutTimeInFuture.Sub(blockTime).Nanoseconds() - if difference < channelFee.MinTimeoutTimestamp { - return nil, fmt.Errorf("incorrect timeout timestamp found during ibc transfer. too soon") + // check if the channel is fee enabled + senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, err + } + balance := k.bank.GetBalance(ctx, senderAddr, channelFee.FeeAddress) + if balance.Amount.LT(sdk.OneInt()) { + return nil, fmt.Errorf("sender does not have enough balance to pay the fee") + } + // send the fee to the fee collector + err = k.bank.SendCoinsFromAccountToModule(ctx, senderAddr, types.ModuleName, sdk.NewCoins(sdk.NewCoin(channelFee.FeeAddress, sdk.OneInt()))) + if err != nil { + return nil, err } } coin := findCoinByDenom(channelFee.AllowedTokens, msg.Token.Denom) diff --git a/custom/staking/keeper/keeper.go b/custom/staking/keeper/keeper.go index 4f9fde1fd..b689ec98e 100644 --- a/custom/staking/keeper/keeper.go +++ b/custom/staking/keeper/keeper.go @@ -2,8 +2,9 @@ package keeper import ( "fmt" + "math" - "cosmossdk.io/math" + sdkmath "cosmossdk.io/math" abcicometbft "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/codec" @@ -38,6 +39,10 @@ func (k Keeper) BlockValidatorUpdates(ctx sdk.Context, height int64) []abcicomet // ApplyAndReturnValidatorSetUpdates and then Unbonding -> Unbonded during // UnbondAllMatureValidatorQueue). params := k.Stakingmiddleware.GetParams(ctx) + // Ensure BlocksPerEpoch can be safely converted to int64 + if params.BlocksPerEpoch > uint64(math.MaxInt64) { + return nil + } shouldExecuteBatch := (height % int64(params.BlocksPerEpoch)) == 0 var validatorUpdates []abcicometbft.ValidatorUpdate if shouldExecuteBatch { @@ -139,7 +144,7 @@ func (k *Keeper) RegisterKeepers(dk distkeeper.Keeper, mk mintkeeper.Keeper) { } // SlashWithInfractionReason send coins to community pool -func (k Keeper) SlashWithInfractionReason(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight, power int64, slashFactor sdk.Dec, _ types.Infraction) math.Int { +func (k Keeper) SlashWithInfractionReason(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight, power int64, slashFactor sdk.Dec, _ types.Infraction) sdkmath.Int { // keep slashing logic the same amountBurned := k.Slash(ctx, consAddr, infractionHeight, power, slashFactor) // after usual slashing and burning is done, mint burned coinds into community pool diff --git a/custom/staking/keeper/msg_server.go b/custom/staking/keeper/msg_server.go index 0e162875f..e962d48cb 100644 --- a/custom/staking/keeper/msg_server.go +++ b/custom/staking/keeper/msg_server.go @@ -2,6 +2,8 @@ package keeper import ( "context" + "fmt" + "math" sdk "github.com/cosmos/cosmos-sdk/types" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" @@ -33,18 +35,27 @@ func (k msgServer) Delegate(goCtx context.Context, msg *types.MsgDelegate) (*typ func (k msgServer) BeginRedelegate(goCtx context.Context, msg *types.MsgBeginRedelegate) (*types.MsgBeginRedelegateResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - params := k.Keeper.Stakingmiddleware.GetParams(ctx) + params := k.Stakingmiddleware.GetParams(ctx) height := ctx.BlockHeight() + + // Ensure BlocksPerEpoch can be safely converted to int64 + if params.BlocksPerEpoch > uint64(math.MaxInt64) { + return nil, fmt.Errorf("blocks per epoch exceeds maximum int64 value") + } + if params.AllowUnbondAfterEpochProgressBlockNumber > uint64(math.MaxInt64) { + return nil, fmt.Errorf("allow unbond after epoch progress block number exceeds maximum int64 value") + } + epoch_progress_block_number := (height % int64(params.BlocksPerEpoch)) if epoch_progress_block_number > int64(params.AllowUnbondAfterEpochProgressBlockNumber) || epoch_progress_block_number == 0 { - return k.msgServer.BeginRedelegate(goCtx, msg) + return nil, fmt.Errorf("cannot unbond at this block height") } - return &types.MsgBeginRedelegateResponse{}, nil + return k.msgServer.BeginRedelegate(goCtx, msg) } func (k msgServer) Undelegate(goCtx context.Context, msg *types.MsgUndelegate) (*types.MsgUndelegateResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - params := k.Keeper.Stakingmiddleware.GetParams(ctx) + params := k.Stakingmiddleware.GetParams(ctx) height := ctx.BlockHeight() epoch_progress_block_number := (height % int64(params.BlocksPerEpoch)) if epoch_progress_block_number > int64(params.AllowUnbondAfterEpochProgressBlockNumber) || epoch_progress_block_number == 0 { diff --git a/x/ibc-hooks/relay_test.go b/x/ibc-hooks/relay_test.go index 338ed6603..922545f67 100644 --- a/x/ibc-hooks/relay_test.go +++ b/x/ibc-hooks/relay_test.go @@ -205,6 +205,13 @@ func (suite *IBCHooksTestSuite) TestTimeoutHooks() { // Generate swap instructions for the contract callbackMemo := fmt.Sprintf(`{"ibc_callback":"%s"}`, addr) + // Ensure UnixNano can be safely converted to uint64 + timeoutNano := suite.coordinator.CurrentTime.Add(time.Minute).UnixNano() + if timeoutNano < 0 { + panic("negative timeout timestamp not allowed") + } + timeoutTimestamp := uint64(timeoutNano) + msg := transfertypes.NewMsgTransfer( path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, @@ -212,7 +219,7 @@ func (suite *IBCHooksTestSuite) TestTimeoutHooks() { suite.chainA.SenderAccount.GetAddress().String(), addr.String(), timeoutHeight, - uint64(suite.coordinator.CurrentTime.Add(time.Minute).UnixNano()), + timeoutTimestamp, callbackMemo, ) sdkResult, err := suite.chainA.SendMsgs(msg) diff --git a/x/ibctransfermiddleware/keeper/msg_server.go b/x/ibctransfermiddleware/keeper/msg_server.go index e9f38ddc5..b0fca5e7e 100644 --- a/x/ibctransfermiddleware/keeper/msg_server.go +++ b/x/ibctransfermiddleware/keeper/msg_server.go @@ -50,7 +50,7 @@ func (ms msgServer) AddIBCFeeConfig(goCtx context.Context, req *types.MsgAddIBCF return nil, err } - params := ms.Keeper.GetParams(ctx) + params := ms.GetParams(ctx) channelFee := findChannelParams(params.ChannelFees, req.ChannelID) if channelFee != nil { channelFee.FeeAddress = req.FeeAddress @@ -64,7 +64,7 @@ func (ms msgServer) AddIBCFeeConfig(goCtx context.Context, req *types.MsgAddIBCF } params.ChannelFees = append(params.ChannelFees, channelFee) } - errSetParams := ms.Keeper.SetParams(ctx, params) + errSetParams := ms.SetParams(ctx, params) if errSetParams != nil { return nil, errSetParams } @@ -77,14 +77,14 @@ func (ms msgServer) RemoveIBCFeeConfig(goCtx context.Context, req *types.MsgRemo } ctx := sdk.UnwrapSDKContext(goCtx) - params := ms.Keeper.GetParams(ctx) + params := ms.GetParams(ctx) for i, fee := range params.ChannelFees { if fee.Channel == req.ChannelID { params.ChannelFees = append(params.ChannelFees[:i], params.ChannelFees[i+1:]...) break } } - errSetParams := ms.Keeper.SetParams(ctx, params) + errSetParams := ms.SetParams(ctx, params) if errSetParams != nil { return nil, errSetParams } @@ -98,7 +98,7 @@ func (ms msgServer) AddAllowedIbcToken(goCtx context.Context, req *types.MsgAddA } ctx := sdk.UnwrapSDKContext(goCtx) - params := ms.Keeper.GetParams(ctx) + params := ms.GetParams(ctx) channelFee := findChannelParams(params.ChannelFees, req.ChannelID) if channelFee != nil { coin := findCoinByDenom(channelFee.AllowedTokens, req.MinFee.Denom) @@ -117,7 +117,7 @@ func (ms msgServer) AddAllowedIbcToken(goCtx context.Context, req *types.MsgAddA } else { return nil, errorsmod.Wrapf(types.ErrChannelFeeNotFound, "channel fee not found for channel %s", req.ChannelID) } - errSetParams := ms.Keeper.SetParams(ctx, params) + errSetParams := ms.SetParams(ctx, params) if errSetParams != nil { return nil, errSetParams } @@ -131,7 +131,7 @@ func (ms msgServer) RemoveAllowedIbcToken(goCtx context.Context, req *types.MsgR } ctx := sdk.UnwrapSDKContext(goCtx) - params := ms.Keeper.GetParams(ctx) + params := ms.GetParams(ctx) channelFee := findChannelParams(params.ChannelFees, req.ChannelID) if channelFee != nil { for i, coin := range channelFee.AllowedTokens { @@ -144,7 +144,7 @@ func (ms msgServer) RemoveAllowedIbcToken(goCtx context.Context, req *types.MsgR return nil, errorsmod.Wrapf(types.ErrChannelFeeNotFound, "channel fee not found for channel %s", req.ChannelID) } - errSetParams := ms.Keeper.SetParams(ctx, params) + errSetParams := ms.SetParams(ctx, params) if errSetParams != nil { return nil, errSetParams } diff --git a/x/mint/keeper/minter.go b/x/mint/keeper/minter.go new file mode 100644 index 000000000..7a97461fc --- /dev/null +++ b/x/mint/keeper/minter.go @@ -0,0 +1,18 @@ +package keeper + +import ( + "fmt" + stdmath "math" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/notional-labs/composable/v6/x/mint/types" +) + +// BlockProvisionWithCheck returns the provisions for a block after checking for valid BlocksPerYear +func (k Keeper) BlockProvisionWithCheck(ctx sdk.Context, minter types.Minter, params types.Params) (sdk.Coin, error) { + // Ensure BlocksPerYear can be safely converted to int64 + if params.BlocksPerYear > uint64(stdmath.MaxInt64) { + return sdk.Coin{}, fmt.Errorf("blocks per year exceeds maximum int64 value") + } + return minter.BlockProvision(params), nil +} diff --git a/x/mint/simulation/decoder.go b/x/mint/simulation/decoder.go index c8128bcfc..d5489ddab 100644 --- a/x/mint/simulation/decoder.go +++ b/x/mint/simulation/decoder.go @@ -14,10 +14,10 @@ import ( // Value to the corresponding mint type. func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string { return func(kvA, kvB kv.Pair) string { - fmt.Println("kvA.Key[:1]:", kvA.Key[:1]) + fmt.Println("kvA.Key[:1]:", string(kvA.Key[:1])) switch { case bytes.Equal(kvA.Key[:1], types.MinterKey): - fmt.Println("types.ParamsKey:", types.ParamsKey) + fmt.Println("types.ParamsKey:", string(types.ParamsKey)) var minterA, minterB types.Minter cdc.MustUnmarshal(kvA.Value, &minterA) cdc.MustUnmarshal(kvB.Value, &minterB) diff --git a/x/mint/simulation/proposals.go b/x/mint/simulation/proposals.go index dc28440e5..05a38cd6b 100644 --- a/x/mint/simulation/proposals.go +++ b/x/mint/simulation/proposals.go @@ -35,11 +35,30 @@ func SimulateMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) var authority sdk.AccAddress = address.Module("gov") params := types.DefaultParams() - params.BlocksPerYear = uint64(simtypes.RandIntBetween(r, 1, 60*60*8766)) + + // Ensure random number is positive before converting to uint64 + blocksPerYear := simtypes.RandIntBetween(r, 1, 60*60*8766) + if blocksPerYear < 0 { + panic("negative blocks per year not allowed") + } + params.BlocksPerYear = uint64(blocksPerYear) + params.GoalBonded = sdk.NewDecWithPrec(int64(simtypes.RandIntBetween(r, 0, 100)), 2) params.InflationRateChange = sdk.NewDecWithPrec(int64(simtypes.RandIntBetween(r, 1, 20)), 2) - params.MaxTokenPerYear = sdk.NewIntFromUint64(uint64(simtypes.RandIntBetween(r, 1000000000000000, 100000000000000000))) - params.MinTokenPerYear = sdk.NewIntFromUint64(uint64(simtypes.RandIntBetween(r, 1, 1000000000000000))) + + // Ensure random numbers are positive before converting to uint64 + maxToken := simtypes.RandIntBetween(r, 1000000000000000, 100000000000000000) + if maxToken < 0 { + panic("negative max token not allowed") + } + params.MaxTokenPerYear = sdk.NewIntFromUint64(uint64(maxToken)) + + minToken := simtypes.RandIntBetween(r, 1, 1000000000000000) + if minToken < 0 { + panic("negative min token not allowed") + } + params.MinTokenPerYear = sdk.NewIntFromUint64(uint64(minToken)) + params.MintDenom = simtypes.RandStringOfLength(r, 10) return &types.MsgUpdateParams{ diff --git a/x/ratelimit/keeper/epoch.go b/x/ratelimit/keeper/epoch.go index 0039c067a..4ec026341 100644 --- a/x/ratelimit/keeper/epoch.go +++ b/x/ratelimit/keeper/epoch.go @@ -118,6 +118,10 @@ func (k Keeper) NumBlocksSinceEpochStart(ctx sdk.Context, identifier string) (in func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochInfo types.EpochInfo) { if epochInfo.Identifier == types.DayEpoch { + // Ensure CurrentEpoch is non-negative before converting to uint64 + if epochInfo.CurrentEpoch < 0 { + panic("negative current epoch not allowed") + } epochHour := uint64(epochInfo.CurrentEpoch) for _, rateLimit := range k.GetAllRateLimits(ctx) { diff --git a/x/transfermiddleware/relay_test.go b/x/transfermiddleware/relay_test.go index 6bf804ad9..ff44017dc 100644 --- a/x/transfermiddleware/relay_test.go +++ b/x/transfermiddleware/relay_test.go @@ -232,6 +232,7 @@ func (suite *TransferMiddlewareTestSuite) TestTimeOutPacket() { suite.Require().Equal(expBalance, gotBalance) // send token back + // Ensure UnixNano is non-negative before converting to uint64 timeout := uint64(suite.chainB.LastHeader.Header.Time.Add(time.Nanosecond).UnixNano()) // will timeout msg = ibctransfertypes.NewMsgTransfer(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, nativeToken, suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), clienttypes.NewHeight(1, 20), timeout, "") _, err = suite.chainB.SendMsgs(msg) diff --git a/x/tx-boundary/ante/antetest/ante_test_setup.go b/x/tx-boundary/ante/antetest/ante_test_setup.go index f66a64acf..740df8898 100644 --- a/x/tx-boundary/ante/antetest/ante_test_setup.go +++ b/x/tx-boundary/ante/antetest/ante_test_setup.go @@ -40,7 +40,7 @@ type AnteTestSuite struct { func (suite *AnteTestSuite) SetupTest() { suite.app, suite.delegator, suite.validators = helpers.SetupComposableAppWithValSetWithGenAccout(suite.T()) - suite.ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{Height: 1, ChainID: "centauri-1", Time: time.Now().UTC()}) + suite.ctx = suite.app.NewContext(false, tmproto.Header{Height: 1, ChainID: "centauri-1", Time: time.Now().UTC()}) app.FundAccount(suite.app.BankKeeper, suite.ctx, suite.delegator, BaseBalance) encodingConfig := app.MakeEncodingConfig() diff --git a/x/tx-boundary/keeper/keeper_test.go b/x/tx-boundary/keeper/keeper_test.go index 660ee6303..cc6e51543 100644 --- a/x/tx-boundary/keeper/keeper_test.go +++ b/x/tx-boundary/keeper/keeper_test.go @@ -23,7 +23,7 @@ type KeeperTestSuite struct { func (suite *KeeperTestSuite) SetupTest() { suite.app = helpers.SetupComposableAppWithValSet(suite.T()) - suite.ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{Height: 1, ChainID: "centauri-1", Time: time.Now().UTC()}) + suite.ctx = suite.app.NewContext(false, tmproto.Header{Height: 1, ChainID: "centauri-1", Time: time.Now().UTC()}) } func TestKeeperTestSuite(t *testing.T) {