Skip to content

Commit

Permalink
Merge branch 'main' into spoorthi/move-alloc-to-collections
Browse files Browse the repository at this point in the history
  • Loading branch information
spoo-bar committed May 7, 2024
2 parents 7249b76 + 3a7e9d4 commit e98a7c2
Show file tree
Hide file tree
Showing 11 changed files with 790 additions and 35 deletions.
27 changes: 14 additions & 13 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ steps:
password:
from_secret: docker_password
tags:
- 13.0.0-beta.9
- 14.0.0-alpha.2
when:
event:
- push
branch:
- spoorthi/ica-controller
- jhernandezb/upgrade-test
- name: docker_release
image: plugins/docker
settings:
Expand Down Expand Up @@ -314,7 +314,7 @@ steps:
environment:
GOPROXY: http://goproxy
- name: stargaze
image: publicawesome/stargaze:12.0.0
image: publicawesome/stargaze:13.0.0
commands:
- ./scripts/ci/upgrade/setup-preinstalled-stargaze.sh
environment:
Expand All @@ -332,26 +332,27 @@ steps:
- http://osmosis:26657
- http://icad:26657
- name: relayer
image: publicawesome/hermes:0.15.0
image: publicawesome/hermes:1.7.3
commands:
- /bin/bash ./scripts/ci/setup-relayer.sh
- sleep 10
- /bin/bash ./scripts/ci/setup-hermes-1.7.sh

- name: relayer-start
image: publicawesome/hermes:0.15.0
image: publicawesome/hermes:1.7.3
commands:
- /bin/bash ./scripts/ci/start-relayer.sh
- /bin/bash ./scripts/ci/start-relayer-v1.7.sh
detach: true
- name: relayer-sender
image: publicawesome/hermes:0.15.0
image: publicawesome/hermes:1.7.3
commands:
- /bin/bash ./scripts/ci/transfer-relayer.sh
- /bin/bash ./scripts/ci/transfer-relayer-v1.7.sh
- name: proposal
image: publicawesome/stargaze:12.1.0
image: publicawesome/stargaze:13.0.0
commands:
- ./scripts/ci/upgrade/proposal.sh
- name: stargaze-upgraded
pull: always
image: publicawesome/stargaze:13.0.0-beta.9
image: publicawesome/stargaze:14.0.0-alpha.2
commands:
- ./scripts/ci/upgrade/run-upgrade.sh
environment:
Expand All @@ -370,7 +371,7 @@ steps:
- http://icad:26657
- name: check-params
pull: always
image: publicawesome/stargaze:13.0.0-beta.9
image: publicawesome/stargaze:14.0.0-alpha.2
commands:
- starsd q mint params --node http://stargaze-upgraded:26657
- starsd q alloc params --node http://stargaze-upgraded:26657
Expand Down Expand Up @@ -420,6 +421,6 @@ volumes:

---
kind: signature
hmac: 8d837bf88cfaf3a378dbf814c7d279a1a4bc7070ecd42ecd77c061369c1c9b04
hmac: 0e0c7fcfdbb1269dbc8595903d663c53bf327aabfca1298150e2e13638b2c3c2

...
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ release/
mytestnet/
github.com/
swagger-proto/
tmp-swagger-gen/
tmp-swagger-gen/
stargaze-testnet/
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ build-linux:
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build $(BUILD_FLAGS) -o bin/starsd github.com/public-awesome/stargaze/cmd/starsd

build-docker-arm:
docker buildx build --platform linux/arm64 --load .
docker buildx build --platform linux/arm64 --load .

build-docker:
docker buildx build --platform linux/amd64 --load .
docker buildx build -t publicawesome/stargaze:local --platform linux/amd64 --load .

docker-test: build-linux
docker build -f docker/Dockerfile.test -t rocketprotocol/stargaze-relayer-test:latest .
Expand Down
246 changes: 246 additions & 0 deletions cmd/starsd/cmd/genesis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
package cmd

import (
"encoding/json"
"fmt"
"time"

"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
minttypes "github.com/public-awesome/stargaze/v14/x/mint/types"

wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
alloctypes "github.com/public-awesome/stargaze/v14/x/alloc/types"

cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
globalfeetypes "github.com/public-awesome/stargaze/v14/x/globalfee/types"
tokenfactorytypes "github.com/public-awesome/stargaze/v14/x/tokenfactory/types"
)

const (
HumanCoinUnit = "stars"
BaseCoinUnit = "ustars"
StarsExponent = 6
Bech32PrefixAccAddr = "stars"
)

type GenesisParams struct {
GenesisTime time.Time
NativeCoinMetadatas []banktypes.Metadata

StakingParams stakingtypes.Params
DistributionParams distributiontypes.Params

SlashingParams slashingtypes.Params

AllocParams alloctypes.Params

MintParams minttypes.Params
GlobalFeeParams globalfeetypes.Params
WasmParams wasmtypes.Params

GovParams govtypes.Params

TokenFactoryParams tokenfactorytypes.Params

ConsensusParams *cmtproto.ConsensusParams

CrisisConstantFee sdk.Coin
}

func PrepareGenesis(
clientCtx client.Context,
appState map[string]json.RawMessage,
genesisParams GenesisParams,
) map[string]json.RawMessage {
// IBC transfer module genesis
ibcGenState := ibctransfertypes.DefaultGenesisState()
ibcGenState.Params.SendEnabled = true
ibcGenState.Params.ReceiveEnabled = true
ibcGenStateBz := clientCtx.Codec.MustMarshalJSON(ibcGenState)
appState[ibctransfertypes.ModuleName] = ibcGenStateBz

// mint module genesis
mintGenState := minttypes.DefaultGenesisState()
mintGenState.Params = genesisParams.MintParams
mintGenStateBz := clientCtx.Codec.MustMarshalJSON(mintGenState)
appState[minttypes.ModuleName] = mintGenStateBz

// staking module
stakingGenState := stakingtypes.DefaultGenesisState()
stakingGenState.Params = genesisParams.StakingParams
stakingGenStateBz := clientCtx.Codec.MustMarshalJSON(stakingGenState)
appState[stakingtypes.ModuleName] = stakingGenStateBz

// global fee
minGasPrices, err := sdk.ParseDecCoins("0.01ustars")
if err != nil {
panic(fmt.Errorf("failed to parse dec coins: %w", err))
}
globalFeeGenState := &globalfeetypes.GenesisState{
Params: globalfeetypes.Params{
MinimumGasPrices: minGasPrices,
},
}
globalFeeGenStateBz := clientCtx.Codec.MustMarshalJSON(globalFeeGenState)
appState[globalfeetypes.ModuleName] = globalFeeGenStateBz

// tokenfactory

tokenFactoryGenState := tokenfactorytypes.DefaultGenesis()
tokenFactoryGenState.Params = genesisParams.TokenFactoryParams

tokenFactoryGenStateBz := clientCtx.Codec.MustMarshalJSON(tokenFactoryGenState)
appState[tokenfactorytypes.ModuleName] = tokenFactoryGenStateBz

// governance

governanceGenState := govtypes.NewGenesisState(1, genesisParams.GovParams)
governanceGenStateBz := clientCtx.Codec.MustMarshalJSON(governanceGenState)
appState["gov"] = governanceGenStateBz

crisisGenState := crisistypes.DefaultGenesisState()
crisisGenState.ConstantFee = genesisParams.CrisisConstantFee
crisisGenStateBz := clientCtx.Codec.MustMarshalJSON(crisisGenState)
appState[crisistypes.ModuleName] = crisisGenStateBz

return appState
}

// params only
func DefaultGenesisParams() GenesisParams {
genParams := GenesisParams{}

genParams.GenesisTime = time.Now()

genParams.NativeCoinMetadatas = []banktypes.Metadata{
{
Description: "The native token of Stargaze",
DenomUnits: []*banktypes.DenomUnit{
{
Denom: BaseCoinUnit,
Exponent: 0,
Aliases: nil,
},
{
Denom: HumanCoinUnit,
Exponent: StarsExponent,
Aliases: nil,
},
},
Name: "Stargaze STARS",
Base: BaseCoinUnit,
Display: HumanCoinUnit,
Symbol: "STARS",
},
}

// alloc
genParams.AllocParams = alloctypes.DefaultParams()
genParams.AllocParams.DistributionProportions = alloctypes.DistributionProportions{
NftIncentives: math.LegacyNewDecWithPrec(45, 2), // 45%
DeveloperRewards: math.LegacyNewDecWithPrec(15, 2), // 15%
}
genParams.AllocParams.WeightedDeveloperRewardsReceivers = []alloctypes.WeightedAddress{}

// mint
genParams.MintParams = minttypes.DefaultParams()
genParams.MintParams.MintDenom = BaseCoinUnit
genParams.MintParams.StartTime = genParams.GenesisTime.AddDate(1, 0, 0)
genParams.MintParams.InitialAnnualProvisions = math.LegacyNewDec(1_000_000_000_000_000)
genParams.MintParams.ReductionFactor = math.LegacyNewDec(2).QuoInt64(3)
genParams.MintParams.BlocksPerYear = uint64(5737588)

genParams.StakingParams = stakingtypes.DefaultParams()
genParams.StakingParams.UnbondingTime = time.Hour * 24 * 7 * 2 // 2 weeks
genParams.StakingParams.MaxValidators = 10
genParams.StakingParams.BondDenom = genParams.NativeCoinMetadatas[0].Base
genParams.StakingParams.MinCommissionRate = math.LegacyNewDecWithPrec(5, 2)

genParams.DistributionParams = distributiontypes.DefaultParams()
genParams.DistributionParams.CommunityTax = math.LegacyMustNewDecFromStr("0")
genParams.DistributionParams.WithdrawAddrEnabled = true

genParams.GovParams = govtypes.DefaultParams()
votingPeriod := time.Hour * 24 * 14
genParams.GovParams.MaxDepositPeriod = &votingPeriod
genParams.GovParams.MinDeposit = sdk.NewCoins(sdk.NewCoin(
genParams.NativeCoinMetadatas[0].Base,
math.NewInt(10_000_000_000),
))
genParams.GovParams.ExpeditedMinDeposit = sdk.NewCoins(sdk.NewCoin(
genParams.NativeCoinMetadatas[0].Base,
math.NewInt(20_000_000_000),
))
genParams.GovParams.Quorum = math.LegacyMustNewDecFromStr("0.2").String()
genParams.GovParams.VotingPeriod = &votingPeriod

genParams.CrisisConstantFee = sdk.NewCoin(
genParams.NativeCoinMetadatas[0].Base,
math.NewInt(100_000_000_000),
)

genParams.SlashingParams = slashingtypes.DefaultParams()
genParams.SlashingParams.SignedBlocksWindow = int64(25000) // ~41 hr at 6 second blocks
genParams.SlashingParams.MinSignedPerWindow = math.LegacyMustNewDecFromStr("0.05") // 5% minimum liveness
genParams.SlashingParams.DowntimeJailDuration = time.Minute // 1 minute jail period
genParams.SlashingParams.SlashFractionDoubleSign = math.LegacyMustNewDecFromStr("0.05") // 5% double sign slashing
genParams.SlashingParams.SlashFractionDowntime = math.LegacyMustNewDecFromStr("0.0001") // 0.01% liveness slashing

genParams.WasmParams = wasmtypes.DefaultParams()

genParams.GlobalFeeParams = globalfeetypes.DefaultParams()
genParams.TokenFactoryParams = tokenfactorytypes.DefaultParams()
genParams.TokenFactoryParams.DenomCreationFee = sdk.NewCoins(sdk.NewInt64Coin(genParams.NativeCoinMetadatas[0].Base, 100_000_000))

return genParams
}

// params only
func TestnetGenesisParams() GenesisParams {
genParams := DefaultGenesisParams()

genParams.GenesisTime = time.Now()

// mint
genParams.MintParams.StartTime = genParams.GenesisTime.Add(time.Minute * 5)

genParams.GovParams.MinDeposit = sdk.NewCoins(sdk.NewCoin(
genParams.NativeCoinMetadatas[0].Base,
math.NewInt(1_000_000),
))

votingPeriod := time.Minute * 15
genParams.GovParams.Quorum = math.LegacyMustNewDecFromStr("0.1").String() // 10%
genParams.GovParams.VotingPeriod = &votingPeriod // 15 min

// alloc
genParams.AllocParams = alloctypes.DefaultParams()
genParams.AllocParams.DistributionProportions = alloctypes.DistributionProportions{
NftIncentives: math.LegacyNewDecWithPrec(30, 2), // 30%
DeveloperRewards: math.LegacyNewDecWithPrec(30, 2), // 30%
}
genParams.AllocParams.WeightedDeveloperRewardsReceivers = []alloctypes.WeightedAddress{
// faucet
{
Address: "stars1qpeu488858wm3uzqfz9e6m76s5jmjjtcuwr8e2",
Weight: math.LegacyNewDecWithPrec(80, 2),
},
{
Address: "stars1fayut6xzyka29zvznsumlgy5pl4vkn4fkmaznc",
Weight: math.LegacyNewDecWithPrec(20, 2),
},
}
genParams.WasmParams.CodeUploadAccess = wasmtypes.AllowEverybody
genParams.WasmParams.InstantiateDefaultPermission = wasmtypes.AccessTypeEverybody

return genParams
}
1 change: 1 addition & 0 deletions cmd/starsd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ func initRootCmd(
debug.Cmd(),
confixcmd.ConfigCommand(),
Bech32Cmd(),
NewTestnetCmd(basicManager),
// pruning.Cmd(newApp, app.DefaultNodeHome),
// snapshot.Cmd(newApp),
)
Expand Down

0 comments on commit e98a7c2

Please sign in to comment.