Skip to content

Commit

Permalink
Merge branch 'main' into ty/perf_memo_check
Browse files Browse the repository at this point in the history
  • Loading branch information
technicallyty authored Oct 13, 2022
2 parents 3f1d600 + 459af58 commit ac07a8b
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
make build-docs
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4.4.0
uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
branch: gh-pages
folder: ~/output
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### CLI Breaking Changes

* (x/genutil) [#13535](https://github.com/cosmos/cosmos-sdk/pull/13535) Replace in `simd init`, the `--staking-bond-denom` flag with `--default-denom` which is used for all default denomination in the genesis, instead of only staking.
* (tx) [#12659](https://github.com/cosmos/cosmos-sdk/pull/12659) Remove broadcast mode `block`.

### Bug Fixes
Expand Down
14 changes: 7 additions & 7 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@you54f/theme-github-codeblock": "^0.1.1",
"autoprefixer": "^10.4.12",
"clsx": "^1.2.1",
"postcss": "^8.4.17",
"postcss": "^8.4.18",
"postcss-import": "^15.0.0",
"prism-react-renderer": "^1.3.5",
"react": "^17.0.2",
Expand Down
31 changes: 15 additions & 16 deletions types/staking.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
package types

// staking constants
const (
// Delay, in blocks, between when validator updates are returned to the
// consensus-engine and when they are applied. For example, if
// ValidatorUpdateDelay is set to X, and if a validator set update is
// returned with new validators at the end of block 10, then the new
// validators are expected to sign blocks beginning at block 11+X.
//
// This value is constant as this should not change without a hard fork.
// For Tendermint this should be set to 1 block, for more details see:
// https://tendermint.com/docs/spec/abci/apps.html#endblock
const ValidatorUpdateDelay int64 = 1

// default bond denomination
var (
// DefaultBondDenom is the default bondable coin denomination (defaults to stake)
// Overwriting this value has the side effect of changing the default denomination in genesis
DefaultBondDenom = "stake"

// Delay, in blocks, between when validator updates are returned to the
// consensus-engine and when they are applied. For example, if
// ValidatorUpdateDelay is set to X, and if a validator set update is
// returned with new validators at the end of block 10, then the new
// validators are expected to sign blocks beginning at block 11+X.
//
// This value is constant as this should not change without a hard fork.
// For Tendermint this should be set to 1 block, for more details see:
// https://tendermint.com/docs/spec/abci/apps.html#endblock
ValidatorUpdateDelay int64 = 1
// DefaultPowerReduction is the default amount of staking tokens required for 1 unit of consensus-engine power
DefaultPowerReduction = NewIntFromUint64(1000000)
)

// DefaultPowerReduction is the default amount of staking tokens required for 1 unit of consensus-engine power
var DefaultPowerReduction = NewIntFromUint64(1000000)

// TokensToConsensusPower - convert input tokens to potential consensus-engine power
func TokensToConsensusPower(tokens Int, powerReduction Int) int64 {
return (tokens.Quo(powerReduction)).Int64()
Expand Down
31 changes: 8 additions & 23 deletions x/genutil/client/cli/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/genutil"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

const (
Expand All @@ -32,8 +31,8 @@ const (
// FlagSeed defines a flag to initialize the private validator key from a specific seed.
FlagRecover = "recover"

// FlagStakingBondDenom defines a flag to specify the staking token in the genesis file.
FlagStakingBondDenom = "staking-bond-denom"
// FlagDefaultBondDenom defines the default denom to use in the genesis file.
FlagDefaultBondDenom = "default-denom"
)

type printInfo struct {
Expand Down Expand Up @@ -115,33 +114,19 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {

genFile := config.GenesisFile()
overwrite, _ := cmd.Flags().GetBool(FlagOverwrite)
stakingBondDenom, _ := cmd.Flags().GetString(FlagStakingBondDenom)
defaultDenom, _ := cmd.Flags().GetString(FlagDefaultBondDenom)

// use os.Stat to check if the file exists
_, err = os.Stat(genFile)
if !overwrite && !os.IsNotExist(err) {
return fmt.Errorf("genesis.json file already exists: %v", genFile)
}

appGenState := mbm.DefaultGenesis(cdc)

if stakingBondDenom != "" {
var stakingGenesis stakingtypes.GenesisState

stakingRaw := appGenState[stakingtypes.ModuleName]
err := clientCtx.Codec.UnmarshalJSON(stakingRaw, &stakingGenesis)
if err != nil {
return err
}

stakingGenesis.Params.BondDenom = stakingBondDenom
modifiedStakingStr, err := clientCtx.Codec.MarshalJSON(&stakingGenesis)
if err != nil {
return err
}

appGenState[stakingtypes.ModuleName] = modifiedStakingStr
// Overwrites the SDK default denom for side-effects
if defaultDenom != "" {
sdk.DefaultBondDenom = defaultDenom
}
appGenState := mbm.DefaultGenesis(cdc)

appState, err := json.MarshalIndent(appGenState, "", " ")
if err != nil {
Expand Down Expand Up @@ -179,7 +164,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
cmd.Flags().BoolP(FlagOverwrite, "o", false, "overwrite the genesis.json file")
cmd.Flags().Bool(FlagRecover, false, "provide seed phrase to recover existing key instead of creating")
cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created")
cmd.Flags().String(FlagStakingBondDenom, "", "genesis file staking bond denomination, if left blank default value is 'stake'")
cmd.Flags().String(FlagDefaultBondDenom, "", "genesis file default denomination, if left blank default value is 'stake'")

return cmd
}
4 changes: 2 additions & 2 deletions x/genutil/client/cli/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestInitRecover(t *testing.T) {
require.NoError(t, cmd.ExecuteContext(ctx))
}

func TestInitStakingBondDenom(t *testing.T) {
func TestInitDefaultBondDenom(t *testing.T) {
home := t.TempDir()
logger := log.NewNopLogger()
cfg, err := genutiltest.CreateDefaultTendermintConfig(home)
Expand All @@ -143,7 +143,7 @@ func TestInitStakingBondDenom(t *testing.T) {
cmd.SetArgs([]string{
"appnode-test",
fmt.Sprintf("--%s=%s", cli.HomeFlag, home),
fmt.Sprintf("--%s=testtoken", genutilcli.FlagStakingBondDenom),
fmt.Sprintf("--%s=testtoken", genutilcli.FlagDefaultBondDenom),
})
require.NoError(t, cmd.ExecuteContext(ctx))
}
Expand Down

0 comments on commit ac07a8b

Please sign in to comment.