diff --git a/.dockerignore b/.dockerignore index 27f51f3c1..8654e8453 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,6 @@ -# build +build rocksdb data Dockerfile scripts/tg271/data +web-ui diff --git a/Dockerfile b/Dockerfile index 47faa5c5e..15d00fcb0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,12 +9,12 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/root/go/pkg/mod \ go mod download -# Cosmwasm - download correct libwasmvm version -RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 2) && \ - wget https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}/libwasmvm_muslc.$(uname -m).a \ +RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | sed 's/.* //') && \ + wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$ARCH.a \ -O /lib/libwasmvm_muslc.a && \ - wget https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}/checksums.txt -O /tmp/checksums.txt && \ - sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep $(uname -m) | cut -d ' ' -f 1) + # verify checksum + wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \ + sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$ARCH | cut -d ' ' -f 1) COPY . . RUN --mount=type=cache,target=/root/.cache/go-build \ diff --git a/Dockerfile.hermes b/Dockerfile.hermes index 471e6ed95..fd18654a7 100644 --- a/Dockerfile.hermes +++ b/Dockerfile.hermes @@ -1,14 +1,14 @@ FROM rust:1.72 as build +ARG VERSION RUN apt update && apt install git -y WORKDIR /app/src -RUN git clone https://github.com/informalsystems/ibc-rs --branch v1.5.0 +RUN git clone https://github.com/informalsystems/ibc-rs --branch $VERSION WORKDIR ibc-rs -RUN sed -i 's/CHUNK_LENGTH: usize = 50;/CHUNK_LENGTH: usize = 3;/' ./crates/relayer/src/link/packet_events.rs RUN cargo build --release FROM debian:bullseye-slim diff --git a/Dockerfile.osmosis b/Dockerfile.osmosis index 89475d00e..1487a173c 100644 --- a/Dockerfile.osmosis +++ b/Dockerfile.osmosis @@ -2,24 +2,22 @@ # Build # -------------------------------------------------------- -FROM golang:1.21-alpine3.18 as build +FROM golang:1.20.11-alpine3.18 as build RUN set -eux; apk add --no-cache ca-certificates build-base; RUN apk add git # Needed by github.com/zondax/hid RUN apk add linux-headers -RUN git clone https://github.com/osmosis-labs/osmosis /osmosis --branch v12.1.0 +RUN git clone https://github.com/osmosis-labs/osmosis /osmosis --branch v21.1.2 WORKDIR /osmosis -# CosmWasm: see https://github.com/CosmWasm/wasmvm/releases -ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a -ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a -RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7d2239e9f25e96d0d4daba982ce92367aacf0cbd95d2facb8442268f2b1cc1fc -RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479 - -# CosmWasm: copy the right library according to architecture. The final location will be found by the linker flag `-lwasmvm_muslc` -RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a +RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | sed 's/.* //') && \ + wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$ARCH.a \ + -O /lib/libwasmvm_muslc.a && \ + # verify checksum + wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \ + sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$ARCH | cut -d ' ' -f 1) RUN BUILD_TAGS=muslc LINK_STATICALLY=true make build @@ -27,7 +25,7 @@ RUN BUILD_TAGS=muslc LINK_STATICALLY=true make build # Runner # -------------------------------------------------------- -FROM debian:11 +FROM alpine:3.18 RUN apt update && apt install bash -y COPY --from=build /osmosis/build/osmosisd /bin/osmosisd diff --git a/Dockerfile.relayer b/Dockerfile.relayer index b25a8c1b0..39a13872c 100644 --- a/Dockerfile.relayer +++ b/Dockerfile.relayer @@ -1,4 +1,4 @@ -FROM golang:1.21-alpine3.18 AS builder +FROM golang:1.21.5-alpine3.18 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 @@ -8,7 +8,7 @@ RUN go mod download RUN make build # Add to a distroless container -FROM alpine:3.15 +FROM alpine:3.18 COPY --from=builder /src/app/build/rly /usr/local/bin/rly RUN adduser -S -h /rly -D rly -u 1000 USER rly diff --git a/Makefile b/Makefile index 6de018f7e..8e73e44a6 100755 --- a/Makefile +++ b/Makefile @@ -25,6 +25,8 @@ DOCKER_TAG := $(COMMIT_HASH) GO_MAJOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1) GO_MINOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2) +HERMES_VERSION=v1.7.4 + export GO111MODULE = on # Default target executed when no arguments are given to make. @@ -102,10 +104,7 @@ endif build_tags += $(BUILD_TAGS) build_tags := $(strip $(build_tags)) -whitespace := -whitespace += $(whitespace) -comma := , -build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags)) +build_tags_comma_sep := $(shell echo $(build_tags) | sed 's/ /,/g') ldflags += -X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS))) @@ -147,12 +146,12 @@ $(BUILDDIR)/: mkdir -p $(BUILDDIR)/ build-docker: - DOCKER_BUILDKIT=1 $(DOCKER) build . -f Dockerfile -t quicksilverzone/quicksilver:$(DOCKER_VERSION) -t quicksilverzone/quicksilver:latest + $(DOCKER) build . -f Dockerfile -t quicksilverzone/quicksilver:$(DOCKER_VERSION) -t quicksilverzone/quicksilver:latest -build-docker-local: build - DOCKER_BUILDKIT=1 $(DOCKER) build -f Dockerfile.local . -t quicksilverzone/quicksilver:$(DOCKER_VERSION) +build-docker-xbuild: + $(DOCKER) buildx build --platform linux/amd64 . -f Dockerfile -t quicksilverzone/quicksilver:$(DOCKER_VERSION) -t quicksilverzone/quicksilver:latest -build-docker-release: build-docker +build-docker-release: build-docker-xbuild $(DOCKER) run -v /tmp:/tmp quicksilverzone/quicksilver:$(DOCKER_VERSION) cp /usr/local/bin/quicksilverd /tmp/quicksilverd mv /tmp/quicksilverd build/quicksilverd-$(DOCKER_VERSION)-amd64 @@ -537,4 +536,10 @@ proto-setup: @$(DOCKER) build --rm --tag quicksilver-proto:latest --file proto/Dockerfile . @echo "✅ Setup protobuf environment!" +### Other tools +.PHONY: hermes-build + +hermes-build: + docker buildx build --platform linux/amd64 --build-arg VERSION=$HERMES_VERSION -f Dockerfile.hermes . -t quicksilverzone/hermes:$HERMES_VERSION + docker push quicksilverzone/hermes:$HERMES_VERSION diff --git a/app/app.go b/app/app.go index 177e11381..76038d486 100644 --- a/app/app.go +++ b/app/app.go @@ -115,6 +115,7 @@ func NewQuicksilver( appOpts servertypes.AppOptions, wasmOpts []wasm.Option, mock bool, + enableSupplyEndpoint bool, baseAppOptions ...func(*baseapp.BaseApp), ) *Quicksilver { appCodec := encodingConfig.Marshaler @@ -162,6 +163,7 @@ func NewQuicksilver( wasmConfig, enabledProposals, wasmOpts, + enableSupplyEndpoint, ) // **** Module Options ****/ diff --git a/app/app_test.go b/app/app_test.go index 309cd8d9b..b8356a5b2 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -56,6 +56,7 @@ func TestQuicksilverExport(t *testing.T) { app.EmptyAppOptions{}, app.GetWasmOpts(app.EmptyAppOptions{}), false, + false, ) genesisState := app.NewDefaultGenesisState() @@ -87,6 +88,7 @@ func TestQuicksilverExport(t *testing.T) { app.EmptyAppOptions{}, app.GetWasmOpts(app.EmptyAppOptions{}), false, + false, ) _, err = app2.ExportAppStateAndValidators(false, []string{}) require.NoError(t, err, "ExportAppStateAndValidators should not have an error") diff --git a/app/config.go b/app/config.go index 2f315c537..793d97ca6 100644 --- a/app/config.go +++ b/app/config.go @@ -59,6 +59,7 @@ func NewAppConstructor(encCfg EncodingConfig) network.AppConstructor { EmptyAppOptions{}, GetWasmOpts(EmptyAppOptions{}), false, + false, baseapp.SetPruning(purningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), // baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices), ) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 16a6c4125..ba6ceb6d4 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -154,6 +154,7 @@ func NewAppKeepers( wasmConfig wasm.Config, wasmEnabledProposals []wasm.ProposalType, wasmOpts []wasm.Option, + supplyEndpointEnabled bool, ) AppKeepers { appKeepers := AppKeepers{} @@ -183,6 +184,7 @@ func NewAppKeepers( wasmConfig, wasmEnabledProposals, wasmOpts, + supplyEndpointEnabled, ) appKeepers.SetupHooks() @@ -206,6 +208,7 @@ func (appKeepers *AppKeepers) InitKeepers( wasmConfig wasm.Config, wasmEnabledProposals []wasm.ProposalType, wasmOpts []wasm.Option, + supplyEndpointEnabled bool, ) { // Add 'normal' keepers proofOpsFn := utils.ValidateProofOps @@ -352,6 +355,7 @@ func (appKeepers *AppKeepers) InitKeepers( appKeepers.BankKeeper, appKeepers.StakingKeeper, utils.Keys[[]string](maccPerms), + supplyEndpointEnabled, ) appKeepers.PacketForwardKeeper.SetTransferKeeper(appKeepers.TransferKeeper) appKeepers.TransferModule = transfer.NewAppModule(appKeepers.TransferKeeper) diff --git a/app/modules.go b/app/modules.go index c29a093d8..45d35ca1e 100644 --- a/app/modules.go +++ b/app/modules.go @@ -66,6 +66,7 @@ import ( "github.com/quicksilver-zone/quicksilver/x/participationrewards" participationrewardsclient "github.com/quicksilver-zone/quicksilver/x/participationrewards/client" participationrewardstypes "github.com/quicksilver-zone/quicksilver/x/participationrewards/types" + "github.com/quicksilver-zone/quicksilver/x/supply" supplytypes "github.com/quicksilver-zone/quicksilver/x/supply/types" "github.com/quicksilver-zone/quicksilver/x/tokenfactory" tokenfactorytypes "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" @@ -110,6 +111,7 @@ var ( airdrop.AppModuleBasic{}, tokenfactory.AppModuleBasic{}, wasm.AppModuleBasic{}, + supply.AppModuleBasic{}, ) // module account permissions. @@ -178,6 +180,7 @@ func appModules( airdrop.NewAppModule(appCodec, app.AirdropKeeper), tokenfactory.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper), wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), + supply.NewAppModule(appCodec, app.SupplyKeeper), } } @@ -216,6 +219,7 @@ func simulationModules( participationrewards.NewAppModule(appCodec, app.ParticipationRewardsKeeper), airdrop.NewAppModule(appCodec, app.AirdropKeeper), tokenfactory.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper), + // supply.NewAppModule(appCodec, app.SupplyKeeper), // wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), } } diff --git a/app/test_helpers.go b/app/test_helpers.go index 2f5d8ae05..3c3edf6b0 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -93,6 +93,7 @@ func Setup(t *testing.T, isCheckTx bool) *Quicksilver { EmptyAppOptions{}, GetWasmOpts(EmptyAppOptions{}), false, + false, ) genesisState := NewDefaultGenesisState() @@ -142,6 +143,7 @@ func SetupTestingApp() (testApp ibctesting.TestingApp, genesisState map[string]j EmptyAppOptions{}, GetWasmOpts(EmptyAppOptions{}), true, // set mock state to true + false, ) return app, NewDefaultGenesisState() } diff --git a/app/upgrades.go b/app/upgrades.go index 704e78b1d..67e5dd8a8 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -41,12 +41,6 @@ func (app *Quicksilver) setUpgradeStoreLoaders() { var storeUpgrades *storetypes.StoreUpgrades switch upgradeInfo.Name { // nolint:gocritic - // case v001000UpgradeName: - - // storeUpgrades = &storetypes.StoreUpgrades{ - // Added: []string{claimsmanagertypes.ModuleName}, - // } - case upgrades.V010402rc3UpgradeName: storeUpgrades = &storetypes.StoreUpgrades{ @@ -57,6 +51,12 @@ func (app *Quicksilver) setUpgradeStoreLoaders() { storeUpgrades = &storetypes.StoreUpgrades{ Added: []string{supplytypes.ModuleName}, } + + case upgrades.V010405UpgradeName: + storeUpgrades = &storetypes.StoreUpgrades{ + Added: []string{packetforwardtypes.ModuleName, supplytypes.ModuleName}, + } + default: // no-op } diff --git a/app/upgrades/types.go b/app/upgrades/types.go index c7d8f6dfc..70f08e5d9 100644 --- a/app/upgrades/types.go +++ b/app/upgrades/types.go @@ -12,14 +12,15 @@ import ( // upgrade name consts: vMMmmppUpgradeName (M=Major, m=minor, p=patch). const ( ProductionChainID = "quicksilver-2" - RhyeChainID = "rhye-1" - DevnetChainID = "magic-1" + RhyeChainID = "rhye-2" + DevnetChainID = "magic-2" TestChainID = "testchain1" OsmosisTestnetChainID = "osmo-test-5" JunoTestnetChainID = "uni-6" StargazeTestnetChainID = "elgafar-1" SommelierChainID = "sommelier-3" + // testnet upgrades V010402rc1UpgradeName = "v1.4.2-rc1" V010402rc2UpgradeName = "v1.4.2-rc2" V010402rc3UpgradeName = "v1.4.2-rc3" @@ -41,6 +42,10 @@ const ( V010404rc3UpgradeName = "v1.4.4-rc.3" V010404rc4UpgradeName = "v1.4.4-rc.4" V010405rc0UpgradeName = "v1.4.5-rc0" + V010405rc2UpgradeName = "v1.4.5-rc2" + + // mainnet upgrades + V010405UpgradeName = "v1.4.5" ) // Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal diff --git a/app/upgrades/upgrades.go b/app/upgrades/upgrades.go index 45bdba5b2..b782383d1 100644 --- a/app/upgrades/upgrades.go +++ b/app/upgrades/upgrades.go @@ -41,6 +41,8 @@ func Upgrades() []Upgrade { {UpgradeName: V010404rc2UpgradeName, CreateUpgradeHandler: V010404beta10UpgradeHandler}, {UpgradeName: V010404rc3UpgradeName, CreateUpgradeHandler: NoOpHandler}, {UpgradeName: V010404rc4UpgradeName, CreateUpgradeHandler: NoOpHandler}, + {UpgradeName: V010405rc2UpgradeName, CreateUpgradeHandler: NoOpHandler}, + {UpgradeName: V010405UpgradeName, CreateUpgradeHandler: NoOpHandler}, } } diff --git a/cmd/quicksilverd/root.go b/cmd/quicksilverd/root.go index 4631fb330..c2db48690 100644 --- a/cmd/quicksilverd/root.go +++ b/cmd/quicksilverd/root.go @@ -42,7 +42,8 @@ import ( ) const ( - EnvPrefix = "QUICK" + EnvPrefix = "QUICK" + FlagSupplyEnabled = "supply.enabled" ) type appCreator struct { @@ -134,8 +135,8 @@ func initTendermintConfig() *tmcfg.Config { cfg := tmcfg.DefaultConfig() // peers - cfg.P2P.MaxNumInboundPeers = 200 - cfg.P2P.MaxNumOutboundPeers = 40 + cfg.P2P.MaxNumInboundPeers = 30 + cfg.P2P.MaxNumOutboundPeers = 20 // block times (this comes in post-50) // cfg.Consensus.TimeoutCommit = 2 * time.Second // 2s blocks, think more on it later @@ -262,6 +263,7 @@ func (ac appCreator) newApp( appOpts, wasmOpts, false, + cast.ToBool(appOpts.Get(FlagSupplyEnabled)), baseapp.SetPruning(pruningOpts), baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))), baseapp.SetHaltHeight(cast.ToUint64(appOpts.Get(server.FlagHaltHeight))), @@ -276,6 +278,7 @@ func (ac appCreator) newApp( func addModuleInitFlags(startCmd *cobra.Command) { crisis.AddModuleInitFlags(startCmd) + startCmd.Flags().Bool(FlagSupplyEnabled, false, "Enable supply module endpoint") } func (ac appCreator) appExport( @@ -311,6 +314,7 @@ func (ac appCreator) appExport( appOpts, emptyWasmOpts, false, + false, ) if height != -1 { diff --git a/go.mod b/go.mod index 69dda91a3..b18e631c7 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,6 @@ require ( github.com/gorilla/mux v1.8.1 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/ingenuity-build/multierror v0.1.0 - github.com/iqlusioninc/liquidity-staking-module v1.0.0 github.com/prometheus/client_golang v1.17.0 github.com/rakyll/statik v0.1.7 github.com/spf13/cast v1.6.0 @@ -34,9 +33,9 @@ require ( github.com/tendermint/tendermint v0.34.29 github.com/tendermint/tm-db v0.6.8-0.20220506192307-f628bb5dc95b go.opencensus.io v0.24.0 - golang.org/x/exp v0.0.0-20230905200255-921286631fa9 + golang.org/x/exp v0.0.0-20231127185646-65229373498e golang.org/x/tools v0.16.1 - google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 + google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 google.golang.org/grpc v1.60.1 google.golang.org/protobuf v1.32.0 gopkg.in/yaml.v2 v2.4.0 @@ -315,7 +314,7 @@ require ( golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.153.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 // indirect + google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect gopkg.in/ini.v1 v1.67.0 // indirect honnef.co/go/tools v0.4.6 // indirect @@ -338,8 +337,6 @@ replace ( // use cosmos flavored protobufs github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 - // import 46'd lsm - github.com/iqlusioninc/liquidity-staking-module => github.com/notional-labs/liquidity-staking-module v0.0.3-0.20220914043211-d4675d9af6ae // replace broken goleveldb github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // use cometbft diff --git a/go.sum b/go.sum index cf730e27d..54c919762 100644 --- a/go.sum +++ b/go.sum @@ -988,8 +988,6 @@ github.com/nishanths/exhaustive v0.11.0 h1:T3I8nUGhl/Cwu5Z2hfc92l0e04D2GEW6e0l8p github.com/nishanths/exhaustive v0.11.0/go.mod h1:RqwDsZ1xY0dNdqHho2z6X+bgzizwbLYOWnZbbl2wLB4= github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk= github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c= -github.com/notional-labs/liquidity-staking-module v0.0.3-0.20220914043211-d4675d9af6ae h1:graJYtXw+vsZAvlLgfcejEQ5vsFs1LaPJ0Ek7vcysGY= -github.com/notional-labs/liquidity-staking-module v0.0.3-0.20220914043211-d4675d9af6ae/go.mod h1:56yrn9/cmuDbUn8BJ9XNXyuYw0ZbqUN11I3bl0Tb/7Y= github.com/notional-labs/tm-db v0.6.8-0.20230214123107-77c191d0f7ee h1:wr7Se0X/SHUeYzwXhj6eEZRJNrv6u01MMjdbFSiQAYw= github.com/notional-labs/tm-db v0.6.8-0.20230214123107-77c191d0f7ee/go.mod h1:lD+ep9hiDc0VXg9gZcI14OQuxkt+Dubtsz2FDzPlPvQ= github.com/notional-labs/wasmd v0.29.0-sdk46.0.20221114145317-d6e67fd50956 h1:gT+v1UFkZAL9GK5paedZPxL8Venc7SqbrAuKBh1q5Jk= @@ -1376,8 +1374,8 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= +golang.org/x/exp v0.0.0-20231127185646-65229373498e h1:Gvh4YaCaXNs6dKTlfgismwWZKyjVZXwOPfIyUaqU3No= +golang.org/x/exp v0.0.0-20231127185646-65229373498e/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 h1:jWGQJV4niP+CCmFW9ekjA9Zx8vYORzOUH2/Nl5WPuLQ= @@ -1914,10 +1912,10 @@ google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e/go.mod h1:3526vdqw google.golang.org/genproto v0.0.0-20221014173430-6e2ab493f96b/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= -google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 h1:wpZ8pe2x1Q3f2KyT5f8oP/fa9rHAKgFPr/HZdNuS+PQ= -google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:J7XzRzVy1+IPwWHZUzoD0IccYZIrXILAQpc+Qy9CMhY= -google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 h1:JpwMPBpFN3uKhdaekDpiNlImDdkUAyiJ6ez/uxGaUSo= -google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:0xJLfVdJqpAPl8tDg1ujOCGzx6LFLttXT5NhllGOXY4= +google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f h1:Vn+VyHU5guc9KjB5KrjI2q0wCOWEOIh0OEsleqakHJg= +google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f/go.mod h1:nWSwAFPb+qfNJXsoeO3Io7zf4tMSfN8EA8RlDA04GhY= +google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 h1:ZcOkrmX74HbKFYnpPY8Qsw93fC29TbJXspYKaBkSXDQ= +google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4/go.mod h1:k2dtGpRrbsSyKcNPKKI5sstZkrNCZwpU/ns96JoHbGg= google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f h1:ultW7fxlIvee4HYrtnaRPon9HpEgFk5zYpmfMgtKB5I= google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f/go.mod h1:L9KNLi232K1/xB6f7AlSX692koaRnKaWSR0stBki0Yc= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= diff --git a/icq-relayer/Dockerfile b/icq-relayer/Dockerfile index 1b4e96738..9594177e8 100644 --- a/icq-relayer/Dockerfile +++ b/icq-relayer/Dockerfile @@ -1,4 +1,4 @@ -FROM 1.20.11-alpine3.18 as build +FROM golang:1.21.5-alpine3.18 as build WORKDIR /src/app @@ -13,7 +13,7 @@ COPY . . RUN go build -FROM alpine:edge +FROM alpine:3.19 RUN apk add --no-cache ca-certificates diff --git a/proto/Dockerfile b/proto/Dockerfile index 3dd0de5f7..30a4baee5 100644 --- a/proto/Dockerfile +++ b/proto/Dockerfile @@ -1,5 +1,5 @@ FROM bufbuild/buf:latest as BUILDER -FROM golang:1.21.5-alpine +FROM golang:1.21.5-alpine3.18 RUN apk add --no-cache \ nodejs \ diff --git a/proto/quicksilver/supply/v1/query.proto b/proto/quicksilver/supply/v1/query.proto index 2e087a032..cd4282d1d 100644 --- a/proto/quicksilver/supply/v1/query.proto +++ b/proto/quicksilver/supply/v1/query.proto @@ -3,7 +3,7 @@ package quicksilver.supply.v1; import "google/api/annotations.proto"; -option go_package = "github.com/ingenuity-build/quicksilver/x/supply/types"; +option go_package = "github.com/quicksilver-zone/quicksilver/x/supply/types"; // Query defines the gRPC querier service. service Query { diff --git a/server/config/config.go b/server/config/config.go index 455a38cd0..a0bd84d6f 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -21,7 +21,8 @@ const ( // from the SDK as well as the TLS configuration. type Config struct { config.Config - TLS TLSConfig `mapstructure:"tls"` + TLS TLSConfig `mapstructure:"tls"` + Supply SupplyConfig `mapstructure:"supply"` } // TLSConfig defines the certificate and matching private key for the server. @@ -32,6 +33,11 @@ type TLSConfig struct { KeyPath string `mapstructure:"key-path"` } +type SupplyConfig struct { + // Enabled determines whether we expose the supply endpoint. + Enabled bool `mapstructure:"enabled"` +} + // AppConfig helps to override default appConfig template and configs. // return "", nil if no custom configuration is required for the application. func AppConfig(denom string) (customAppTemplate string, customAppConfig interface{}) { @@ -58,6 +64,7 @@ func AppConfig(denom string) (customAppTemplate string, customAppConfig interfac customAppConfig = Config{ Config: *srvCfg, TLS: *DefaultTLSConfig(), + Supply: *DefaultSupplyConfig(), } customAppTemplate = config.DefaultConfigTemplate + DefaultConfigTemplate @@ -70,6 +77,14 @@ func DefaultConfig() *Config { return &Config{ Config: *config.DefaultConfig(), TLS: *DefaultTLSConfig(), + Supply: *DefaultSupplyConfig(), + } +} + +// DefaultConfig returns server's default configuration. +func DefaultSupplyConfig() *SupplyConfig { + return &SupplyConfig{ + Enabled: false, } } @@ -108,6 +123,9 @@ func GetConfig(v *viper.Viper) Config { CertificatePath: v.GetString("tls.certificate-path"), KeyPath: v.GetString("tls.key-path"), }, + Supply: SupplyConfig{ + Enabled: v.GetBool("supply.enabled"), + }, } } diff --git a/server/config/template.go b/server/config/template.go index 6abf7441a..54c1a75d4 100644 --- a/server/config/template.go +++ b/server/config/template.go @@ -10,4 +10,8 @@ const DefaultConfigTemplate = ` certificate-path = "{{ .TLS.CertificatePath }}" # Key path defines the key.pem file path for the TLS configuration. key-path = "{{ .TLS.KeyPath }}" + +[supply] +# The supply module endpoint is resource intensive, and should never be opened publicly. +enabled = "{{ .Supply.Enabled }}" ` diff --git a/test/simulation/sim_test.go b/test/simulation/sim_test.go index e3f994ad3..aa7bc8f13 100644 --- a/test/simulation/sim_test.go +++ b/test/simulation/sim_test.go @@ -60,6 +60,7 @@ func BenchmarkSimulation(b *testing.B) { app.EmptyAppOptions{}, app.GetWasmOpts(app.EmptyAppOptions{}), false, + false, ) // Run randomized simulations @@ -120,6 +121,7 @@ func TestAppStateDeterminism(t *testing.T) { app.EmptyAppOptions{}, app.GetWasmOpts(app.EmptyAppOptions{}), false, + false, interBlockCacheOpt(), ) diff --git a/x/interchainquery/types/msgs.go b/x/interchainquery/types/msgs.go index 4fc9f8899..636135a7a 100644 --- a/x/interchainquery/types/msgs.go +++ b/x/interchainquery/types/msgs.go @@ -33,7 +33,7 @@ func (msg MsgSubmitQueryResponse) ValidateBasic() error { // TODO: is there a chain validation spec in ICS? chainParts := strings.Split(msg.ChainId, "-") - if len(chainParts) < 2 { + if len(chainParts) < 2 && msg.ChainId != "provider" { return errors.New("chainID must be of form XXXX-N") } diff --git a/x/interchainstaking/client/cli/tx.go b/x/interchainstaking/client/cli/tx.go index ddc63546d..a6bfc5a84 100644 --- a/x/interchainstaking/client/cli/tx.go +++ b/x/interchainstaking/client/cli/tx.go @@ -175,7 +175,7 @@ Where proposal.json contains: from := clientCtx.GetFromAddress() content := types.NewRegisterZoneProposal(proposal.Title, proposal.Description, proposal.ConnectionId, proposal.BaseDenom, - proposal.LocalDenom, proposal.AccountPrefix, proposal.ReturnToSender, proposal.UnbondingEnabled, proposal.DepositsEnabled, proposal.LiquidityModule, proposal.Decimals, proposal.MessagesPerTx) + proposal.LocalDenom, proposal.AccountPrefix, proposal.ReturnToSender, proposal.UnbondingEnabled, proposal.DepositsEnabled, proposal.LiquidityModule, proposal.Decimals, proposal.MessagesPerTx, proposal.Is_118) msg, err := govv1beta1.NewMsgSubmitProposal(content, deposit, from) if err != nil { diff --git a/x/interchainstaking/keeper/callbacks.go b/x/interchainstaking/keeper/callbacks.go index 6c6d4cc25..061c27a2d 100644 --- a/x/interchainstaking/keeper/callbacks.go +++ b/x/interchainstaking/keeper/callbacks.go @@ -274,6 +274,7 @@ func SigningInfoCallback(k *Keeper, ctx sdk.Context, args []byte, query icqtypes valSigningInfo := slashingtypes.ValidatorSigningInfo{} if len(args) == 0 { + k.Logger(ctx).Error("unable to find signing info for validator", "query", query.Request) return errors.New("attempted to unmarshal zero length byte slice (10)") } err := k.cdc.Unmarshal(args, &valSigningInfo) @@ -281,7 +282,7 @@ func SigningInfoCallback(k *Keeper, ctx sdk.Context, args []byte, query icqtypes return err } if valSigningInfo.Tombstoned { - consAddr, err := sdk.ConsAddressFromBech32(valSigningInfo.Address) + consAddr, err := addressutils.AddressFromBech32(valSigningInfo.Address, "") if err != nil { return err } @@ -297,6 +298,7 @@ func SigningInfoCallback(k *Keeper, ctx sdk.Context, args []byte, query icqtypes return err } val, found := k.GetValidator(ctx, zone.ChainId, valAddrBytes) + // NOTE: this shouldn't be reachable, but keeping here as it doesn't do any harm. if !found { err := k.SetValidator(ctx, zone.ChainId, types.Validator{ ValoperAddress: valAddr, @@ -312,11 +314,9 @@ func SigningInfoCallback(k *Keeper, ctx sdk.Context, args []byte, query icqtypes return err } } - k.Logger(ctx).Info("%q on chainID: %q was found to already have been tombstoned, added information", val.ValoperAddress, zone.ChainId) + k.Logger(ctx).Info(fmt.Sprintf("%q on chainID: %q was found to already have been tombstoned, added information", val.ValoperAddress, zone.ChainId)) - return nil } - return nil } diff --git a/x/interchainstaking/keeper/keeper.go b/x/interchainstaking/keeper/keeper.go index 9781964f3..0addccd1c 100644 --- a/x/interchainstaking/keeper/keeper.go +++ b/x/interchainstaking/keeper/keeper.go @@ -254,8 +254,10 @@ func (k *Keeper) SetValidatorsForZone(ctx sdk.Context, data []byte, icqQuery icq } if toQuery { - err := k.EmitValidatorQuery(ctx, icqQuery.ConnectionId, icqQuery.ChainId, validator) - k.Logger(ctx).Error("EmitValidatorQuery error", "valoper", validator.OperatorAddress, "err", err) + if err := k.EmitValidatorQuery(ctx, icqQuery.ConnectionId, icqQuery.ChainId, validator); err != nil { + k.Logger(ctx).Error("EmitValidatorQuery error", "valoper", validator.OperatorAddress, "err", err) + return err + } } } @@ -300,12 +302,7 @@ func (k *Keeper) SetValidatorForZone(ctx sdk.Context, zone *types.Zone, data []b return err } } - _, found := k.GetValidator(ctx, zone.ChainId, valAddrBytes) - // if found is true, it means that validator was tombstoned because we set it's information in SigningInfoCallback func - if found { - k.Logger(ctx).Info("%q on chainID: %q have been tombstoned", validator.OperatorAddress, zone.ChainId) - return nil - } + if err := k.SetValidator(ctx, zone.ChainId, types.Validator{ ValoperAddress: validator.OperatorAddress, CommissionRate: validator.GetCommission(), @@ -324,7 +321,7 @@ func (k *Keeper) SetValidatorForZone(ctx sdk.Context, zone *types.Zone, data []b } } else { if val.Tombstoned { - k.Logger(ctx).Info("%q on chainID: %q was found to already have been tombstoned", validator.OperatorAddress, zone.ChainId) + k.Logger(ctx).Debug(fmt.Sprintf("%q on chainID: %q was found to already have been tombstoned; not updating state.", validator.OperatorAddress, zone.ChainId)) return nil } @@ -343,13 +340,11 @@ func (k *Keeper) SetValidatorForZone(ctx sdk.Context, zone *types.Zone, data []b if err != nil { return err } - val, _ := k.GetValidator(ctx, zone.ChainId, valAddrBytes) - if val.Tombstoned { - return nil - } val.Jailed = true val.JailedSince = ctx.BlockTime() + + // be defensive, so we don't get division weirdness! if !val.VotingPower.IsPositive() { return fmt.Errorf("existing voting power must be greater than zero, received %s", val.VotingPower) } @@ -516,6 +511,9 @@ func (k *Keeper) EmitPerformanceBalanceQuery(ctx sdk.Context, zone *types.Zone) 100, ) + zone.PerformanceAddress.BalanceWaitgroup = 1 + k.SetZone(ctx, zone) + return nil } @@ -586,11 +584,12 @@ func (k *Keeper) EmitDepositIntervalQuery(ctx sdk.Context, zone *types.Zone) { } func (k *Keeper) EmitSigningInfoQuery(ctx sdk.Context, connectionID, chainID string, validator lsmstakingtypes.Validator) error { - _, addr, err := bech32.DecodeAndConvert(validator.OperatorAddress) + consAddress, err := validator.GetConsAddr() if err != nil { return err } - data := slashingtypes.ValidatorSigningInfoKey(addr) + + data := slashingtypes.ValidatorSigningInfoKey(consAddress) k.ICQKeeper.MakeRequest( ctx, connectionID, diff --git a/x/interchainstaking/keeper/redemptions.go b/x/interchainstaking/keeper/redemptions.go index 6076b936c..c9ef25e83 100644 --- a/x/interchainstaking/keeper/redemptions.go +++ b/x/interchainstaking/keeper/redemptions.go @@ -6,8 +6,6 @@ import ( "sort" "time" - lsmstakingtypes "github.com/iqlusioninc/liquidity-staking-module/x/staking/types" - "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -16,6 +14,7 @@ import ( "github.com/quicksilver-zone/quicksilver/utils" epochstypes "github.com/quicksilver-zone/quicksilver/x/epochs/types" "github.com/quicksilver-zone/quicksilver/x/interchainstaking/types" + lsmstakingtypes "github.com/quicksilver-zone/quicksilver/x/lsmtypes" ) // processRedemptionForLsm will determine based on user intent, the tokens to return to the user, generate Redeem message and send them. diff --git a/x/interchainstaking/keeper/zones_test.go b/x/interchainstaking/keeper/zones_test.go index 5beaebed4..031285ba1 100644 --- a/x/interchainstaking/keeper/zones_test.go +++ b/x/interchainstaking/keeper/zones_test.go @@ -38,6 +38,7 @@ func newQuicksilver(t *testing.T) *app.Quicksilver { app.EmptyAppOptions{}, app.GetWasmOpts(app.EmptyAppOptions{}), true, + false, ) } diff --git a/x/interchainstaking/types/proposals.go b/x/interchainstaking/types/proposals.go index 3760d9c7b..ced9964af 100644 --- a/x/interchainstaking/types/proposals.go +++ b/x/interchainstaking/types/proposals.go @@ -32,6 +32,7 @@ func NewRegisterZoneProposal( liquidityModule bool, decimals int64, messagePerTx int64, + is118 bool, ) *RegisterZoneProposal { return &RegisterZoneProposal{ Title: title, @@ -46,6 +47,7 @@ func NewRegisterZoneProposal( LiquidityModule: liquidityModule, Decimals: decimals, MessagesPerTx: messagePerTx, + Is_118: is118, } } @@ -86,10 +88,6 @@ func (m RegisterZoneProposal) ValidateBasic() error { return errors.New("messages_per_tx must be a positive non-zero integer") } - if m.LiquidityModule { - return errors.New("liquidity module is unsupported") - } - if m.Decimals == 0 { return errors.New("decimals field is mandatory") } @@ -111,6 +109,7 @@ func (m RegisterZoneProposal) String() string { Liquidity Staking Module Enabled: %t Messages per Tx: %d Decimals: %d + Is_118: %t `, m.Title, m.Description, @@ -123,6 +122,7 @@ func (m RegisterZoneProposal) String() string { m.LiquidityModule, m.MessagesPerTx, m.Decimals, + m.Is_118, ) } diff --git a/x/interchainstaking/types/proposals_test.go b/x/interchainstaking/types/proposals_test.go index 71782b4ee..766ce96eb 100644 --- a/x/interchainstaking/types/proposals_test.go +++ b/x/interchainstaking/types/proposals_test.go @@ -23,6 +23,7 @@ func TestRegisterZoneProposal_ValidateBasic(t *testing.T) { LiquidityModule bool Decimals int64 MessagesPerTx int64 + Is118 bool } tests := []struct { name string @@ -44,6 +45,7 @@ func TestRegisterZoneProposal_ValidateBasic(t *testing.T) { LiquidityModule: false, Decimals: 6, MessagesPerTx: 5, + Is118: true, }, wantErr: false, }, @@ -62,6 +64,7 @@ func TestRegisterZoneProposal_ValidateBasic(t *testing.T) { LiquidityModule: false, Decimals: 6, MessagesPerTx: 5, + Is118: true, }, wantErr: true, }, @@ -80,6 +83,7 @@ func TestRegisterZoneProposal_ValidateBasic(t *testing.T) { LiquidityModule: false, Decimals: 6, MessagesPerTx: 5, + Is118: true, }, wantErr: true, }, @@ -98,6 +102,7 @@ func TestRegisterZoneProposal_ValidateBasic(t *testing.T) { LiquidityModule: false, Decimals: 6, MessagesPerTx: 5, + Is118: true, }, wantErr: true, }, @@ -116,6 +121,7 @@ func TestRegisterZoneProposal_ValidateBasic(t *testing.T) { LiquidityModule: false, Decimals: 6, MessagesPerTx: 5, + Is118: true, }, wantErr: true, }, @@ -134,24 +140,7 @@ func TestRegisterZoneProposal_ValidateBasic(t *testing.T) { LiquidityModule: false, Decimals: 6, MessagesPerTx: 5, - }, - wantErr: true, - }, - { - name: "liquidity", - fields: fields{ - Title: "Enable testzone-1", - Description: "onboard testzone-1", - ConnectionID: "connection-0", - BaseDenom: "uatom", - LocalDenom: "uqatom", - AccountPrefix: "cosmos", - ReturnToSender: false, - UnbondingEnabled: false, - Deposits: false, - LiquidityModule: true, - Decimals: 6, - MessagesPerTx: 5, + Is118: true, }, wantErr: true, }, @@ -170,6 +159,7 @@ func TestRegisterZoneProposal_ValidateBasic(t *testing.T) { LiquidityModule: false, Decimals: 0, MessagesPerTx: 5, + Is118: true, }, wantErr: true, }, @@ -188,6 +178,7 @@ func TestRegisterZoneProposal_ValidateBasic(t *testing.T) { LiquidityModule: false, Decimals: 0, MessagesPerTx: 0, + Is118: true, }, wantErr: true, }, @@ -206,6 +197,7 @@ func TestRegisterZoneProposal_ValidateBasic(t *testing.T) { LiquidityModule: false, Decimals: 0, MessagesPerTx: -1, + Is118: true, }, wantErr: true, }, @@ -225,6 +217,7 @@ func TestRegisterZoneProposal_ValidateBasic(t *testing.T) { tt.fields.LiquidityModule, tt.fields.Decimals, tt.fields.MessagesPerTx, + tt.fields.Is118, ) err := m.ValidateBasic() diff --git a/x/supply/keeper/grpc_query.go b/x/supply/keeper/grpc_query.go index 348ccf4c6..a2ac84cd0 100644 --- a/x/supply/keeper/grpc_query.go +++ b/x/supply/keeper/grpc_query.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "fmt" sdk "github.com/cosmos/cosmos-sdk/types" @@ -23,18 +24,23 @@ func NewQuerier(k Keeper) Querier { // Supply returns supply and circulating supply of the staking denom. func (q Querier) Supply(c context.Context, _ *types.QuerySupplyRequest) (*types.QuerySupplyResponse, error) { ctx := sdk.UnwrapSDKContext(c) - supply := q.Keeper.bankKeeper.GetSupply(ctx, q.Keeper.baseDenom) - circulatingSupply := q.Keeper.CalculateCirculatingSupply(ctx, []string{ - "quick1yxe3vmd2ypjf0fs4cejnmv2559tqq5x5cc5nyh", // foundation account - "quick1j5cgdlthhstqy2gqnglpjf4fvx3gs24yrcdtrf", // founder - "quick1puj8yjmgrvn4w8vfswsnx972lucywetd57zalh", // founder - "quick1d04jsq0kw4797kk4vp53y7hgmy8zdn8x7es279", // founder - "quick1etqtc49wywy9ptx2gplhj0nrw5hy48hzzc6n20", // founder - "quick1hdl587g7urer06myjkua86gc63vmq6pcr4d9hl", // founder - "quick1ghwtkyrdr8lxm6x8dyr0nkqzghny955qe4j6zr", // founder - "quick1a8dg5fuxtcwt8z6d9earl2sd0tukknx2txjm4j", // founder - "quick1e22za5qrqqp488h5p7vw2pfx8v0y4u444ufeuw", // ingenuity - }) - - return &types.QuerySupplyResponse{Supply: supply.Amount.Uint64(), CirculatingSupply: circulatingSupply.Uint64()}, nil + + if q.endpointEnabled { + baseDenom := q.stakingKeeper.BondDenom(ctx) + supply := q.bankKeeper.GetSupply(ctx, baseDenom) + circulatingSupply := q.CalculateCirculatingSupply(ctx, baseDenom, []string{ + "quick1yxe3vmd2ypjf0fs4cejnmv2559tqq5x5cc5nyh", // foundation account + "quick1j5cgdlthhstqy2gqnglpjf4fvx3gs24yrcdtrf", // founder + "quick1puj8yjmgrvn4w8vfswsnx972lucywetd57zalh", // founder + "quick1d04jsq0kw4797kk4vp53y7hgmy8zdn8x7es279", // founder + "quick1etqtc49wywy9ptx2gplhj0nrw5hy48hzzc6n20", // founder + "quick1hdl587g7urer06myjkua86gc63vmq6pcr4d9hl", // founder + "quick1ghwtkyrdr8lxm6x8dyr0nkqzghny955qe4j6zr", // founder + "quick1a8dg5fuxtcwt8z6d9earl2sd0tukknx2txjm4j", // founder + "quick1e22za5qrqqp488h5p7vw2pfx8v0y4u444ufeuw", // ingenuity + }) + + return &types.QuerySupplyResponse{Supply: supply.Amount.Uint64(), CirculatingSupply: circulatingSupply.Uint64()}, nil + } + return nil, fmt.Errorf("endpoint disabled") } diff --git a/x/supply/keeper/keeper.go b/x/supply/keeper/keeper.go index eaa9a5ac7..e7e8e7ab0 100644 --- a/x/supply/keeper/keeper.go +++ b/x/supply/keeper/keeper.go @@ -1,8 +1,6 @@ package keeper import ( - "fmt" - "github.com/tendermint/tendermint/libs/log" "cosmossdk.io/math" @@ -18,13 +16,13 @@ import ( // Keeper of the mint store. type Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - accountKeeper types.AccountKeeper - bankKeeper types.BankKeeper - stakingKeeper types.StakingKeeper - moduleAccounts []string - baseDenom string + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper + stakingKeeper types.StakingKeeper + moduleAccounts []string + endpointEnabled bool } // NewKeeper creates a new mint Keeper instance. @@ -35,14 +33,16 @@ func NewKeeper( bk types.BankKeeper, sk types.StakingKeeper, moduleAccounts []string, + endpointEnabled bool, ) Keeper { return Keeper{ - cdc: cdc, - storeKey: storeKey, - accountKeeper: ak, - bankKeeper: bk, - stakingKeeper: sk, - moduleAccounts: moduleAccounts, + cdc: cdc, + storeKey: storeKey, + accountKeeper: ak, + bankKeeper: bk, + stakingKeeper: sk, + moduleAccounts: moduleAccounts, + endpointEnabled: endpointEnabled, } } @@ -53,9 +53,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+types.ModuleName) } -func (k Keeper) CalculateCirculatingSupply(ctx sdk.Context, excludeAddresses []string) math.Int { - baseDenom := k.stakingKeeper.BondDenom(ctx) - // Creates context with current height and checks txs for ctx to be usable by start of next block +func (k Keeper) CalculateCirculatingSupply(ctx sdk.Context, baseDenom string, excludeAddresses []string) math.Int { nonCirculating := math.ZeroInt() k.accountKeeper.IterateAccounts(ctx, func(account authtypes.AccountI) (stop bool) { for _, addr := range excludeAddresses { @@ -75,10 +73,9 @@ func (k Keeper) CalculateCirculatingSupply(ctx sdk.Context, excludeAddresses []s if macc != stakingtypes.BondedPoolName && macc != stakingtypes.NotBondedPoolName { addr := k.accountKeeper.GetModuleAddress(macc) maccBalance := k.bankKeeper.GetBalance(ctx, addr, baseDenom).Amount - fmt.Println(macc, maccBalance) nonCirculating = nonCirculating.Add(maccBalance) } } - return k.bankKeeper.GetSupply(ctx, k.baseDenom).Amount.Sub(nonCirculating) + return k.bankKeeper.GetSupply(ctx, baseDenom).Amount.Sub(nonCirculating) } diff --git a/x/supply/module.go b/x/supply/module.go index 2c0b252b6..8cdd4a450 100644 --- a/x/supply/module.go +++ b/x/supply/module.go @@ -43,7 +43,7 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } // RegisterInterfaces registers the module's interface types -func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { +func (AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { } // DefaultGenesis returns the participationrewards module's default genesis state. @@ -65,7 +65,7 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r } // GetTxCmd returns the participationrewards module's root tx command. -func (a AppModuleBasic) GetTxCmd() *cobra.Command { +func (AppModuleBasic) GetTxCmd() *cobra.Command { return nil } @@ -95,11 +95,11 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { } // RegisterInvariants registers the participationrewards module invariants. -func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} +func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} // Route returns the message routing key for the participationrewards module. -func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(types.RouterKey, nil) +func (AppModule) Route() sdk.Route { + return sdk.Route{} } // QuerierRoute returns the participationrewards module's querier route name. @@ -108,7 +108,7 @@ func (AppModule) QuerierRoute() string { } // LegacyQuerierHandler returns the x/participationrewards module's sdk.Querier. -func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { +func (AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { return func(sdk.Context, []string, abci.RequestQuery) ([]byte, error) { return nil, fmt.Errorf("legacy querier not supported for the x/%s module", types.ModuleName) } @@ -122,22 +122,22 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { // InitGenesis performs the participationrewards module's genesis // initialization It returns no validator updates. -func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { +func (AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { return []abci.ValidatorUpdate{} } // ExportGenesis returns the participationrewards module's exported genesis state as raw JSON bytes. -func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { +func (AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { return nil } // BeginBlock executes all ABCI BeginBlock logic respective to the participationrewards module. -func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { +func (AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { } // EndBlock executes all ABCI EndBlock logic respective to the participationrewards module. It // returns no validator updates. -func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { +func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { return []abci.ValidatorUpdate{} } diff --git a/x/supply/types/query.pb.go b/x/supply/types/query.pb.go index 3af3c949f..c484692b9 100644 --- a/x/supply/types/query.pb.go +++ b/x/supply/types/query.pb.go @@ -124,7 +124,7 @@ func init() { func init() { proto.RegisterFile("quicksilver/supply/v1/query.proto", fileDescriptor_885bf2a118745e6a) } var fileDescriptor_885bf2a118745e6a = []byte{ - // 282 bytes of a gzipped FileDescriptorProto + // 273 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2c, 0x2c, 0xcd, 0x4c, 0xce, 0x2e, 0xce, 0xcc, 0x29, 0x4b, 0x2d, 0xd2, 0x2f, 0x2e, 0x2d, 0x28, 0xc8, 0xa9, 0xd4, 0x2f, 0x33, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x45, @@ -137,12 +137,12 @@ var fileDescriptor_885bf2a118745e6a = []byte{ 0x04, 0x56, 0x23, 0x88, 0x24, 0x03, 0x31, 0xce, 0x68, 0x02, 0x23, 0x17, 0x2b, 0xd8, 0x78, 0xa1, 0x36, 0x46, 0x2e, 0x36, 0x88, 0xa0, 0x90, 0xa6, 0x1e, 0x56, 0xe7, 0xeb, 0x61, 0xba, 0x4e, 0x4a, 0x8b, 0x18, 0xa5, 0x10, 0x27, 0x2b, 0xa9, 0x36, 0x5d, 0x7e, 0x32, 0x99, 0x49, 0x5e, 0x48, 0x56, - 0x1f, 0x7b, 0x00, 0x42, 0x58, 0x4e, 0xfe, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, + 0x1f, 0x7b, 0x00, 0x42, 0x58, 0x4e, 0x01, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, - 0x10, 0x65, 0x9a, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x9f, 0x99, 0x97, - 0x9e, 0x9a, 0x57, 0x9a, 0x59, 0x52, 0xa9, 0x9b, 0x54, 0x9a, 0x99, 0x93, 0x82, 0x62, 0x64, 0x05, - 0xcc, 0xd0, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0xf0, 0x1a, 0x03, 0x02, 0x00, 0x00, - 0xff, 0xff, 0x63, 0x5d, 0x89, 0x27, 0xb8, 0x01, 0x00, 0x00, + 0x10, 0x65, 0x96, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0x8b, 0x6c, 0x84, 0x6e, + 0x55, 0x7e, 0x5e, 0x2a, 0x8a, 0x99, 0x15, 0x30, 0x53, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, + 0xc0, 0xe1, 0x6b, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x28, 0x6b, 0x57, 0x0d, 0xb9, 0x01, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/supply/types/query.pb.gw.go b/x/supply/types/query.pb.gw.go index 5fbd318d5..260b7d941 100644 --- a/x/supply/types/query.pb.gw.go +++ b/x/supply/types/query.pb.gw.go @@ -145,7 +145,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Supply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1}, []string{"quicksilver", "supply", "v1"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Supply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1}, []string{"quicksilver", "supply", "v1"}, "", runtime.AssumeColonVerbOpt(true))) ) var (