Skip to content

Commit

Permalink
Merge branch 'evmos:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups authored Nov 9, 2022
2 parents c7f941a + 343ff54 commit 833c4bf
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 100 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### State Machine Breaking

* (ante) [#1054](https://github.com/evmos/evmos/pull/1054) Remove validator commission `AnteHandler` decorator and replace it with the new `MinCommissionRate` staking parameter.
- (deps) [\#1041](https://github.com/evmos/evmos/pull/1041) Add ics23 dragonberry replace in go.mod as mentioned in the [Cosmos SDK release](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.4)
- (deps) [\#1037](https://github.com/evmos/evmos/pull/1037) Bump Ethermint version to [`v0.20.0-rc2`](https://github.com/evmos/ethermint/releases/tag/v0.20.0-rc2)

Expand All @@ -48,6 +49,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

- (erc20) [#1059](https://github.com/evmos/evmos/pull/1059) Add util functions (iterator and params) for ERC20 module.
- (go) [\#1039](https://github.com/evmos/evmos/pull/1039) Bump go v1.19
- (deps) [\#1033](https://github.com/evmos/evmos/pull/1033) Bump Cosmos SDK to [`v0.46.4`](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.4)
- (ante) [\#993](https://github.com/evmos/evmos/pull/993) Re-order AnteHandlers for better performance
Expand Down
85 changes: 0 additions & 85 deletions app/ante/comission.go

This file was deleted.

2 changes: 0 additions & 2 deletions app/ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
NewVestingDelegationDecorator(options.AccountKeeper, options.StakingKeeper, options.Cdc),
NewValidatorCommissionDecorator(options.Cdc),
// SetPubKeyDecorator must be called before all signature verification decorators
ante.NewSetPubKeyDecorator(options.AccountKeeper),
ante.NewValidateSigCountDecorator(options.AccountKeeper),
Expand All @@ -114,7 +113,6 @@ func newCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler {
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
NewVestingDelegationDecorator(options.AccountKeeper, options.StakingKeeper, options.Cdc),
NewValidatorCommissionDecorator(options.Cdc),
// SetPubKeyDecorator must be called before all signature verification decorators
ante.NewSetPubKeyDecorator(options.AccountKeeper),
ante.NewValidateSigCountDecorator(options.AccountKeeper),
Expand Down
3 changes: 3 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ func init() {
// modify fee market parameter defaults through global
feemarkettypes.DefaultMinGasPrice = MainnetMinGasPrices
feemarkettypes.DefaultMinGasMultiplier = MainnetMinGasMultiplier
// modify default min commission to 5%
stakingtypes.DefaultMinCommissionRate = sdk.NewDecWithPrec(5, 2)
}

// Name defines the application binary name
Expand Down Expand Up @@ -1109,6 +1111,7 @@ func (app *Evmos) setupUpgradeHandlers() {
v10.UpgradeName,
v10.CreateUpgradeHandler(
app.mm, app.configurator,
app.StakingKeeper,
),
)

Expand Down
20 changes: 20 additions & 0 deletions app/upgrades/v10/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,39 @@ package v10
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

// CreateUpgradeHandler creates an SDK upgrade handler for v10
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
stakingKeeper stakingkeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := ctx.Logger().With("upgrade", UpgradeName)

setMinCommissionRate(ctx, stakingKeeper)

// Leave modules are as-is to avoid running InitGenesis.
logger.Debug("running module migrations ...")
return mm.RunMigrations(ctx, configurator, vm)
}
}

// setMinCommissionRate sets the minimum commission rate for validators
// to 5%.
func setMinCommissionRate(ctx sdk.Context, sk stakingkeeper.Keeper) {
stakingParams := stakingtypes.Params{
UnbondingTime: sk.UnbondingTime(ctx),
MaxValidators: sk.MaxValidators(ctx),
MaxEntries: sk.MaxEntries(ctx),
HistoricalEntries: sk.HistoricalEntries(ctx),
BondDenom: sk.BondDenom(ctx),
MinCommissionRate: sdk.NewDecWithPrec(5, 2), // 5%
}

sk.SetParams(ctx, stakingParams)
}
1 change: 1 addition & 0 deletions docs/developers/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ You can also use [chainlist.org](https://chainlist.org/) to add the node directl
| `https://evmos-rest.publicnode.com` | `Cosmos` `REST` | [PublicNode (by Allnodes)](https://evmos.publicnode.com/) |
| `https://evmos-api.validatrium.club` | `Tendermint` `API` | [Validatrium](https://validatrium.com/) |
| `https://evmos-rpc.validatrium.club` | `Tendermint` `RPC` | [Validatrium](https://validatrium.com/) |
| `https://evmos-rpc.gateway.pokt.network` | `Ethereum` `JSON-RPC` | [PocketNetwork](https://www.pokt.network/) |

:::
::: tab Testnet
Expand Down
2 changes: 1 addition & 1 deletion docs/protocol/telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ order: 3

Gather relevant insights about the Evmos application and modules with custom metrics and telemetry. {synopsis}

To understand how to use the metrics below, please refer to the [Cosmos SDK telemetry documentation](https://docs.cosmos.network/master/core/telemetry.html).
To understand how to use the metrics below, please refer to the [Cosmos SDK telemetry documentation](https://docs.cosmos.network/main/core/telemetry.html).

## Supported Metrics

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/golang/protobuf v1.5.2
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/onsi/ginkgo/v2 v2.4.0
github.com/onsi/ginkgo/v2 v2.5.0
github.com/onsi/gomega v1.24.0
github.com/pkg/errors v0.9.1
github.com/rakyll/statik v0.1.7
Expand All @@ -24,7 +24,7 @@ require (
github.com/stretchr/testify v1.8.1
github.com/tendermint/tendermint v0.34.22
github.com/tendermint/tm-db v0.6.7
go.opencensus.io v0.23.0
go.opencensus.io v0.24.0
google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71
google.golang.org/grpc v1.50.1
google.golang.org/protobuf v1.28.1
Expand Down
7 changes: 4 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,8 @@ github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA=
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
github.com/onsi/ginkgo/v2 v2.4.0 h1:+Ig9nvqgS5OBSACXNk15PLdp0U9XPYROt9CFzVdFGIs=
github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkAt4OrFo=
github.com/onsi/ginkgo/v2 v2.5.0 h1:TRtrvv2vdQqzkwrQ1ke6vtXf7IK34RBUJafIy1wMwls=
github.com/onsi/ginkgo/v2 v2.5.0/go.mod h1:Luc4sArBICYCS8THh8v3i3i5CuSZO+RaQRaJoeNwomw=
github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
Expand Down Expand Up @@ -1065,8 +1065,9 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
Expand Down
3 changes: 1 addition & 2 deletions x/erc20/keeper/mint.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ func (k Keeper) MintingEnabled(
sender, receiver sdk.AccAddress,
token string,
) (types.TokenPair, error) {
params := k.GetParams(ctx)
if !params.EnableErc20 {
if !k.IsERC20Enabled(ctx) {
return types.TokenPair{}, sdkerrors.Wrap(
types.ErrERC20Disabled, "module is currently disabled by governance",
)
Expand Down
7 changes: 7 additions & 0 deletions x/erc20/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
k.paramstore.SetParamSet(ctx, &params)
}

// IsERC20Enabled returns true if the module logic is enabled
func (k Keeper) IsERC20Enabled(ctx sdk.Context) bool {
var enabled bool
k.paramstore.GetIfExists(ctx, types.ParamStoreKeyEnableErc20, &enabled)
return enabled
}
16 changes: 13 additions & 3 deletions x/erc20/keeper/token_pairs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ import (
func (k Keeper) GetTokenPairs(ctx sdk.Context) []types.TokenPair {
tokenPairs := []types.TokenPair{}

k.IterateTokenPairs(ctx, func(tokenPair types.TokenPair) (stop bool) {
tokenPairs = append(tokenPairs, tokenPair)
return false
})

return tokenPairs
}

// IterateTokenPairs iterates over all the stored token pairs
func (k Keeper) IterateTokenPairs(ctx sdk.Context, cb func(tokenPair types.TokenPair) (stop bool)) {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.KeyPrefixTokenPair)
defer iterator.Close()
Expand All @@ -20,10 +30,10 @@ func (k Keeper) GetTokenPairs(ctx sdk.Context) []types.TokenPair {
var tokenPair types.TokenPair
k.cdc.MustUnmarshal(iterator.Value(), &tokenPair)

tokenPairs = append(tokenPairs, tokenPair)
if cb(tokenPair) {
break
}
}

return tokenPairs
}

// GetTokenPairID returns the pair id from either of the registered tokens.
Expand Down
3 changes: 1 addition & 2 deletions x/erc20/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import (
func NewErc20ProposalHandler(k *keeper.Keeper) govv1beta1.Handler {
return func(ctx sdk.Context, content govv1beta1.Content) error {
// Check if the conversion is globally enabled
params := k.GetParams(ctx)
if !params.EnableErc20 {
if !k.IsERC20Enabled(ctx) {
return sdkerrors.Wrap(
types.ErrERC20Disabled, "registration is currently disabled by governance",
)
Expand Down

0 comments on commit 833c4bf

Please sign in to comment.