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

Handle non staking tokens #1132

Merged
merged 35 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b3c00c7
test: update versions of external tools
Feb 8, 2024
1f48ff3
Always use helpers to increment/decrement/set withdrawal waitgroup in…
Feb 8, 2024
c3fc7b7
fix: race condition in non-staking denom reward dist
Feb 8, 2024
0773519
add non-staking denom test to bash tests
Feb 8, 2024
bd42bba
improve validateCoinsForZone, and handle non-staking coins airdropped…
Feb 10, 2024
5e89a14
test: add delegate account airdrops test to bash tests
Feb 10, 2024
3560fd7
fix: SendToWithdrawal shouldn't use fixed sender
Feb 10, 2024
8c8fc77
Ensure we have the same cases for failed messages
Feb 10, 2024
c6249c4
fix: handle race condition in delegation record update
Feb 10, 2024
7705109
update port for testzone
Feb 10, 2024
b6bdf51
lint
Feb 10, 2024
37b7d2a
Update x/interchainstaking/keeper/ibc_packet_handlers.go
Feb 10, 2024
4740264
tigy logging
Feb 10, 2024
05f7259
Merge branch 'main' into feature-1118-handle-non-staking-tokens
faddat Feb 10, 2024
e33120e
Merge branch 'main' into feature-1118-handle-non-staking-tokens
faddat Feb 10, 2024
7bf525a
run tests with go 1.22
faddat Feb 10, 2024
09681cb
update golang
faddat Feb 10, 2024
872c2fa
bump golangci-lint
faddat Feb 10, 2024
0ae72e9
update Makefile for go 1.22
faddat Feb 10, 2024
58c8c4e
Update Makefile
faddat Feb 10, 2024
dd80f7d
exclude amd64 for darwin, no one really has that anymore anyhow.
faddat Feb 11, 2024
acfbef3
fix test where error is no longer thrown
Feb 12, 2024
157d99d
revert bump to go1.22 until it is more mature
Feb 12, 2024
5aef227
add missed Dockerfile
Feb 12, 2024
3a70764
Bump makefile
Feb 12, 2024
29e5fe4
fix #1140; recreate redelegation record if long delays mean original …
Feb 13, 2024
ed81656
tests
Feb 13, 2024
3f9e3f3
change some error messages to info
Feb 13, 2024
ec4085d
sendToWithdrawal ack test
Feb 13, 2024
f4c9ef3
add test for redelegation record creation
Feb 13, 2024
dba928f
add test for 0 wg in DelegationAccountBalances
Feb 13, 2024
67d1f09
add tests (from cosmos-sdk) for decoder funcs
Feb 13, 2024
c94d2a7
lint
Feb 13, 2024
9572b8f
Merge branch 'main' into feature-1118-handle-non-staking-tokens
Feb 13, 2024
608447d
Merge branch 'main' into feature-1118-handle-non-staking-tokens
faddat Feb 13, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/buildtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
strategy:
matrix:
arch: [amd64]
targetos: [linux, windows, darwin]
targetos: [linux, windows]
include:
- targetos: darwin
arch: arm64
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.21.5
go-version: 1.21.7
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.21.x'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.55.2
version: v1.56.1
args: --timeout 15m
# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/interchaintest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Set up go 1.21
- name: Set up go
uses: actions/setup-go@v5
with:
go-version: "1.21"
Expand All @@ -72,7 +72,7 @@ jobs:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Set up go 1.21
- name: Set up go
uses: actions/setup-go@v5
with:
go-version: "1.21"
Expand All @@ -89,7 +89,7 @@ jobs:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Set up go 1.21
- name: Set up go
uses: actions/setup-go@v5
with:
go-version: "1.21"
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.5-alpine3.18 AS builder
FROM golang:1.21.7-alpine3.19 AS builder
RUN apk add --no-cache git musl-dev openssl-dev linux-headers ca-certificates build-base

WORKDIR /src/app/
Expand All @@ -22,7 +22,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
LINK_STATICALLY=true make build

# Add to a distroless container
FROM alpine:3.18
FROM alpine:3.19
COPY --from=builder /src/app/build/quicksilverd /usr/local/bin/quicksilverd
RUN adduser -S -h /quicksilver -D quicksilver -u 1000
USER quicksilver
Expand Down
20 changes: 0 additions & 20 deletions Dockerfile.hermes

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile.relayer
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.5-alpine3.18 AS builder
FROM golang:1.21.7-alpine3.19 AS builder
RUN apk add --no-cache make git gcc musl-dev openssl-dev linux-headers

RUN git clone https://github.com/cosmos/relayer --branch v2.1.1 /src/app
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ BUILD_TARGETS := build install

check_version:
ifneq ($(GO_MINOR_VERSION),21)
@echo "ERROR: Go version 1.21 is required for building Quicksilver. There are consensus breaking changes between binaries compiled with different Go versions."
@echo "ERROR: Go version 1.21 is required for building Quicksilver. Detected version: $(GO_MAJOR_VERSION).$(GO_MINOR_VERSION). There are
consensus breaking changes between binaries compiled with different Go versions."
exit 1
endif

Expand Down
18 changes: 7 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ services:
- start
ports:
- 27657:26657
- 23137:1317
- 21317:1317
testzone1-2:
image: quicksilverzone/testzone:latest
hostname: testzone1-2
Expand Down Expand Up @@ -98,31 +98,27 @@ services:
- osmosisd
- start
hermes:
image: quicksilverzone/hermes:v1.5.0
image: informalsystems/hermes:v1.8.0
hostname: hermes
volumes:
- ./data/hermes:/hermes/.hermes
- ./data/hermes:/home/hermes/.hermes
command:
- hermes
- start
restart: always
build:
context: .
dockerfile: Dockerfile.hermes
icq:
image: quicksilverzone/interchain-queries:v0.9.1
image: quicksilverzone/interchain-queries:v0.10.0
volumes:
- ./data/icq:/icq/.icq
command:
- interchain-queries
- icq-relayer
- run
restart: always
icq2:
image: quicksilverzone/interchain-queries:v0.9.1
image: quicksilverzone/interchain-queries:v0.10.0
volumes:
- ./data/icq2:/icq/.icq
command:
- interchain-queries
- icq-relayer
- run
restart: always
relayer:
Expand Down
2 changes: 1 addition & 1 deletion icq-relayer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.5-alpine3.19 as build
FROM golang:1.21.7-alpine3.19 as build

WORKDIR /src/app

Expand Down
2 changes: 1 addition & 1 deletion proto/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM bufbuild/buf:latest as BUILDER
FROM golang:1.21.5-alpine3.18
FROM golang:1.21.7-alpine3.18

RUN apk add --no-cache \
nodejs \
Expand Down
9 changes: 7 additions & 2 deletions scripts/config/hermes.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enabled = true
enabled = true
clear_interval = 100
clear_on_start = true
tx_confirmation = true

[rest]
enabled = true
Expand All @@ -29,7 +30,7 @@ port = 3001
id = 'qstest-1'
rpc_addr = 'http://quicksilver:26657'
grpc_addr = 'http://quicksilver:9090'
websocket_addr = 'ws://quicksilver:26657/websocket'
event_source = { mode = "pull" }
rpc_timeout = '10s'
account_prefix = 'quick'
key_name = 'testkey'
Expand All @@ -45,12 +46,14 @@ max_block_time = '10s'
trusting_period = '3minutes'
trust_threshold = { numerator = '1', denominator = '3' }
address_type = { derivation = 'cosmos' }
trusted_node = true
sequential_batch_tx = true

[[chains]]
id = 'lstest-1'
rpc_addr = 'http://testzone1-1:26657'
grpc_addr = 'http://testzone1-1:9090'
websocket_addr = 'ws://testzone1-1:26657/websocket'
event_source = { mode = "pull" }
rpc_timeout = '10s'
account_prefix = 'cosmos'
key_name = 'testkey'
Expand All @@ -66,3 +69,5 @@ max_block_time = '10s'
trusting_period = '3minutes'
trust_threshold = { numerator = '1', denominator = '3' }
address_type = { derivation = 'cosmos' }
trusted_node = true
sequential_batch_tx = true
4 changes: 2 additions & 2 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ $QS1_RUN add-genesis-account ${DEMO_ADDRESS_7} 100000000000uqck
$QS2_RUN add-genesis-account ${VAL_ADDRESS_6} 100000000000uqck
$QS3_RUN add-genesis-account ${VAL_ADDRESS_7} 100000000000uqck

$TZ1_1_RUN add-genesis-account ${VAL_ADDRESS_2} 100000000000uatom
$TZ1_1_RUN add-genesis-account ${VAL_ADDRESS_2} 100000000000uatom,100000000uother
$TZ1_1_RUN add-genesis-account ${VAL_ADDRESS_3} 100000000000uatom
$TZ1_1_RUN add-genesis-account ${VAL_ADDRESS_4} 100000000000uatom
$TZ1_1_RUN add-genesis-account ${VAL_ADDRESS_5} 100000000000uatom
Expand Down Expand Up @@ -475,7 +475,7 @@ if [ "$IS_MULTI_ZONE_TEST" = true ]; then
fi

## set the 'epoch' epoch to 5m interval
jq '.app_state.epochs.epochs = [{"identifier": "epoch","start_time": "0001-01-01T00:00:00Z","duration": "240s","current_epoch": "0","current_epoch_start_time": "0001-01-01T00:00:00Z","epoch_counting_started": false,"current_epoch_start_height": "0"}]' ./${CHAIN_DIR}/${CHAINID_0}/config/genesis.json > ./${CHAIN_DIR}/${CHAINID_0}/config/genesis.json.new && mv ./${CHAIN_DIR}/${CHAINID_0}/config/genesis.json{.new,}
jq '.app_state.epochs.epochs = [{"identifier": "epoch","start_time": "0001-01-01T00:00:00Z","duration": "360s","current_epoch": "0","current_epoch_start_time": "0001-01-01T00:00:00Z","epoch_counting_started": false,"current_epoch_start_height": "0"},{"identifier": "day","start_time": "0001-01-01T00:00:00Z","duration": "120s","current_epoch": "0","current_epoch_start_time": "0001-01-01T00:00:00Z","epoch_counting_started": false,"current_epoch_start_height": "0"}]' ./${CHAIN_DIR}/${CHAINID_0}/config/genesis.json > ./${CHAIN_DIR}/${CHAINID_0}/config/genesis.json.new && mv ./${CHAIN_DIR}/${CHAINID_0}/config/genesis.json{.new,}
jq '.app_state.interchainstaking.params.deposit_interval = 25' ./${CHAIN_DIR}/${CHAINID_0}/config/genesis.json > ./${CHAIN_DIR}/${CHAINID_0}/config/genesis.json.new && mv ./${CHAIN_DIR}/${CHAINID_0}/config/genesis.json{.new,}
jq '.app_state.mint.params.epoch_identifier = "epoch"' ./${CHAIN_DIR}/${CHAINID_0}/config/genesis.json > ./${CHAIN_DIR}/${CHAINID_0}/config/genesis.json.new && mv ./${CHAIN_DIR}/${CHAINID_0}/config/genesis.json{.new,}
jq '.app_state.gov.deposit_params.min_deposit = [{"denom": "uqck", "amount": "100"}]' ./${CHAIN_DIR}/${CHAINID_0}/config/genesis.json > ./${CHAIN_DIR}/${CHAINID_0}/config/genesis.json.new && mv ./${CHAIN_DIR}/${CHAINID_0}/config/genesis.json{.new,}
Expand Down
19 changes: 18 additions & 1 deletion scripts/simple-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,32 @@ while [[ "$PERFORMANCE_ACCOUNT" == "null" ]]; do
PERFORMANCE_ACCOUNT=$($QS1_EXEC q interchainstaking zones --output=json | jq .zones[0].performance_address.address -r)
done

$TZ1_1_EXEC tx bank send val2 $PERFORMANCE_ACCOUNT 40000uatom --chain-id $CHAINID_1 -y --keyring-backend=test
WITHDRAWAL_ACCOUNT=$($QS1_EXEC q interchainstaking zones --output=json | jq .zones[0].withdrawal_address.address -r)
while [[ "$WITHDRAWAL_ACCOUNT" == "null" ]]; do
sleep 2
WITHDRAWAL_ACCOUNT=$($QS1_EXEC q interchainstaking zones --output=json | jq .zones[0].withdrawal_address.address -r)
done

DELEGATE_ACCOUNT=$($QS1_EXEC q interchainstaking zones --output=json | jq .zones[0].delegation_address.address -r)
while [[ "DELEGATE_ACCOUNT" == "null" ]]; do
sleep 2
DELEGATE_ACCOUNT=$($QS1_EXEC q interchainstaking zones --output=json | jq .zones[0].delegation_address.address -r)
done

$TZ1_1_EXEC tx bank send val2 $PERFORMANCE_ACCOUNT 40000uatom --chain-id $CHAINID_1 -y --keyring-backend=test
sleep 3
#$TZ1_1_EXEC tx bank send val2 $DEPOSIT_ACCOUNT 10000000${VAL_VALOPER_2}1 --chain-id $CHAINID_1 -y --keyring-backend=test
#sleep 5
#$TZ1_2_EXEC tx bank send val3 $DEPOSIT_ACCOUNT 15000000${VAL_VALOPER_3}2 --chain-id $CHAINID_1 -y --keyring-backend=test
#sleep 5
$TZ1_1_EXEC tx bank send demowallet2 $DEPOSIT_ACCOUNT 333333uatom --chain-id $CHAINID_1 -y --keyring-backend=test
sleep 5
$TZ1_1_EXEC tx bank send val2 $DEPOSIT_ACCOUNT 5000000uother --chain-id $CHAINID_1 -y --keyring-backend=test
sleep 5
$TZ1_1_EXEC tx bank send val2 $WITHDRAWAL_ACCOUNT 8000000uother --chain-id $CHAINID_1 -y --keyring-backend=test
sleep 5
$TZ1_1_EXEC tx bank send val2 $DELEGATE_ACCOUNT 10000000uother --chain-id $CHAINID_1 -y --keyring-backend=test
sleep 5
$TZ1_1_EXEC tx bank send demowallet2 $DEPOSIT_ACCOUNT 20000000uatom --chain-id $CHAINID_1 -y --keyring-backend=test --note MgTUzEjWVVYoDZBarqFL1akb38mxlgTsqdZ/sFxTJBNf+tv6rtckvn3T
sleep 5
$TZ1_1_EXEC tx bank send demowallet2 $DEPOSIT_ACCOUNT 33000000uatom --chain-id $CHAINID_1 -y --keyring-backend=test
Expand Down
6 changes: 3 additions & 3 deletions scripts/vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ TZ2_2_RUN="docker-compose $DC --ansi never run --rm -T testzone2-2 osmosisd"
TZ2_3_RUN="docker-compose $DC --ansi never run --rm -T testzone2-3 osmosisd"
TZ2_4_RUN="docker-compose $DC --ansi never run --rm -T testzone2-4 osmosisd"
RLY_RUN="docker-compose $DC --ansi never run --rm -T relayer rly"
HERMES_RUN="docker-compose $DC --ansi never run --rm -T hermes hermes"
HERMES_RUN="docker-compose $DC --ansi never run --rm -T hermes"

QS1_EXEC="docker-compose $DC --ansi never exec -T quicksilver quicksilverd"
QS2_EXEC="docker-compose $DC --ansi never exec -T quicksilver2 quicksilverd"
Expand All @@ -65,8 +65,8 @@ TZ2_3_EXEC="docker-compose $DC --ansi never exec -T testzone2-3 osmosisd"
TZ2_4_EXEC="docker-compose $DC --ansi never exec -T testzone2-4 osmosisd"
RLY_EXEC="docker-compose $DC --ansi never exec -T relayer"

ICQ_RUN="docker-compose $DC --ansi never run --rm -T icq interchain-queries"
ICQ2_RUN="docker-compose $DC --ansi never run --rm -T icq2 interchain-queries"
ICQ_RUN="docker-compose $DC --ansi never run --rm -T icq icq-relayer"
ICQ2_RUN="docker-compose $DC --ansi never run --rm -T icq2 icq-relayer"

VAL_MNEMONIC_1="clock post desk civil pottery foster expand merit dash seminar song memory figure uniform spice circle try happy obvious trash crime hybrid hood cushion"
VAL_MNEMONIC_2="angry twist harsh drastic left brass behave host shove marriage fall update business leg direct reward object ugly security warm tuna model broccoli choice"
Expand Down
22 changes: 16 additions & 6 deletions x/interchainstaking/keeper/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@

// decrement waitgroup as we have received back the query
// (initially incremented in AfterEpochEnd)
err = zone.DecrementWithdrawalWaitgroup()
err = zone.DecrementWithdrawalWaitgroup(k.Logger(ctx), 1, "rewards callback")
joe-bowman marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return err
}

k.Logger(ctx).Debug("QueryDelegationRewards callback", "wg", zone.WithdrawalWaitgroup, "delegatorAddress", rewardsQuery.DelegatorAddress, "zone", query.ChainId)
k.Logger(ctx).Debug("QueryDelegationRewards callback", "wg", zone.GetWithdrawalWaitgroup(), "delegatorAddress", rewardsQuery.DelegatorAddress, "zone", query.ChainId)
joe-bowman marked this conversation as resolved.
Show resolved Hide resolved

return k.WithdrawDelegationRewardsForResponse(ctx, &zone, rewardsQuery.DelegatorAddress, args)
}
Expand Down Expand Up @@ -622,7 +622,7 @@
}

k.Logger(ctx).Info("Received balance response for denom", "denom", coin.Denom)
err = zone.DecrementWithdrawalWaitgroup()
err = zone.DecrementWithdrawalWaitgroup(k.Logger(ctx), 1, "delegationaccountbalance callback")
joe-bowman marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return err
}
Expand All @@ -642,6 +642,12 @@

k.SetZone(ctx, &zone)

// if token is not valid for staking, then send to withdrawal account.
if valid, _ := zone.ValidateCoinsForZone(sdk.NewCoins(coin), k.GetValidatorAddressesAsMap(ctx, zone.ChainId)); !valid {
k.Logger(ctx).Info("token is not a valid staking token, so sending to withdrawal account for disbursal", "chain", zone.ChainId, "assets", coin)
return k.SendToWithdrawal(ctx, &zone, zone.DelegationAddress, sdk.NewCoins(coin))

Check warning on line 648 in x/interchainstaking/keeper/callbacks.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/keeper/callbacks.go#L647-L648

Added lines #L647 - L648 were not covered by tests
}

joe-bowman marked this conversation as resolved.
Show resolved Hide resolved
return k.FlushOutstandingDelegations(ctx, &zone, coin)
}

Expand All @@ -653,7 +659,9 @@
result := banktypes.QueryAllBalancesResponse{}
k.cdc.MustUnmarshal(args, &result)

zone.WithdrawalWaitgroup--
if err := zone.DecrementWithdrawalWaitgroup(k.Logger(ctx), 1, "delegationaccountbalances callback"); err != nil {
return err

Check warning on line 663 in x/interchainstaking/keeper/callbacks.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/keeper/callbacks.go#L663

Added line #L663 was not covered by tests
}
joe-bowman marked this conversation as resolved.
Show resolved Hide resolved

addressBytes, err := addressutils.AccAddressFromBech32(zone.DelegationAddress.Address, zone.AccountPrefix)
if err != nil {
Expand All @@ -677,8 +685,10 @@
0,
)

k.Logger(ctx).Info("Emitting balance request for denom", "denom", coin.Denom)
zone.WithdrawalWaitgroup++
if err = zone.IncrementWithdrawalWaitgroup(k.Logger(ctx), 1, fmt.Sprintf("delegation account balance for %s", coin.Denom)); err != nil {
return err

Check warning on line 689 in x/interchainstaking/keeper/callbacks.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/keeper/callbacks.go#L689

Added line #L689 was not covered by tests
}
k.Logger(ctx).Info("Emitting balance request for denom", "denom", coin.Denom, "waitgroup", zone.GetWithdrawalWaitgroup())
}
k.SetZone(ctx, &zone)

Expand Down
Loading
Loading