Skip to content

Commit

Permalink
Handle non staking tokens (quicksilver-zone#1132)
Browse files Browse the repository at this point in the history
* test: update versions of external tools

* Always use helpers to increment/decrement/set withdrawal waitgroup in order for under/overflow checks

* fix: race condition in non-staking denom reward dist

* add non-staking denom test to bash tests

* improve validateCoinsForZone, and handle non-staking coins airdropped to delegate account

* test: add delegate account airdrops test to bash tests

* fix: SendToWithdrawal shouldn't use fixed sender

* Ensure we have the same cases for failed messages

* fix: handle race condition in delegation record update

* update port for testzone

* lint

* Update x/interchainstaking/keeper/ibc_packet_handlers.go

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* tigy logging

* run tests with go 1.22

* update golang

* bump golangci-lint

* update Makefile for go 1.22

* Update Makefile

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Jacob Gadikian <[email protected]>
  • Loading branch information
3 people authored Feb 13, 2024
1 parent 9b441a7 commit 73f875b
Show file tree
Hide file tree
Showing 31 changed files with 767 additions and 220 deletions.
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@v4
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
Loading

0 comments on commit 73f875b

Please sign in to comment.