From 5d467ca4d5bd15d31e6514798a9fc87596163efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Kunze=20K=C3=BCllmer?= <31522760+fedekunze@users.noreply.github.com> Date: Mon, 7 Nov 2022 17:54:49 +0100 Subject: [PATCH 1/9] ante: remove min validator commision decorator (#1057) * Set validator's min commission * Remove min-commission ante * Update CHANGELOG * delete decorator * changelog * c++ * update init * upgrade logic Co-authored-by: Giancarlos Salas --- CHANGELOG.md | 1 + app/ante/comission.go | 85 ------------------------------------ app/ante/handler_options.go | 2 - app/app.go | 3 ++ app/upgrades/v10/upgrades.go | 20 +++++++++ 5 files changed, 24 insertions(+), 87 deletions(-) delete mode 100644 app/ante/comission.go diff --git a/CHANGELOG.md b/CHANGELOG.md index b456119afd..bfffcfc49d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/app/ante/comission.go b/app/ante/comission.go deleted file mode 100644 index 7a105d81b8..0000000000 --- a/app/ante/comission.go +++ /dev/null @@ -1,85 +0,0 @@ -package ante - -import ( - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - errortypes "github.com/cosmos/cosmos-sdk/types/errors" - - sdkerrors "cosmossdk.io/errors" - "github.com/cosmos/cosmos-sdk/x/authz" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" -) - -var minCommission = sdk.NewDecWithPrec(5, 2) // 5% - -// TODO: remove once Cosmos SDK is upgraded to v0.46 - -// ValidatorCommissionDecorator validates that the validator commission is always -// greater or equal than the min commission rate -type ValidatorCommissionDecorator struct { - cdc codec.BinaryCodec -} - -// NewValidatorCommissionDecorator creates a new NewValidatorCommissionDecorator -func NewValidatorCommissionDecorator(cdc codec.BinaryCodec) ValidatorCommissionDecorator { - return ValidatorCommissionDecorator{ - cdc: cdc, - } -} - -// AnteHandle checks if the tx contains a staking create validator or edit validator. -// It errors if the the commission rate is below the min threshold. -func (vcd ValidatorCommissionDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { - for _, msg := range tx.GetMsgs() { - switch msg := msg.(type) { - case *authz.MsgExec: - // Check for bypassing authorization - if err := vcd.validateAuthz(ctx, msg); err != nil { - return ctx, err - } - - default: - if err := vcd.validateMsg(ctx, msg); err != nil { - return ctx, err - } - } - } - - return next(ctx, tx, simulate) -} - -// validateAuthz validates the authorization internal message -func (vcd ValidatorCommissionDecorator) validateAuthz(ctx sdk.Context, execMsg *authz.MsgExec) error { - for _, v := range execMsg.Msgs { - var innerMsg sdk.Msg - err := vcd.cdc.UnpackAny(v, &innerMsg) - if err != nil { - return sdkerrors.Wrap(err, "cannot unmarshal authz exec msgs") - } - - if err := vcd.validateMsg(ctx, innerMsg); err != nil { - return err - } - } - - return nil -} - -// validateMsg checks that the commission rate is over 5% for create and edit validator msgs -func (vcd ValidatorCommissionDecorator) validateMsg(_ sdk.Context, msg sdk.Msg) error { - switch msg := msg.(type) { - case *stakingtypes.MsgCreateValidator: - if msg.Commission.Rate.LT(minCommission) { - return sdkerrors.Wrapf( - errortypes.ErrInvalidRequest, - "validator commission %s be lower than minimum of %s", msg.Commission.Rate, minCommission) - } - case *stakingtypes.MsgEditValidator: - if msg.CommissionRate != nil && msg.CommissionRate.LT(minCommission) { - return sdkerrors.Wrapf( - errortypes.ErrInvalidRequest, - "validator commission %s be lower than minimum of %s", msg.CommissionRate, minCommission) - } - } - return nil -} diff --git a/app/ante/handler_options.go b/app/ante/handler_options.go index 9535c2dbbf..d79f87d672 100644 --- a/app/ante/handler_options.go +++ b/app/ante/handler_options.go @@ -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), @@ -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), diff --git a/app/app.go b/app/app.go index 7586f8f686..009bdfa352 100644 --- a/app/app.go +++ b/app/app.go @@ -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 @@ -1109,6 +1111,7 @@ func (app *Evmos) setupUpgradeHandlers() { v10.UpgradeName, v10.CreateUpgradeHandler( app.mm, app.configurator, + app.StakingKeeper, ), ) diff --git a/app/upgrades/v10/upgrades.go b/app/upgrades/v10/upgrades.go index ab8a948fc3..ae150f9acd 100644 --- a/app/upgrades/v10/upgrades.go +++ b/app/upgrades/v10/upgrades.go @@ -3,6 +3,8 @@ 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" ) @@ -10,12 +12,30 @@ import ( 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) +} From ce484d035070d63f1f253b4002dc0f8b68af0cc7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Nov 2022 01:45:37 +0000 Subject: [PATCH 2/9] build(deps): bump go.opencensus.io from 0.23.0 to 0.24.0 (#1048) Bumps [go.opencensus.io](https://github.com/census-instrumentation/opencensus-go) from 0.23.0 to 0.24.0. - [Release notes](https://github.com/census-instrumentation/opencensus-go/releases) - [Commits](https://github.com/census-instrumentation/opencensus-go/compare/v0.23.0...v0.24.0) --- updated-dependencies: - dependency-name: go.opencensus.io dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Freddy Caceres --- go.mod | 2 +- go.sum | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index bc377d6465..131d58d83d 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index b407aafb88..ebb5072175 100644 --- a/go.sum +++ b/go.sum @@ -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= From 36e7dd68cee2d283b49fc999779b910eefc15c0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Kunze=20K=C3=BCllmer?= <31522760+fedekunze@users.noreply.github.com> Date: Tue, 8 Nov 2022 07:56:54 +0100 Subject: [PATCH 3/9] imp(erc20): util functions --- x/erc20/keeper/mint.go | 3 +-- x/erc20/keeper/params.go | 7 +++++++ x/erc20/keeper/token_pairs.go | 16 +++++++++++++--- x/erc20/proposal_handler.go | 3 +-- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/x/erc20/keeper/mint.go b/x/erc20/keeper/mint.go index d0445a1538..879be96520 100644 --- a/x/erc20/keeper/mint.go +++ b/x/erc20/keeper/mint.go @@ -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", ) diff --git a/x/erc20/keeper/params.go b/x/erc20/keeper/params.go index 0286ee20a2..c4982c1c24 100644 --- a/x/erc20/keeper/params.go +++ b/x/erc20/keeper/params.go @@ -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, ¶ms) } + +// 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 +} diff --git a/x/erc20/keeper/token_pairs.go b/x/erc20/keeper/token_pairs.go index dcc5796d4a..b76402e23b 100644 --- a/x/erc20/keeper/token_pairs.go +++ b/x/erc20/keeper/token_pairs.go @@ -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() @@ -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. diff --git a/x/erc20/proposal_handler.go b/x/erc20/proposal_handler.go index 7dae97a06d..b7a86cdb00 100644 --- a/x/erc20/proposal_handler.go +++ b/x/erc20/proposal_handler.go @@ -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", ) From 227298ceeb88f6edbbb71f748ea7a0aa7ad33bbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Kunze=20K=C3=BCllmer?= <31522760+fedekunze@users.noreply.github.com> Date: Tue, 8 Nov 2022 07:57:29 +0100 Subject: [PATCH 4/9] Revert "imp(erc20): util functions" This reverts commit 36e7dd68cee2d283b49fc999779b910eefc15c0b. --- x/erc20/keeper/mint.go | 3 ++- x/erc20/keeper/params.go | 7 ------- x/erc20/keeper/token_pairs.go | 16 +++------------- x/erc20/proposal_handler.go | 3 ++- 4 files changed, 7 insertions(+), 22 deletions(-) diff --git a/x/erc20/keeper/mint.go b/x/erc20/keeper/mint.go index 879be96520..d0445a1538 100644 --- a/x/erc20/keeper/mint.go +++ b/x/erc20/keeper/mint.go @@ -19,7 +19,8 @@ func (k Keeper) MintingEnabled( sender, receiver sdk.AccAddress, token string, ) (types.TokenPair, error) { - if !k.IsERC20Enabled(ctx) { + params := k.GetParams(ctx) + if !params.EnableErc20 { return types.TokenPair{}, sdkerrors.Wrap( types.ErrERC20Disabled, "module is currently disabled by governance", ) diff --git a/x/erc20/keeper/params.go b/x/erc20/keeper/params.go index c4982c1c24..0286ee20a2 100644 --- a/x/erc20/keeper/params.go +++ b/x/erc20/keeper/params.go @@ -16,10 +16,3 @@ func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { k.paramstore.SetParamSet(ctx, ¶ms) } - -// 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 -} diff --git a/x/erc20/keeper/token_pairs.go b/x/erc20/keeper/token_pairs.go index b76402e23b..dcc5796d4a 100644 --- a/x/erc20/keeper/token_pairs.go +++ b/x/erc20/keeper/token_pairs.go @@ -12,16 +12,6 @@ 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() @@ -30,10 +20,10 @@ func (k Keeper) IterateTokenPairs(ctx sdk.Context, cb func(tokenPair types.Token var tokenPair types.TokenPair k.cdc.MustUnmarshal(iterator.Value(), &tokenPair) - if cb(tokenPair) { - break - } + tokenPairs = append(tokenPairs, tokenPair) } + + return tokenPairs } // GetTokenPairID returns the pair id from either of the registered tokens. diff --git a/x/erc20/proposal_handler.go b/x/erc20/proposal_handler.go index b7a86cdb00..7dae97a06d 100644 --- a/x/erc20/proposal_handler.go +++ b/x/erc20/proposal_handler.go @@ -15,7 +15,8 @@ import ( func NewErc20ProposalHandler(k *keeper.Keeper) govv1beta1.Handler { return func(ctx sdk.Context, content govv1beta1.Content) error { // Check if the conversion is globally enabled - if !k.IsERC20Enabled(ctx) { + params := k.GetParams(ctx) + if !params.EnableErc20 { return sdkerrors.Wrap( types.ErrERC20Disabled, "registration is currently disabled by governance", ) From ddd8234040c835f0883e27990ab567bb9a3a952d Mon Sep 17 00:00:00 2001 From: eullrich Date: Tue, 8 Nov 2022 02:03:36 -0500 Subject: [PATCH 5/9] docs: add Pokt endpoint (#1052) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added Pocket Network public endpoint Co-authored-by: Freddy Caceres Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> --- docs/developers/connect.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/developers/connect.md b/docs/developers/connect.md index eec60eb22d..7ea17f4388 100644 --- a/docs/developers/connect.md +++ b/docs/developers/connect.md @@ -21,6 +21,7 @@ You can also use [chainlist.org](https://chainlist.org/) to add the node directl | Address | Category | Maintainer | | --------------------------------------------- | ---------------------- | --------------------------------------- | +| `https://evmos-rpc.gateway.pokt.network` | `Ethereum` `JSON-RPC` | [PocketNetwork(https://www.pokt.network/) | | `https://grpc.bd.evmos.org:9090` | `Cosmos` `gRPC` | [Blockdaemon](https://blockdaemon.com/) | | `https://rest.bd.evmos.org:1317` | `Cosmos` `REST` | [Blockdaemon](https://blockdaemon.com/) | | `https://tendermint.bd.evmos.org:26657` | `Tendermint` `RPC` | [Blockdaemon](https://blockdaemon.com/) | From 8cc72522c027f7dbb17a3498e3c949d2f66ecaea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Kunze=20K=C3=BCllmer?= <31522760+fedekunze@users.noreply.github.com> Date: Tue, 8 Nov 2022 12:22:16 +0100 Subject: [PATCH 6/9] imp(erc20): util functions (#1059) * imp(erc20): util functions * c++ --- CHANGELOG.md | 1 + x/erc20/keeper/mint.go | 3 +-- x/erc20/keeper/params.go | 7 +++++++ x/erc20/keeper/token_pairs.go | 16 +++++++++++++--- x/erc20/proposal_handler.go | 3 +-- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfffcfc49d..99de92cfc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,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 diff --git a/x/erc20/keeper/mint.go b/x/erc20/keeper/mint.go index d0445a1538..879be96520 100644 --- a/x/erc20/keeper/mint.go +++ b/x/erc20/keeper/mint.go @@ -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", ) diff --git a/x/erc20/keeper/params.go b/x/erc20/keeper/params.go index 0286ee20a2..c4982c1c24 100644 --- a/x/erc20/keeper/params.go +++ b/x/erc20/keeper/params.go @@ -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, ¶ms) } + +// 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 +} diff --git a/x/erc20/keeper/token_pairs.go b/x/erc20/keeper/token_pairs.go index dcc5796d4a..b76402e23b 100644 --- a/x/erc20/keeper/token_pairs.go +++ b/x/erc20/keeper/token_pairs.go @@ -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() @@ -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. diff --git a/x/erc20/proposal_handler.go b/x/erc20/proposal_handler.go index 7dae97a06d..b7a86cdb00 100644 --- a/x/erc20/proposal_handler.go +++ b/x/erc20/proposal_handler.go @@ -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", ) From cfb29735f142e64f674ee53d1dd397413ea64801 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Nov 2022 11:31:37 +0000 Subject: [PATCH 7/9] build(deps): bump github.com/onsi/ginkgo/v2 from 2.4.0 to 2.5.0 (#1061) Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.4.0 to 2.5.0. - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/ginkgo/compare/v2.4.0...v2.5.0) --- updated-dependencies: - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 131d58d83d..48a880234d 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index ebb5072175..f2b25ad976 100644 --- a/go.sum +++ b/go.sum @@ -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= From 134d47c0c13c55e1dc629f5fd1be032cd331dc0b Mon Sep 17 00:00:00 2001 From: Liam <11711732+devli13@users.noreply.github.com> Date: Tue, 8 Nov 2022 11:31:34 -0800 Subject: [PATCH 8/9] docs: sort public endpoints from older to latest Updated POKT entry to include close square-bracket for their link and moved them to the bottom of the list to be fair to others (historically others have added to the bottom rather than to the top) --- docs/developers/connect.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developers/connect.md b/docs/developers/connect.md index 7ea17f4388..c2d6846974 100644 --- a/docs/developers/connect.md +++ b/docs/developers/connect.md @@ -21,7 +21,6 @@ You can also use [chainlist.org](https://chainlist.org/) to add the node directl | Address | Category | Maintainer | | --------------------------------------------- | ---------------------- | --------------------------------------- | -| `https://evmos-rpc.gateway.pokt.network` | `Ethereum` `JSON-RPC` | [PocketNetwork(https://www.pokt.network/) | | `https://grpc.bd.evmos.org:9090` | `Cosmos` `gRPC` | [Blockdaemon](https://blockdaemon.com/) | | `https://rest.bd.evmos.org:1317` | `Cosmos` `REST` | [Blockdaemon](https://blockdaemon.com/) | | `https://tendermint.bd.evmos.org:26657` | `Tendermint` `RPC` | [Blockdaemon](https://blockdaemon.com/) | @@ -51,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 From 343ff54bb593299032d903feb6416e23d024eb48 Mon Sep 17 00:00:00 2001 From: sanjay-neobase <112819907+sanjay-neobase@users.noreply.github.com> Date: Wed, 9 Nov 2022 02:58:38 +0530 Subject: [PATCH 9/9] docs: Update telemetry.md with correct url to cosmos telemetry docs (#1063) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> --- docs/protocol/telemetry.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/protocol/telemetry.md b/docs/protocol/telemetry.md index a81091aed0..ef45ea820b 100644 --- a/docs/protocol/telemetry.md +++ b/docs/protocol/telemetry.md @@ -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