This repository was archived by the owner on Mar 3, 2026. It is now read-only.
forked from ChihuahuaChain/chihuahua
-
Notifications
You must be signed in to change notification settings - Fork 1
5% min starting point #1
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f289d4e
5% min starting point
6fe1988
get rid of wasm
lydia-pierce c4a482e
get rid of wasm and add juno #103
12aa5c9
comment out testutil/keeper/chihuahua.go
b7e142e
added changelog
6ae217b
Test for the minimum validator commision (#2)
evan-forbes b421900
RegisterUpgradeHandlers
f8141e7
npm update
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| <!-- | ||
| Guiding Principles: | ||
|
|
||
| Changelogs are for humans, not machines. | ||
| There should be an entry for every single version. | ||
| The same types of changes should be grouped. | ||
| Versions and sections should be linkable. | ||
| The latest version comes first. | ||
| The release date of each version is displayed. | ||
| Mention whether you follow Semantic Versioning. | ||
|
|
||
| Usage: | ||
|
|
||
| Change log entries are to be added to the Unreleased section under the | ||
| appropriate stanza (see below). Each entry should ideally include a tag and | ||
| the Github issue reference in the following format: | ||
|
|
||
| * (<tag>) \#<issue-number> message | ||
|
|
||
| The issue numbers will later be link-ified during the release process so you do | ||
| not have to worry about including a link manually, but you can if you wish. | ||
|
|
||
| Types of changes (Stanzas): | ||
|
|
||
| "Features" for new features. | ||
| "Improvements" for changes in existing functionality. | ||
| "Deprecated" for soon-to-be removed features. | ||
| "Bug Fixes" for any bug fixes. | ||
| "Client Breaking" for breaking CLI commands and REST routes used by end-users. | ||
| "API Breaking" for breaking exported APIs used by developers building on SDK. | ||
| "State Machine Breaking" for any changes that result in a different AppState given same genesisState and txList. | ||
| Ref: https://keepachangelog.com/en/1.0.0/ | ||
| --> | ||
|
|
||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [Unreleased] | ||
|
|
||
| ## Features | ||
|
|
||
| - [#1](https://github.com/pomifer/chihuahua/pull/1) Add a minimum validator commission of 5% based on proposal [#1](https://omniflix.chihuahua.wtf/proposals) | ||
|
|
||
| ## [v1.0.0](https://github.com/ChihuahuaChain/chihuahua/releases/tag/v1.0.0) - 2021-12-18 | ||
|
|
||
| Release mainnet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| package app | ||
|
|
||
| import ( | ||
| sdk "github.com/cosmos/cosmos-sdk/types" | ||
| sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
| "github.com/cosmos/cosmos-sdk/x/auth/ante" | ||
| stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" | ||
| channelkeeper "github.com/cosmos/ibc-go/modules/core/04-channel/keeper" | ||
| ibcante "github.com/cosmos/ibc-go/modules/core/ante" | ||
| ) | ||
|
|
||
| // HandlerOptions extends the SDK's AnteHandler options by requiring the IBC | ||
| // channel keeper. | ||
| type HandlerOptions struct { | ||
| ante.HandlerOptions | ||
|
|
||
| IBCChannelkeeper channelkeeper.Keeper | ||
| } | ||
|
|
||
| type MinCommissionDecorator struct{} | ||
|
|
||
| func NewMinCommissionDecorator() MinCommissionDecorator { | ||
| return MinCommissionDecorator{} | ||
| } | ||
|
|
||
| func (MinCommissionDecorator) AnteHandle( | ||
| ctx sdk.Context, tx sdk.Tx, | ||
| simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { | ||
| msgs := tx.GetMsgs() | ||
| minCommissionRate := sdk.NewDecWithPrec(5, 2) | ||
| for _, m := range msgs { | ||
| switch msg := m.(type) { | ||
| case *stakingtypes.MsgCreateValidator: | ||
| // prevent new validators joining the set with | ||
| // commission set below 5% | ||
| c := msg.Commission | ||
| if c.Rate.LT(minCommissionRate) { | ||
| return ctx, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "commission can't be lower than 5%") | ||
| } | ||
| case *stakingtypes.MsgEditValidator: | ||
| // if commission rate is nil, it means only | ||
| // other fields are affected - skip | ||
| if msg.CommissionRate == nil { | ||
| continue | ||
| } | ||
| if msg.CommissionRate.LT(minCommissionRate) { | ||
| return ctx, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "commission can't be lower than 5%") | ||
| } | ||
| default: | ||
| continue | ||
| } | ||
| } | ||
| return next(ctx, tx, simulate) | ||
| } | ||
|
|
||
| // NewAnteHandler returns an AnteHandler that checks and increments sequence | ||
| // numbers, checks signatures & account numbers, and deducts fees from the first | ||
| // signer. | ||
| func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { | ||
| if options.AccountKeeper == nil { | ||
| return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for ante builder") | ||
| } | ||
|
|
||
| if options.BankKeeper == nil { | ||
| return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for ante builder") | ||
| } | ||
|
|
||
| if options.SignModeHandler == nil { | ||
| return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder") | ||
| } | ||
|
|
||
| var sigGasConsumer = options.SigGasConsumer | ||
| if sigGasConsumer == nil { | ||
| sigGasConsumer = ante.DefaultSigVerificationGasConsumer | ||
| } | ||
|
|
||
| anteDecorators := []sdk.AnteDecorator{ | ||
| ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first | ||
| NewMinCommissionDecorator(), | ||
| ante.NewRejectExtensionOptionsDecorator(), | ||
| ante.NewMempoolFeeDecorator(), | ||
| ante.NewValidateBasicDecorator(), | ||
| ante.NewTxTimeoutHeightDecorator(), | ||
| ante.NewValidateMemoDecorator(options.AccountKeeper), | ||
| ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), | ||
| ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper), | ||
| // SetPubKeyDecorator must be called before all signature verification decorators | ||
| ante.NewSetPubKeyDecorator(options.AccountKeeper), | ||
| ante.NewValidateSigCountDecorator(options.AccountKeeper), | ||
| ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer), | ||
| ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), | ||
| ante.NewIncrementSequenceDecorator(options.AccountKeeper), | ||
| ibcante.NewAnteDecorator(options.IBCChannelkeeper), | ||
| } | ||
|
|
||
| return sdk.ChainAnteDecorators(anteDecorators...), nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -o errexit -o nounset | ||
|
|
||
| CHAINID="test" | ||
|
|
||
| # Build genesis file incl account for passed address | ||
| coins="10000000000stake,100000000000samoleans" | ||
| chihuahuad init $CHAINID --chain-id $CHAINID | ||
| chihuahuad keys add validator --keyring-backend="test" | ||
| # this won't work because the some proto types are decalared twice and the logs output to stdout (dependency hell involving iavl) | ||
| chihuahuad add-genesis-account $(chihuahuad keys show validator -a --keyring-backend="test") $coins | ||
| chihuahuad gentx validator 5000000000stake --keyring-backend="test" --chain-id $CHAINID | ||
| chihuahuad collect-gentxs | ||
|
|
||
| # Set proper defaults and change ports | ||
| sed -i 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' ~/.chihuahua/config/config.toml | ||
| sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' ~/.chihuahua/config/config.toml | ||
| sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' ~/.chihuahua/config/config.toml | ||
| sed -i 's/index_all_keys = false/index_all_keys = true/g' ~/.chihuahua/config/config.toml | ||
|
|
||
| # Start the chihuahua | ||
| chihuahuad start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,38 @@ | ||
| package keeper | ||
|
|
||
| import ( | ||
| "testing" | ||
| // import ( | ||
| // "testing" | ||
|
|
||
| "github.com/ChihuahuaChain/chihuahua/x/chihuahua/keeper" | ||
| "github.com/ChihuahuaChain/chihuahua/x/chihuahua/types" | ||
| "github.com/cosmos/cosmos-sdk/codec" | ||
| codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
| "github.com/cosmos/cosmos-sdk/store" | ||
| storetypes "github.com/cosmos/cosmos-sdk/store/types" | ||
| sdk "github.com/cosmos/cosmos-sdk/types" | ||
| "github.com/stretchr/testify/require" | ||
| "github.com/tendermint/tendermint/libs/log" | ||
| tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
| tmdb "github.com/tendermint/tm-db" | ||
| ) | ||
| // "github.com/ChihuahuaChain/chihuahua/x/chihuahua/keeper" | ||
| // "github.com/ChihuahuaChain/chihuahua/x/chihuahua/types" | ||
| // "github.com/cosmos/cosmos-sdk/codec" | ||
| // codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
| // "github.com/cosmos/cosmos-sdk/store" | ||
| // storetypes "github.com/cosmos/cosmos-sdk/store/types" | ||
| // sdk "github.com/cosmos/cosmos-sdk/types" | ||
| // "github.com/stretchr/testify/require" | ||
| // "github.com/tendermint/tendermint/libs/log" | ||
| // tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
| // tmdb "github.com/tendermint/tm-db" | ||
| // ) | ||
|
|
||
| func ChihuahuaKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { | ||
| storeKey := sdk.NewKVStoreKey(types.StoreKey) | ||
| memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) | ||
| // func ChihuahuaKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { | ||
| // storeKey := sdk.NewKVStoreKey(types.StoreKey) | ||
| // memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) | ||
|
|
||
| db := tmdb.NewMemDB() | ||
| stateStore := store.NewCommitMultiStore(db) | ||
| stateStore.MountStoreWithDB(storeKey, sdk.StoreTypeIAVL, db) | ||
| stateStore.MountStoreWithDB(memStoreKey, sdk.StoreTypeMemory, nil) | ||
| require.NoError(t, stateStore.LoadLatestVersion()) | ||
| // db := tmdb.NewMemDB() | ||
| // stateStore := store.NewCommitMultiStore(db) | ||
| // stateStore.MountStoreWithDB(storeKey, sdk.StoreTypeIAVL, db) | ||
| // stateStore.MountStoreWithDB(memStoreKey, sdk.StoreTypeMemory, nil) | ||
| // require.NoError(t, stateStore.LoadLatestVersion()) | ||
|
|
||
| registry := codectypes.NewInterfaceRegistry() | ||
| k := keeper.NewKeeper( | ||
| codec.NewProtoCodec(registry), | ||
| storeKey, | ||
| memStoreKey, | ||
| ) | ||
| // registry := codectypes.NewInterfaceRegistry() | ||
| // k := keeper.NewKeeper( | ||
| // codec.NewProtoCodec(registry), | ||
| // storeKey, | ||
| // memStoreKey, | ||
| // ) | ||
|
|
||
| ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) | ||
| return k, ctx | ||
| } | ||
| // ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) | ||
| // return k, ctx | ||
| // } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #81 they named this "moneta-alpha" but ours doesn't have a name, so I left it blank.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is this used? Just to note that we will likely want to point this out when publishing our PR