-
Notifications
You must be signed in to change notification settings - Fork 558
/
genesis.go
576 lines (507 loc) · 20.9 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
package cmd
import (
"encoding/json"
"fmt"
"time"
"github.com/spf13/cobra"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/genutil"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
appParams "github.com/osmosis-labs/osmosis/v7/app/params"
claimtypes "github.com/osmosis-labs/osmosis/v7/x/claim/types"
epochstypes "github.com/osmosis-labs/osmosis/v7/x/epochs/types"
incentivestypes "github.com/osmosis-labs/osmosis/v7/x/incentives/types"
minttypes "github.com/osmosis-labs/osmosis/v7/x/mint/types"
poolincentivestypes "github.com/osmosis-labs/osmosis/v7/x/pool-incentives/types"
)
func PrepareGenesisCmd(defaultNodeHome string, mbm module.BasicManager) *cobra.Command {
cmd := &cobra.Command{
Use: "prepare-genesis",
Short: "Prepare a genesis file with initial setup",
Long: `Prepare a genesis file with initial setup.
Examples include:
- Setting module initial params
- Setting denom metadata
Example:
osmosisd prepare-genesis mainnet osmosis-1
- Check input genesis:
file is at ~/.osmosisd/config/genesis.json
`,
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
depCdc := clientCtx.Codec
cdc := depCdc.(codec.Codec)
serverCtx := server.GetServerContextFromCmd(cmd)
config := serverCtx.Config
// read genesis file
genFile := config.GenesisFile()
appState, genDoc, err := genutiltypes.GenesisStateFromGenFile(genFile)
if err != nil {
return fmt.Errorf("failed to unmarshal genesis state: %w", err)
}
// get genesis params
var genesisParams GenesisParams
network := args[0]
if network == "testnet" {
genesisParams = TestnetGenesisParams()
} else if network == "mainnet" {
genesisParams = MainnetGenesisParams()
} else {
return fmt.Errorf("please choose 'mainnet' or 'testnet'")
}
// get genesis params
chainID := args[1]
// run Prepare Genesis
appState, genDoc, err = PrepareGenesis(clientCtx, appState, genDoc, genesisParams, chainID)
// validate genesis state
if err = mbm.ValidateGenesis(cdc, clientCtx.TxConfig, appState); err != nil {
return fmt.Errorf("error validating genesis file: %s", err.Error())
}
// save genesis
appStateJSON, err := json.Marshal(appState)
if err != nil {
return fmt.Errorf("failed to marshal application genesis state: %w", err)
}
genDoc.AppState = appStateJSON
err = genutil.ExportGenesisFile(genDoc, genFile)
return err
},
}
cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory")
flags.AddQueryFlagsToCmd(cmd)
return cmd
}
func PrepareGenesis(clientCtx client.Context, appState map[string]json.RawMessage, genDoc *tmtypes.GenesisDoc, genesisParams GenesisParams, chainID string) (map[string]json.RawMessage, *tmtypes.GenesisDoc, error) {
depCdc := clientCtx.Codec
cdc := depCdc.(codec.Codec)
// chain params genesis
genDoc.ChainID = chainID
genDoc.GenesisTime = genesisParams.GenesisTime
genDoc.ConsensusParams = genesisParams.ConsensusParams
// ---
// staking module genesis
stakingGenState := stakingtypes.GetGenesisStateFromAppState(depCdc, appState)
stakingGenState.Params = genesisParams.StakingParams
stakingGenStateBz, err := cdc.MarshalJSON(stakingGenState)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal staking genesis state: %w", err)
}
appState[stakingtypes.ModuleName] = stakingGenStateBz
// mint module genesis
mintGenState := minttypes.DefaultGenesisState()
mintGenState.Params = genesisParams.MintParams
mintGenStateBz, err := cdc.MarshalJSON(mintGenState)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal mint genesis state: %w", err)
}
appState[minttypes.ModuleName] = mintGenStateBz
// distribution module genesis
distributionGenState := distributiontypes.DefaultGenesisState()
distributionGenState.Params = genesisParams.DistributionParams
// TODO Set initial community pool
// distributionGenState.FeePool.CommunityPool = sdk.NewDecCoins()
distributionGenStateBz, err := cdc.MarshalJSON(distributionGenState)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal distribution genesis state: %w", err)
}
appState[distributiontypes.ModuleName] = distributionGenStateBz
// gov module genesis
govGenState := govtypes.DefaultGenesisState()
govGenState.DepositParams = genesisParams.GovParams.DepositParams
govGenState.TallyParams = genesisParams.GovParams.TallyParams
govGenState.VotingParams = genesisParams.GovParams.VotingParams
govGenStateBz, err := cdc.MarshalJSON(govGenState)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal gov genesis state: %w", err)
}
appState[govtypes.ModuleName] = govGenStateBz
// crisis module genesis
crisisGenState := crisistypes.DefaultGenesisState()
crisisGenState.ConstantFee = genesisParams.CrisisConstantFee
// TODO Set initial community pool
// distributionGenState.FeePool.CommunityPool = sdk.NewDecCoins()
crisisGenStateBz, err := cdc.MarshalJSON(crisisGenState)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal crisis genesis state: %w", err)
}
appState[crisistypes.ModuleName] = crisisGenStateBz
// slashing module genesis
slashingGenState := slashingtypes.DefaultGenesisState()
slashingGenState.Params = genesisParams.SlashingParams
slashingGenStateBz, err := cdc.MarshalJSON(slashingGenState)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal slashing genesis state: %w", err)
}
appState[slashingtypes.ModuleName] = slashingGenStateBz
// incentives module genesis
incentivesGenState := incentivestypes.GetGenesisStateFromAppState(depCdc, appState)
incentivesGenState.Params = genesisParams.IncentivesGenesis.Params
incentivesGenState.LockableDurations = genesisParams.IncentivesGenesis.LockableDurations
incentivesGenState.Gauges = genesisParams.IncentivesGenesis.Gauges
incentivesGenStateBz, err := cdc.MarshalJSON(incentivesGenState)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal incentives genesis state: %w", err)
}
appState[incentivestypes.ModuleName] = incentivesGenStateBz
// epochs module genesis
epochsGenState := epochstypes.DefaultGenesis()
epochsGenState.Epochs = genesisParams.Epochs
epochsGenStateBz, err := cdc.MarshalJSON(epochsGenState)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal epochs genesis state: %w", err)
}
appState[epochstypes.ModuleName] = epochsGenStateBz
// claim module genesis
claimGenState := claimtypes.GetGenesisStateFromAppState(depCdc, appState)
claimGenState.Params = genesisParams.ClaimParams
claimGenStateBz, err := cdc.MarshalJSON(claimGenState)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal claim genesis state: %w", err)
}
appState[claimtypes.ModuleName] = claimGenStateBz
// poolincentives module genesis
poolincentivesGenState := &genesisParams.PoolIncentivesGenesis
poolincentivesGenStateBz, err := cdc.MarshalJSON(poolincentivesGenState)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal poolincentives genesis state: %w", err)
}
appState[poolincentivestypes.ModuleName] = poolincentivesGenStateBz
// return appState and genDoc
return appState, genDoc, nil
}
type GenesisParams struct {
AirdropSupply sdk.Int
StrategicReserveAccounts []banktypes.Balance
ConsensusParams *tmproto.ConsensusParams
GenesisTime time.Time
NativeCoinMetadatas []banktypes.Metadata
StakingParams stakingtypes.Params
MintParams minttypes.Params
DistributionParams distributiontypes.Params
GovParams govtypes.Params
CrisisConstantFee sdk.Coin
SlashingParams slashingtypes.Params
IncentivesGenesis incentivestypes.GenesisState
PoolIncentivesGenesis poolincentivestypes.GenesisState
Epochs []epochstypes.EpochInfo
ClaimParams claimtypes.Params
}
func MainnetGenesisParams() GenesisParams {
genParams := GenesisParams{}
genParams.AirdropSupply = sdk.NewIntWithDecimal(5, 13) // 5*10^13 uosmo, 5*10^7 (50 million) osmo
genParams.GenesisTime = time.Date(2021, 6, 18, 17, 0, 0, 0, time.UTC) // Jun 18, 2021 - 17:00 UTC
genParams.NativeCoinMetadatas = []banktypes.Metadata{
{
Description: fmt.Sprintf("The native token of Osmosis"),
DenomUnits: []*banktypes.DenomUnit{
{
Denom: appParams.BaseCoinUnit,
Exponent: 0,
Aliases: nil,
},
{
Denom: appParams.HumanCoinUnit,
Exponent: appParams.OsmoExponent,
Aliases: nil,
},
},
Base: appParams.BaseCoinUnit,
Display: appParams.HumanCoinUnit,
},
{
DenomUnits: []*banktypes.DenomUnit{
{
Denom: "uion",
Exponent: 0,
Aliases: nil,
},
{
Denom: "ion",
Exponent: 6,
Aliases: nil,
},
},
Base: "uion",
Display: "ion",
},
}
genParams.StrategicReserveAccounts = []banktypes.Balance{
{
Address: "osmo1el3aytvehpvxw2ymmya4kdyj9yndyy47fw5zh4",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(47_874_500_000_000))), // 47.8745 million OSMO
},
{
Address: "osmo1g7rp8h6wzekjjy8n6my8za3vg3338eqz3v295v",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(500_000_000_000))), // 500 thousand OSMO
},
{
Address: "osmo1z7ql0vcjlznrruw3hwgm043w8yhzqmtpu5rlp9",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(1_000_000_000_000))), // 1 million OSMO
},
{
Address: "osmo1grgelyng2v6v3t8z87wu3sxgt9m5s03xytvfcl",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))),
},
{
Address: "osmo1yuz4fct5cc3td6fp7he055mut0d4ukcsvlgpkg",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))),
},
{
Address: "osmo1epr7gp5gf9ftkduzlkckmehqk9dyn063xref53",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))),
},
{
Address: "osmo1enu76xfqkadu022hkdg7rwyc4pqq6jzn3zy395",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))),
},
{
Address: "osmo1njvfq5pdad2f5j0uvqtfdujyg8c5sde2n6yw2t",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))),
},
{
Address: "osmo1gaajper2qphnk6rnpy8zjhhg2kstnd87sh36hx",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(25_000_000_000))),
},
{
Address: "osmo1xl6r0n34mq0z7gfx7w2qf3f2vq70g5ph7n78hs",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))),
},
{
Address: "osmo13stzqk27y46cr8fz7vfr8dsqqk4wpz90fqmc23",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))),
},
{
Address: "osmo12wmptq2zm3s2d8c0xukwj3fkcl0qw66wmxwr7x",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(25_000_000_000))),
},
{
Address: "osmo1qc74lw7f8ak737jy2at36wa9tyrgldk8kpskzg",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(5_000_000_000))),
},
{
Address: "osmo1m3lvlydlu3mqv7z9xgtqjplcx20yc3lmx3p73e",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(10_000_000_000))),
},
{
Address: "osmo14u94qvqqdyjruufc08m6rwq8yz3ukurkzkvczx",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(7_500_000_000))),
},
{
Address: "osmo15t8y5mzdmz54fcj2wq3qutgtharuxdg7zu9q98",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))),
},
{
Address: "osmo1ngt8m8722qxcgdpqjwe3ggwcpg6zns8axpxtt0",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))),
},
{
Address: "osmo17ncgp84x5vmphdlaaktzp7hljh3mhysqw9up3u",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))),
},
{
Address: "osmo16n7070n4whce0wlu76j42dyrxh9f7nlapg6c4a",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))),
},
{
Address: "osmo1vnyc6q49sr0hs9ddjepcmtlaq3l6wwj0rrw6hd",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(1_000_000_000))),
},
{
Address: "osmo1ujx3rqerqdksnxnjka2n9tde874mzut75hzx92",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(1_000_000_000))),
},
{
Address: "osmo1a2r7nqnc9e032wj37ptskh207e232462vcrrjf",
Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(1_000_000_000))),
},
}
genParams.StakingParams = stakingtypes.DefaultParams()
genParams.StakingParams.UnbondingTime = time.Hour * 24 * 7 * 2 // 2 weeks
genParams.StakingParams.MaxValidators = 100
genParams.StakingParams.BondDenom = genParams.NativeCoinMetadatas[0].Base
genParams.StakingParams.MinCommissionRate = sdk.MustNewDecFromStr("0.05")
genParams.MintParams = minttypes.DefaultParams()
genParams.MintParams.EpochIdentifier = "day" // 1 day
genParams.MintParams.GenesisEpochProvisions = sdk.NewDec(300_000_000_000_000).QuoInt64(365) // 300M * 10^6 / 365 = ~821917.8082191781 * 10^6
genParams.MintParams.MintDenom = genParams.NativeCoinMetadatas[0].Base
genParams.MintParams.ReductionFactor = sdk.NewDec(2).QuoInt64(3) // 2/3
genParams.MintParams.ReductionPeriodInEpochs = 365 // 1 year (screw leap years)
genParams.MintParams.DistributionProportions = minttypes.DistributionProportions{
Staking: sdk.MustNewDecFromStr("0.25"), // 25%
DeveloperRewards: sdk.MustNewDecFromStr("0.25"), // 25%
PoolIncentives: sdk.MustNewDecFromStr("0.45"), // 45%
CommunityPool: sdk.MustNewDecFromStr("0.05"), // 5%
}
genParams.MintParams.MintingRewardsDistributionStartEpoch = 1
genParams.MintParams.WeightedDeveloperRewardsReceivers = []minttypes.WeightedAddress{
{
Address: "osmo14kjcwdwcqsujkdt8n5qwpd8x8ty2rys5rjrdjj",
Weight: sdk.MustNewDecFromStr("0.2887"),
},
{
Address: "osmo1gw445ta0aqn26suz2rg3tkqfpxnq2hs224d7gq",
Weight: sdk.MustNewDecFromStr("0.2290"),
},
{
Address: "osmo13lt0hzc6u3htsk7z5rs6vuurmgg4hh2ecgxqkf",
Weight: sdk.MustNewDecFromStr("0.1625"),
},
{
Address: "osmo1kvc3he93ygc0us3ycslwlv2gdqry4ta73vk9hu",
Weight: sdk.MustNewDecFromStr("0.109"),
},
{
Address: "osmo19qgldlsk7hdv3ddtwwpvzff30pxqe9phq9evxf",
Weight: sdk.MustNewDecFromStr("0.0995"),
},
{
Address: "osmo19fs55cx4594een7qr8tglrjtt5h9jrxg458htd",
Weight: sdk.MustNewDecFromStr("0.06"),
},
{
Address: "osmo1ssp6px3fs3kwreles3ft6c07mfvj89a544yj9k",
Weight: sdk.MustNewDecFromStr("0.015"),
},
{
Address: "osmo1c5yu8498yzqte9cmfv5zcgtl07lhpjrj0skqdx",
Weight: sdk.MustNewDecFromStr("0.01"),
},
{
Address: "osmo1yhj3r9t9vw7qgeg22cehfzj7enwgklw5k5v7lj",
Weight: sdk.MustNewDecFromStr("0.0075"),
},
{
Address: "osmo18nzmtyn5vy5y45dmcdnta8askldyvehx66lqgm",
Weight: sdk.MustNewDecFromStr("0.007"),
},
{
Address: "osmo1z2x9z58cg96ujvhvu6ga07yv9edq2mvkxpgwmc",
Weight: sdk.MustNewDecFromStr("0.005"),
},
{
Address: "osmo1tvf3373skua8e6480eyy38avv8mw3hnt8jcxg9",
Weight: sdk.MustNewDecFromStr("0.0025"),
},
{
Address: "osmo1zs0txy03pv5crj2rvty8wemd3zhrka2ne8u05n",
Weight: sdk.MustNewDecFromStr("0.0025"),
},
{
Address: "osmo1djgf9p53n7m5a55hcn6gg0cm5mue4r5g3fadee",
Weight: sdk.MustNewDecFromStr("0.001"),
},
{
Address: "osmo1488zldkrn8xcjh3z40v2mexq7d088qkna8ceze",
Weight: sdk.MustNewDecFromStr("0.0008"),
},
}
genParams.DistributionParams = distributiontypes.DefaultParams()
genParams.DistributionParams.BaseProposerReward = sdk.MustNewDecFromStr("0.01")
genParams.DistributionParams.BonusProposerReward = sdk.MustNewDecFromStr("0.04")
genParams.DistributionParams.CommunityTax = sdk.MustNewDecFromStr("0")
genParams.DistributionParams.WithdrawAddrEnabled = true
genParams.GovParams = govtypes.DefaultParams()
genParams.GovParams.DepositParams.MaxDepositPeriod = time.Hour * 24 * 14 // 2 weeks
genParams.GovParams.DepositParams.MinDeposit = sdk.NewCoins(sdk.NewCoin(
genParams.NativeCoinMetadatas[0].Base,
sdk.NewInt(2_500_000_000),
))
genParams.GovParams.TallyParams.Quorum = sdk.MustNewDecFromStr("0.2") // 20%
genParams.GovParams.VotingParams.VotingPeriod = time.Hour * 24 * 3 // 3 days
genParams.CrisisConstantFee = sdk.NewCoin(
genParams.NativeCoinMetadatas[0].Base,
sdk.NewInt(500_000_000_000),
)
genParams.SlashingParams = slashingtypes.DefaultParams()
genParams.SlashingParams.SignedBlocksWindow = int64(30000) // 30000 blocks (~41 hr at 5 second blocks)
genParams.SlashingParams.MinSignedPerWindow = sdk.MustNewDecFromStr("0.05") // 5% minimum liveness
genParams.SlashingParams.DowntimeJailDuration = time.Minute // 1 minute jail period
genParams.SlashingParams.SlashFractionDoubleSign = sdk.MustNewDecFromStr("0.05") // 5% double sign slashing
genParams.SlashingParams.SlashFractionDowntime = sdk.ZeroDec() // 0% liveness slashing
genParams.Epochs = epochstypes.DefaultGenesis().Epochs
for _, epoch := range genParams.Epochs {
epoch.StartTime = genParams.GenesisTime
}
genParams.IncentivesGenesis = *incentivestypes.DefaultGenesis()
genParams.IncentivesGenesis.Params.DistrEpochIdentifier = "day"
genParams.IncentivesGenesis.LockableDurations = []time.Duration{
time.Hour * 24, // 1 day
time.Hour * 24 * 7, // 7 day
time.Hour * 24 * 14, // 14 days
}
genParams.ClaimParams = claimtypes.Params{
AirdropStartTime: genParams.GenesisTime,
DurationUntilDecay: time.Hour * 24 * 60, // 60 days = ~2 months
DurationOfDecay: time.Hour * 24 * 120, // 120 days = ~4 months
ClaimDenom: genParams.NativeCoinMetadatas[0].Base,
}
genParams.ConsensusParams = tmtypes.DefaultConsensusParams()
genParams.ConsensusParams.Block.MaxBytes = 5 * 1024 * 1024
genParams.ConsensusParams.Block.MaxGas = 6_000_000
genParams.ConsensusParams.Evidence.MaxAgeDuration = genParams.StakingParams.UnbondingTime
genParams.ConsensusParams.Evidence.MaxAgeNumBlocks = int64(genParams.StakingParams.UnbondingTime.Seconds()) / 3
genParams.ConsensusParams.Version.AppVersion = 1
genParams.PoolIncentivesGenesis = *poolincentivestypes.DefaultGenesisState()
genParams.PoolIncentivesGenesis.Params.MintedDenom = genParams.NativeCoinMetadatas[0].Base
genParams.PoolIncentivesGenesis.LockableDurations = genParams.IncentivesGenesis.LockableDurations
genParams.PoolIncentivesGenesis.DistrInfo = &poolincentivestypes.DistrInfo{
TotalWeight: sdk.NewInt(1000),
Records: []poolincentivestypes.DistrRecord{
{
GaugeId: 0,
Weight: sdk.NewInt(1000),
},
},
}
return genParams
}
func TestnetGenesisParams() GenesisParams {
genParams := MainnetGenesisParams()
genParams.GenesisTime = time.Now()
genParams.Epochs = append(genParams.Epochs, epochstypes.EpochInfo{
Identifier: "15min",
StartTime: time.Time{},
Duration: 15 * time.Minute,
CurrentEpoch: 0,
CurrentEpochStartTime: time.Time{},
EpochCountingStarted: false,
})
for _, epoch := range genParams.Epochs {
epoch.StartTime = genParams.GenesisTime
}
genParams.StakingParams.UnbondingTime = time.Hour * 24 * 7 * 2 // 2 weeks
genParams.MintParams.EpochIdentifier = "15min" // 15min
genParams.MintParams.ReductionPeriodInEpochs = 192 // 2 days
genParams.GovParams.DepositParams.MinDeposit = sdk.NewCoins(sdk.NewCoin(
genParams.NativeCoinMetadatas[0].Base,
sdk.NewInt(1000000), // 1 OSMO
))
genParams.GovParams.TallyParams.Quorum = sdk.MustNewDecFromStr("0.0000000001") // 0.00000001%
genParams.GovParams.VotingParams.VotingPeriod = time.Second * 300 // 300 seconds
genParams.IncentivesGenesis = *incentivestypes.DefaultGenesis()
genParams.IncentivesGenesis.Params.DistrEpochIdentifier = "15min"
genParams.IncentivesGenesis.LockableDurations = []time.Duration{
time.Minute * 30, // 30 min
time.Hour * 1, // 1 hour
time.Hour * 2, // 2 hours
}
genParams.ClaimParams.AirdropStartTime = genParams.GenesisTime
genParams.ClaimParams.DurationUntilDecay = time.Hour * 48 // 2 days
genParams.ClaimParams.DurationOfDecay = time.Hour * 48 // 2 days
genParams.PoolIncentivesGenesis.LockableDurations = genParams.IncentivesGenesis.LockableDurations
return genParams
}