Skip to content

Commit

Permalink
Pr tvl updates (#445)
Browse files Browse the repository at this point in the history
* front-port v1.2.13

* fix delegation flush test

* add tests for HandleDepositTransaction

* update tests for new error handling

* remove superflous field in proto

* final v1.2.13 front-port and test fixes

* s/s/suite/

* remove fmt.Printlns used for debugging

* update participation rewards and protocoldatas, to add validation, automatic key generation, basechain/basedenom in osmosisparams and updated tvl calculation

* front-port v1.2.13

* remove balancerPoolPretty json marshal/unmarshal, as we deal with raw KV store objects; switch to native bech32 decode/encode as we dont expect prefix of pools to match sdk.GetConfig().Bech32Prefix

* fix: allow support for multiple denoms from same zone in tvl calc

* lint

* fix: refactor utils/address.go to avoid import cycle when using in osmosis-types

* add test for randomutils

* fix: remove potential non-det by iterating over maps using sorted keys

* resolve outstanding nits

* lint

* fix nits

* bump go to 1.20.5

* Update x/interchainstaking/keeper/receipt.go

* Apply suggestions from code review

* lint

* bump hermes to v1.5.0

* update icq and relayer in test scripts
  • Loading branch information
Joe Bowman authored Jun 12, 2023
1 parent 1e4aa6b commit c5fbdb3
Show file tree
Hide file tree
Showing 103 changed files with 3,534 additions and 3,260 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/buildtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.20.4'
go-version: "1.20.5"
env:
GOOS: ${{ matrix.targetos }}
GOARCH: ${{ matrix.arch }}
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.20.4'
go-version: "1.20.5"
env:
GOOS: ${{ matrix.targetos }}
GOARCH: ${{ matrix.arch }}
Expand Down Expand Up @@ -93,10 +93,10 @@ jobs:
filename=$(echo $filename | sed 's/^./github.com\/ingenuity-build\/quicksilver/g')
echo "Excluding ${filename} from coverage report..."
sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
done
done
- name: "Go vulnerability checks"
continue-on-error: false #temp-till we upgrade to v1.20
continue-on-error: false #temp-till we upgrade to v1.20
run: make vulncheck

- name: Upload coverage reports to Codecov with GitHub Action
Expand Down Expand Up @@ -124,6 +124,6 @@ jobs:
${{ runner.os }}-go-
- uses: actions/setup-go@v4
with:
go-version: '1.20.4'
go-version: "1.20.5"
- name: Run simulation tests
run: make test-sim-ci
7 changes: 3 additions & 4 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ name: Docker
on:
push:
branches:
- 'develop'
- "develop"

jobs:
docker:
runs-on: ubuntu-latest
steps:

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

Expand All @@ -25,7 +24,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.20.4'
go-version: "1.20.5"

- name: Setup Golang caches
uses: actions/cache@v3
Expand All @@ -40,4 +39,4 @@ jobs:
- name: build and push container
run: |
DOCKER_BUILDKIT=1 /usr/bin/docker build . -f Dockerfile -t quicksilverzone/quicksilver:latest
/usr/bin/docker push quicksilverzone/quicksilver:latest
/usr/bin/docker push quicksilverzone/quicksilver:latest
2 changes: 1 addition & 1 deletion .github/workflows/golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.20.4'
go-version: "1.20.5"
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
22 changes: 10 additions & 12 deletions .github/workflows/interchaintest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ name: create docker image + E2E Tests
on:
push:
tags:
- '**'
- "**"
branches:
- 'main'
- 'develop'
- "main"
- "develop"
paths:
- '**.go'
- 'go.sum'
- "**.go"
- "go.sum"

env:
REGISTRY: quicksilverzone
Expand All @@ -23,7 +23,6 @@ jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

Expand All @@ -39,10 +38,9 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.20.4'
go-version: "1.20.5"

-
name: Build and push
- name: Build and push
id: build_push_image
uses: docker/build-push-action@v3
with:
Expand All @@ -60,7 +58,7 @@ jobs:
- name: Set up Go 1.20
uses: actions/setup-go@v4
with:
go-version: '1.20.4'
go-version: "1.20.5"
id: go

- name: checkout chain
Expand All @@ -77,7 +75,7 @@ jobs:
- name: Set up Go 1.20
uses: actions/setup-go@v4
with:
go-version: '1.20.4'
go-version: "1.20.5"
id: go

- name: checkout chain
Expand All @@ -94,7 +92,7 @@ jobs:
- name: Set up Go 1.20
uses: actions/setup-go@v4
with:
go-version: '1.20.4'
go-version: "1.20.5"
id: go

- name: checkout chain
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/simulation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: simulate quicksilver

on:
schedule:
- cron: '0 0 * * 0' # run once a week
- cron: "0 0 * * 0" # run once a week

jobs:
simulate:
Expand All @@ -19,7 +19,7 @@ jobs:
${{ runner.os }}-go-
- uses: actions/setup-go@v4
with:
go-version: '1.20.4'
go-version: "1.20.5"

- name: Run simulation tests
run: make test-sim-non-determinism
2 changes: 1 addition & 1 deletion Dockerfile.hermes
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ RUN apt update && apt install git -y

WORKDIR /app/src

RUN git clone https://github.com/informalsystems/ibc-rs --branch v1.4.0
RUN git clone https://github.com/informalsystems/ibc-rs --branch v1.5.0

WORKDIR ibc-rs

Expand Down
1 change: 1 addition & 0 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (
V010402rc5UpgradeName = "v1.4.2-rc5"
V010402rc6UpgradeName = "v1.4.2-rc6"
V010402rc7UpgradeName = "v1.4.2-rc7"
V010403rc0UpgradeName = "v1.4.3-rc0"
)

// Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal
Expand Down
35 changes: 30 additions & 5 deletions app/upgrades/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/ingenuity-build/quicksilver/app/keepers"
"github.com/ingenuity-build/quicksilver/utils"
"github.com/ingenuity-build/quicksilver/utils/addressutils"
"github.com/ingenuity-build/quicksilver/x/interchainstaking/types"
prtypes "github.com/ingenuity-build/quicksilver/x/participationrewards/types"
)
Expand All @@ -25,6 +25,7 @@ func Upgrades() []Upgrade {
{UpgradeName: V010402rc5UpgradeName, CreateUpgradeHandler: V010402rc5UpgradeHandler},
{UpgradeName: V010402rc6UpgradeName, CreateUpgradeHandler: V010402rc6UpgradeHandler},
{UpgradeName: V010402rc7UpgradeName, CreateUpgradeHandler: NoOpHandler},
{UpgradeName: V010403rc0UpgradeName, CreateUpgradeHandler: V010403rc0UpgradeHandler},
}
}

Expand Down Expand Up @@ -86,10 +87,10 @@ func V010402rc3UpgradeHandler(
panic("connection protocol data type not found")
}

appKeepers.ParticipationRewardsKeeper.DeleteProtocolData(ctx, string(prtypes.GetProtocolDataKey(prtypes.ProtocolDataType(pdType), "rege-redwood-1")))
appKeepers.ParticipationRewardsKeeper.DeleteProtocolData(ctx, prtypes.GetProtocolDataKey(prtypes.ProtocolDataType(pdType), []byte("rege-redwood-1")))
vals := appKeepers.InterchainstakingKeeper.GetValidators(ctx, OsmosisTestnetChainID)
for _, val := range vals {
valoper, _ := utils.ValAddressFromBech32(val.ValoperAddress, "osmovaloper")
valoper, _ := addressutils.ValAddressFromBech32(val.ValoperAddress, "osmovaloper")
appKeepers.InterchainstakingKeeper.DeleteValidator(ctx, OsmosisTestnetChainID, valoper)
}
}
Expand All @@ -109,8 +110,8 @@ func V010402rc4UpgradeHandler(
if !exists {
panic("liquid tokens protocol data type not found")
}
appKeepers.ParticipationRewardsKeeper.DeleteProtocolData(ctx, string(prtypes.GetProtocolDataKey(prtypes.ProtocolDataType(pdType), "osmo-test-5/ibc/FBD3AC18A981B89F60F9FE5B21BD7F1DE87A53C3505D5A5E438E2399409CFB6F")))
appKeepers.ParticipationRewardsKeeper.DeleteProtocolData(ctx, string(prtypes.GetProtocolDataKey(prtypes.ProtocolDataType(pdType), "rhye-1/uqosmo")))
appKeepers.ParticipationRewardsKeeper.DeleteProtocolData(ctx, prtypes.GetProtocolDataKey(prtypes.ProtocolDataType(pdType), []byte("osmo-test-5/ibc/FBD3AC18A981B89F60F9FE5B21BD7F1DE87A53C3505D5A5E438E2399409CFB6F")))
appKeepers.ParticipationRewardsKeeper.DeleteProtocolData(ctx, prtypes.GetProtocolDataKey(prtypes.ProtocolDataType(pdType), []byte("rhye-1/uqosmo")))
rcptTime := time.Unix(1682932342, 0)
rcpt1 := types.Receipt{
ChainId: "theta-testnet-001",
Expand Down Expand Up @@ -250,6 +251,30 @@ func V010402rc6UpgradeHandler(
}
}

func V010403rc0UpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
appKeepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
if isTestnet(ctx) || isTest(ctx) {
appKeepers.ParticipationRewardsKeeper.IteratePrefixedProtocolDatas(ctx, prtypes.GetPrefixProtocolDataKey(prtypes.ProtocolDataTypeLiquidToken), func(index int64, key []byte, data prtypes.ProtocolData) (stop bool) {
prefixedKey := append(prtypes.GetPrefixProtocolDataKey(prtypes.ProtocolDataTypeLiquidToken), key...)
appKeepers.ParticipationRewardsKeeper.DeleteProtocolData(ctx, prefixedKey)
pd, err := prtypes.UnmarshalProtocolData(prtypes.ProtocolDataTypeLiquidToken, data.Data)
if err != nil {
panic(err)
}
newKey := pd.GenerateKey()
appKeepers.ParticipationRewardsKeeper.SetProtocolData(ctx, newKey, &data)
return false
})
}

return mm.RunMigrations(ctx, configurator, fromVM)
}
}

// func V010400UpgradeHandler(
// mm *module.Manager,
// configurator module.Configurator,
Expand Down
26 changes: 10 additions & 16 deletions app/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/stretchr/testify/suite"

"github.com/ingenuity-build/quicksilver/app/upgrades"
"github.com/ingenuity-build/quicksilver/utils"
"github.com/ingenuity-build/quicksilver/utils/addressutils"
icskeeper "github.com/ingenuity-build/quicksilver/x/interchainstaking/keeper"
icstypes "github.com/ingenuity-build/quicksilver/x/interchainstaking/types"
prtypes "github.com/ingenuity-build/quicksilver/x/participationrewards/types"
Expand Down Expand Up @@ -126,7 +126,7 @@ func (s *AppTestSuite) initTestZone() {

receipt := icstypes.Receipt{
ChainId: "uni-5",
Sender: utils.GenerateAccAddressForTest().String(),
Sender: addressutils.GenerateAddressForTestWithPrefix(zone.AccountPrefix),
Txhash: "TestDeposit01",
Amount: sdk.NewCoins(
sdk.NewCoin(
Expand Down Expand Up @@ -178,7 +178,7 @@ func (s *AppTestSuite) initTestZone() {

wRecord := icstypes.WithdrawalRecord{
ChainId: "uni-5",
Delegator: utils.GenerateAccAddressForTest().String(),
Delegator: addressutils.GenerateAccAddressForTest().String(),
Distribution: []*icstypes.Distribution{
{Valoper: "junovaloper185hgkqs8q8ysnc8cvkgd8j2knnq2m0ah6ae73gntv9ampgwpmrxqlfzywn", Amount: 1000000},
{Valoper: "junovaloper1z89utvygweg5l56fsk8ak7t6hh88fd0aa9ywed", Amount: 1000000},
Expand All @@ -195,14 +195,8 @@ func (s *AppTestSuite) initTestZone() {
if err != nil {
return
}
addr1, err := utils.AccAddressFromBech32("quick17v9kk34km3w6hdjs2sn5s5qjdu2zrm0m3rgtmq", "quick")
if err != nil {
return
}
addr2, err := utils.AccAddressFromBech32("quick16x03wcp37kx5e8ehckjxvwcgk9j0cqnhcccnty", "quick")
if err != nil {
return
}
addr1 := addressutils.GenerateAccAddressForTest()
addr2 := addressutils.GenerateAccAddressForTest()

err = s.GetQuicksilverApp(s.chainA).BankKeeper.SendCoinsFromModuleToAccount(s.chainA.GetContext(), tokenfactorytypes.ModuleName, addr1, sdk.NewCoins(sdk.NewCoin("uqjunox", sdkmath.NewInt(1600000))))
if err != nil {
Expand Down Expand Up @@ -278,22 +272,22 @@ func (s *AppTestSuite) TestV010402rc1UpgradeHandler() {
app.InterchainstakingKeeper.IterateZones(ctx, func(index int64, zone *icstypes.Zone) (stop bool) {
if zone.ChainId == "uni-5" {
s.Require().Nil(zone.Validators)
valAddrBytes, err := utils.ValAddressFromBech32("junovaloper185hgkqs8q8ysnc8cvkgd8j2knnq2m0ah6ae73gntv9ampgwpmrxqlfzywn", "junovaloper")
valAddrBytes, err := addressutils.ValAddressFromBech32("junovaloper185hgkqs8q8ysnc8cvkgd8j2knnq2m0ah6ae73gntv9ampgwpmrxqlfzywn", "junovaloper")
s.Require().NoError(err)
_, found := app.InterchainstakingKeeper.GetValidator(ctx, zone.ChainId, valAddrBytes)
s.Require().True(found)
valAddrBytes2, err := utils.ValAddressFromBech32("junovaloper1z89utvygweg5l56fsk8ak7t6hh88fd0aa9ywed", "junovaloper")
valAddrBytes2, err := addressutils.ValAddressFromBech32("junovaloper1z89utvygweg5l56fsk8ak7t6hh88fd0aa9ywed", "junovaloper")
s.Require().NoError(err)
_, found = app.InterchainstakingKeeper.GetValidator(ctx, zone.ChainId, valAddrBytes2)
s.Require().True(found)
}
if zone.ChainId == "osmosis-1" {
s.Require().Nil(zone.Validators)
valAddrBytes, err := utils.ValAddressFromBech32("osmovaloper1zxavllftfx3a3y5ldfyze7jnu5uyuktsfx2jcc", "osmovaloper")
valAddrBytes, err := addressutils.ValAddressFromBech32("osmovaloper1zxavllftfx3a3y5ldfyze7jnu5uyuktsfx2jcc", "osmovaloper")
s.Require().NoError(err)
_, found := app.InterchainstakingKeeper.GetValidator(ctx, zone.ChainId, valAddrBytes)
s.Require().True(found)
valAddrBytes2, err := utils.ValAddressFromBech32("osmovaloper13eq5c99ym05jn02e78l8cac2fagzgdhh4294zk", "osmovaloper")
valAddrBytes2, err := addressutils.ValAddressFromBech32("osmovaloper13eq5c99ym05jn02e78l8cac2fagzgdhh4294zk", "osmovaloper")
s.Require().NoError(err)
_, found = app.InterchainstakingKeeper.GetValidator(ctx, zone.ChainId, valAddrBytes2)
s.Require().True(found)
Expand All @@ -316,7 +310,7 @@ func (s *AppTestSuite) TestV010402rc3UpgradeHandler() {
Data: []byte(`{"ConnectionID":"connection-2","ChainID":"regen-redwood-1","Prefix":"regen"}`),
}

app.ParticipationRewardsKeeper.SetProtocolData(ctx, string(prtypes.GetProtocolDataKey(prtypes.ProtocolDataType(pdType), "rege-redwood-1")), &prData)
app.ParticipationRewardsKeeper.SetProtocolData(ctx, prtypes.GetProtocolDataKey(prtypes.ProtocolDataType(pdType), []byte("rege-redwood-1")), &prData)
val0 := icstypes.Validator{ValoperAddress: "osmovaloper1zxavllftfx3a3y5ldfyze7jnu5uyuktsfx2jcc", CommissionRate: sdk.MustNewDecFromStr("1"), VotingPower: sdk.NewInt(2000), Status: stakingtypes.BondStatusBonded}
app.InterchainstakingKeeper.SetValidator(ctx, upgrades.OsmosisTestnetChainID, val0)
val1 := icstypes.Validator{ValoperAddress: "osmovaloper13eq5c99ym05jn02e78l8cac2fagzgdhh4294zk", CommissionRate: sdk.MustNewDecFromStr("1"), VotingPower: sdk.NewInt(2000), Status: stakingtypes.BondStatusBonded}
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ services:
- osmosisd
- start
hermes:
image: quicksilverzone/hermes:v1.4.0
image: quicksilverzone/hermes:v1.5.0
hostname: hermes
volumes:
- ./data/hermes:/hermes/.hermes
Expand All @@ -110,23 +110,23 @@ services:
context: .
dockerfile: Dockerfile.hermes
icq:
image: quicksilverzone/interchain-queries:v0.8.7
image: quicksilverzone/interchain-queries:v0.9.1
volumes:
- ./data/icq:/icq/.icq
command:
- interchain-queries
- run
restart: always
icq2:
image: quicksilverzone/interchain-queries:v0.6.2
image: quicksilverzone/interchain-queries:v0.9.1
volumes:
- ./data/icq2:/icq/.icq
command:
- interchain-queries
- run
restart: always
relayer:
image: quicksilverzone/relayer:v2.1.1
image: quicksilverzone/relayer:v2.3.0
build:
context: .
dockerfile: Dockerfile.relayer
Expand Down
Loading

0 comments on commit c5fbdb3

Please sign in to comment.