-
Notifications
You must be signed in to change notification settings - Fork 0
/
genesis.go
executable file
·64 lines (52 loc) · 2.62 KB
/
genesis.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package app
import (
"encoding/json"
"time"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
crisis "github.com/cosmos/cosmos-sdk/x/crisis/types"
gov "github.com/cosmos/cosmos-sdk/x/gov/types"
mint "github.com/cosmos/cosmos-sdk/x/mint/types"
staking "github.com/cosmos/cosmos-sdk/x/staking/types"
appconfig "github.com/furyunderverse/furya/cmd/config"
)
// GenesisState default state for the application
type GenesisState map[string]json.RawMessage
// NewDefaultGenesisState generates the default state for the application.
func NewDefaultGenesisState(cdc codec.Codec) GenesisState {
genesisState := make(GenesisState)
// Get default genesis states of the modules we are to override.
stakingGenesis := staking.DefaultGenesisState()
mintGenesis := mint.DefaultGenesisState()
govGenesis := gov.DefaultGenesisState()
crisisGenesis := crisis.DefaultGenesisState()
stakingGenesis.Params.BondDenom = appconfig.Bech32Prefix
stakingGenesis.Params.HistoricalEntries = 1000
// TODO: testnet figures only
stakingGenesis.Params.UnbondingTime = time.Hour * 2
stakingGenesis.Params.MaxValidators = 100
genesisState[staking.ModuleName] = cdc.MustMarshalJSON(stakingGenesis)
mintGenesis.Params.BlocksPerYear = 6311200 // target 5-second block time
mintGenesis.Params.MintDenom = appconfig.Bech32Prefix
genesisState[mint.ModuleName] = cdc.MustMarshalJSON(mintGenesis)
govGenesis.DepositParams.MinDeposit = sdk.NewCoins(sdk.NewCoin(appconfig.Bech32Prefix, sdk.TokensFromConsensusPower(10, sdk.NewInt(1000000))))
// TODO: testing
govGenesis.VotingParams.VotingPeriod = time.Second * 30 // test for 10 mins voting period
genesisState[gov.ModuleName] = cdc.MustMarshalJSON(govGenesis)
crisisGenesis.ConstantFee = sdk.NewCoin(appconfig.Bech32Prefix, sdk.TokensFromConsensusPower(10, sdk.NewInt(1000000)))
genesisState[crisis.ModuleName] = cdc.MustMarshalJSON(crisisGenesis)
// slashingGenesis.Params.SignedBlocksWindow = 30000 // approximately 1 day
// slashingGenesis.Params.MinSignedPerWindow = sdk.NewDecWithPrec(5, 2) // 5%
// slashingGenesis.Params.DowntimeJailDuration = 60 * 10 * time.Second // 10 minutes
// slashingGenesis.Params.SlashFractionDoubleSign = sdk.NewDecWithPrec(5, 2) // 5%
// slashingGenesis.Params.SlashFractionDowntime = sdk.NewDecWithPrec(1, 4) // 0.01%
// Add your modules here for the genesis states
for _, b := range ModuleBasics {
name := b.Name()
if name == staking.ModuleName || name == mint.ModuleName || name == gov.ModuleName || name == crisis.ModuleName {
continue
}
genesisState[b.Name()] = b.DefaultGenesis(cdc)
}
return genesisState
}