Skip to content

Commit

Permalink
feat: disable default system based validator rewards (#288)
Browse files Browse the repository at this point in the history
* feat: update params  proto to add inflation change percentage

* feat: update validator token  allocation

* chore: update changelog

* fix: rewards distribution

* fix: unit tests

* chore: fix lint code

* chore: update calculations

* chore: add inflation calc

* feat: update proto params

* fix: test case update

* feat: update inflation calculation

* chore: update regression tests

* chore: lint code

* chore: update logger
  • Loading branch information
shreyasbhat0 authored Oct 2, 2024
1 parent accc858 commit 9b85246
Show file tree
Hide file tree
Showing 22 changed files with 1,385 additions and 768 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Contains all the PRs that improved the code without changing the behaviors.

## Changed
- Removed unused module account
- Disabled System Validator Rewards
- Default Mint params set to zero

## Fixed
- Testnet binary generation using go build
Expand Down
585 changes: 506 additions & 79 deletions api/arkeo/arkeo/params.pulsar.go

Large diffs are not rendered by default.

22 changes: 19 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
clienthelpers "cosmossdk.io/client/v2/helpers"
"cosmossdk.io/math"
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/gogoproto/proto"
Expand Down Expand Up @@ -209,7 +210,7 @@ var (
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
claimmoduletypes.ModuleName: {authtypes.Minter},
arkeomoduletypes.ModuleName: {authtypes.Minter},
arkeomoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner},
arkeomoduletypes.ProviderName: {},
arkeomoduletypes.ContractName: {},
}
Expand Down Expand Up @@ -620,7 +621,7 @@ func NewArkeoApp(
groupmodule.NewAppModule(appCodec, app.Keepers.GroupKeeper, app.Keepers.AccountKeeper, app.Keepers.BankKeeper, app.interfaceRegistry),
crisis.NewAppModule(&app.Keepers.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)),
gov.NewAppModule(appCodec, app.Keepers.GovKeeper, app.Keepers.AccountKeeper, app.Keepers.BankKeeper, app.GetSubspace(govtypes.ModuleName)),
mint.NewAppModule(appCodec, app.Keepers.MintKeeper, app.Keepers.AccountKeeper, minttypes.DefaultInflationCalculationFn, app.GetSubspace(minttypes.ModuleName)),
mint.NewAppModule(appCodec, app.Keepers.MintKeeper, app.Keepers.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)),
slashing.NewAppModule(appCodec, app.Keepers.SlashingKeeper, app.Keepers.AccountKeeper, app.Keepers.BankKeeper, app.Keepers.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry),
distr.NewAppModule(appCodec, app.Keepers.DistrKeeper, app.Keepers.AccountKeeper, app.Keepers.BankKeeper, app.Keepers.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)),
staking.NewAppModule(appCodec, app.Keepers.StakingKeeper, app.Keepers.AccountKeeper, app.Keepers.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
Expand Down Expand Up @@ -760,7 +761,7 @@ func NewArkeoApp(
capability.NewAppModule(appCodec, *app.Keepers.CapabilityKeeper, false),
feegrantmodule.NewAppModule(appCodec, app.Keepers.AccountKeeper, app.Keepers.BankKeeper, app.Keepers.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.Keepers.GovKeeper, app.Keepers.AccountKeeper, app.Keepers.BankKeeper, app.GetSubspace(govtypes.ModuleName)),
mint.NewAppModule(appCodec, app.Keepers.MintKeeper, app.Keepers.AccountKeeper, minttypes.DefaultInflationCalculationFn, app.GetSubspace(minttypes.ModuleName)),
mint.NewAppModule(appCodec, app.Keepers.MintKeeper, app.Keepers.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)),
staking.NewAppModule(appCodec, app.Keepers.StakingKeeper, app.Keepers.AccountKeeper, app.Keepers.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
distr.NewAppModule(appCodec, app.Keepers.DistrKeeper, app.Keepers.AccountKeeper, app.Keepers.BankKeeper, app.Keepers.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)),
slashing.NewAppModule(appCodec, app.Keepers.SlashingKeeper, app.Keepers.AccountKeeper, app.Keepers.BankKeeper, app.Keepers.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry),
Expand Down Expand Up @@ -852,6 +853,21 @@ func (app *ArkeoApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*
if err != nil {
panic(err)
}
mintGen := minttypes.GenesisState{
Minter: minttypes.Minter{
Inflation: math.LegacyMustNewDecFromStr("0.000000000000000000"),
AnnualProvisions: math.LegacyMustNewDecFromStr("0.000000000000000000"),
},
Params: minttypes.Params{
MintDenom: "uarkeo",
InflationRateChange: math.LegacyMustNewDecFromStr("0.000000000000000000"),
InflationMax: math.LegacyMustNewDecFromStr("0.000000000000000000"),
InflationMin: math.LegacyMustNewDecFromStr("0.000000000000000000"),
GoalBonded: math.LegacyNewDec(670000000000000000),
BlocksPerYear: 6311520,
},
}
genesisState[minttypes.ModuleName] = app.cdc.MustMarshalJSON(&mintGen)
return app.mm.InitGenesis(ctx, app.appCodec, genesisState)
}

Expand Down
2 changes: 1 addition & 1 deletion app/app_regtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ var (
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
arkeomoduletypes.ModuleName: {authtypes.Minter},
arkeomoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner},
arkeomoduletypes.ProviderName: {},
arkeomoduletypes.ContractName: {},
claimmoduletypes.ModuleName: {authtypes.Minter},
Expand Down
22 changes: 21 additions & 1 deletion app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package app
import (
"encoding/json"

"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/codec"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
)

// The genesis state of the blockchain is represented here as a map of raw json
Expand All @@ -17,5 +19,23 @@ type GenesisState map[string]json.RawMessage

// NewDefaultGenesisState generates the default state for the application.
func NewDefaultGenesisState(cdc codec.JSONCodec) GenesisState {
return ModuleBasics.DefaultGenesis(cdc)
defaultGenesis := ModuleBasics.DefaultGenesis(cdc)
// set mint module params for genesis state
mintGen := minttypes.GenesisState{
Minter: minttypes.Minter{
Inflation: math.LegacyMustNewDecFromStr("0.000000000000000000"),
AnnualProvisions: math.LegacyMustNewDecFromStr("0.000000000000000000"),
},
Params: minttypes.Params{
MintDenom: "uarkeo",
InflationRateChange: math.LegacyMustNewDecFromStr("0.000000000000000000"),
InflationMax: math.LegacyMustNewDecFromStr("0.000000000000000000"),
InflationMin: math.LegacyMustNewDecFromStr("0.000000000000000000"),
GoalBonded: math.LegacyNewDec(670000000000000000),
BlocksPerYear: 5256666,
},
}
defaultGenesis[minttypes.ModuleName] = cdc.MustMarshalJSON(&mintGen)

return defaultGenesis
}
44 changes: 41 additions & 3 deletions proto/arkeo/arkeo/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,45 @@ option go_package = "github.com/arkeonetwork/arkeo/x/arkeo/types";
// Params defines the parameters for the module.
message Params {
option (gogoproto.goproto_stringer) = false;
string CommunityPoolPercentage= 1 [(cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false];
string DevFundPercentage= 2 [(cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false];
string GrantFundPercentage= 3 [(cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false];
string community_pool_percentage= 1 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
string dev_fund_percentage= 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
string grant_fund_percentage= 3 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
string inflation_change_percentage = 4 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
string inflation_min = 5 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

string inflation_max = 6 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

string goal_bonded = 7 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

uint64 block_per_year = 8;

uint64 emission_curve = 9;
}
34 changes: 17 additions & 17 deletions scripts/genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ set -o pipefail
set -ex

CHAIN_ID="arkeo-testnet-v2"
STAKE="50000000000000000uarkeo"
STAKE="1000000000uarkeo"
TOKEN="uarkeo"
USER="ark"
TOTAL_SUPPLY=50000000000000000 # Initial supply corresponding to the stake
TOTAL_SUPPLY=1000000000 # Initial supply corresponding to the stake

add_module() {
jq --arg ADDRESS "$1" --arg ASSET "$2" --arg AMOUNT "$3" --arg NAME "$4" '.app_state.auth.accounts += [{
Expand Down Expand Up @@ -82,8 +82,7 @@ if [ ! -f ~/.arkeo/config/genesis.json ]; then
add_account "$FAUCET" $TOKEN 10000000000000000 # faucet, 10m

if [ "$NET" = "mocknet" ] || [ "$NET" = "testnet" ]; then
add_module tarkeo1d0m97ywk2y4vq58ud6q5e0r3q9khj9e3unfe4t $TOKEN 10000000000000000 'arkeo-reserve' # reserve, 10m
add_module tarkeo14tmx70mvve3u7hfmd45vle49kvylk6s2wllxny $TOKEN 10000000000000000 'claimarkeo'
add_module tarkeo14tmx70mvve3u7hfmd45vle49kvylk6s2wllxny $TOKEN 30250000000000 'claimarkeo'

echo "shoulder heavy loyal save patient deposit crew bag pull club escape eyebrow hip verify border into wire start pact faint fame festival solve shop" | arkeod keys add alice --keyring-backend test --recover
ALICE=$(arkeod keys show alice -a --keyring-backend test)
Expand All @@ -94,13 +93,14 @@ if [ ! -f ~/.arkeo/config/genesis.json ]; then
add_account "$BOB" $TOKEN 1000000000000000 # bob, 1m
add_claim_records "ARKEO" "$BOB" 1000 1000 1000 true


# Add Foundational Accounts
# FoundationCommunityAccount = "tarkeo1v50hrsxx0mxar4653aujcnqyjft07w0npcxrjx"
add_account "tarkeo1v50hrsxx0mxar4653aujcnqyjft07w0npcxrjx" $TOKEN 10000
# FoundationDevAccount = "tarkeo10sav33v67743s6cl2cvjmmua7c5arysw3txz9r"
add_account "tarkeo10sav33v67743s6cl2cvjmmua7c5arysw3txz9r" $TOKEN 10000
# FoundationGrantsAccount = "tarkeo16k3k0erkwaanqnup20dxxenpd6wh058nh4pgup"
add_account "tarkeo16k3k0erkwaanqnup20dxxenpd6wh058nh4pgup" $TOKEN 10000
# FoundationCommunityAccount = "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc"
add_account "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc" $TOKEN 1048400000000000000
# FoundationDevAccount = "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q"
add_account "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q" $TOKEN 12100000000000
# FoundationGrantsAccount = "tarkeo1a307z4a82mcyv9njdj9ajnd9xpp90kmeqwntxj"
add_account "tarkeo1a307z4a82mcyv9njdj9ajnd9xpp90kmeqwntxj" $TOKEN 6050000000000


# Thorchain derived test addresses
Expand All @@ -116,15 +116,15 @@ if [ ! -f ~/.arkeo/config/genesis.json ]; then
add_claim_records "ETHEREUM" "0x92E14917A0508Eb56C90C90619f5F9Adbf49f47d" 500000 600000 700000 true

# enable CORs on testnet/localnet
sed -i 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' ~/.arkeo/config/app.toml
sed -i 's/cors_allowed_origins = \[\]/cors_allowed_origins = \["*"\]/g' ~/.arkeo/config/config.toml
sed -i '' 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' ~/.arkeo/config/app.toml
sed -i '' 's/cors_allowed_origins = \[\]/cors_allowed_origins = \["*"\]/g' ~/.arkeo/config/config.toml
fi

sed -i 's/"stake"/"uarkeo"/g' ~/.arkeo/config/genesis.json
sed -i '/"duration_until_decay"\|"duration_of_decay"/s/"3600s"/"7884000s"/' ~/.arkeo/config/genesis.json
sed -i 's/enable = false/enable = true/g' ~/.arkeo/config/app.toml
sed -i 's/127.0.0.1:26657/0.0.0.0:26657/g' ~/.arkeo/config/config.toml
sed -i 's/address = "tcp:\/\/localhost:1317"/address = "tcp:\/\/0.0.0.0:1317"/g' ~/.arkeo/config/app.toml
sed -i '' 's/"stake"/"uarkeo"/g' ~/.arkeo/config/genesis.json
sed -i '' '/"duration_until_decay"\|"duration_of_decay"/s/"3600s"/"7884000s"/' ~/.arkeo/config/genesis.json
sed -i '' 's/enable = false/enable = true/g' ~/.arkeo/config/app.toml
sed -i '' 's/127.0.0.1:26657/0.0.0.0:26657/g' ~/.arkeo/config/config.toml
sed -i '' 's/address = "tcp:\/\/localhost:1317"/address = "tcp:\/\/0.0.0.0:1317"/g' ~/.arkeo/config/app.toml

# Update the supply field in genesis.json using jq
jq --arg DENOM "$TOKEN" --arg AMOUNT "$TOTAL_SUPPLY" '.app_state.bank.supply = [{"denom": $DENOM, "amount": $AMOUNT}]' <~/.arkeo/config/genesis.json >/tmp/genesis.json
Expand Down
Loading

0 comments on commit 9b85246

Please sign in to comment.