Skip to content

Commit

Permalink
fixing fees (#1032)
Browse files Browse the repository at this point in the history
* fixing fees

* test(estaking): fix tests

* ci: disable proposal

---------

Co-authored-by: Cosmic Vagabond <121588426+cosmic-vagabond@users.noreply.github.com>
  • Loading branch information
avkr003 and cosmic-vagabond authored Dec 5, 2024
1 parent b4e5292 commit cfd730c
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 59 deletions.
89 changes: 45 additions & 44 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,54 +26,55 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create software upgrade proposal
run: |
# helper functions
extract_txhash() { awk -F 'txhash: ' '/txhash:/{print $2; exit}'; }
extract_proposal_id() { awk -F 'key: proposal_id|value: ' '/key: proposal_id/ { getline; gsub(/"/, "", $2); print $2; exit }'; }
extract_and_calc_upgrade_height() { awk -F'"latest_block_height":"' '{ split($2,a,"\""); print a[1]+450; exit }'; }
extract_checksum() { awk "/elysd-${{ github.ref_name }}-linux-amd64.tar.gz/ {print \$1; exit}"; }
# FIXME: disabled software upgrade proposal as PSS is not yet enabled
# - name: Create software upgrade proposal
# run: |
# # helper functions
# extract_txhash() { awk -F 'txhash: ' '/txhash:/{print $2; exit}'; }
# extract_proposal_id() { awk -F 'key: proposal_id|value: ' '/key: proposal_id/ { getline; gsub(/"/, "", $2); print $2; exit }'; }
# extract_and_calc_upgrade_height() { awk -F'"latest_block_height":"' '{ split($2,a,"\""); print a[1]+450; exit }'; }
# extract_checksum() { awk "/elysd-${{ github.ref_name }}-linux-amd64.tar.gz/ {print \$1; exit}"; }

# environment variables
ELYSD=dist/elysd-linux-amd64_linux_amd64_v1/elysd
NODE=https://rpc.testnet.elys.network:443
OPTIONS="--node $NODE --chain-id elystestnet-1 --keyring-backend=test -b=sync --fees=100000uelys --gas=300000 -y"
# # environment variables
# ELYSD=dist/elysd-linux-amd64_linux_amd64_v1/elysd
# NODE=https://rpc.testnet.elys.network:443
# OPTIONS="--node $NODE --chain-id elystestnet-1 --keyring-backend=test -b=sync --fees=100000uelys --gas=300000 -y"

# save private keys to files
echo "${{ secrets.PRIVATE_KEY_1 }}" > /tmp/private_key_1.txt
echo "${{ secrets.PRIVATE_KEY_2 }}" > /tmp/private_key_2.txt
echo "${{ secrets.PRIVATE_KEY_3 }}" > /tmp/private_key_3.txt
echo "${{ secrets.PRIVATE_KEY_4 }}" > /tmp/private_key_4.txt
# # save private keys to files
# echo "${{ secrets.PRIVATE_KEY_1 }}" > /tmp/private_key_1.txt
# echo "${{ secrets.PRIVATE_KEY_2 }}" > /tmp/private_key_2.txt
# echo "${{ secrets.PRIVATE_KEY_3 }}" > /tmp/private_key_3.txt
# echo "${{ secrets.PRIVATE_KEY_4 }}" > /tmp/private_key_4.txt

# recover keys
echo "${{ secrets.PASSPHRASE_1 }}" | ${ELYSD} keys import key_1 --keyring-backend test /tmp/private_key_1.txt
echo "${{ secrets.PASSPHRASE_2 }}" | ${ELYSD} keys import key_2 --keyring-backend test /tmp/private_key_2.txt
echo "${{ secrets.PASSPHRASE_3 }}" | ${ELYSD} keys import key_3 --keyring-backend test /tmp/private_key_3.txt
echo "${{ secrets.PASSPHRASE_4 }}" | ${ELYSD} keys import key_4 --keyring-backend test /tmp/private_key_4.txt
# # recover keys
# echo "${{ secrets.PASSPHRASE_1 }}" | ${ELYSD} keys import key_1 --keyring-backend test /tmp/private_key_1.txt
# echo "${{ secrets.PASSPHRASE_2 }}" | ${ELYSD} keys import key_2 --keyring-backend test /tmp/private_key_2.txt
# echo "${{ secrets.PASSPHRASE_3 }}" | ${ELYSD} keys import key_3 --keyring-backend test /tmp/private_key_3.txt
# echo "${{ secrets.PASSPHRASE_4 }}" | ${ELYSD} keys import key_4 --keyring-backend test /tmp/private_key_4.txt

# get checksum
checksum=$(cat dist/sha256sum.txt | extract_checksum)
# # get checksum
# checksum=$(cat dist/sha256sum.txt | extract_checksum)

# query and upgrade height
height=$(${ELYSD} status --node $NODE | extract_and_calc_upgrade_height)
# # query and upgrade height
# height=$(${ELYSD} status --node $NODE | extract_and_calc_upgrade_height)

# create proposal
txhash=$(
${ELYSD} software-upgrade-tx \
${{ github.ref_name }} \
$height \
10000000uelys \
"Elys Network ${{ github.ref_name }} released. Focuses on enhancements and codebase improvements." \
"{\"binaries\":{\"linux/amd64\":\"https://github.com/elys-network/elys/releases/download/${{ github.ref_name }}/elysd-${{ github.ref_name }}-linux-amd64.tar.gz?checksum=$checksum\"}}" \
--from=key_1 \
$OPTIONS | extract_txhash
)
sleep 10
proposalid=$(${ELYSD} q tx $txhash --node $NODE | extract_proposal_id)
# # create proposal
# txhash=$(
# ${ELYSD} software-upgrade-tx \
# ${{ github.ref_name }} \
# $height \
# 10000000uelys \
# "Elys Network ${{ github.ref_name }} released. Focuses on enhancements and codebase improvements." \
# "{\"binaries\":{\"linux/amd64\":\"https://github.com/elys-network/elys/releases/download/${{ github.ref_name }}/elysd-${{ github.ref_name }}-linux-amd64.tar.gz?checksum=$checksum\"}}" \
# --from=key_1 \
# $OPTIONS | extract_txhash
# )
# sleep 10
# proposalid=$(${ELYSD} q tx $txhash --node $NODE | extract_proposal_id)

# vote on proposal
${ELYSD} tx gov vote $proposalid yes --from=key_1 $OPTIONS
${ELYSD} tx gov vote $proposalid yes --from=key_2 $OPTIONS
${ELYSD} tx gov vote $proposalid yes --from=key_3 $OPTIONS
${ELYSD} tx gov vote $proposalid yes --from=key_4 $OPTIONS
sleep 10
# # vote on proposal
# ${ELYSD} tx gov vote $proposalid yes --from=key_1 $OPTIONS
# ${ELYSD} tx gov vote $proposalid yes --from=key_2 $OPTIONS
# ${ELYSD} tx gov vote $proposalid yes --from=key_3 $OPTIONS
# ${ELYSD} tx gov vote $proposalid yes --from=key_4 $OPTIONS
# sleep 10
14 changes: 8 additions & 6 deletions .github/workflows/software-upgrade-test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: Test Software Upgrade

on:
pull_request:
push:
branches:
- develop
- devnet
- main
workflow_dispatch:
# FIXME: disable as we move to PSS, we need to update those settings to work with PSS
# pull_request:
# push:
# branches:
# - develop
# - devnet
# - main

jobs:
create-new-snapshot:
Expand Down
17 changes: 10 additions & 7 deletions x/estaking/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ func (k Keeper) UpdateStakersRewards(ctx sdk.Context) error {
}
stakersEdenAmount := edenAmountPerYear.Quo(math.NewInt(totalBlocksPerYear))

providerEdenAmount := stakersEdenAmount.ToLegacyDec().Mul(params.ProviderStakingRewardsPortion).TruncateInt()
err := k.commKeeper.MintCoins(ctx, ccvconsumertypes.ConsumerToSendToProviderName, sdk.NewCoins(sdk.NewCoin(ptypes.Eden, providerEdenAmount)))
if err != nil {
return err
}

stakersEdenAmountAfterProvider := stakersEdenAmount.Sub(providerEdenAmount)

totalElysEdenEdenBStake, err := k.TotalBondedTokens(ctx)
if err != nil {
return err
Expand All @@ -129,22 +137,17 @@ func (k Keeper) UpdateStakersRewards(ctx sdk.Context) error {
QuoInt64(totalBlocksPerYear)

// Use min amount (eden allocation from tokenomics and max apr based eden amount)
stakersEdenAmount = math.MinInt(stakersEdenAmount, stakersMaxEdenAmount.TruncateInt())
stakersEdenAmountForGovernors := math.MinInt(stakersEdenAmountAfterProvider, stakersMaxEdenAmount.TruncateInt())

// EdenB should be mint based on Elys + Eden staked (should exclude edenB staked)
stakersEdenBAmount := math.LegacyNewDecFromInt(totalElysEdenEdenBStake).
Mul(params.EdenBoostApr).
QuoInt64(totalBlocksPerYear).
RoundInt()

providerEdenAmount := stakersEdenAmount.ToLegacyDec().Mul(params.ProviderStakingRewardsPortion).TruncateInt()
consumerCoins := sdk.NewCoins(
sdk.NewCoin(ptypes.Eden, stakersEdenAmount.Sub(providerEdenAmount)),
sdk.NewCoin(ptypes.Eden, stakersEdenAmountForGovernors),
sdk.NewCoin(ptypes.EdenB, stakersEdenBAmount),
)
err = k.commKeeper.MintCoins(ctx, ccvconsumertypes.ConsumerToSendToProviderName, sdk.NewCoins(sdk.NewCoin(ptypes.Eden, providerEdenAmount)))
if err != nil {
return err
}
return k.commKeeper.MintCoins(ctx, ccvconsumertypes.ConsumerRedistributeName, consumerCoins.Sort())
}
2 changes: 1 addition & 1 deletion x/estaking/keeper/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (suite *EstakingKeeperTestSuite) TestAbci() {
ValidatorAddress: valAddr.String(),
})
suite.Require().Nil(err)
suite.Require().Equal(res.Amount.String(), "110706ueden")
suite.Require().Equal(res.Amount.String(), "147608ueden")
},
},
//{
Expand Down
2 changes: 1 addition & 1 deletion x/estaking/keeper/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (suite *EstakingKeeperTestSuite) TestQuery() {
Address: addr.String(),
})
suite.Require().Nil(err)
suite.Require().Equal(res.Total.String(), "110706ueden")
suite.Require().Equal(res.Total.String(), "147608ueden")
},
},
{
Expand Down

0 comments on commit cfd730c

Please sign in to comment.