Skip to content

Commit

Permalink
Merge branch 'main' into reece/clock-module
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups authored Aug 28, 2023
2 parents 7813f68 + 1ec8af2 commit 2d835ca
Show file tree
Hide file tree
Showing 20 changed files with 129 additions and 177 deletions.
81 changes: 0 additions & 81 deletions ROADMAP.md

This file was deleted.

22 changes: 22 additions & 0 deletions app/upgrades/v17/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@ func TestKeeperTestSuite(t *testing.T) {
func (s *UpgradeTestSuite) TestUpgrade() {
s.Setup()

preUpgradeChecks(s)

upgradeHeight := int64(5)
s.ConfirmUpgradeSucceeded(v17.UpgradeName, upgradeHeight)

postUpgradeChecks(s)
}

func preUpgradeChecks(s *UpgradeTestSuite) {
mp := s.App.AppKeepers.MintKeeper.GetParams(s.Ctx)
s.Require().Equal(mp.BlocksPerYear, uint64(6311520))

sp := s.App.AppKeepers.SlashingKeeper.GetParams(s.Ctx)
s.Require().Equal(sp.SignedBlocksWindow, int64(100))
}

func postUpgradeChecks(s *UpgradeTestSuite) {
// Ensure the mint params have doubled
mp := s.App.AppKeepers.MintKeeper.GetParams(s.Ctx)
s.Require().Equal(mp.BlocksPerYear, uint64(6311520*2))

// Ensure the slashing params have doubled
sp := s.App.AppKeepers.SlashingKeeper.GetParams(s.Ctx)
s.Require().Equal(sp.SignedBlocksWindow, int64(100*2))
}
18 changes: 18 additions & 0 deletions app/upgrades/v17/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@ func CreateV17UpgradeHandler(
}
logger.Info(fmt.Sprintf("post migrate version map: %v", versionMap))

// x/Mint
// Double blocks per year (from 6 seconds to 3 = 2x blocks per year)
mintParams := keepers.MintKeeper.GetParams(ctx)
mintParams.BlocksPerYear *= 2
if err = keepers.MintKeeper.SetParams(ctx, mintParams); err != nil {
return nil, err
}
logger.Info(fmt.Sprintf("updated minted blocks per year logic to %v", mintParams))

// x/Slashing
// Double slashing window due to double blocks per year
slashingParams := keepers.SlashingKeeper.GetParams(ctx)
slashingParams.SignedBlocksWindow *= 2
if err := keepers.SlashingKeeper.SetParams(ctx, slashingParams); err != nil {
return nil, err
}
logger.Info(fmt.Sprintf("updated slashing params to %v", slashingParams))

// x/drip
if err := keepers.DripKeeper.SetParams(ctx, driptypes.DefaultParams()); err != nil {
return nil, err
Expand Down
15 changes: 11 additions & 4 deletions cmd/junod/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"os"
"path/filepath"
"time"

wasm "github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
Expand Down Expand Up @@ -89,8 +90,14 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
return err
}

// 2 seconds + 1 second tendermint = 3 second blocks
timeoutCommit := 2 * time.Second

customAppTemplate, customAppConfig := initAppConfig()
customTMConfig := initTendermintConfig()
customTMConfig := initTendermintConfig(timeoutCommit)

// Force faster block times
os.Setenv("JUNOD_CONSENSUS_TIMEOUT_COMMIT", cast.ToString(timeoutCommit))

return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customTMConfig)
},
Expand All @@ -103,15 +110,15 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {

// initTendermintConfig helps to override default Tendermint Config values.
// return tmcfg.DefaultConfig if no custom configuration is required for the application.
func initTendermintConfig() *tmcfg.Config {
func initTendermintConfig(timeoutCommit time.Duration) *tmcfg.Config {
cfg := tmcfg.DefaultConfig()

// these values put a higher strain on node memory
// cfg.P2P.MaxNumInboundPeers = 100
// cfg.P2P.MaxNumOutboundPeers = 40

// 2 seconds + 1 second tendermint = 3 second blocks (v15 upgrade)
// cfg.Consensus.TimeoutCommit = 2 * time.Second
// While this is set, it only applies to new configs.
cfg.Consensus.TimeoutCommit = timeoutCommit

return cfg
}
Expand Down
Binary file modified interchaintest/contracts/tokenfactory_core.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion interchaintest/module_tokenfactory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestJunoTokenFactory(t *testing.T) {
}

// This allows the uaddr here to mint tokens on behalf of the contract. Typically you only allow a contract here, but this is testing.
coreInitMsg := fmt.Sprintf(`{"allowed_mint_addresses":["%s"],"denoms":["%s"]}`, uaddr, tfDenom)
coreInitMsg := fmt.Sprintf(`{"allowed_mint_addresses":["%s"],"existing_denoms":["%s"]}`, uaddr, tfDenom)
_, coreTFContract := helpers.SetupContract(t, ctx, juno, user.KeyName(), "contracts/tokenfactory_core.wasm", coreInitMsg)
t.Log("coreContract", coreTFContract)

Expand Down
8 changes: 6 additions & 2 deletions x/globalfee/ante/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (mfd FeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne
// if feeCoinsNoZeroDenom=[], DenomsSubsetOf returns true
// if feeCoinsNoZeroDenom is not empty, but nonZeroCoinFeesReq empty, return false
if !feeCoinsNonZeroDenom.DenomsSubsetOf(nonZeroCoinFeesReq) {
return ctx, errorsmod.Wrapf(sdkerrors.ErrInsufficientFee, "fee is not a subset of required fees; got %s, required: %s", feeCoins, combinedFeeRequirement)
return ctx, errorsmod.Wrapf(sdkerrors.ErrInsufficientFee, "this fee denom is not accepted; got %s, one is required: %s", feeCoins, PrettyPrint(combinedFeeRequirement))
}

// Accept zero fee transactions only if both of the following statements are true:
Expand Down Expand Up @@ -125,7 +125,11 @@ func (mfd FeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne
// because when nonZeroCoinFeesReq empty, and DenomsSubsetOf check passed,
// the tx should already passed before)
if !feeCoinsNonZeroDenom.IsAnyGTE(nonZeroCoinFeesReq) {
return ctx, errorsmod.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, combinedFeeRequirement)
if len(feeCoins) == 0 {
return ctx, errorsmod.Wrapf(sdkerrors.ErrInsufficientFee, "no fees were specified; one fee must be provided %s", PrettyPrint(combinedFeeRequirement))
}

return ctx, errorsmod.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; only got: %s. one is required: %s. ", feeCoins, PrettyPrint(combinedFeeRequirement))
}
}

Expand Down
18 changes: 18 additions & 0 deletions x/globalfee/ante/fee_utils.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package ante

import (
"encoding/json"
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand All @@ -19,6 +22,21 @@ func ContainZeroCoins(coins sdk.Coins) bool {
return false
}

// PrettyPrint returns a pretty printed representation of the given coins.
func PrettyPrint(coins sdk.Coins) string {
arr := make([]string, len(coins))
for idx, coin := range coins {
arr[idx] = fmt.Sprintf("%s%s", coin.Amount.String(), coin.Denom)
}

bz, err := json.MarshalIndent(arr, "", " ")
if err != nil {
return ""
}

return string(bz)
}

// CombinedFeeRequirement returns the global fee and min_gas_price combined and sorted.
// Both globalFees and minGasPrices must be valid, but CombinedFeeRequirement
// does not validate them, so it may return 0denom.
Expand Down
1 change: 1 addition & 0 deletions x/globalfee/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func (a AppModule) QuerierRoute() string {
}

func (a AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(a.keeper))
types.RegisterQueryServer(cfg.QueryServer(), NewGrpcQuerier(a.keeper))

m := keeper.NewMigrator(a.keeper, a.bondDenom)
Expand Down
2 changes: 2 additions & 0 deletions x/globalfee/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
govcodec "github.com/cosmos/cosmos-sdk/x/gov/codec"
)

var (
Expand All @@ -24,6 +25,7 @@ func init() {
// so that this can later be used to properly serialize MsgGrant and MsgExec
// instances.
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
}

// RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec
Expand Down
Loading

0 comments on commit 2d835ca

Please sign in to comment.