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

Autopilot Channel Verification #728

Merged
merged 24 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e00a771
added additional safety check in airdrop autopilot
sampocs Apr 19, 2023
fe17412
fixed unit test
sampocs Apr 19, 2023
2a6972a
added test cases for different port/channel ids
sampocs Apr 19, 2023
73ebe37
added chain_id and autopilot enabled fields to airdrop type
sampocs Apr 19, 2023
5f30d0b
added chain_id and autopilot enabled fields to msg create airdrop
sampocs Apr 19, 2023
0d5afbb
updated CreateAirdropAndEpoch to check the chain-id
sampocs Apr 19, 2023
2eca370
fixed unit tests for create airdrop
sampocs Apr 19, 2023
0a432d2
added more unit tests to create airdrop to check errors
sampocs Apr 19, 2023
266b1a8
added airdrop lookup by chain-id in autopilot
sampocs Apr 19, 2023
3e1b85b
removed airdrop id from packet metadata and updated unit tests
sampocs Apr 19, 2023
b7e5f0c
added check that autopilot is enabled for the airdrop and correspondi…
sampocs Apr 19, 2023
fd0456f
updated integration test scripts
sampocs Apr 19, 2023
3f0bd06
nit changes to airdrop scripts
sampocs Apr 20, 2023
0e19367
more airdrop script cleanup
sampocs Apr 20, 2023
0f49b0f
added default epoch duration as a param
sampocs Apr 20, 2023
c4eb338
finalized integration tests
sampocs Apr 20, 2023
4d9b073
addressed riley pr comments
sampocs Apr 21, 2023
648744c
addressed vishal pr comments
sampocs Apr 21, 2023
a63f4de
Merge branch 'main' into airdrop-channel-check
sampocs Apr 21, 2023
06b6bd8
cleaned up evmos airdrop script
sampocs Apr 21, 2023
d5c226d
some more nits
sampocs Apr 21, 2023
1b31e87
renamed scripts and updated docs
sampocs Apr 21, 2023
0351d75
added channel invariant check to msg_register_host_zone
sampocs Apr 21, 2023
0c68fa1
nit comment
sampocs Apr 21, 2023
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
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
195 changes: 0 additions & 195 deletions dockernet/scripts/airdrop.sh

This file was deleted.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extreme nit: differnet -> different

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


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

### Instructions
* If running Part 3 or 4: Before building stride, you must update the following airdrop timing parameters in `x/claim/types/params.go`:
sampocs marked this conversation as resolved.
Show resolved Hide resolved
* `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
sampocs marked this conversation as resolved.
Show resolved Hide resolved
```
* **NOTE**: Each script must be run independently, meaning you must restart dockernet between runs (`make start-docker build=sgr`)
41 changes: 22 additions & 19 deletions dockernet/scripts/airdrop/airdrop1.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
### 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

# 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

# First, start the network with `make start-docker`
# Then, run this script with `bash dockernet/scripts/airdrop.sh`
# Then, run this script with `bash dockernet/scripts/airdrop/airdrop1.sh`
sampocs marked this conversation as resolved.
Show resolved Hide resolved

# 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 +35,33 @@ 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
# QUESTION: I assume these tests cannot be run back to back - but if they can then I can change the expectations below to be deltas
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they actually can be re-run but it requires the airdrop duration (line 38) to be something smaller, like 240s. imo not worth prioritizing this now, given it'll also take time to modify all of the queries, and I don't think we'll be running these back-to-back very often

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup agreed! I think for now we should treat these tests as idempotent scripts that need a dockernet restart each time. And we can always come back and try to make them idempotent later, but low priority!

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