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: make v0.50 compile and fix unit-tests #1930

Open
wants to merge 41 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
41 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
7f058c1
fix: unwire all modules
matthiasmatt May 29, 2024
3801d79
feat: upgrade x/common
matthiasmatt May 29, 2024
ef3b145
feat: unwire eth
matthiasmatt May 29, 2024
6f1cbf3
feat: upgrade to new begin/end block logic
matthiasmatt May 29, 2024
8fb2028
feat: fix compilation issue
matthiasmatt Jun 3, 2024
fcccf99
fix: update the denom setting for account keeper
matthiasmatt Jun 3, 2024
1ada7f8
fix: fix invalid initial total supply
matthiasmatt Jun 5, 2024
d3364a0
fix: fix encoding config creation and address prefix for val
matthiasmatt Jun 5, 2024
99c998a
fix: fix some unit tests
matthiasmatt Jun 5, 2024
01d596e
fix: fix more unit tests
matthiasmatt Jun 5, 2024
dcfe7ce
fix: make ibc mint tokens for tests
matthiasmatt Jun 7, 2024
06f079e
fix: use cmtjson to marshal genesis
matthiasmatt Jun 8, 2024
140ff8e
fix: fix last unit test
matthiasmatt Jun 10, 2024
5318861
Spekals: fix v0.50 localnet (#2040)
SpekalsG3 Sep 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 17 additions & 17 deletions app/ante.go
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
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"
devgaskeeper "github.com/NibiruChain/nibiru/x/devgas/v1/keeper"
// devgasante "github.com/NibiruChain/nibiru/x/devgas/v1/ante"
// devgaskeeper "github.com/NibiruChain/nibiru/x/devgas/v1/keeper"
)

type AnteHandlerOptions struct {
sdkante.HandlerOptions
IBCKeeper *ibckeeper.Keeper
DevGasKeeper *devgaskeeper.Keeper
DevGasBankKeeper devgasante.BankKeeper
IBCKeeper *ibckeeper.Keeper
// 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,19 +37,19 @@ 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(),
sdkante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewPostPriceFixedPriceDecorator(),
// ante.NewPostPriceFixedPriceDecorator(),
ante.AnteDecoratorStakingCommission{},
sdkante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
// Replace fee ante from cosmos auth with a custom one.
sdkante.NewDeductFeeDecorator(
options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
devgasante.NewDevGasPayoutDecorator(
options.DevGasBankKeeper, options.DevGasKeeper),
// devgasante.NewDevGasPayoutDecorator(
// options.DevGasBankKeeper, options.DevGasKeeper),
// SetPubKeyDecorator must be called before all signature verification decorators
sdkante.NewSetPubKeyDecorator(options.AccountKeeper),
sdkante.NewValidateSigCountDecorator(options.AccountKeeper),
Expand Down Expand Up @@ -78,9 +78,9 @@ func (opts *AnteHandlerOptions) ValidateAndClean() error {
if opts.WasmConfig == nil {
return AnteHandlerError("wasm config")
}
if opts.DevGasKeeper == nil {
return AnteHandlerError("devgas keeper")
}
// if opts.DevGasKeeper == nil {
// return AnteHandlerError("devgas keeper")
// }
if opts.IBCKeeper == nil {
return AnteHandlerError("ibc keeper")
}
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
5 changes: 3 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 Expand Up @@ -120,6 +120,7 @@ func (s *AnteTestSuite) TestAnteDecoratorStakingCommission() {
WithFees(txGasCoins.String()).
WithChainID(s.ctx.ChainID()).
WithTxConfig(encCfg.TxConfig).
WithChainID("nibi-test-chain").
BuildUnsignedTx(tc.txMsgs...)
s.NoError(err)

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())
}
101 changes: 47 additions & 54 deletions app/ante/fixed_gas.go
Original file line number Diff line number Diff line change
@@ -1,56 +1,49 @@
package ante

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

oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
)

const OracleMessageGas = 500

var _ sdk.AnteDecorator = EnsureSinglePostPriceMessageDecorator{}

// EnsureSinglePostPriceMessageDecorator ensures that there is only one oracle vote message in the transaction
// and sets the gas meter to a fixed value.
type EnsureSinglePostPriceMessageDecorator struct{}

func NewPostPriceFixedPriceDecorator() EnsureSinglePostPriceMessageDecorator {
return EnsureSinglePostPriceMessageDecorator{}
}

func (gd EnsureSinglePostPriceMessageDecorator) AnteHandle(
ctx sdk.Context,
tx sdk.Tx,
simulate bool,
next sdk.AnteHandler,
) (newCtx sdk.Context, err error) {
hasOracleVoteMsg := false
hasOraclePreVoteMsg := false

msgs := tx.GetMsgs()
for _, msg := range msgs {
switch msg.(type) {
case *oracletypes.MsgAggregateExchangeRatePrevote:
hasOraclePreVoteMsg = true
case *oracletypes.MsgAggregateExchangeRateVote:
hasOracleVoteMsg = true
}
}

if hasOracleVoteMsg && hasOraclePreVoteMsg {
if len(msgs) > 2 {
return ctx, sdkerrors.Wrap(ErrOracleAnte, "a transaction cannot have more than a single oracle vote and prevote message")
}

ctx = ctx.WithGasMeter(NewFixedGasMeter(OracleMessageGas))
} else if hasOraclePreVoteMsg || hasOracleVoteMsg {
if len(msgs) > 1 {
return ctx, sdkerrors.Wrap(ErrOracleAnte, "a transaction that includes an oracle vote or prevote message cannot have more than those two messages")
}

ctx = ctx.WithGasMeter(NewFixedGasMeter(OracleMessageGas))
}

return next(ctx, tx, simulate)
}
// const OracleMessageGas = 500

// var _ sdk.AnteDecorator = EnsureSinglePostPriceMessageDecorator{}

// // EnsureSinglePostPriceMessageDecorator ensures that there is only one oracle vote message in the transaction
// // and sets the gas meter to a fixed value.
// type EnsureSinglePostPriceMessageDecorator struct{}

// func NewPostPriceFixedPriceDecorator() EnsureSinglePostPriceMessageDecorator {
// return EnsureSinglePostPriceMessageDecorator{}
// }

// func (gd EnsureSinglePostPriceMessageDecorator) AnteHandle(
// ctx sdk.Context,
// tx sdk.Tx,
// simulate bool,
// next sdk.AnteHandler,
// ) (newCtx sdk.Context, err error) {
// hasOracleVoteMsg := false
// hasOraclePreVoteMsg := false

// msgs := tx.GetMsgs()
// for _, msg := range msgs {
// switch msg.(type) {
// case *oracletypes.MsgAggregateExchangeRatePrevote:
// hasOraclePreVoteMsg = true
// case *oracletypes.MsgAggregateExchangeRateVote:
// hasOracleVoteMsg = true
// }
// }

// if hasOracleVoteMsg && hasOraclePreVoteMsg {
// if len(msgs) > 2 {
// return ctx, sdkerrors.Wrap(ErrOracleAnte, "a transaction cannot have more than a single oracle vote and prevote message")
// }

// ctx = ctx.WithGasMeter(NewFixedGasMeter(OracleMessageGas))
// } else if hasOraclePreVoteMsg || hasOracleVoteMsg {
// if len(msgs) > 1 {
// return ctx, sdkerrors.Wrap(ErrOracleAnte, "a transaction that includes an oracle vote or prevote message cannot have more than those two messages")
// }

// ctx = ctx.WithGasMeter(NewFixedGasMeter(OracleMessageGas))
// }

// return next(ctx, tx, simulate)
// }
Loading