Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update validator payout from arkeo reserve #290

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Contains all the PRs that improved the code without changing the behaviors.
- Removed unused module account
- Disabled System Validator Rewards
- Default Mint params set to zero
- Validator and Delegator rewards from Reserve Module

## Fixed
- Testnet binary generation using go build
Expand Down
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ var (
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
claimmoduletypes.ModuleName: {authtypes.Minter},
arkeomoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner},
arkeomoduletypes.ReserveName: {},
arkeomoduletypes.ModuleName: {},
arkeomoduletypes.ProviderName: {},
arkeomoduletypes.ContractName: {},
}
Expand Down
3 changes: 2 additions & 1 deletion app/app_regtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ var (
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
arkeomoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner},
arkeomoduletypes.ReserveName: {},
arkeomoduletypes.ModuleName: {},
arkeomoduletypes.ProviderName: {},
arkeomoduletypes.ContractName: {},
claimmoduletypes.ModuleName: {authtypes.Minter},
Expand Down
26 changes: 5 additions & 21 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
)

// GetSafeShare does the same as GetUncappedShare , but GetSafeShare will guarantee the result will not more than total
func GetSafeShare(part, total, allocation cosmos.Int) cosmos.Int {
func GetSafeShare(part, total, allocation cosmos.Dec) cosmos.Dec {
if part.GTE(total) {
part = total
}
Expand All @@ -29,33 +29,17 @@ func GetSafeShare(part, total, allocation cosmos.Int) cosmos.Int {

// GetUncappedShare this method will panic if any of the input parameter can't be convert to cosmos.Dec
// which shouldn't happen
func GetUncappedShare(part, total, allocation cosmos.Int) (share cosmos.Int) {
func GetUncappedShare(part, total, allocation cosmos.Dec) (share cosmos.Dec) {
if part.IsZero() || total.IsZero() {
return cosmos.ZeroInt()
return cosmos.ZeroDec()
}
defer func() {
if err := recover(); err != nil {
share = cosmos.ZeroInt()
share = cosmos.ZeroDec()
}
}()
// use string to convert cosmos.Int to cosmos.Dec is the only way I can find out without being constrain to uint64
// cosmos.Int can hold values way larger than uint64 , because it is using big.Int internally
aD, err := cosmos.NewDecFromStr(allocation.String())
if err != nil {
panic(fmt.Errorf("fail to convert %s to cosmos.Dec: %w", allocation.String(), err))
}

pD, err := cosmos.NewDecFromStr(part.String())
if err != nil {
panic(fmt.Errorf("fail to convert %s to cosmos.Dec: %w", part.String(), err))
}
tD, err := cosmos.NewDecFromStr(total.String())
if err != nil {
panic(fmt.Errorf("fail to convert%s to cosmos.Dec: %w", total.String(), err))
}
// A / (Total / part) == A * (part/Total) but safer when part < Totals
result := aD.Quo(tD.Quo(pD))
share = cosmos.NewIntFromBigInt(result.RoundInt().BigInt())
share = allocation.Quo(total.Quo(part))
return
}

Expand Down
10 changes: 6 additions & 4 deletions common/common_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package common

import (
"fmt"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -12,14 +13,15 @@ func TestGetUncappedShare(t *testing.T) {
part := cosmos.NewInt(149506590)
total := cosmos.NewInt(50165561086)
alloc := cosmos.NewInt(50000000)
share := GetUncappedShare(part, total, alloc)
require.True(t, share.Equal(cosmos.NewInt(149013)))
share := GetUncappedShare(part.ToLegacyDec(), total.ToLegacyDec(), alloc.ToLegacyDec())
fmt.Println(share)
require.True(t, share.RoundInt().Equal(cosmos.NewInt(149013)))
}

func TestGetSafeShare(t *testing.T) {
part := cosmos.NewInt(14950659000000000)
total := cosmos.NewInt(50165561086)
alloc := cosmos.NewInt(50000000)
share := GetSafeShare(part, total, alloc)
require.True(t, share.Equal(cosmos.NewInt(50000000)))
share := GetSafeShare(part.ToLegacyDec(), total.ToLegacyDec(), alloc.ToLegacyDec())
require.True(t, share.Equal(cosmos.NewDec(50000000)))
}
38 changes: 0 additions & 38 deletions proto/arkeo/arkeo/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,6 @@ 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 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;
Expand Down
49 changes: 33 additions & 16 deletions scripts/genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,27 @@ add_claim_records() {
mv /tmp/genesis.json ~/.arkeo/config/genesis.json
}

set_fee_pool() {
local denom="$1"
local amount="$2"

jq --arg DENOM "$denom" --arg AMOUNT "$amount" '.app_state.distribution.fee_pool.community_pool = [{
"denom": $DENOM,
"amount": $AMOUNT
}]' <~/.arkeo/config/genesis.json >/tmp/genesis.json
mv /tmp/genesis.json ~/.arkeo/config/genesis.json
}

disable_mint_params() {
jq '.app_state.mint.minter.inflation = "0.000000000000000000" |
.app_state.mint.minter.annual_provisions = "0.000000000000000000" |
.app_state.mint.params.inflation_rate_change = "0.000000000000000000" |
.app_state.mint.params.inflation_max = "0.000000000000000000" |
.app_state.mint.params.inflation_min = "0.000000000000000000"' \
<~/.arkeo/config/genesis.json >/tmp/genesis.json
mv /tmp/genesis.json ~/.arkeo/config/genesis.json
}

if [ ! -f ~/.arkeo/config/priv_validator_key.json ]; then
# remove the original generate genesis file, as below will init chain again
rm -rf ~/.arkeo/config/genesis.json
Expand All @@ -79,28 +100,24 @@ if [ ! -f ~/.arkeo/config/genesis.json ]; then

arkeod keys add faucet --keyring-backend test
FAUCET=$(arkeod keys show faucet -a --keyring-backend test)
add_account "$FAUCET" $TOKEN 10000000000000000 # faucet, 10m
add_account "$FAUCET" $TOKEN 2900000000000000 # faucet, 29m
disable_mint_params

if [ "$NET" = "mocknet" ] || [ "$NET" = "testnet" ]; then
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)
add_account "$ALICE" $TOKEN 1100000000000000 # alice, 1.1m

echo "clog swear steak glide artwork glory solution short company borrow aerobic idle corn climb believe wink forum destroy miracle oak cover solid valve make" | arkeod keys add bob --keyring-backend test --recover
BOB=$(arkeod keys show bob -a --keyring-backend test)
add_account "$BOB" $TOKEN 1000000000000000 # bob, 1m
add_claim_records "ARKEO" "$BOB" 1000 1000 1000 true
add_module tarkeo1d0m97ywk2y4vq58ud6q5e0r3q9khj9e3unfe4t $TOKEN 2420000000000000 'arkeo-reserve'
add_module tarkeo14tmx70mvve3u7hfmd45vle49kvylk6s2wllxny $TOKEN 3025000000000000 'claimarkeo'
add_module tarkeo1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8t6gr9e $TOKEN 4840000000000000 'distribution'
# this is to handle the balance set to distribution as a community pool
set_fee_pool $TOKEN 4840000000000000



# Add Foundational Accounts
# FoundationCommunityAccount = "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc"
add_account "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc" $TOKEN 1048400000000000000
# Add Foundational Accounts
# FoundationDevAccount = "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q"
add_account "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q" $TOKEN 12100000000000
add_account "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q" $TOKEN 1210000000000000
# FoundationGrantsAccount = "tarkeo1a307z4a82mcyv9njdj9ajnd9xpp90kmeqwntxj"
add_account "tarkeo1a307z4a82mcyv9njdj9ajnd9xpp90kmeqwntxj" $TOKEN 6050000000000
add_account "tarkeo1a307z4a82mcyv9njdj9ajnd9xpp90kmeqwntxj" $TOKEN 605000000000000



# Thorchain derived test addresses
Expand Down
73 changes: 11 additions & 62 deletions test/regression/mnt/exports/suites_contracts_pay-as-you-go.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,7 @@
"next_contract_id": "2",
"params": {
"block_per_year": "6311520",
"community_pool_percentage": "0.100000000000000000",
"dev_fund_percentage": "0.200000000000000000",
"emission_curve": "6",
"goal_bonded": "0.670000000000000000",
"grant_fund_percentage": "0.000000000000000000",
"inflation_change_percentage": "0.030000000000000000",
"inflation_max": "0.050000000000000000",
"inflation_min": "0.020000000000000000"
"emission_curve": "6"
},
"providers": [
{
Expand Down Expand Up @@ -87,13 +80,6 @@
},
"auth": {
"accounts": [
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"account_number": "10",
"address": "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q",
"pub_key": null,
"sequence": "0"
},
{
"@type": "/cosmos.auth.v1beta1.ModuleAccount",
"base_account": {
Expand All @@ -108,13 +94,6 @@
"staking"
]
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"account_number": "11",
"address": "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc",
"pub_key": null,
"sequence": "0"
},
{
"@type": "/cosmos.auth.v1beta1.ModuleAccount",
"base_account": {
Expand Down Expand Up @@ -168,7 +147,7 @@
{
"@type": "/cosmos.auth.v1beta1.ModuleAccount",
"base_account": {
"account_number": "12",
"account_number": "10",
"address": "tarkeo1kz2dkl8zlxwte008astc5e65htrxdcse6x3h3h",
"pub_key": null,
"sequence": "0"
Expand All @@ -185,10 +164,7 @@
"sequence": "0"
},
"name": "arkeo",
"permissions": [
"minter",
"burner"
]
"permissions": []
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
Expand Down Expand Up @@ -257,15 +233,6 @@
}
]
},
{
"address": "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q",
"coins": [
{
"amount": "1200605009566",
"denom": "uarkeo"
}
]
},
{
"address": "tarkeo1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3e79s43",
"coins": [
Expand All @@ -275,15 +242,6 @@
}
]
},
{
"address": "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc",
"coins": [
{
"amount": "600538144583",
"denom": "uarkeo"
}
]
},
{
"address": "tarkeo1v0n7wer498vqq6yddkr4clg3lck7kaw9lstp4k",
"coins": [
Expand All @@ -297,7 +255,7 @@
"address": "tarkeo1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8t6gr9e",
"coins": [
{
"amount": "15830782786",
"amount": "16066162928",
"denom": "uarkeo"
}
]
Expand All @@ -311,15 +269,6 @@
}
]
},
{
"address": "tarkeo1hnyy4gp5tgarpg3xu6w5cw4zsyphx2lyvls9rz",
"coins": [
{
"amount": "103474",
"denom": "uarkeo"
}
]
},
{
"address": "tarkeo1uhapc6jjq6ns0ydnk7zld5x7f5kl2ukemjw5fg",
"coins": [
Expand All @@ -338,7 +287,7 @@
"send_enabled": [],
"supply": [
{
"amount": "52002816974040409",
"amount": "52001016066162928",
"denom": "uarkeo"
}
]
Expand Down Expand Up @@ -413,7 +362,7 @@
"fee_pool": {
"community_pool": [
{
"amount": "85688652.700000000000000000",
"amount": "321323258.560000000000000000",
"denom": "uarkeo"
}
]
Expand All @@ -422,7 +371,7 @@
{
"outstanding_rewards": [
{
"amount": "15745094231.300000000000000000",
"amount": "15744839669.440000000000000000",
"denom": "uarkeo"
}
],
Expand All @@ -441,7 +390,7 @@
"accumulated": {
"commission": [
{
"amount": "1574509423.130000000000000000",
"amount": "1574483966.944000000000000000",
"denom": "uarkeo"
}
]
Expand All @@ -455,7 +404,7 @@
"period": "2",
"rewards": [
{
"amount": "14170584808.170000000000000000",
"amount": "14170355702.496000000000000000",
"denom": "uarkeo"
}
]
Expand Down Expand Up @@ -630,8 +579,8 @@
},
"mint": {
"minter": {
"annual_provisions": "6760343469143471.564097458997205602",
"inflation": "0.129999865577861409"
"annual_provisions": "6760124958900879.440734825593079684",
"inflation": "0.129999865570695682"
},
"params": {
"blocks_per_year": "6311520",
Expand Down
Loading
Loading