-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: CNS-994 - refactor StakeStorage (#1566)
* CNS-994: use utils to encode/decode epoch * CNS-994: stake storage refactor not final * CNS-994: fix some of the unit tests * CNS-994: finish refactor * CNS-994: fix serialization to be big endian (avoid common 0 prefix of little endian) * CNS-994: fix unit test * CNS-994: fix e2e * CNS-994: migrator * CNS-994: fix migrator * CNS-994: updated readme * CNS-994: the pairing mechanism assumes that the retrived entries are with decending order of stake * CNS-994: fix unit test * CNS-994: revert Serialize to little endian and created SerializeBigEndian * CNS-994: remove outdated migrators * CNS-994: complete migrator removal * CNS-994: delete outdated test file * CNS-994: sort stake storage in GetAllStakeEntriesForGenesis * CNS-994: reverted removal of stakeEntries map in unresponsive provider code * CNS-994: test scripts 100 providers * CNS-994: migrator fix order stake entries for pairing * CNS-994: another migrator fix * refactor: CNS-998 - use collections instead of KV stores (#1570) * CNS-998: install collections * CNS-998: rename collections.go to collcompat (for standard) * CNS-998: make stake entries use collections * CNS-998: iterate over providers in reverse * CNS-998: fix unit test * CNS-998: make stakeEntries hold extra unique index of epoch, chainid and address * CNS-998: add chain id and vault indices for stake entries current * CNS-998: small changes * CNS-998: added comment * CNS-998: other part of merge * CNS-998: make epoch hashes a collections map * CNS-998: add error handling for epoch hash remove * CNS-998: migrator fix * Update scripts/test/inich_100_providers.sh Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * CNS-994: fix lint and small issues * CNS-994: fix lint * Update scripts/test/inich_100_providers.sh Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update x/epochstorage/keeper/stake_entries.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * CNS-994: enhance error messages in stake entries methods * CNS-994: revert epoch details proto change * CNS-994: minor changes * CNS-994: import fixes * CNS-994: fix protocgen script * CNS-994: fix lint --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
- Loading branch information
1 parent
7103963
commit 0fe0e9c
Showing
81 changed files
with
1,339 additions
and
7,927 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
#!/bin/bash | ||
__dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
source $__dir/../useful_commands.sh | ||
. ${__dir}/vars/variables.sh | ||
# Making sure old screens are not running | ||
echo "current vote number $(latest_vote)" | ||
killall screen | ||
screen -wipe | ||
GASPRICE="0.000000001ulava" | ||
|
||
echo; echo "#### Sending proposal for specs ####" | ||
cd ./cookbook/specs/ || exit | ||
lavad tx gov submit-legacy-proposal spec-add ./ibc.json,./tendermint.json,./cosmoswasm.json,./cosmossdk.json,./cosmossdk_45.json,./cosmossdk_full.json,./ethermint.json,./ethereum.json,./cosmoshub.json,./lava.json,./osmosis.json,./fantom.json,./celo.json,./optimism.json,./arbitrum.json,./starknet.json,./aptos.json,./juno.json,./polygon.json,./evmos.json,./base.json,./canto.json,./sui.json,./solana.json,./bsc.json,./axelar.json,./avalanche.json,./fvm.json,./near.json,./sqdsubgraph.json,./agoric.json,./koii.json,./stargaze.json,./blast.json,./secret.json,./celestia.json --lava-dev-test -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE | ||
cd ../../ || exit | ||
echo; echo "#### Waiting 2 blocks ####" | ||
wait_count_blocks 2 | ||
|
||
echo; echo "#### Voting on specs proposal ####" | ||
lavad tx gov vote "$(latest_vote)" yes -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE | ||
|
||
echo; echo "#### Waiting 4 blocks ####" | ||
wait_count_blocks 4 | ||
sleep 4 | ||
|
||
echo; echo "#### Sending proposal for test plans add ####" | ||
lavad tx gov submit-legacy-proposal plans-add ./cookbook/plans/test_plans/default.json,./cookbook/plans/test_plans/temporary-add.json -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE | ||
|
||
echo; echo "#### Waiting 2 blocks ####" | ||
wait_count_blocks 2 | ||
|
||
echo; echo "#### Voting on plans test add proposal ####" | ||
lavad tx gov vote "$(latest_vote)" yes -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE | ||
|
||
echo; echo "#### Waiting 4 blocks ####" | ||
wait_count_blocks 2 | ||
|
||
echo; echo "#### Sending proposal for plans add ####" | ||
lavad tx gov submit-legacy-proposal plans-add ./cookbook/plans/explorer.json,./cookbook/plans/adventurer.json,./cookbook/plans/whale.json -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE | ||
|
||
echo; echo "#### Waiting 2 blocks ####" | ||
wait_count_blocks 2 | ||
|
||
echo; echo "#### Voting on plans add proposal ####" | ||
lavad tx gov vote "$(latest_vote)" yes -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE | ||
|
||
echo; echo "#### Waiting 4 blocks ####" | ||
wait_count_blocks 4 | ||
|
||
PROVIDERSTAKE="500000000000ulava" | ||
|
||
PROVIDER1_LISTENER="127.0.0.1:2221" | ||
PROVIDER2_LISTENER="127.0.0.1:2222" | ||
PROVIDER3_LISTENER="127.0.0.1:2223" | ||
|
||
sleep 4 | ||
|
||
echo; echo "#### Sending proposal for plans del ####" | ||
lavad tx gov submit-legacy-proposal plans-del ./cookbook/plans/test_plans/temporary-del.json -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE | ||
|
||
echo; echo "#### Waiting 2 blocks ####" | ||
wait_count_blocks 2 | ||
|
||
echo; echo "#### Voting on plans del proposal ####" | ||
lavad tx gov vote "$(latest_vote)" yes -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE | ||
|
||
echo; echo "#### Sending proposal for plans del ####" | ||
lavad tx subscription buy DefaultPlan "$(lavad keys show user1 -a)" --enable-auto-renewal -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE | ||
# wait_count_blocks 2 | ||
# lavad tx project set-policy $(lavad keys show user1 -a)-admin ./cookbook/projects/policy_all_chains_with_addon.yml -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE | ||
|
||
# MANTLE | ||
CHAINS="ETH1,SEP1,HOL1,OSMOSIS,FTM250,CELO,LAV1,OSMOSIST,ALFAJORES,ARB1,ARBN,APT1,STRK,JUN1,COSMOSHUB,POLYGON1,EVMOS,OPTM,BASES,CANTO,SUIT,SOLANA,BSC,AXELAR,AVAX,FVM,NEAR,SQDSUBGRAPH,AGR,AGRT,KOIIT,AVAXT,CELESTIATM" | ||
BASE_CHAINS="ETH1,LAV1" | ||
# stake providers on all chains | ||
echo; echo "#### Staking provider 1 ####" | ||
lavad tx pairing bulk-stake-provider $CHAINS $PROVIDERSTAKE "$PROVIDER1_LISTENER,1" 1 "$(operator_address)" -y --delegate-commission 50 --delegate-limit $PROVIDERSTAKE --from servicer1 --provider-moniker "servicer1" --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE | ||
|
||
echo; echo "#### Staking provider 2 ####" | ||
lavad tx pairing bulk-stake-provider $BASE_CHAINS $PROVIDERSTAKE "$PROVIDER2_LISTENER,1" 1 "$(operator_address)" -y --delegate-commission 50 --delegate-limit $PROVIDERSTAKE --from servicer2 --provider-moniker "servicer2" --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE | ||
|
||
echo; echo "#### Staking provider 3 ####" | ||
lavad tx pairing bulk-stake-provider $BASE_CHAINS $PROVIDERSTAKE "$PROVIDER3_LISTENER,1" 1 "$(operator_address)" -y --delegate-commission 50 --delegate-limit $PROVIDERSTAKE --from servicer3 --provider-moniker "servicer3" --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE | ||
|
||
echo; echo "#### Staking 100 providers ####" | ||
users=() | ||
for i in $(seq 1 100); do | ||
users+=("useroren$i") | ||
done | ||
|
||
for user in "${users[@]}"; do | ||
lavad tx pairing stake-provider ETH1 600000000000ulava "127.0.0.1:2221,EU" EU "$(operator_address)" --from $user -y --provider-moniker $user --gas-adjustment "1.5" --gas "auto" --gas-prices 0.000000001ulava --delegate-limit 0ulava | ||
done | ||
|
||
echo; echo "#### Waiting 1 block ####" | ||
wait_count_blocks 1 | ||
|
||
echo; echo "#### Delegating provider 1 ####" | ||
lavad tx dualstaking delegate "$(lavad keys show servicer1 -a)" ETH1 "$(operator_address)" $PROVIDERSTAKE -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE | ||
|
||
echo; echo "#### Waiting 1 block ####" | ||
wait_count_blocks 1 | ||
|
||
echo; echo "#### Delegating provider 2 ####" | ||
lavad tx dualstaking delegate "$(lavad keys show servicer2 -a)" ETH1 "$(operator_address)" $PROVIDERSTAKE -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE | ||
|
||
echo; echo "#### Waiting 1 block ####" | ||
wait_count_blocks 1 | ||
|
||
echo; echo "#### Delegating provider 3 ####" | ||
lavad tx dualstaking delegate "$(lavad keys show servicer3 -a)" ETH1 "$(operator_address)" $PROVIDERSTAKE -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE | ||
|
||
# we need to wait for the next epoch for the stake to take action. | ||
echo; echo "#### Waiting 1 epoch ####" | ||
sleep_until_next_epoch | ||
|
||
HEALTH_FILE="config/health_examples/health_template.yml" | ||
create_health_config $HEALTH_FILE "$(lavad keys show user1 -a)" "$(lavad keys show servicer2 -a)" "$(lavad keys show servicer3 -a)" | ||
|
||
lavad tx gov submit-legacy-proposal set-iprpc-data 1000000000ulava --min-cost 100ulava --add-subscriptions $(lavad keys show -a user1) --from alice -y | ||
wait_count_blocks 1 | ||
lavad tx gov vote "$(latest_vote)" yes -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE | ||
|
||
for user in "${users[@]}"; do | ||
lavad tx pairing stake-provider ETH1 600000000000ulava "127.0.0.1:2221,EU" EU "$(operator_address)" --from $user -y --provider-moniker $user --gas-adjustment "1.5" --gas "auto" --gas-prices 0.000000001ulava --delegate-limit 0ulava | ||
done | ||
|
||
wait_count_blocks 1 | ||
|
||
for user in "${users[@]}"; do | ||
lavad q pairing get-pairing ETH1 user1 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
#!/bin/bash | ||
# make install-all | ||
killall -9 lavad | ||
__dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
source $__dir/../useful_commands.sh | ||
|
||
# Check if jq is not installed | ||
if ! command_exists jq; then | ||
echo "jq not found. Please install jq using the init_install.sh script or manually." | ||
exit 1 | ||
fi | ||
|
||
rm -rf ~/.lava | ||
chainID="lava" | ||
lavad init validator --chain-id $chainID | ||
lavad config broadcast-mode sync | ||
lavad config keyring-backend test | ||
|
||
# Specify the file path, field to edit, and new value | ||
path="$HOME/.lava/config/" | ||
genesis='genesis.json' | ||
config='config.toml' | ||
app='app.toml' | ||
|
||
# Edit genesis file | ||
if [ "$1" == "debug" ]; then | ||
# Edit genesis file with additional line | ||
data=$(cat "$path$genesis" \ | ||
| jq '.app_state.gov.params.min_deposit[0].denom = "ulava"' \ | ||
| jq '.app_state.gov.params.min_deposit[0].amount = "100"' \ | ||
| jq '.app_state.gov.params.voting_period = "4s"' \ | ||
| jq '.app_state.gov.params.expedited_voting_period = "3s"' \ | ||
| jq '.app_state.gov.params.expedited_min_deposit[0].denom = "ulava"' \ | ||
| jq '.app_state.gov.params.expedited_min_deposit[0].amount = "200"' \ | ||
| jq '.app_state.gov.params.expedited_threshold = "0.67"' \ | ||
| jq '.app_state.mint.params.mint_denom = "ulava"' \ | ||
| jq '.app_state.staking.params.bond_denom = "ulava"' \ | ||
| jq '.app_state.crisis.constant_fee.denom = "ulava"' \ | ||
| jq '.app_state.epochstorage.params.epochsToSave = "5"' \ | ||
| jq '.app_state.epochstorage.params.epochBlocks = "4"' \ | ||
| jq '.app_state.distribution.params.community_tax = "0"' \ | ||
| jq '.app_state.rewards.params.validators_subscription_participation = "0"' \ | ||
| jq '.app_state.downtime.params.downtime_duration = "1s"' \ | ||
) | ||
else | ||
# Edit genesis file without the additional line | ||
data=$(cat "$path$genesis" \ | ||
| jq '.app_state.gov.params.min_deposit[0].denom = "ulava"' \ | ||
| jq '.app_state.gov.params.min_deposit[0].amount = "100"' \ | ||
| jq '.app_state.gov.params.voting_period = "4s"' \ | ||
| jq '.app_state.gov.params.expedited_voting_period = "3s"' \ | ||
| jq '.app_state.gov.params.expedited_min_deposit[0].denom = "ulava"' \ | ||
| jq '.app_state.gov.params.expedited_min_deposit[0].amount = "200"' \ | ||
| jq '.app_state.gov.params.expedited_threshold = "0.67"' \ | ||
| jq '.app_state.mint.params.mint_denom = "ulava"' \ | ||
| jq '.app_state.mint.params.mint_denom = "ulava"' \ | ||
| jq '.app_state.staking.params.bond_denom = "ulava"' \ | ||
| jq '.app_state.crisis.constant_fee.denom = "ulava"' \ | ||
| jq '.app_state.downtime.params.downtime_duration = "6s"' \ | ||
| jq '.app_state.downtime.params.epoch_duration = "10s"' \ | ||
| jq '.app_state.epochstorage.params.epochsToSave = "8"' \ | ||
| jq '.app_state.epochstorage.params.epochBlocks = "20"' \ | ||
| jq '.app_state.pairing.params.recommendedEpochNumToCollectPayment = "2"' \ | ||
) | ||
fi | ||
|
||
echo -n "$data" > "$path$genesis" | ||
|
||
echo "using genesis file" | ||
echo "$(cat "$path$genesis")" | ||
|
||
# Determine OS | ||
case "$(uname)" in | ||
Darwin) | ||
SED_INLINE="-i ''" ;; | ||
Linux) | ||
SED_INLINE="-i" ;; | ||
*) | ||
echo "unknown system: $(uname)" | ||
exit 1 ;; | ||
esac | ||
|
||
|
||
sed $SED_INLINE \ | ||
-e 's/timeout_propose = .*/timeout_propose = "1s"/' \ | ||
-e 's/timeout_propose_delta = .*/timeout_propose_delta = "500ms"/' \ | ||
-e 's/timeout_prevote = .*/timeout_prevote = "1s"/' \ | ||
-e 's/timeout_prevote_delta = .*/timeout_prevote_delta = "500ms"/' \ | ||
-e 's/timeout_precommit = .*/timeout_precommit = "500ms"/' \ | ||
-e 's/timeout_precommit_delta = .*/timeout_precommit_delta = "1s"/' \ | ||
-e 's/timeout_commit = .*/timeout_commit = "1s"/' \ | ||
-e 's/skip_timeout_commit = .*/skip_timeout_commit = false/' "$path$config" | ||
|
||
# Edit app.toml file | ||
sed $SED_INLINE -e "s/enable = .*/enable = true/" "$path$app" | ||
sed $SED_INLINE -e "/Enable defines if the Rosetta API server should be enabled.*/{n;s/enable = .*/enable = false/}" "$path$app" | ||
|
||
# Add users | ||
users=("alice" "bob" "user1" "user2" "user3" "user4" "user5" "servicer1" "servicer2" "servicer3" "servicer4" "servicer5" "servicer6" "servicer7" "servicer8" "servicer9" "servicer10" "useroren1" "useroren2" "useroren3" "useroren4" "useroren5" "useroren6" "useroren7" "useroren8" "useroren9" "useroren10" "useroren11" "useroren12" "useroren13" "useroren14" "useroren15" "useroren16" "useroren17" "useroren18" "useroren19" "useroren20" "useroren21" "useroren22" "useroren23" "useroren24" "useroren25" "useroren26" "useroren27" "useroren28" "useroren29" "useroren30" "useroren31" "useroren32" "useroren33" "useroren34" "useroren35" "useroren36" "useroren37" "useroren38" "useroren39" "useroren40" "useroren41" "useroren42" "useroren43" "useroren44" "useroren45" "useroren46" "useroren47" "useroren48" "useroren49" "useroren50" "useroren51" "useroren52" "useroren53" "useroren54" "useroren55" "useroren56" "useroren57" "useroren58" "useroren59" "useroren60" "useroren61" "useroren62" "useroren63" "useroren64" "useroren65" "useroren66" "useroren67" "useroren68" "useroren69" "useroren70" "useroren71" "useroren72" "useroren73" "useroren74" "useroren75" "useroren76" "useroren77" "useroren78" "useroren79" "useroren80" "useroren81" "useroren82" "useroren83" "useroren84" "useroren85" "useroren86" "useroren87" "useroren88" "useroren89" "useroren90" "useroren91" "useroren92" "useroren93" "useroren94" "useroren95" "useroren96" "useroren97" "useroren98" "useroren99" "useroren100") | ||
|
||
for user in "${users[@]}"; do | ||
lavad keys add "$user" --keyring-backend test | ||
lavad add-genesis-account "$user" 50000000000000ulava --keyring-backend test | ||
done | ||
|
||
# add validators_allocation_pool for validators block rewards | ||
# its total balance is 3% from the total tokens amount: 10^9 * 10^6 ulava | ||
lavad add-genesis-account validators_rewards_allocation_pool 30000000000000ulava --module-account | ||
if [ "$1" == "debug" ]; then | ||
lavad add-genesis-account providers_rewards_allocation_pool 0ulava --module-account | ||
else | ||
lavad add-genesis-account providers_rewards_allocation_pool 30000000000000ulava --module-account | ||
fi | ||
lavad add-genesis-account iprpc_pool 0ulava --module-account | ||
lavad gentx alice 10000000000000ulava --chain-id $chainID --keyring-backend test | ||
lavad collect-gentxs | ||
lavad start --pruning=nothing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
__dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
source $__dir/../useful_commands.sh | ||
. ${__dir}/vars/variables.sh | ||
# Making sure old screens are not running | ||
echo "current vote number $(latest_vote)" | ||
killall screen | ||
screen -wipe | ||
GASPRICE="0.000000001ulava" | ||
|
||
for i in $(seq 1 100); do | ||
users+=("useroren$i") | ||
done | ||
|
||
for user in "${users[@]}"; do | ||
lavad tx pairing unstake-provider ETH1 "$(operator_address)" --from $user -y --gas-adjustment "1.5" --gas "auto" --gas-prices "$GASPRICE" | ||
done |
Oops, something went wrong.