Skip to content
Permalink
Browse files
[DFI-597] minSelfDelegation, Cosmos fork migration (#195)
* [DFI-597] project migrated to dfinance Cosmos SDK fork (based on 0.39.1); default MinSelfDelegation set 250000.0 xfi; test fixes

* [DFI-597] go mod alias removed
  • Loading branch information
Mikhail Kornilov committed Aug 30, 2020
1 parent e2ea8c2 commit 3cbb4eb00dc45098eadb2ccbd8ab2d6283a48cc6
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 33 deletions.
@@ -398,6 +398,7 @@ func GetGenesis(app *DnServiceApp, chainID, monikerID string, nodeAccPrivKey sec
commissionRate, _ := sdk.NewDecFromStr("0.100000000000000000")
commissionMaxRate, _ := sdk.NewDecFromStr("0.200000000000000000")
commissionChangeRate, _ := sdk.NewDecFromStr("0.010000000000000000")
minSelfDelegation := sdk.NewInt(staking.DefaultMinSelfDelegationLvl)
tokenAmount := sdk.TokensFromConsensusPower(1)

msg := staking.NewMsgCreateValidator(
@@ -406,7 +407,7 @@ func GetGenesis(app *DnServiceApp, chainID, monikerID string, nodeAccPrivKey sec
sdk.NewCoin(dnConfig.MainDenom, tokenAmount),
staking.NewDescription(monikerID, "", "", "", ""),
staking.NewCommissionRates(commissionRate, commissionMaxRate, commissionChangeRate),
sdk.OneInt(),
minSelfDelegation,
)

txFee := auth.StdFee{
@@ -39,6 +39,9 @@ const (

// Invariants check period for crisis module (in blocks)
DefInvCheckPeriod = 10

// Default staking validator minSelfDelegation amount
DefMinSelfDelegation = "250000000000000000000000" // 250000 xfi
)

var (
@@ -94,12 +94,18 @@ func InitCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager,

appGenState := mbm.DefaultGenesis()

// Change default staking denom.
// Change default staking denom, minSelfDelegation
minSelfDelegation, ok := sdk.NewIntFromString(DefMinSelfDelegation)
if !ok {
return fmt.Errorf("staking genState: default minSelfDelegation convertion failed: %s", DefMinSelfDelegation)
}

stakingDataBz := appGenState[staking.ModuleName]
var stakingGenState staking.GenesisState

cdc.MustUnmarshalJSON(stakingDataBz, &stakingGenState)
stakingGenState.Params.BondDenom = MainDenom
stakingGenState.Params.MinSelfDelegationLvl = minSelfDelegation
appGenState[staking.ModuleName] = cdc.MustMarshalJSON(stakingGenState)

// Change default mint stake.
12 go.mod
@@ -2,25 +2,28 @@ module github.com/dfinance/dnode

go 1.14

replace github.com/cosmos/cosmos-sdk => github.com/dfinance/cosmos-sdk v0.38.4-0.20200827093801-ea5361e994d8

// Local development option
//replace github.com/cosmos/cosmos-sdk => /Users/tiky/Go_Projects/src/github.com/dfinance/cosmos-sdk

require (
github.com/99designs/keyring v1.1.3
github.com/Microsoft/hcsshim v0.8.7 // indirect
github.com/OneOfOne/xxhash v1.2.7
github.com/atlassian/go-sentry-api v0.0.0-20200117001222-a9ccec16c98b
github.com/containerd/containerd v1.3.3 // indirect
github.com/containerd/continuity v0.0.0-20200228182428-0f16d7a0959c // indirect
github.com/cosmos/cosmos-sdk v0.39.0
github.com/cosmos/cosmos-sdk v0.0.1
github.com/dfinance/dvm-proto/go v0.0.0-20200819065410-6b70956c85de
github.com/dfinance/glav v0.0.0-20200814081332-c4701f6c12a6
github.com/dfinance/lcs v0.1.7-big
github.com/fsouza/go-dockerclient v1.6.3
github.com/g3co/go-swagger-merger v0.0.0-20200729134821-4edc8debe55f // indirect
github.com/getsentry/sentry-go v0.5.1
github.com/ghodss/yaml v1.0.0
github.com/go-openapi/spec v0.19.9 // indirect
github.com/go-openapi/swag v0.19.9 // indirect
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.4.1
github.com/gorilla/handlers v1.4.2
github.com/gorilla/mux v1.7.4
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
@@ -38,9 +41,8 @@ require (
github.com/swaggo/http-swagger v0.0.0-20200308142732-58ac5e232fba
github.com/swaggo/swag v1.6.7
github.com/tendermint/go-amino v0.15.1
github.com/tendermint/tendermint v0.33.6
github.com/tendermint/tendermint v0.33.7
github.com/tendermint/tm-db v0.5.1
github.com/urfave/cli/v2 v2.2.0 // indirect
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc // indirect
golang.org/x/tools v0.0.0-20200818005847-188abfa75333 // indirect
google.golang.org/grpc v1.30.0
30 go.sum
@@ -128,8 +128,6 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cosmos/cosmos-sdk v0.39.0 h1:lWZQLFxLYQ4ydD01cDZF7tRF8IN2xclDmoNPIJ5Kw44=
github.com/cosmos/cosmos-sdk v0.39.0/go.mod h1:3iKiqnQ48T0UG4IDw9EM8utQSwItutLUkmGkRSWpS5U=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4=
@@ -148,16 +146,12 @@ github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dfinance/dvm-proto/go v0.0.0-20200629145843-bfdcef619a26 h1:HjCcumhDVs5KmXxy7AAzcRzHVaHF3msBoWCpSewdFAc=
github.com/dfinance/dvm-proto/go v0.0.0-20200629145843-bfdcef619a26/go.mod h1:Vt1T0G56AYXbsduNKzSkq1RDTNa8PFraSqB9DaTCV0U=
github.com/dfinance/dvm-proto/go v0.0.0-20200806082036-06b76cf8c183 h1:h1gLIUPEbVIVHSrJvC9FPpaVKHXmVmUYAoEEoH/ZxeE=
github.com/dfinance/dvm-proto/go v0.0.0-20200806082036-06b76cf8c183/go.mod h1:Vt1T0G56AYXbsduNKzSkq1RDTNa8PFraSqB9DaTCV0U=
github.com/dfinance/cosmos-sdk v0.38.4-0.20200822133034-42c3c57df3e2 h1:MLKTT0LreNrqAPbCuS/7Xpiuhls47z6SeO+EsvnF43c=
github.com/dfinance/cosmos-sdk v0.38.4-0.20200822133034-42c3c57df3e2/go.mod h1:ry2ROl5n+f2/QXpKJo3rdWNJwll00z7KhIVcxNcl16M=
github.com/dfinance/cosmos-sdk v0.38.4-0.20200827093801-ea5361e994d8 h1:NY8ufCNHaBXUpLOqFz42W24Yu012qVr3vOTLzIId6EM=
github.com/dfinance/cosmos-sdk v0.38.4-0.20200827093801-ea5361e994d8/go.mod h1:ry2ROl5n+f2/QXpKJo3rdWNJwll00z7KhIVcxNcl16M=
github.com/dfinance/dvm-proto/go v0.0.0-20200819065410-6b70956c85de h1:PZfrjeOs9epAU0n+FpX/JAr/e+5m5/GdfUsgtO8gCOY=
github.com/dfinance/dvm-proto/go v0.0.0-20200819065410-6b70956c85de/go.mod h1:Vt1T0G56AYXbsduNKzSkq1RDTNa8PFraSqB9DaTCV0U=
github.com/dfinance/glav v0.0.0-20200731202515-8e21f58877c8 h1:SpACwa85hu9vFveIBPE4Xe28KiSrwxU8Lge3Pcdtr8s=
github.com/dfinance/glav v0.0.0-20200731202515-8e21f58877c8/go.mod h1:/0gr38+QzVxCNSNKc/WjGKtdTfV8NtMagCNO0/VjOQU=
github.com/dfinance/glav v0.0.0-20200810142408-b45f02eb7f56 h1:fHl+W6KAqVKdTmwpmpAQX8z0ZSH4qf3FS4X/dNJk3cc=
github.com/dfinance/glav v0.0.0-20200810142408-b45f02eb7f56/go.mod h1:/0gr38+QzVxCNSNKc/WjGKtdTfV8NtMagCNO0/VjOQU=
github.com/dfinance/glav v0.0.0-20200814081332-c4701f6c12a6 h1:fZIYncA5BRad0+YnP88cfBfo0ZPgxPSVeuh/jvoGrLc=
github.com/dfinance/glav v0.0.0-20200814081332-c4701f6c12a6/go.mod h1:/0gr38+QzVxCNSNKc/WjGKtdTfV8NtMagCNO0/VjOQU=
github.com/dfinance/lcs v0.1.7-big h1:z+Pvxcxvr6lKSy1vjYJtM5MnCTQ7DBjPitTywoWO9X0=
@@ -212,8 +206,6 @@ github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsouza/go-dockerclient v1.6.3 h1:VS/I3mxieZVIeaWXd57JKvSjheELafUJYtblGg75RIQ=
github.com/fsouza/go-dockerclient v1.6.3/go.mod h1:OiSy/IhZIF+zheikZkXK7LVpGzxWchJPJKGWhBqOK4M=
github.com/g3co/go-swagger-merger v0.0.0-20200729134821-4edc8debe55f h1:k5O6l2MEnI8MBFwK5SBGyC9OGVlPCbEf+HJwOHxGhQE=
github.com/g3co/go-swagger-merger v0.0.0-20200729134821-4edc8debe55f/go.mod h1:jvC3b+YoOx9/SJYqqo1pN1vJ31StlOCugGCyO3EW9XA=
github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc=
github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ=
github.com/getsentry/sentry-go v0.4.0/go.mod h1:xkGcb82SipKQloDNa5b7hTV4VdEyc2bhwd1/UczP52k=
@@ -471,8 +463,6 @@ github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.7.2 h1:V9ecaZWDYm7v9uJ15RZD6DajMu5sE0hdep0aoDwT9g4=
github.com/mailru/easyjson v0.7.2/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mailru/easyjson v0.7.3 h1:M6wcO9gFHCIPynXGu4iA+NMs//FCgFUWR2jxqV3/+Xk=
github.com/mailru/easyjson v0.7.3/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
@@ -742,8 +732,8 @@ github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoM
github.com/tendermint/iavl v0.14.0 h1:Jkff+IFrXxRWtH9Jn/ga/2cxNnzMTv58xEKgCJsKUBg=
github.com/tendermint/iavl v0.14.0/go.mod h1:QmfViflFiXzxKLQE4tAUuWQHq+RSuQFxablW5oJZ6sE=
github.com/tendermint/tendermint v0.33.5/go.mod h1:0yUs9eIuuDq07nQql9BmI30FtYGcEC60Tu5JzB5IezM=
github.com/tendermint/tendermint v0.33.6 h1:W4UOsXY4ROJZ3TLLGVVv71VXD4WK2gJRb3gzeced+mg=
github.com/tendermint/tendermint v0.33.6/go.mod h1:0yUs9eIuuDq07nQql9BmI30FtYGcEC60Tu5JzB5IezM=
github.com/tendermint/tendermint v0.33.7 h1:b5CQD8ggDtl4u0EbXzabi0MaOw9NrcXker6ijEkAE74=
github.com/tendermint/tendermint v0.33.7/go.mod h1:0yUs9eIuuDq07nQql9BmI30FtYGcEC60Tu5JzB5IezM=
github.com/tendermint/tm-db v0.5.1 h1:H9HDq8UEA7Eeg13kdYckkgwwkQLBnJGgX4PgLJRhieY=
github.com/tendermint/tm-db v0.5.1/go.mod h1:g92zWjHpCYlEvQXvy9M168Su8V1IBEeawpXVVBaK4f4=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
@@ -761,8 +751,6 @@ github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k=
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
github.com/urfave/cli/v2 v2.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4=
github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
@@ -859,8 +847,6 @@ golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU=
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc h1:zK/HqS5bZxDptfPJNq8v7vJfXtkU7r9TLIoSr1bXaP4=
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
@@ -941,10 +927,6 @@ golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114 h1:DnSr2mCsxyCE6ZgIkmcWUQY2R5cH/6wL7eIxEmQOMSE=
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200729041821-df70183b1872 h1:/U95VAvB4ZsR91rpZX2MwiKpejhWr+UxJ+N2VlJuESk=
golang.org/x/tools v0.0.0-20200729041821-df70183b1872/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d h1:szSOL78iTCl0LF1AMjhSWJj8tIM0KixlUUnBtYXsmd8=
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200818005847-188abfa75333 h1:a6ryybeZHQf5qnBc6IwRfVnI/75UmdtJo71f0//8Dqo=
golang.org/x/tools v0.0.0-20200818005847-188abfa75333/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -123,7 +123,7 @@ func NewAccountMap() (accounts map[string]*CLIAccount, retErr error) {
return
}

bigAmount, ok := sdk.NewIntFromString("100000000000000000000000") // 100000xfi
bigAmount, ok := sdk.NewIntFromString("1000000000000000000000000") // 1000000xfi
if !ok {
retErr = fmt.Errorf("NewInt for bigAmount")
return
@@ -6,6 +6,7 @@ import (
"strings"

sdkKeys "github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/spf13/viper"
"github.com/stretchr/testify/require"
@@ -160,14 +161,18 @@ func (ct *CLITester) initChain() {

// validator genTX
{
minSelfDelegation, ok := sdk.NewIntFromString(dnConfig.DefMinSelfDelegation)
require.True(ct.t, ok, "DefMinSelfDelegation conversion failed")

stakingCoin := ct.Accounts["pos"].Coins[config.MainDenom]
stakingCoin.Amount = stakingCoin.Amount.QuoRaw(4)
stakingCoin.Amount = minSelfDelegation

cmd := ct.newWbdCmd().
AddArg("", "gentx").
AddArg("home-client", ct.Dirs.DncliDir).
AddArg("name", "pos").
AddArg("amount", stakingCoin.String()).
AddArg("min-self-delegation", minSelfDelegation.String()).
AddArg("keyring-backend", string(ct.keyringBackend))

cmd.CheckSuccessfulExecute(nil, ct.AccountPassphrase, ct.AccountPassphrase, ct.AccountPassphrase)

0 comments on commit 3cbb4eb

Please sign in to comment.