Skip to content

Commit

Permalink
Autopilot Channel Verification (#728)
Browse files Browse the repository at this point in the history
  • Loading branch information
sampocs authored Apr 21, 2023
1 parent 3323949 commit 62295e3
Show file tree
Hide file tree
Showing 36 changed files with 1,233 additions and 787 deletions.
11 changes: 10 additions & 1 deletion app/upgrades/v3/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

claimkeeper "github.com/Stride-Labs/stride/v8/x/claim/keeper"
"github.com/Stride-Labs/stride/v8/x/claim/types"
claimtypes "github.com/Stride-Labs/stride/v8/x/claim/types"
)

Expand All @@ -22,6 +23,7 @@ var (
"stride12pum4adk5dhp32d90f8g8gfwujm0gwxqnrdlum",
}
airdropIdentifiers = []string{"stride", "gaia", "osmosis", "juno", "stars"}
airdropChainIds = []string{"stride-1", "cosmoshub-4", "osmosis-1", "juno-1", "stargaze-1"}
airdropDuration = time.Hour * 24 * 30 * 12 * 3 // 3 years
)

Expand All @@ -40,7 +42,14 @@ func CreateUpgradeHandler(
// total number of airdrop distributors must be equal to identifiers
if len(airdropDistributors) == len(airdropIdentifiers) {
for idx, airdropDistributor := range airdropDistributors {
err = ck.CreateAirdropAndEpoch(ctx, airdropDistributor, claimtypes.DefaultClaimDenom, uint64(ctx.BlockTime().Unix()), uint64(airdropDuration.Seconds()), airdropIdentifiers[idx])
err = ck.CreateAirdropAndEpoch(ctx, types.MsgCreateAirdrop{
Distributor: airdropDistributor,
Identifier: airdropIdentifiers[idx],
ChainId: airdropChainIds[idx],
Denom: claimtypes.DefaultClaimDenom,
StartTime: uint64(ctx.BlockTime().Unix()),
Duration: uint64(airdropDuration.Seconds()),
})
if err != nil {
return newVm, err
}
Expand Down
11 changes: 10 additions & 1 deletion app/upgrades/v8/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var (
UpgradeName = "v8"
EvmosAirdropDistributor = "stride10dy5pmc2fq7fnmufjfschkfrxaqnpykl6ezy5j"
EvmosAirdropIdentifier = "evmos"
EvmosChainId = "evmos_9001-2"
AirdropDuration = time.Hour * 24 * 30 * 12 * 3 // 3 years
ResetAirdropIdentifiers = []string{"stride", "gaia", "osmosis", "juno", "stars"}
AirdropStartTime = time.Date(2023, 4, 3, 16, 0, 0, 0, time.UTC) // April 3, 2023 @ 16:00 UTC (12:00 EST)
Expand Down Expand Up @@ -71,7 +72,15 @@ func CreateUpgradeHandler(
// Add the evmos airdrop
ctx.Logger().Info("Adding evmos airdrop...")
duration := uint64(AirdropDuration.Seconds())
if err := claimKeeper.CreateAirdropAndEpoch(ctx, EvmosAirdropDistributor, claimtypes.DefaultClaimDenom, uint64(AirdropStartTime.Unix()), duration, EvmosAirdropIdentifier); err != nil {
if err := claimKeeper.CreateAirdropAndEpoch(ctx, types.MsgCreateAirdrop{
Distributor: EvmosAirdropDistributor,
Identifier: EvmosAirdropIdentifier,
ChainId: EvmosChainId,
Denom: claimtypes.DefaultClaimDenom,
StartTime: uint64(AirdropStartTime.Unix()),
Duration: duration,
AutopilotEnabled: true,
}); err != nil {
return vm, err
}

Expand Down
6 changes: 3 additions & 3 deletions dockernet/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TX_LOGS=$DOCKERNET_HOME/logs/tx.log
KEYS_LOGS=$DOCKERNET_HOME/logs/keys.log

# List of hosts enabled
HOST_CHAINS=()
HOST_CHAINS=(EVMOS)

# If no host zones are specified above:
# `start-docker` defaults to just GAIA if HOST_CHAINS is empty
Expand Down Expand Up @@ -228,9 +228,9 @@ EVMOS_CHAIN_ID=evmos_9001-2
EVMOS_NODE_PREFIX=evmos
EVMOS_NUM_NODES=1
EVMOS_BINARY="$DOCKERNET_HOME/../build/evmosd"
EVMOS_VAL_PREFIX=nval
EVMOS_VAL_PREFIX=eval
EVMOS_ADDRESS_PREFIX=evmos
EVMOS_REV_ACCT=nrev1
EVMOS_REV_ACCT=erev1
EVMOS_DENOM=$EVMOS_DENOM
EVMOS_RPC_PORT=26057
EVMOS_MAIN_CMD="$EVMOS_BINARY --home $DOCKERNET_HOME/state/${EVMOS_NODE_PREFIX}1"
Expand Down
195 changes: 0 additions & 195 deletions dockernet/scripts/airdrop.sh

This file was deleted.

25 changes: 25 additions & 0 deletions dockernet/scripts/airdrop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Airdrop Integration Tests
Each airdrop testing script (1 through 4) tests different aspects of the airdrop.

### Overview
**NOTE**: You must update the airdrop timing params before running parts 4 and 5 (see next section)
* **Part 1: Standard**: Tests basic airdrop claims and actions
* **Part 2: Autopilot**: Tests claiming through autopilot on GAIA (ibc-go v3)
* **Part 3: Evmos**: Tests claiming through autopilot on EVMOS (ibc-go v5)
* **Part 4: Resets**: Tests that the airdrop resets properly at the epoch
* **Part 5: Staggered**: Tests two airdrops running side by side and staggered

### Instructions
* If running part 3, change the `HOST_CHAINS` variable in `config.sh` to run only evmos.
* If running Part 4 or 5: Before building stride, you must update the following airdrop timing parameters in `x/claim/types/params.go`:
* `DefaultEpochDuration` to `time.Second * 60`
* `DefaultVestingInitialPeriod` to `time.Second * 120`
* Only the GAIA host zone is required. Start dockernet with:
```bash
make start-docker build=sgr
```
* Run the corresponding script
```bash
bash dockernet/scripts/airdrop/airdrop{1/2/3/4}.sh
```
* **NOTE**: Each script must be run independently, meaning you must restart dockernet between runs (`make start-docker build=sgr`)
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
### AIRDROP TESTING FLOW
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source ${SCRIPT_DIR}/../../config.sh

# CLEANUP if running tests twice, clear out and re-fund accounts
$STRIDE_MAIN_CMD keys delete airdrop-test -y &> /dev/null || true
$STRIDE_MAIN_CMD keys delete distributor-test -y &> /dev/null || true
$OSMO_MAIN_CMD keys delete host-address-test -y &> /dev/null || true
### AIRDROP TESTING FLOW Pt 1 (STANDARD)

# First, start the network with `make start-docker`
# Then, run this script with `bash dockernet/scripts/airdrop.sh`
# This script tests airdrop claiming directly on Stride
# This covers the case where the host zone has a coin type of 118
# and autopilot is disabled for the claim

# To run:
# 1. Start the network with `make start-docker`
# 2. Run this script with `bash dockernet/scripts/airdrop/airdrop1_standard.sh`

# NOTE: First, store the keys using the following mnemonics
echo "Registering accounts..."
# distributor address: stride1z835j3j65nqr6ng257q0xkkc9gta72gf48txwl
# distributor mnemonic: barrel salmon half click confirm crunch sense defy salute process cart fiscal sport clump weasel render private manage picture spell wreck hill frozen before
echo "barrel salmon half click confirm crunch sense defy salute process cart fiscal sport clump weasel render private manage picture spell wreck hill frozen before" | \
Expand All @@ -33,32 +36,32 @@ sleep 5
$STRIDE_MAIN_CMD tx bank send val1 stride1nf6v2paty9m22l3ecm7dpakq2c92ueyununayr 1000000000ustrd --from val1 -y | TRIM_TX
sleep 5
# Create the airdrop, so that the airdrop account can claim tokens
$STRIDE_MAIN_CMD tx claim create-airdrop stride 1679715340 40000000 ustrd --from distributor-test -y | TRIM_TX
$STRIDE_MAIN_CMD tx claim create-airdrop gaia GAIA ustrd 1679715340 40000000 false --from distributor-test -y | TRIM_TX
sleep 5
# Set airdrop allocations
$STRIDE_MAIN_CMD tx claim set-airdrop-allocations stride stride1nf6v2paty9m22l3ecm7dpakq2c92ueyununayr 1 --from distributor-test -y | TRIM_TX
$STRIDE_MAIN_CMD tx claim set-airdrop-allocations gaia stride1nf6v2paty9m22l3ecm7dpakq2c92ueyununayr 1 --from distributor-test -y | TRIM_TX
sleep 5

# AIRDROP CLAIMS
# Check balances before claims
echo "Initial balance before claim:"
$STRIDE_MAIN_CMD query bank balances stride1nf6v2paty9m22l3ecm7dpakq2c92ueyununayr
echo -e "\nInitial balance before claim [1000000000ustrd expected]:"
$STRIDE_MAIN_CMD query bank balances stride1nf6v2paty9m22l3ecm7dpakq2c92ueyununayr --denom ustrd
# NOTE: You can claim here using the CLI, or from the frontend!
# Claim 20% of the free tokens
echo "Claiming fee amount..."
echo -e "\nClaiming free amount..."
$STRIDE_MAIN_CMD tx claim claim-free-amount --from airdrop-test --gas 400000 -y | TRIM_TX
sleep 5
echo "Balance after claim:"
$STRIDE_MAIN_CMD query bank balances stride1nf6v2paty9m22l3ecm7dpakq2c92ueyununayr
echo -e "\nBalance after claim [1000120000ustrd expected]:"
$STRIDE_MAIN_CMD query bank balances stride1nf6v2paty9m22l3ecm7dpakq2c92ueyununayr --denom ustrd
# Stake, to claim another 20%
echo "Staking..."
echo -e "\nStaking..."
$STRIDE_MAIN_CMD tx staking delegate stridevaloper1nnurja9zt97huqvsfuartetyjx63tc5zrj5x9f 100ustrd --from airdrop-test --gas 400000 -y | TRIM_TX
sleep 5
echo "Balance after stake:"
$STRIDE_MAIN_CMD query bank balances stride1nf6v2paty9m22l3ecm7dpakq2c92ueyununayr
echo -e "\nBalance after stake [1000239900ustrd expected]:"
$STRIDE_MAIN_CMD query bank balances stride1nf6v2paty9m22l3ecm7dpakq2c92ueyununayr --denom ustrd
# Liquid stake, to claim the final 60% of tokens
echo "Liquid staking..."
echo -e "\nLiquid staking..."
$STRIDE_MAIN_CMD tx stakeibc liquid-stake 1000 uatom --from airdrop-test --gas 400000 -y | TRIM_TX
sleep 5
echo "Balance after liquid stake:"
$STRIDE_MAIN_CMD query bank balances stride1nf6v2paty9m22l3ecm7dpakq2c92ueyununayr
echo -e "\nBalance after liquid stake [1000599900ustrd expected]:"
$STRIDE_MAIN_CMD query bank balances stride1nf6v2paty9m22l3ecm7dpakq2c92ueyununayr --denom ustrd
Loading

0 comments on commit 62295e3

Please sign in to comment.