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: update app/server folder for v0.50 #1928

Open
wants to merge 27 commits into
base: v0.50.6b
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fdbbfd1
fix: remove all stringer for proto types
matthiasmatt May 14, 2024
7d4a29e
chore: changelog
matthiasmatt May 14, 2024
d0dd56b
chore: changelog
matthiasmatt May 14, 2024
f770f49
fix: fix test
matthiasmatt May 15, 2024
3b051a4
Update CHANGELOG.md
matthiasmatt May 15, 2024
2e831aa
fix: fix name of pretty string funcction
matthiasmatt May 15, 2024
a98447f
Merge branch 'mat/stringer-protobuf' of github.com:NibiruChain/nibiru…
matthiasmatt May 15, 2024
2568e04
Merge branch 'main' into mat/stringer-protobuf
matthiasmatt May 15, 2024
0e02cf3
fix: remove the infinite loop
matthiasmatt May 16, 2024
19bac32
Merge branch 'mat/stringer-protobuf' of github.com:NibiruChain/nibiru…
matthiasmatt May 16, 2024
9372747
feat: upgrate go.mod to v0.50
matthiasmatt May 22, 2024
9f54441
fix: update sdk.Dec to math.LegacyDec
matthiasmatt May 22, 2024
aab0344
fix: migrate sdk.Gas to storetypes
matthiasmatt May 22, 2024
d41e51f
fix: fix ante module
matthiasmatt May 22, 2024
636a62a
fix: update rosetta
matthiasmatt May 22, 2024
4d67259
fix: fix typo in roseta import
matthiasmatt May 22, 2024
7dd1476
Merge branch 'main' into mat/final-v050
matthiasmatt May 23, 2024
266beb3
feat: upgrade server to cometBFT and cleanup
matthiasmatt May 27, 2024
f94210e
Merge branch 'mat/final-v050' of github.com:NibiruChain/nibiru into m…
matthiasmatt May 27, 2024
a606f27
feat: upgrade comet bft log to cosmossdk.io/log
matthiasmatt May 27, 2024
ba38df5
feat: upgrade migration to use context.Context
matthiasmatt May 27, 2024
713331e
feat: almost upgrade all of app.go except begin/end block
matthiasmatt May 27, 2024
03c6782
feat: update the export.go
matthiasmatt May 27, 2024
31281c4
feat: upgrade app/keepers.go
matthiasmatt May 27, 2024
009f14a
feat: update proto types for legacy dec
matthiasmatt May 27, 2024
d69f565
feat: upgrade cmd folder
matthiasmatt May 28, 2024
e5f966e
feat: upgrade simapp
matthiasmatt May 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions app/ante.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package app

import (
corestoretypes "cosmossdk.io/core/store"
sdkerrors "cosmossdk.io/errors"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/errors"
sdkante "github.com/cosmos/cosmos-sdk/x/auth/ante"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"

"github.com/NibiruChain/nibiru/app/ante"
devgasante "github.com/NibiruChain/nibiru/x/devgas/v1/ante"
Expand All @@ -22,8 +22,8 @@ type AnteHandlerOptions struct {
DevGasKeeper *devgaskeeper.Keeper
DevGasBankKeeper devgasante.BankKeeper

TxCounterStoreKey types.StoreKey
WasmConfig *wasmtypes.WasmConfig
TXCounterStoreService corestoretypes.KVStoreService
WasmConfig *wasmtypes.WasmConfig
}

// NewAnteHandler returns and AnteHandler that checks and increments sequence
Expand All @@ -37,7 +37,7 @@ func NewAnteHandler(options AnteHandlerOptions) (sdk.AnteHandler, error) {
anteDecorators := []sdk.AnteDecorator{
sdkante.NewSetUpContextDecorator(),
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit),
wasmkeeper.NewCountTXDecorator(options.TxCounterStoreKey),
wasmkeeper.NewCountTXDecorator(options.TXCounterStoreService),
sdkante.NewExtensionOptionsDecorator(nil),
sdkante.NewValidateBasicDecorator(),
sdkante.NewTxTimeoutHeightDecorator(),
Expand Down
2 changes: 1 addition & 1 deletion app/ante/commission.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

func MAX_COMMISSION() sdk.Dec { return math.LegacyMustNewDecFromStr("0.25") }
func MAX_COMMISSION() math.LegacyDec { return math.LegacyMustNewDecFromStr("0.25") }

var _ sdk.AnteDecorator = (*AnteDecoratorStakingCommission)(nil)

Expand Down
4 changes: 2 additions & 2 deletions app/ante/commission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (s *AnteTestSuite) TestAnteDecoratorStakingCommission() {
}

valAddr := sdk.ValAddress(testutil.AccAddress()).String()
commissionRatePointer := new(sdk.Dec)
commissionRatePointer := new(math.LegacyDec)
*commissionRatePointer = math.LegacyNewDecWithPrec(10, 2)
happyMsgs := []sdk.Msg{
&stakingtypes.MsgCreateValidator{
Expand Down Expand Up @@ -63,7 +63,7 @@ func (s *AnteTestSuite) TestAnteDecoratorStakingCommission() {

sadMsgEditVal := new(stakingtypes.MsgEditValidator)
*sadMsgEditVal = *(happyMsgs[1]).(*stakingtypes.MsgEditValidator)
newCommissionRate := new(sdk.Dec)
newCommissionRate := new(math.LegacyDec)
*newCommissionRate = math.LegacyNewDecWithPrec(26, 2)
sadMsgEditVal.CommissionRate = newCommissionRate

Expand Down
4 changes: 2 additions & 2 deletions app/ante/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ante

import (
sdkerrors "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
"cosmossdk.io/math"
)

var errorCodeIdx uint32 = 1
Expand All @@ -18,7 +18,7 @@ var (
ErrMaxValidatorCommission = registerError("validator commission rate is above max")
)

func NewErrMaxValidatorCommission(gotCommission sdk.Dec) error {
func NewErrMaxValidatorCommission(gotCommission math.LegacyDec) error {
return ErrMaxValidatorCommission.Wrapf(
"got (%s), max rate is (%s)", gotCommission, MAX_COMMISSION())
}
5 changes: 3 additions & 2 deletions app/ante/fixed_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

sdkioerrors "cosmossdk.io/errors"
"cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -26,7 +27,7 @@ func (suite *AnteTestSuite) TestOraclePostPriceTransactionsHaveFixedPrice() {
tests := []struct {
name string
messages []sdk.Msg
expectedGas sdk.Gas
expectedGas storetypes.Gas
expectedErr error
}{
{
Expand Down Expand Up @@ -218,7 +219,7 @@ func (suite *AnteTestSuite) TestOraclePostPriceTransactionsHaveFixedPrice() {
suite.NoError(suite.txBuilder.SetMsgs(tc.messages...))

privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{11}, []uint64{0}
tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID())
tx, err := suite.CreateTestTx(suite.ctx, privs, accNums, accSeqs, suite.ctx.ChainID())
suite.NoErrorf(err, "tx: %v", tx)
suite.NoError(tx.ValidateBasic())
suite.ValidateTx(tx, suite.T())
Expand Down
18 changes: 8 additions & 10 deletions app/ante/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,38 @@ package ante
import (
"fmt"

storetypes "github.com/cosmos/cosmos-sdk/store/types"

"github.com/cosmos/cosmos-sdk/types"
storetypes "cosmossdk.io/store/types"
)

type fixedGasMeter struct {
consumed types.Gas
consumed storetypes.Gas
}

// NewFixedGasMeter returns a reference to a new fixedGasMeter.
func NewFixedGasMeter(fixedGas types.Gas) types.GasMeter {
func NewFixedGasMeter(fixedGas storetypes.Gas) storetypes.GasMeter {
return &fixedGasMeter{
consumed: fixedGas,
}
}

func (g *fixedGasMeter) GasConsumed() types.Gas {
func (g *fixedGasMeter) GasConsumed() storetypes.Gas {
return g.consumed
}

func (g *fixedGasMeter) GasConsumedToLimit() types.Gas {
func (g *fixedGasMeter) GasConsumedToLimit() storetypes.Gas {
return g.consumed
}

func (g *fixedGasMeter) Limit() types.Gas {
func (g *fixedGasMeter) Limit() storetypes.Gas {
return g.consumed
}

func (g *fixedGasMeter) GasRemaining() storetypes.Gas {
return g.consumed
}

func (g *fixedGasMeter) ConsumeGas(types.Gas, string) {}
func (g *fixedGasMeter) RefundGas(types.Gas, string) {}
func (g *fixedGasMeter) ConsumeGas(storetypes.Gas, string) {}
func (g *fixedGasMeter) RefundGas(storetypes.Gas, string) {}

func (g *fixedGasMeter) IsPastLimit() bool {
return false
Expand Down
23 changes: 16 additions & 7 deletions app/ante/testutil_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package ante_test

import (
"context"
"testing"
"time"

"github.com/cosmos/cosmos-sdk/x/auth/ante"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
Expand Down Expand Up @@ -41,7 +42,8 @@ func (suite *AnteTestSuite) SetupTest() {
encodingConfig := app.MakeEncodingConfig()
suite.app = testapp.NewNibiruTestApp(app.NewDefaultGenesisState(encodingConfig.Codec))
chainId := "test-chain-id"
ctx := suite.app.NewContext(true, tmproto.Header{
ctx := suite.app.NewContext(true)
ctx.WithBlockHeader(tmproto.Header{
Height: 1,
ChainID: chainId,
Time: time.Now().UTC(),
Expand All @@ -54,7 +56,7 @@ func (suite *AnteTestSuite) SetupTest() {
WithChainID(chainId).
WithLegacyAmino(encodingConfig.Amino)

err := suite.app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams())
err := suite.app.AccountKeeper.Params.Set(ctx, authtypes.DefaultParams())
suite.Require().NoError(err)
params := suite.app.AccountKeeper.GetParams(ctx)
suite.Require().NoError(params.Validate())
Expand Down Expand Up @@ -84,15 +86,17 @@ func (suite *AnteTestSuite) SetupTest() {
}

// CreateTestTx is a helper function to create a tx given multiple inputs.
func (suite *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) {
func (suite *AnteTestSuite) CreateTestTx(ctx context.Context, privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) {
// First round: we gather all the signer infos. We use the "set empty
// signature" hack to do that.
signMode := signing.SignMode_SIGN_MODE_DIRECT

var sigsV2 []signing.SignatureV2
for i, priv := range privs {
sigV2 := signing.SignatureV2{
PubKey: priv.PubKey(),
Data: &signing.SingleSignatureData{
SignMode: suite.clientCtx.TxConfig.SignModeHandler().DefaultMode(),
SignMode: signMode,
Signature: nil,
},
Sequence: accSeqs[i],
Expand All @@ -117,8 +121,13 @@ func (suite *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []
Sequence: accSeqs[i],
}
sigV2, err := tx.SignWithPrivKey(
suite.clientCtx.TxConfig.SignModeHandler().DefaultMode(), signerData,
suite.txBuilder, priv, suite.clientCtx.TxConfig, accSeqs[i])
ctx,
signMode,
signerData,
suite.txBuilder,
priv,
suite.clientCtx.TxConfig,
accSeqs[i])
if err != nil {
return nil, err
}
Expand Down
38 changes: 19 additions & 19 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,34 @@ import (

"github.com/NibiruChain/nibiru/app/wasmext"

dbm "github.com/cometbft/cometbft-db"
"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
tmos "github.com/cometbft/cometbft/libs/os"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
"github.com/cosmos/cosmos-sdk/client/grpc/node"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
"github.com/cosmos/cosmos-sdk/x/crisis"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
ibctesting "github.com/cosmos/ibc-go/v7/testing"
"github.com/cosmos/ibc-go/v7/testing/types"
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
"github.com/cosmos/ibc-go/v8/testing/types"
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus"
"github.com/rakyll/statik/fs"
Expand Down Expand Up @@ -79,6 +78,7 @@ type NibiruApp struct {
*baseapp.BaseApp
legacyAmino *codec.LegacyAmino
appCodec codec.Codec
txConfig client.TxConfig
interfaceRegistry codectypes.InterfaceRegistry

// keys to access the substores
Expand Down Expand Up @@ -190,11 +190,11 @@ func NewNibiruApp(
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: authante.DefaultSigVerificationGasConsumer,
},
IBCKeeper: app.ibcKeeper,
TxCounterStoreKey: keys[wasmtypes.StoreKey],
WasmConfig: &wasmConfig,
DevGasKeeper: &app.DevGasKeeper,
DevGasBankKeeper: app.BankKeeper,
IBCKeeper: app.ibcKeeper,
TXCounterStoreService: runtime.NewKVStoreService(keys[wasmtypes.StoreKey]),
WasmConfig: &wasmConfig,
DevGasKeeper: &app.DevGasKeeper,
DevGasBankKeeper: app.BankKeeper,
})
if err != nil {
panic(fmt.Errorf("failed to create sdk.AnteHandler: %s", err))
Expand Down Expand Up @@ -253,7 +253,7 @@ func (app *NibiruApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci
}

// InitChainer application update at chain initialization
func (app *NibiruApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
func (app *NibiruApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) {
var genesisState GenesisState
if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
panic(err)
Expand All @@ -267,8 +267,8 @@ func (app *NibiruApp) LoadHeight(height int64) error {
return app.LoadVersion(height)
}

func (app *NibiruApp) RegisterNodeService(clientCtx client.Context) {
node.RegisterNodeService(clientCtx, app.GRPCQueryRouter())
func (app *NibiruApp) RegisterNodeService(clientCtx client.Context, config config.Config) {
node.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), config)
}

// ModuleAccountAddrs returns all the app's module account addresses.
Expand Down Expand Up @@ -346,7 +346,7 @@ func (app *NibiruApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.API
// Register new tx routes from grpc-gateway.
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// Register new tendermint queries routes from grpc-gateway.
tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
cmtservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// Register legacy and grpc-gateway routes for all modules.
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
Expand All @@ -366,7 +366,7 @@ func (app *NibiruApp) RegisterTxService(clientCtx client.Context) {

// RegisterTendermintService implements the Application.RegisterTendermintService method.
func (app *NibiruApp) RegisterTendermintService(clientCtx client.Context) {
tmservice.RegisterTendermintService(
cmtservice.RegisterTendermintService(
clientCtx,
app.BaseApp.GRPCQueryRouter(),
app.interfaceRegistry,
Expand Down
Loading