From 7e2062df7d963a759f2c6c37f26c57d1dd940f5b Mon Sep 17 00:00:00 2001 From: Eric Bolten Date: Fri, 17 Feb 2023 18:09:39 -0800 Subject: [PATCH] v5 incentives/gravity rc1 (#201) * v5 upgrade with only incentives and gravity updates * go.mod major version v4 -> v5 * go 1.15 -> 1.16 * Update prost_build and somm_proto * Generate somm_proto for v5 * Fix proto import path bug and regenerate protos * Fix linter * Pin to ubuntu version in releaser * Set incentives cutoff height --- .github/workflows/integration-tests.yml | 1 + .github/workflows/lint.yml | 6 +- .github/workflows/release.yml | 2 +- .github/workflows/unit-test.yml | 23 + Makefile | 3 + app/app.go | 72 +- app/encoding.go | 2 +- app/sim_test.go | 2 +- app/upgrades/v4/upgrades.go | 4 +- app/upgrades/v5/README.md | 8 + app/upgrades/v5/constants.go | 4 + app/upgrades/v5/upgrades.go | 47 + cmd/sommelier/cmd/root.go | 4 +- cmd/sommelier/main.go | 4 +- go.mod | 7 +- go.sum | 4 +- integration_tests/chain.go | 27 +- integration_tests/cork_test.go | 2 +- integration_tests/incentives_test.go | 227 +++++ integration_tests/proposer.go | 11 + integration_tests/scheduled_cork_test.go | 2 +- integration_tests/setup_test.go | 36 +- integration_tests/validator.go | 2 +- prost_build/Cargo.lock | 2 +- prost_build/Cargo.toml | 4 +- prost_build/src/main.rs | 8 +- proto/cellarfees/v1/genesis.proto | 2 +- proto/cellarfees/v1/params.proto | 2 +- proto/cellarfees/v1/query.proto | 2 +- proto/cork/v1/cork.proto | 2 +- proto/cork/v1/genesis.proto | 2 +- proto/cork/v1/proposal.proto | 2 +- proto/cork/v1/query.proto | 2 +- proto/cork/v1/tx.proto | 2 +- proto/incentives/v1/genesis.proto | 23 + proto/incentives/v1/query.proto | 38 + somm_proto/Cargo.lock | 2 +- somm_proto/Cargo.toml | 4 +- somm_proto/src/prost/cellarfees.v1.rs | 98 ++ somm_proto/src/prost/incentives.v1.rs | 113 +++ testutil/codec.go | 45 + x/cellarfees/client/cli/query.go | 2 +- x/cellarfees/client/cli/tx.go | 2 +- x/cellarfees/handler.go | 2 +- x/cellarfees/keeper/genesis.go | 2 +- x/cellarfees/keeper/keeper.go | 2 +- x/cellarfees/keeper/query_server.go | 2 +- x/cellarfees/module.go | 6 +- x/cellarfees/types/genesis.pb.go | 4 +- x/cellarfees/types/params.pb.go | 4 +- x/cellarfees/types/query.pb.go | 46 +- x/cellarfees/types/query.pb.gw.go | 10 +- x/cork/client/cli/query.go | 2 +- x/cork/client/cli/tx.go | 2 +- x/cork/client/cli/tx_test.go | 2 +- x/cork/client/proposal_handler.go | 4 +- x/cork/client/rest/rest.go | 2 +- x/cork/handler.go | 4 +- x/cork/keeper/abci.go | 2 +- x/cork/keeper/genesis.go | 2 +- x/cork/keeper/keeper.go | 2 +- x/cork/keeper/keeper_test.go | 70 -- x/cork/keeper/msg_server.go | 2 +- x/cork/keeper/proposal_handler.go | 2 +- x/cork/keeper/query_server.go | 2 +- x/cork/keeper/test_common.go | 2 +- x/cork/module.go | 6 +- x/cork/types/cork.pb.go | 38 +- x/cork/types/genesis.pb.go | 46 +- x/cork/types/proposal.pb.go | 40 +- x/cork/types/query.pb.go | 44 +- x/cork/types/query.pb.gw.go | 25 +- x/cork/types/tx.pb.go | 41 +- x/incentives/client/cli/query.go | 81 ++ x/incentives/handler.go | 20 + x/incentives/keeper/abci.go | 41 + x/incentives/keeper/abci_test.go | 58 ++ x/incentives/keeper/genesis.go | 18 + x/incentives/keeper/keeper.go | 81 ++ x/incentives/keeper/keeper_test.go | 102 ++ x/incentives/keeper/query_server.go | 23 + x/incentives/keeper/query_server_test.go | 39 + x/incentives/module.go | 181 ++++ .../testutil/expected_keepers_mocks.go | 263 ++++++ x/incentives/types/codec.go | 8 + x/incentives/types/errors.go | 9 + x/incentives/types/expected_keepers.go | 36 + x/incentives/types/genesis.go | 19 + x/incentives/types/genesis.pb.go | 539 +++++++++++ x/incentives/types/keys.go | 15 + x/incentives/types/params.go | 71 ++ x/incentives/types/query.pb.go | 868 ++++++++++++++++++ x/incentives/types/query.pb.gw.go | 218 +++++ 93 files changed, 3677 insertions(+), 288 deletions(-) create mode 100644 .github/workflows/unit-test.yml create mode 100644 app/upgrades/v5/README.md create mode 100644 app/upgrades/v5/constants.go create mode 100644 app/upgrades/v5/upgrades.go create mode 100644 integration_tests/incentives_test.go create mode 100644 integration_tests/proposer.go create mode 100644 proto/incentives/v1/genesis.proto create mode 100644 proto/incentives/v1/query.proto create mode 100644 somm_proto/src/prost/cellarfees.v1.rs create mode 100644 somm_proto/src/prost/incentives.v1.rs create mode 100644 testutil/codec.go delete mode 100644 x/cork/keeper/keeper_test.go create mode 100644 x/incentives/client/cli/query.go create mode 100644 x/incentives/handler.go create mode 100644 x/incentives/keeper/abci.go create mode 100644 x/incentives/keeper/abci_test.go create mode 100644 x/incentives/keeper/genesis.go create mode 100644 x/incentives/keeper/keeper.go create mode 100644 x/incentives/keeper/keeper_test.go create mode 100644 x/incentives/keeper/query_server.go create mode 100644 x/incentives/keeper/query_server_test.go create mode 100644 x/incentives/module.go create mode 100644 x/incentives/testutil/expected_keepers_mocks.go create mode 100644 x/incentives/types/codec.go create mode 100644 x/incentives/types/errors.go create mode 100644 x/incentives/types/expected_keepers.go create mode 100644 x/incentives/types/genesis.go create mode 100644 x/incentives/types/genesis.pb.go create mode 100644 x/incentives/types/keys.go create mode 100644 x/incentives/types/params.go create mode 100644 x/incentives/types/query.pb.go create mode 100644 x/incentives/types/query.pb.gw.go diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index a208b557..c28cb2d9 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -116,6 +116,7 @@ jobs: test_type: [ "Cork", "ScheduledCork", + "Incentives", ] steps: # Not needed on self hosted test runner that already has go installed diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index da86829e..b67c5714 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,6 +13,9 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 6 steps: + - uses: actions/setup-go@v2 + with: + go-version: 1.16 - uses: actions/checkout@v2 - uses: technote-space/get-diff-action@v4 with: @@ -20,10 +23,11 @@ jobs: **/**.go go.mod go.sum - - uses: golangci/golangci-lint-action@master + - uses: golangci/golangci-lint-action@v3 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. version: v1.37 + skip-go-installation: true args: --timeout 10m github-token: ${{ secrets.github_token }} if: env.GIT_DIFF diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 82a6fbdf..d84680d6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,7 @@ on: jobs: goreleaser: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout uses: actions/checkout@v2.3.4 diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 00000000..26124c8f --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,23 @@ +name: Unit tests + +on: + push: + branches: + - main + tags: + - "v*.*.*" + pull_request: + +jobs: + test: + strategy: + matrix: + go-version: [1.16] + os: [ubuntu-latest] + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go-version }} + - uses: actions/checkout@v3 + - run: go test github.com/peggyjv/sommelier/.../x/... diff --git a/Makefile b/Makefile index dc477a21..ba34b32e 100644 --- a/Makefile +++ b/Makefile @@ -386,6 +386,9 @@ e2e_cork_test: e2e_clean_slate e2e_scheduled_cork_test: e2e_clean_slate @E2E_SKIP_CLEANUP=true integration_tests/integration_tests.test -test.failfast -test.v -test.run IntegrationTestSuite -testify.m TestScheduledCork || make -s fail +e2e_incentives_test: e2e_clean_slate + @E2E_SKIP_CLEANUP=true integration_tests/integration_tests.test -test.failfast -test.v -test.run IntegrationTestSuite -testify.m TestIncentives || make -s fail + fail: @echo 'test failed; dumping container logs into ./testlogs for review' @docker logs ethereum > testlogs/ethereum.log 2>&1 || true diff --git a/app/app.go b/app/app.go index c634b44f..17c941b7 100644 --- a/app/app.go +++ b/app/app.go @@ -88,15 +88,19 @@ import ( gravityclient "github.com/peggyjv/gravity-bridge/module/v2/x/gravity/client" gravitykeeper "github.com/peggyjv/gravity-bridge/module/v2/x/gravity/keeper" gravitytypes "github.com/peggyjv/gravity-bridge/module/v2/x/gravity/types" - appParams "github.com/peggyjv/sommelier/v4/app/params" - v4 "github.com/peggyjv/sommelier/v4/app/upgrades/v4" - "github.com/peggyjv/sommelier/v4/x/cellarfees" - cellarfeeskeeper "github.com/peggyjv/sommelier/v4/x/cellarfees/keeper" - cellarfeestypes "github.com/peggyjv/sommelier/v4/x/cellarfees/types" - "github.com/peggyjv/sommelier/v4/x/cork" - corkclient "github.com/peggyjv/sommelier/v4/x/cork/client" - corkkeeper "github.com/peggyjv/sommelier/v4/x/cork/keeper" - corktypes "github.com/peggyjv/sommelier/v4/x/cork/types" + appParams "github.com/peggyjv/sommelier/v5/app/params" + v4 "github.com/peggyjv/sommelier/v5/app/upgrades/v4" + v5 "github.com/peggyjv/sommelier/v5/app/upgrades/v5" + "github.com/peggyjv/sommelier/v5/x/cellarfees" + cellarfeeskeeper "github.com/peggyjv/sommelier/v5/x/cellarfees/keeper" + cellarfeestypes "github.com/peggyjv/sommelier/v5/x/cellarfees/types" + "github.com/peggyjv/sommelier/v5/x/cork" + corkclient "github.com/peggyjv/sommelier/v5/x/cork/client" + corkkeeper "github.com/peggyjv/sommelier/v5/x/cork/keeper" + corktypes "github.com/peggyjv/sommelier/v5/x/cork/types" + "github.com/peggyjv/sommelier/v5/x/incentives" + incentiveskeeper "github.com/peggyjv/sommelier/v5/x/incentives/keeper" + incentivestypes "github.com/peggyjv/sommelier/v5/x/incentives/types" "github.com/rakyll/statik/fs" abci "github.com/tendermint/tendermint/abci/types" tmjson "github.com/tendermint/tendermint/libs/json" @@ -153,6 +157,7 @@ var ( gravity.AppModuleBasic{}, cork.AppModuleBasic{}, cellarfees.AppModuleBasic{}, + incentives.AppModuleBasic{}, ) // module account permissions @@ -166,6 +171,7 @@ var ( ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, gravitytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, cellarfeestypes.ModuleName: nil, + incentivestypes.ModuleName: nil, } // module accounts that are allowed to receive tokens @@ -213,6 +219,7 @@ type SommelierApp struct { // Sommelier keepers CorkKeeper corkkeeper.Keeper CellarFeesKeeper cellarfeeskeeper.Keeper + IncentivesKeeper incentiveskeeper.Keeper // make capability scoped keepers public for test purposes (IBC only) ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -257,6 +264,7 @@ func NewSommelierApp( govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, gravitytypes.StoreKey, feegrant.StoreKey, authzkeeper.StoreKey, corktypes.StoreKey, + incentivestypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -358,6 +366,10 @@ func NewSommelierApp( app.AccountKeeper, app.BankKeeper, ) + app.IncentivesKeeper = incentiveskeeper.NewKeeper( + appCodec, keys[incentivestypes.StoreKey], app.GetSubspace(incentivestypes.ModuleName), app.DistrKeeper, app.BankKeeper, app.MintKeeper, + ) + app.GravityKeeper = *app.GravityKeeper.SetHooks( gravitytypes.NewMultiGravityHooks( app.CorkKeeper.Hooks(), @@ -398,9 +410,6 @@ func NewSommelierApp( skipGenesisInvariants = opt } - // NOTE: Any module instantiated in the module manager that is later modified - // must be passed by reference here. - // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. app.mm = module.NewManager( @@ -412,7 +421,6 @@ func NewSommelierApp( vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), capability.NewAppModule(appCodec, *app.CapabilityKeeper), - crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), @@ -429,6 +437,7 @@ func NewSommelierApp( authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), cork.NewAppModule(app.CorkKeeper, appCodec), cellarfees.NewAppModule(app.CellarFeesKeeper, appCodec, app.AccountKeeper, app.BankKeeper), + incentives.NewAppModule(app.IncentivesKeeper, app.DistrKeeper, app.BankKeeper, app.MintKeeper, appCodec), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -440,13 +449,13 @@ func NewSommelierApp( upgradetypes.ModuleName, capabilitytypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName, evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName, ibctransfertypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, govtypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, authz.ModuleName, feegrant.ModuleName, - paramstypes.ModuleName, gravitytypes.ModuleName, corktypes.ModuleName, cellarfeestypes.ModuleName, + paramstypes.ModuleName, incentivestypes.ModuleName, gravitytypes.ModuleName, corktypes.ModuleName, cellarfeestypes.ModuleName, ) app.mm.SetOrderEndBlockers( crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName, ibctransfertypes.ModuleName, capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName, minttypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, - upgradetypes.ModuleName, gravitytypes.ModuleName, corktypes.ModuleName, cellarfeestypes.ModuleName, + upgradetypes.ModuleName, incentivestypes.ModuleName, gravitytypes.ModuleName, corktypes.ModuleName, cellarfeestypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -459,7 +468,7 @@ func NewSommelierApp( stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName, ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName, gravitytypes.ModuleName, authz.ModuleName, - feegrant.ModuleName, corktypes.ModuleName, cellarfeestypes.ModuleName, + feegrant.ModuleName, incentivestypes.ModuleName, corktypes.ModuleName, cellarfeestypes.ModuleName, ) app.mm.RegisterInvariants(&app.CrisisKeeper) @@ -489,6 +498,7 @@ func NewSommelierApp( authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), cork.NewAppModule(app.CorkKeeper, appCodec), cellarfees.NewAppModule(app.CellarFeesKeeper, appCodec, app.AccountKeeper, app.BankKeeper), + incentives.NewAppModule(app.IncentivesKeeper, app.DistrKeeper, app.BankKeeper, app.MintKeeper, appCodec), ) app.sm.RegisterStoreDecoders() @@ -720,6 +730,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(gravitytypes.ModuleName) paramsKeeper.Subspace(corktypes.ModuleName) paramsKeeper.Subspace(cellarfeestypes.ModuleName) + paramsKeeper.Subspace(incentivestypes.ModuleName) return paramsKeeper } @@ -730,13 +741,27 @@ func (app *SommelierApp) setupUpgradeStoreLoaders() { panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) } - if upgradeInfo.Name == v4.UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { - storeUpgrades := store.StoreUpgrades{ + if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + return + } + + var storeUpgrades *store.StoreUpgrades = nil + + if upgradeInfo.Name == v4.UpgradeName { + storeUpgrades = &store.StoreUpgrades{ Added: []string{corktypes.ModuleName, cellarfeestypes.ModuleName}, Deleted: []string{"allocation"}, } + } - app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) + if upgradeInfo.Name == v5.UpgradeName { + storeUpgrades = &store.StoreUpgrades{ + Added: []string{incentivestypes.ModuleName}, + } + } + + if storeUpgrades != nil { + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, storeUpgrades)) } } @@ -750,4 +775,13 @@ func (app *SommelierApp) setupUpgradeHandlers() { app.BankKeeper, ), ) + + app.UpgradeKeeper.SetUpgradeHandler( + v5.UpgradeName, + v5.CreateUpgradeHandler( + app.mm, + app.configurator, + app.IncentivesKeeper, + ), + ) } diff --git a/app/encoding.go b/app/encoding.go index 002bd544..267696fc 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -2,7 +2,7 @@ package app import ( "github.com/cosmos/cosmos-sdk/std" - "github.com/peggyjv/sommelier/v4/app/params" + "github.com/peggyjv/sommelier/v5/app/params" ) // MakeEncodingConfig creates an EncodingConfig for testing. This function diff --git a/app/sim_test.go b/app/sim_test.go index 939ad721..560998f3 100644 --- a/app/sim_test.go +++ b/app/sim_test.go @@ -6,7 +6,7 @@ import ( "os" "testing" - sommelier "github.com/peggyjv/sommelier/v4/app" + sommelier "github.com/peggyjv/sommelier/v5/app" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/log" diff --git a/app/upgrades/v4/upgrades.go b/app/upgrades/v4/upgrades.go index 198367aa..15046599 100644 --- a/app/upgrades/v4/upgrades.go +++ b/app/upgrades/v4/upgrades.go @@ -7,8 +7,8 @@ import ( bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" gravitytypes "github.com/peggyjv/gravity-bridge/module/v2/x/gravity/types" - cellarfeestypes "github.com/peggyjv/sommelier/v4/x/cellarfees/types" - corktypes "github.com/peggyjv/sommelier/v4/x/cork/types" + cellarfeestypes "github.com/peggyjv/sommelier/v5/x/cellarfees/types" + corktypes "github.com/peggyjv/sommelier/v5/x/cork/types" ) func CreateUpgradeHandler( diff --git a/app/upgrades/v5/README.md b/app/upgrades/v5/README.md new file mode 100644 index 00000000..90235268 --- /dev/null +++ b/app/upgrades/v5/README.md @@ -0,0 +1,8 @@ +# v5 upgrade + +This upgrade moves Sommelier to major version 5. + +## Summary of changes + +* Add the incentives module to provide a way of distributing community pool funds on a per-block, pro-rata basis to incentivize stakers while cellar TVL is built over time into a meaningful staking return +* Pin to a version of the gravity module with ledger support \ No newline at end of file diff --git a/app/upgrades/v5/constants.go b/app/upgrades/v5/constants.go new file mode 100644 index 00000000..0be7a81b --- /dev/null +++ b/app/upgrades/v5/constants.go @@ -0,0 +1,4 @@ +package v5 + +// UpgradeName defines the on-chain upgrade name for the Sommelier v5 upgrade +const UpgradeName = "v5" diff --git a/app/upgrades/v5/upgrades.go b/app/upgrades/v5/upgrades.go new file mode 100644 index 00000000..f388b3be --- /dev/null +++ b/app/upgrades/v5/upgrades.go @@ -0,0 +1,47 @@ +package v5 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + appparams "github.com/peggyjv/sommelier/v5/app/params" + incentiveskeeper "github.com/peggyjv/sommelier/v5/x/incentives/keeper" + incentivestypes "github.com/peggyjv/sommelier/v5/x/incentives/types" +) + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + incentivesKeeper incentiveskeeper.Keeper, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + ctx.Logger().Info("v5 upgrade: entering handler") + + // We must manually run InitGenesis for incentives so we can adjust their values during the upgrade process. + // Setting the consensus version to 1 prevents RunMigrations from running InitGenesis itself. + fromVM[incentivestypes.ModuleName] = mm.Modules[incentivestypes.ModuleName].ConsensusVersion() + + ctx.Logger().Info("v5 upgrade: initializing incentives genesis state") + incentivesInitGenesis(ctx, incentivesKeeper) + + ctx.Logger().Info("v5 upgrade: running migrations and exiting handler") + return mm.RunMigrations(ctx, configurator, fromVM) + } +} + +// Launch the incentives module with 2 SOMM per block distribution and a cutoff height 5 million blocks past +// the upgrade height +func incentivesInitGenesis(ctx sdk.Context, incentivesKeeper incentiveskeeper.Keeper) { + genesisState := incentivestypes.DefaultGenesisState() + + upgradeHeight := uint64(7766725) + incentivesBlocks := uint64(5000000) + + params := incentivestypes.Params{ + DistributionPerBlock: sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(2000000)), + IncentivesCutoffHeight: upgradeHeight + incentivesBlocks, + } + genesisState.Params = params + + incentiveskeeper.InitGenesis(ctx, incentivesKeeper, genesisState) +} diff --git a/cmd/sommelier/cmd/root.go b/cmd/sommelier/cmd/root.go index 2daf91c5..7ae6b9e3 100644 --- a/cmd/sommelier/cmd/root.go +++ b/cmd/sommelier/cmd/root.go @@ -31,8 +31,8 @@ import ( dbm "github.com/tendermint/tm-db" bridgecmd "github.com/peggyjv/gravity-bridge/module/v2/cmd/gravity/cmd" - "github.com/peggyjv/sommelier/v4/app" - "github.com/peggyjv/sommelier/v4/app/params" + "github.com/peggyjv/sommelier/v5/app" + "github.com/peggyjv/sommelier/v5/app/params" ) // NewRootCmd creates a new root command for simd. It is called once in the diff --git a/cmd/sommelier/main.go b/cmd/sommelier/main.go index a831fbff..90765dde 100644 --- a/cmd/sommelier/main.go +++ b/cmd/sommelier/main.go @@ -5,8 +5,8 @@ import ( "github.com/cosmos/cosmos-sdk/server" scmd "github.com/cosmos/cosmos-sdk/server/cmd" - "github.com/peggyjv/sommelier/v4/app" - "github.com/peggyjv/sommelier/v4/cmd/sommelier/cmd" + "github.com/peggyjv/sommelier/v5/app" + "github.com/peggyjv/sommelier/v5/cmd/sommelier/cmd" ) func main() { diff --git a/go.mod b/go.mod index c379e2c7..3a6bbc61 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ -module github.com/peggyjv/sommelier/v4 +module github.com/peggyjv/sommelier/v5 -go 1.15 +go 1.16 require ( github.com/StackExchange/wmi v1.2.1 // indirect @@ -9,6 +9,7 @@ require ( github.com/cosmos/ibc-go/v2 v2.0.0 github.com/ethereum/go-ethereum v1.10.11 github.com/gogo/protobuf v1.3.3 + github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.2 github.com/google/uuid v1.2.0 // indirect github.com/gorilla/mux v1.8.0 @@ -16,7 +17,7 @@ require ( github.com/miguelmota/go-ethereum-hdwallet v0.1.1 github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect github.com/ory/dockertest/v3 v3.8.1 - github.com/peggyjv/gravity-bridge/module/v2 v2.0.2 + github.com/peggyjv/gravity-bridge/module/v2 v2.0.3-0.20230113013243-7ce6b3c12502 github.com/rakyll/statik v0.1.7 github.com/regen-network/cosmos-proto v0.3.1 github.com/spf13/cast v1.4.1 diff --git a/go.sum b/go.sum index 1dfdf8e6..78044e39 100644 --- a/go.sum +++ b/go.sum @@ -852,8 +852,8 @@ github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144T github.com/paulbellamy/ratecounter v0.2.0/go.mod h1:Hfx1hDpSGoqxkVVpBi/IlYD7kChlfo5C6hzIHwPqfFE= github.com/pborman/uuid v0.0.0-20170112150404-1b00554d8222/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/peggyjv/gravity-bridge/module/v2 v2.0.2 h1:8PiwAPbmeItQu/QbRDzcZUz84ce56NLYmqSSXuLxesY= -github.com/peggyjv/gravity-bridge/module/v2 v2.0.2/go.mod h1:gKOqaz8xccgMEmWaH53n6uCIvRxqPFgya4aHrMi78Fs= +github.com/peggyjv/gravity-bridge/module/v2 v2.0.3-0.20230113013243-7ce6b3c12502 h1:7UCI+/rr5whCXKxcEvfVHT0VM2nvp56LS5kmIgfyI3I= +github.com/peggyjv/gravity-bridge/module/v2 v2.0.3-0.20230113013243-7ce6b3c12502/go.mod h1:xmBcp1ajFkFcsCTU+hEafjcZFAaBEImpz9+VhgAvuNU= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM= diff --git a/integration_tests/chain.go b/integration_tests/chain.go index d44558a9..97b45aae 100644 --- a/integration_tests/chain.go +++ b/integration_tests/chain.go @@ -6,7 +6,7 @@ import ( "os" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - corktypes "github.com/peggyjv/sommelier/v4/x/cork/types" + corktypes "github.com/peggyjv/sommelier/v5/x/cork/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -25,8 +25,8 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" gravitytypes "github.com/peggyjv/gravity-bridge/module/v2/x/gravity/types" - "github.com/peggyjv/sommelier/v4/app" - "github.com/peggyjv/sommelier/v4/app/params" + "github.com/peggyjv/sommelier/v5/app" + "github.com/peggyjv/sommelier/v5/app/params" tmrand "github.com/tendermint/tendermint/libs/rand" rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) @@ -64,6 +64,7 @@ type chain struct { id string validators []*validator orchestrators []*orchestrator + proposer *proposer } func newChain() (*chain, error) { @@ -144,6 +145,26 @@ func (c *chain) createAndInitValidatorsWithMnemonics(mnemonics []string) error { return nil } +func (c *chain) createAndInitProposerWithMnemonic(mnemonic string) error { + hdPath := hd.CreateHDPath(sdk.CoinType, 1, 0) + + // create keys + info, kb, err := createMemoryKeyFromMnemonic("proposer", mnemonic, "", hdPath) + if err != nil { + return err + } + + proposer := proposer{} + + proposer.keyInfo = *info + proposer.mnemonic = mnemonic + proposer.keyring = kb + + c.proposer = &proposer + + return nil +} + func (c *chain) createAndInitOrchestrators(count int) error { // nolint:unused mnemonics := make([]string, count) for i := 0; i < count; i++ { diff --git a/integration_tests/cork_test.go b/integration_tests/cork_test.go index 55ede43b..f204e774 100644 --- a/integration_tests/cork_test.go +++ b/integration_tests/cork_test.go @@ -14,7 +14,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" - "github.com/peggyjv/sommelier/v4/x/cork/types" + "github.com/peggyjv/sommelier/v5/x/cork/types" ) const CounterABI = ` diff --git a/integration_tests/incentives_test.go b/integration_tests/incentives_test.go new file mode 100644 index 00000000..6fbc567a --- /dev/null +++ b/integration_tests/incentives_test.go @@ -0,0 +1,227 @@ +package integration_tests + +import ( + "context" + "fmt" + "time" + + "github.com/cosmos/cosmos-sdk/client" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/bech32" + disttypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + paramsproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/peggyjv/sommelier/v5/app/params" + incentivestypes "github.com/peggyjv/sommelier/v5/x/incentives/types" +) + +func (s *IntegrationTestSuite) TestIncentives() { + s.Run("Bring up chain, observe incentives distribution after param proposal executes", func() { + ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) + defer cancel() + + val := s.chain.validators[0] + s.T().Logf("validator %s", val.keyInfo.GetAddress().String()) + kb, err := val.keyring() + s.Require().NoError(err) + + _, bytes, err := bech32.DecodeAndConvert(val.keyInfo.GetAddress().String()) + s.Require().NoError(err) + valOperatorAddress, err := bech32.ConvertAndEncode("sommvaloper", bytes) + s.Require().NoError(err) + + clientCtx, err := s.chain.clientContext("tcp://localhost:26657", &kb, "val", val.keyInfo.GetAddress()) + s.Require().NoError(err) + + incentivesQueryClient := incentivestypes.NewQueryClient(clientCtx) + distQueryClient := disttypes.NewQueryClient(clientCtx) + mintQueryClient := minttypes.NewQueryClient(clientCtx) + stakingQueryClient := stakingtypes.NewQueryClient(clientCtx) + + s.T().Log("verifying that the base distribution rate is zero") + incentivesParamsRes, err := incentivesQueryClient.QueryParams(ctx, &incentivestypes.QueryParamsRequest{}) + s.Require().NoError(err) + s.Require().Equal(uint64(0), incentivesParamsRes.Params.IncentivesCutoffHeight) + s.Require().Equal(sdk.ZeroInt(), incentivesParamsRes.Params.DistributionPerBlock.Amount) + + s.T().Log("verifying APY query returns zero") + incentivesAPYRes, err := incentivesQueryClient.QueryAPY(ctx, &incentivestypes.QueryAPYRequest{}) + s.Require().NoError(err) + initialAPY, err := sdk.NewDecFromStr(incentivesAPYRes.Apy) + s.Require().NoError(err) + s.Require().True(initialAPY.IsZero()) + + beforeAmount := s.queryValidatorRewards(ctx, valOperatorAddress, distQueryClient) + time.Sleep(time.Second * 12) + afterAmount := s.queryValidatorRewards(ctx, valOperatorAddress, distQueryClient) + s.Require().Equal(beforeAmount, afterAmount) + + s.T().Log("submitting proposal to enable incentives") + proposer := s.chain.proposer + proposerCtx, err := s.chain.clientContext("tcp://localhost:26657", proposer.keyring, "proposer", proposer.keyInfo.GetAddress()) + s.Require().NoError(err) + orch := s.chain.orchestrators[0] + orchClientCtx, err := s.chain.clientContext("tcp://localhost:26657", orch.keyring, "orch", orch.keyInfo.GetAddress()) + s.Require().NoError(err) + + // Collin: test takes about ~110 blocks to reach the cutoff check at the end on my machine. + // Hopefully this is high enough to avoid a false negative in CI. + cutoffHeight := 200 + expectedUsommAmount := int64(2_000_000) + expectedDistributionPerBlock := sdk.NewCoin(params.BaseCoinUnit, sdk.NewInt(expectedUsommAmount)) + proposal := paramsproposal.ParameterChangeProposal{ + Title: "enable incentives", + Description: "enables incentives", + Changes: []paramsproposal.ParamChange{ + { + Subspace: "incentives", + Key: "IncentivesCutoffHeight", + Value: fmt.Sprintf("\"%d\"", cutoffHeight), + }, + { + Subspace: "incentives", + Key: "DistributionPerBlock", + Value: fmt.Sprintf("{\"denom\":\"%s\",\"amount\":\"%d\"}", params.BaseCoinUnit, expectedUsommAmount), + }, + }, + } + + proposalMsg, err := govtypes.NewMsgSubmitProposal( + &proposal, + sdk.Coins{ + { + Denom: testDenom, + Amount: stakeAmount.Quo(sdk.NewInt(2)), + }, + }, + proposer.keyInfo.GetAddress(), + ) + s.Require().NoError(err, "Unable to create governance proposal") + submitProposalResponse, err := s.chain.sendMsgs(*proposerCtx, proposalMsg) + s.Require().NoError(err) + s.Require().Zero(submitProposalResponse.Code, "raw log: %s", submitProposalResponse.RawLog) + + s.T().Log("check proposal was submitted correctly") + govQueryClient := govtypes.NewQueryClient(orchClientCtx) + + s.Require().Eventually(func() bool { + proposalsQueryResponse, err := govQueryClient.Proposals(context.Background(), &govtypes.QueryProposalsRequest{}) + if err != nil { + s.T().Logf("error querying proposals: %e", err) + return false + } + + s.Require().NotEmpty(proposalsQueryResponse.Proposals) + s.Require().Equal(uint64(1), proposalsQueryResponse.Proposals[0].ProposalId, "not proposal id 1") + s.Require().Equal(govtypes.StatusVotingPeriod, proposalsQueryResponse.Proposals[0].Status, "proposal not in voting period") + + return true + }, time.Second*30, time.Second*5, "proposal submission was never found") + + s.T().Log("vote for proposal") + for _, val := range s.chain.validators { + kr, err := val.keyring() + s.Require().NoError(err) + localClientCtx, err := s.chain.clientContext("tcp://localhost:26657", &kr, "val", val.keyInfo.GetAddress()) + s.Require().NoError(err) + + voteMsg := govtypes.NewMsgVote(val.keyInfo.GetAddress(), 1, govtypes.OptionYes) + voteResponse, err := s.chain.sendMsgs(*localClientCtx, voteMsg) + s.Require().NoError(err) + s.Require().Zero(voteResponse.Code, "Vote error: %s", voteResponse.RawLog) + } + + s.T().Log("waiting for proposal to be approved..") + s.Require().Eventually(func() bool { + proposalQueryResponse, _ := govQueryClient.Proposal(context.Background(), &govtypes.QueryProposalRequest{ProposalId: 1}) + return govtypes.StatusPassed == proposalQueryResponse.Proposal.Status + }, time.Second*30, time.Second*5, "proposal was never accepted") + s.T().Log("proposal approved!") + + s.T().Log("verifying parameter was changed") + incentivesParamsRes, err = incentivesQueryClient.QueryParams(ctx, &incentivestypes.QueryParamsRequest{}) + s.Require().NoError(err) + s.Require().Equal(incentivesParamsRes.Params.IncentivesCutoffHeight, uint64(cutoffHeight)) + + s.T().Log("verifying that the base distribution rate is the expected value") + beforeAmount, beforeHeight := s.getRewardAmountAndHeight(ctx, distQueryClient, valOperatorAddress, clientCtx) + time.Sleep(time.Second * 12) + afterAmount, afterHeight := s.getRewardAmountAndHeight(ctx, distQueryClient, valOperatorAddress, clientCtx) + // Assumes each validator has equally weight bonding power + s.T().Logf("blocks %d-%d", beforeHeight, afterHeight) + actualDistributionPerBlock := (afterAmount.Sub(beforeAmount)).Quo(sdk.NewDec(afterHeight - beforeHeight)).Mul(sdk.NewDec(int64(len(s.chain.validators)))) + s.T().Logf("before: %s, after: %s, blocks %d-%d", beforeAmount.String(), afterAmount.String(), beforeHeight, afterHeight) + s.Require().True(afterAmount.GT(beforeAmount)) + s.Require().Equal(expectedDistributionPerBlock.Amount.ToDec(), actualDistributionPerBlock) + + s.T().Log("verifying APY query returns expected value") + mintParams, err := mintQueryClient.Params(ctx, &minttypes.QueryParamsRequest{}) + s.Require().NoError(err) + stakingPool, err := stakingQueryClient.Pool(ctx, &stakingtypes.QueryPoolRequest{}) + s.Require().NoError(err) + tokensTotal := stakingPool.Pool.BondedTokens.Add(stakingPool.Pool.NotBondedTokens) + // assumes bonded ratio is 100% + expectedAPY := actualDistributionPerBlock.Mul(sdk.NewDec(int64(mintParams.Params.BlocksPerYear))).Quo(tokensTotal.ToDec()) + incentivesAPYRes, err = incentivesQueryClient.QueryAPY(ctx, &incentivestypes.QueryAPYRequest{}) + s.Require().NoError(err) + APY, err := sdk.NewDecFromStr(incentivesAPYRes.Apy[:10]) + s.Require().NoError(err) + s.Require().Equal(expectedAPY, APY) + + s.T().Log("verifying incentives end after cutoff") + s.Require().Eventually(func() bool { + startingAmount, startingHeight := s.getRewardAmountAndHeight(ctx, distQueryClient, valOperatorAddress, clientCtx) + // since rewards sent to the distribution module are issued on the next block, we wait for the height after + // the cutoff to check rewards + if startingHeight <= int64(cutoffHeight) { + return false + } + + time.Sleep(time.Second * 5) + endingAmount, _ := s.getRewardAmountAndHeight(ctx, distQueryClient, valOperatorAddress, clientCtx) + + if s.Equal(startingAmount, endingAmount) { + return true + } + + s.FailNow("rewards per block are nonzero after cutoff height") + + // required to satisfy the eventually block even though it's unreachable + return false + }, time.Minute*5, time.Second*10, "incentives did not end after cutoff height") + s.T().Log("incentives ended!") + }) +} + +func (s *IntegrationTestSuite) queryValidatorRewards(ctx context.Context, valOperatorAddress string, distQueryClient disttypes.QueryClient) sdk.Dec { + rewardsRes, err := distQueryClient.ValidatorOutstandingRewards(ctx, &disttypes.QueryValidatorOutstandingRewardsRequest{ + ValidatorAddress: valOperatorAddress, + }) + s.Require().NoError(err) + return rewardsRes.Rewards.Rewards.AmountOf(params.BaseCoinUnit) +} + +func (s *IntegrationTestSuite) getCurrentHeight(clientCtx *client.Context) int64 { + node, err := clientCtx.GetNode() + s.Require().NoError(err) + status, err := node.Status(context.Background()) + s.Require().NoError(err) + + return status.SyncInfo.LatestBlockHeight +} + +func (s *IntegrationTestSuite) getRewardAmountAndHeight(ctx context.Context, distQueryClient disttypes.QueryClient, operatorAddress string, clientCtx *client.Context) (sdk.Dec, int64) { + var amount sdk.Dec + var height int64 + + s.Require().Eventually(func() bool { + initialHeight := s.getCurrentHeight(clientCtx) + amount = s.queryValidatorRewards(ctx, operatorAddress, distQueryClient) + height = s.getCurrentHeight(clientCtx) + return initialHeight == height + }, time.Second*30, time.Second*1, "failed to reliably determine height of reward sample") + + return amount, height +} diff --git a/integration_tests/proposer.go b/integration_tests/proposer.go new file mode 100644 index 00000000..23bf5f33 --- /dev/null +++ b/integration_tests/proposer.go @@ -0,0 +1,11 @@ +package integration_tests + +import ( + "github.com/cosmos/cosmos-sdk/crypto/keyring" +) + +type proposer struct { + mnemonic string + keyInfo keyring.Info + keyring *keyring.Keyring +} diff --git a/integration_tests/scheduled_cork_test.go b/integration_tests/scheduled_cork_test.go index 7b844e05..9195c372 100644 --- a/integration_tests/scheduled_cork_test.go +++ b/integration_tests/scheduled_cork_test.go @@ -8,7 +8,7 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/ethereum/go-ethereum/common" gbtypes "github.com/peggyjv/gravity-bridge/module/v2/x/gravity/types" - "github.com/peggyjv/sommelier/v4/x/cork/types" + "github.com/peggyjv/sommelier/v5/x/cork/types" ) func (s *IntegrationTestSuite) TestScheduledCork() { diff --git a/integration_tests/setup_test.go b/integration_tests/setup_test.go index 03cb3cf2..964d7cff 100644 --- a/integration_tests/setup_test.go +++ b/integration_tests/setup_test.go @@ -14,8 +14,10 @@ import ( "testing" "time" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - corktypes "github.com/peggyjv/sommelier/v4/x/cork/types" + "github.com/peggyjv/sommelier/v5/app/params" + corktypes "github.com/peggyjv/sommelier/v5/x/cork/types" gravitytypes "github.com/peggyjv/gravity-bridge/module/v2/x/gravity/types" @@ -27,6 +29,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + disttypes "github.com/cosmos/cosmos-sdk/x/distribution/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -55,6 +58,8 @@ var ( counterContract = common.HexToAddress("0x0000000000000000000000000000000000000000") unusedGenesisContract = common.HexToAddress("0x0000000000000000000000000000000000000001") unusedAddedContract = common.HexToAddress("0x0000000000000000000000000000000000000002") + + proposerMnemonic = "exit own pull hurry crawl glimpse winter service exclude same dog wrap method online practice deal lend athlete resemble chuckle culture receive autumn cinnamon" ) func MNEMONICS() []string { @@ -157,6 +162,10 @@ func (s *IntegrationTestSuite) initNodes(nodeCount int) { // nolint:unused ) } + s.Require().NoError( + addGenesisAccount(val0ConfigDir, "", initBalanceStr, s.chain.proposer.keyInfo.GetAddress()), + ) + // copy the genesis file to the remaining validators for _, val := range s.chain.validators[1:] { err := copyFile( @@ -170,6 +179,7 @@ func (s *IntegrationTestSuite) initNodes(nodeCount int) { // nolint:unused func (s *IntegrationTestSuite) initNodesWithMnemonics(mnemonics ...string) { s.Require().NoError(s.chain.createAndInitValidatorsWithMnemonics(mnemonics)) s.Require().NoError(s.chain.createAndInitOrchestratorsWithMnemonics(mnemonics)) + s.Require().NoError(s.chain.createAndInitProposerWithMnemonic(proposerMnemonic)) //initialize a genesis file for the first validator val0ConfigDir := s.chain.validators[0].configDir() @@ -186,6 +196,10 @@ func (s *IntegrationTestSuite) initNodesWithMnemonics(mnemonics ...string) { ) } + s.Require().NoError( + addGenesisAccount(val0ConfigDir, "", initBalanceStr, s.chain.proposer.keyInfo.GetAddress()), + ) + // copy the genesis file to the remaining validators for _, val := range s.chain.validators[1:] { err := copyFile( @@ -275,6 +289,12 @@ func (s *IntegrationTestSuite) initGenesis() { }, }) + distBalance := banktypes.Balance{ + Address: authtypes.NewModuleAddress(disttypes.ModuleName).String(), + Coins: sdk.NewCoins(sdk.NewCoin(params.BaseCoinUnit, sdk.NewInt(1000000000))), + } + bankGenState.Balances = append(bankGenState.Balances, distBalance) + bz, err := cdc.MarshalJSON(&bankGenState) s.Require().NoError(err) appGenState[banktypes.ModuleName] = bz @@ -309,10 +329,24 @@ func (s *IntegrationTestSuite) initGenesis() { var mintGenState minttypes.GenesisState s.Require().NoError(cdc.UnmarshalJSON(appGenState[minttypes.ModuleName], &mintGenState)) mintGenState.Params.MintDenom = testDenom + mintGenState.Params.InflationMax = sdk.ZeroDec() + mintGenState.Params.InflationMin = sdk.ZeroDec() + mintGenState.Params.InflationRateChange = sdk.ZeroDec() + mintGenState.Minter.Inflation = sdk.ZeroDec() bz, err = cdc.MarshalJSON(&mintGenState) s.Require().NoError(err) appGenState[minttypes.ModuleName] = bz + distGenState := disttypes.DefaultGenesisState() + s.Require().NoError(cdc.UnmarshalJSON(appGenState[minttypes.ModuleName], &mintGenState)) + distGenState.Params.CommunityTax = sdk.ZeroDec() + distGenState.Params.BaseProposerReward = sdk.ZeroDec() + distGenState.Params.BonusProposerReward = sdk.ZeroDec() + distGenState.FeePool.CommunityPool = sdk.NewDecCoins(sdk.NewDecCoin(params.BaseCoinUnit, sdk.NewInt(1000000000))) + bz, err = cdc.MarshalJSON(distGenState) + s.Require().NoError(err) + appGenState[disttypes.ModuleName] = bz + var genUtilGenState genutiltypes.GenesisState s.Require().NoError(cdc.UnmarshalJSON(appGenState[genutiltypes.ModuleName], &genUtilGenState)) diff --git a/integration_tests/validator.go b/integration_tests/validator.go index dfffa10c..42191976 100644 --- a/integration_tests/validator.go +++ b/integration_tests/validator.go @@ -23,7 +23,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto" gravitytypes "github.com/peggyjv/gravity-bridge/module/v2/x/gravity/types" - "github.com/peggyjv/sommelier/v4/app" + "github.com/peggyjv/sommelier/v5/app" tmcfg "github.com/tendermint/tendermint/config" tmos "github.com/tendermint/tendermint/libs/os" "github.com/tendermint/tendermint/p2p" diff --git a/prost_build/Cargo.lock b/prost_build/Cargo.lock index 63948604..a1e3dcde 100644 --- a/prost_build/Cargo.lock +++ b/prost_build/Cargo.lock @@ -597,7 +597,7 @@ dependencies = [ [[package]] name = "somme_prost_build" -version = "0.1.0" +version = "5.0.0" dependencies = [ "prost", "prost-build", diff --git a/prost_build/Cargo.toml b/prost_build/Cargo.toml index e275d207..e8f3913e 100644 --- a/prost_build/Cargo.toml +++ b/prost_build/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "somme_prost_build" -version = "0.1.0" +version = "5.0.0" authors = ["PeggyJV","Justin Kilpatrick "] edition = "2018" @@ -12,4 +12,4 @@ prost-build = "0.7" tempdir = "0.3" walkdir = "2" tonic-build = "0.4" -regex = "1.5" \ No newline at end of file +regex = "1.5" diff --git a/prost_build/src/main.rs b/prost_build/src/main.rs index db99d72b..3ab14acd 100644 --- a/prost_build/src/main.rs +++ b/prost_build/src/main.rs @@ -44,17 +44,19 @@ fn compile_protos(out_dir: &Path, tmp_dir: &Path) { // this gives us the repo root by going up two levels from the module root let root = root.parent().unwrap().to_path_buf(); - let mut allocation_proto_dir = root.clone(); - allocation_proto_dir.push("proto/allocation/v1"); + let mut cellarfees_proto_dir = root.clone(); + cellarfees_proto_dir.push("proto/cellarfees/v1"); let mut cork_proto_dir = root.clone(); cork_proto_dir.push("proto/cork/v1"); + let mut incentives_proto_dir = root.clone(); + incentives_proto_dir.push("proto/incentives/v1"); let mut somm_proto_include_dir = root.clone(); somm_proto_include_dir.push("proto"); let mut third_party_proto_include_dir = root; third_party_proto_include_dir.push("third_party/proto"); // Paths - let proto_paths = [allocation_proto_dir, cork_proto_dir]; + let proto_paths = [cellarfees_proto_dir, cork_proto_dir, incentives_proto_dir]; // we need to have an include which is just the folder of our protos to satisfy protoc // which insists that any passed file be included in a directory passed as an include let proto_include_paths = [somm_proto_include_dir, third_party_proto_include_dir]; diff --git a/proto/cellarfees/v1/genesis.proto b/proto/cellarfees/v1/genesis.proto index 9ef07988..1ffdd44c 100644 --- a/proto/cellarfees/v1/genesis.proto +++ b/proto/cellarfees/v1/genesis.proto @@ -4,7 +4,7 @@ package cellarfees.v1; import "gogoproto/gogo.proto"; import "cellarfees/v1/params.proto"; -option go_package = "github.com/peggyjv/sommelier/v4/x/cellarfees/types"; +option go_package = "github.com/peggyjv/sommelier/v5/x/cellarfees/types"; // GenesisState defines the cellarfees module's genesis state. message GenesisState { diff --git a/proto/cellarfees/v1/params.proto b/proto/cellarfees/v1/params.proto index 97dae1ee..d11c9fcc 100644 --- a/proto/cellarfees/v1/params.proto +++ b/proto/cellarfees/v1/params.proto @@ -3,7 +3,7 @@ package cellarfees.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/peggyjv/sommelier/v4/x/cellarfees/types"; +option go_package = "github.com/peggyjv/sommelier/v5/x/cellarfees/types"; // Params defines the parameters for the module. message Params { diff --git a/proto/cellarfees/v1/query.proto b/proto/cellarfees/v1/query.proto index ced39434..aabc6dee 100644 --- a/proto/cellarfees/v1/query.proto +++ b/proto/cellarfees/v1/query.proto @@ -6,7 +6,7 @@ import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "cellarfees/v1/params.proto"; -option go_package = "github.com/peggyjv/sommelier/v4/x/cellarfees/types"; +option go_package = "github.com/peggyjv/sommelier/v5/x/cellarfees/types"; service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { diff --git a/proto/cork/v1/cork.proto b/proto/cork/v1/cork.proto index 290e9b4b..fd3e9c66 100644 --- a/proto/cork/v1/cork.proto +++ b/proto/cork/v1/cork.proto @@ -3,7 +3,7 @@ package cork.v1; import "cosmos_proto/cosmos.proto"; -option go_package = "github.com/peggyjv/sommelier/v4/x/cork/types"; +option go_package = "github.com/peggyjv/sommelier/v5/x/cork/types"; message Cork { // call body containing the ABI encoded bytes to send to the contract diff --git a/proto/cork/v1/genesis.proto b/proto/cork/v1/genesis.proto index 837a5a6a..1ea3b741 100644 --- a/proto/cork/v1/genesis.proto +++ b/proto/cork/v1/genesis.proto @@ -5,7 +5,7 @@ import "cork/v1/tx.proto"; import "cork/v1/cork.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/peggyjv/sommelier/v4/x/cork/types"; +option go_package = "github.com/peggyjv/sommelier/v5/x/cork/types"; // GenesisState - all cork state that must be provided at genesis diff --git a/proto/cork/v1/proposal.proto b/proto/cork/v1/proposal.proto index c980d850..c4e249c1 100644 --- a/proto/cork/v1/proposal.proto +++ b/proto/cork/v1/proposal.proto @@ -4,7 +4,7 @@ package cork.v1; import "cosmos_proto/cosmos.proto"; import "cork/v1/cork.proto"; -option go_package = "github.com/peggyjv/sommelier/v3/x/cork/types"; +option go_package = "github.com/peggyjv/sommelier/v5/x/cork/types"; message AddManagedCellarIDsProposal { string title = 1; diff --git a/proto/cork/v1/query.proto b/proto/cork/v1/query.proto index 7bf94f52..c39cbfc5 100644 --- a/proto/cork/v1/query.proto +++ b/proto/cork/v1/query.proto @@ -8,7 +8,7 @@ import "cork/v1/cork.proto"; import "cosmos_proto/cosmos.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; -option go_package = "github.com/peggyjv/sommelier/v4/x/cork/types"; +option go_package = "github.com/peggyjv/sommelier/v5/x/cork/types"; // Query defines the gRPC query service for the cork module. service Query { diff --git a/proto/cork/v1/tx.proto b/proto/cork/v1/tx.proto index 0407126c..f7e91c6c 100644 --- a/proto/cork/v1/tx.proto +++ b/proto/cork/v1/tx.proto @@ -5,7 +5,7 @@ import "cosmos_proto/cosmos.proto"; import "google/protobuf/any.proto"; import "cork/v1/cork.proto"; -option go_package = "github.com/peggyjv/sommelier/v4/x/cork/types"; +option go_package = "github.com/peggyjv/sommelier/v5/x/cork/types"; // MsgService defines the msgs that the cork module handles service Msg { diff --git a/proto/incentives/v1/genesis.proto b/proto/incentives/v1/genesis.proto new file mode 100644 index 00000000..b055b438 --- /dev/null +++ b/proto/incentives/v1/genesis.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; +package incentives.v1; + + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/peggyjv/sommelier/v5/x/incentives/types"; + + +message GenesisState { + Params params = 1 [ (gogoproto.nullable) = false ]; + } + + +// Params incentives parameters +message Params { + // DistributionPerBlock defines the coin to be sent to the distribution module from the community pool every block + cosmos.base.v1beta1.Coin distribution_per_block = 1 [(gogoproto.nullable) = false]; + // IncentivesCutoffHeight defines the block height after which the incentives module will stop sending coins to the distribution module from + // the community pool + uint64 incentives_cutoff_height = 2; +} diff --git a/proto/incentives/v1/query.proto b/proto/incentives/v1/query.proto new file mode 100644 index 00000000..cdd965a0 --- /dev/null +++ b/proto/incentives/v1/query.proto @@ -0,0 +1,38 @@ +syntax = "proto3"; +package incentives.v1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "incentives/v1/genesis.proto"; + +option go_package = "github.com/peggyjv/sommelier/v5/x/incentives/types"; + +// Query defines the gRPC query service for the cork module. +service Query { + // QueryParams queries the allocation module parameters. + rpc QueryParams(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/sommelier/incentives/v1/params"; + } + // QueryAPY queries the APY returned from the incentives module. + rpc QueryAPY(QueryAPYRequest) returns (QueryAPYResponse) { + option (google.api.http).get = "/sommelier/incentives/v1/apy"; + } +} + +// QueryParamsRequest is the request type for the QueryParams gRPC method. +message QueryParamsRequest {} + +// QueryParamsRequest is the response type for the QueryParams gRPC method. +message QueryParamsResponse { + // allocation parameters + Params params = 1 [(gogoproto.nullable) = false]; +} + +// QueryAPYRequest is the request type for the QueryAPY gRPC method. +message QueryAPYRequest {} + + +// QueryAPYRequest is the response type for the QueryAPY gRPC method. +message QueryAPYResponse { + string apy = 1; +} diff --git a/somm_proto/Cargo.lock b/somm_proto/Cargo.lock index d1bfc119..3731ce5a 100644 --- a/somm_proto/Cargo.lock +++ b/somm_proto/Cargo.lock @@ -606,7 +606,7 @@ dependencies = [ [[package]] name = "somm_proto" -version = "0.1.0" +version = "5.0.0" dependencies = [ "bytes", "cosmos-sdk-proto", diff --git a/somm_proto/Cargo.toml b/somm_proto/Cargo.toml index 2525af44..6c3f4e9a 100644 --- a/somm_proto/Cargo.toml +++ b/somm_proto/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "somm_proto" -version = "0.1.0" +version = "5.0.0" authors = ["PeggyJV"] edition = "2018" @@ -11,4 +11,4 @@ prost = "0.7" prost-types = "0.7" bytes = "1" cosmos-sdk-proto = {git="http://github.com/cosmos/cosmos-rust", branch="main"} -tonic = "0.4" \ No newline at end of file +tonic = "0.4" diff --git a/somm_proto/src/prost/cellarfees.v1.rs b/somm_proto/src/prost/cellarfees.v1.rs new file mode 100644 index 00000000..fdcd14c7 --- /dev/null +++ b/somm_proto/src/prost/cellarfees.v1.rs @@ -0,0 +1,98 @@ +/// Params defines the parameters for the module. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Params {} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct QueryParamsRequest {} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct QueryParamsResponse { + #[prost(message, optional, tag = "1")] + pub params: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct QueryModuleAccountsRequest {} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct QueryModuleAccountsResponse { + #[prost(string, tag = "1")] + pub fees_address: ::prost::alloc::string::String, +} +#[doc = r" Generated client implementations."] +pub mod query_client { + #![allow(unused_variables, dead_code, missing_docs)] + use tonic::codegen::*; + pub struct QueryClient { + inner: tonic::client::Grpc, + } + impl QueryClient { + #[doc = r" Attempt to create a new client by connecting to a given endpoint."] + pub async fn connect(dst: D) -> Result + where + D: std::convert::TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } + } + impl QueryClient + where + T: tonic::client::GrpcService, + T::ResponseBody: Body + HttpBody + Send + 'static, + T::Error: Into, + ::Error: Into + Send, + { + pub fn new(inner: T) -> Self { + let inner = tonic::client::Grpc::new(inner); + Self { inner } + } + pub fn with_interceptor(inner: T, interceptor: impl Into) -> Self { + let inner = tonic::client::Grpc::with_interceptor(inner, interceptor); + Self { inner } + } + pub async fn params( + &mut self, + request: impl tonic::IntoRequest, + ) -> Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/cellarfees.v1.Query/Params"); + self.inner.unary(request.into_request(), path, codec).await + } + pub async fn module_accounts( + &mut self, + request: impl tonic::IntoRequest, + ) -> Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/cellarfees.v1.Query/ModuleAccounts"); + self.inner.unary(request.into_request(), path, codec).await + } + } + impl Clone for QueryClient { + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + } + } + } + impl std::fmt::Debug for QueryClient { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "QueryClient {{ ... }}") + } + } +} +/// GenesisState defines the cellarfees module's genesis state. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GenesisState { + #[prost(message, optional, tag = "1")] + pub params: ::core::option::Option, +} diff --git a/somm_proto/src/prost/incentives.v1.rs b/somm_proto/src/prost/incentives.v1.rs new file mode 100644 index 00000000..01727eec --- /dev/null +++ b/somm_proto/src/prost/incentives.v1.rs @@ -0,0 +1,113 @@ +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GenesisState { + #[prost(message, optional, tag = "1")] + pub params: ::core::option::Option, +} +/// Params incentives parameters +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Params { + /// DistributionPerBlock defines the coin to be sent to the distribution module from the community pool every block + #[prost(message, optional, tag = "1")] + pub distribution_per_block: ::core::option::Option, + /// IncentivesCutoffHeight defines the block height after which the incentives module will stop sending coins to the distribution module from + /// the community pool + #[prost(uint64, tag = "2")] + pub incentives_cutoff_height: u64, +} +/// QueryParamsRequest is the request type for the QueryParams gRPC method. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct QueryParamsRequest {} +/// QueryParamsRequest is the response type for the QueryParams gRPC method. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct QueryParamsResponse { + /// allocation parameters + #[prost(message, optional, tag = "1")] + pub params: ::core::option::Option, +} +/// QueryAPYRequest is the request type for the QueryAPY gRPC method. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct QueryApyRequest {} +/// QueryAPYRequest is the response type for the QueryAPY gRPC method. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct QueryApyResponse { + #[prost(string, tag = "1")] + pub apy: ::prost::alloc::string::String, +} +#[doc = r" Generated client implementations."] +pub mod query_client { + #![allow(unused_variables, dead_code, missing_docs)] + use tonic::codegen::*; + #[doc = " Query defines the gRPC query service for the cork module."] + pub struct QueryClient { + inner: tonic::client::Grpc, + } + impl QueryClient { + #[doc = r" Attempt to create a new client by connecting to a given endpoint."] + pub async fn connect(dst: D) -> Result + where + D: std::convert::TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } + } + impl QueryClient + where + T: tonic::client::GrpcService, + T::ResponseBody: Body + HttpBody + Send + 'static, + T::Error: Into, + ::Error: Into + Send, + { + pub fn new(inner: T) -> Self { + let inner = tonic::client::Grpc::new(inner); + Self { inner } + } + pub fn with_interceptor(inner: T, interceptor: impl Into) -> Self { + let inner = tonic::client::Grpc::with_interceptor(inner, interceptor); + Self { inner } + } + #[doc = " QueryParams queries the allocation module parameters."] + pub async fn query_params( + &mut self, + request: impl tonic::IntoRequest, + ) -> Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/incentives.v1.Query/QueryParams"); + self.inner.unary(request.into_request(), path, codec).await + } + #[doc = " QueryAPY queries the APY returned from the incentives module."] + pub async fn query_apy( + &mut self, + request: impl tonic::IntoRequest, + ) -> Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/incentives.v1.Query/QueryAPY"); + self.inner.unary(request.into_request(), path, codec).await + } + } + impl Clone for QueryClient { + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + } + } + } + impl std::fmt::Debug for QueryClient { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "QueryClient {{ ... }}") + } + } +} diff --git a/testutil/codec.go b/testutil/codec.go new file mode 100644 index 00000000..2f8b816f --- /dev/null +++ b/testutil/codec.go @@ -0,0 +1,45 @@ +package testutil + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/std" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/x/auth/tx" +) + +// TODO(pbal): This is copied from an unreleased version of the cosmos sdk. Upon upgrading our sdk version to 0.46.1 we should import this file + +// TestEncodingConfig defines an encoding configuration that is used for testing +// purposes. Note, MakeTestEncodingConfig takes a series of AppModuleBasic types +// which should only contain the relevant module being tested and any potential +// dependencies. +type TestEncodingConfig struct { + InterfaceRegistry types.InterfaceRegistry + Codec codec.Codec + TxConfig client.TxConfig + Amino *codec.LegacyAmino +} + +func MakeTestEncodingConfig(modules ...module.AppModuleBasic) TestEncodingConfig { + cdc := codec.NewLegacyAmino() + interfaceRegistry := types.NewInterfaceRegistry() + codec := codec.NewProtoCodec(interfaceRegistry) + + encCfg := TestEncodingConfig{ + InterfaceRegistry: interfaceRegistry, + Codec: codec, + TxConfig: tx.NewTxConfig(codec, tx.DefaultSignModes), + Amino: cdc, + } + + mb := module.NewBasicManager(modules...) + + std.RegisterLegacyAminoCodec(encCfg.Amino) + std.RegisterInterfaces(encCfg.InterfaceRegistry) + mb.RegisterLegacyAminoCodec(encCfg.Amino) + mb.RegisterInterfaces(encCfg.InterfaceRegistry) + + return encCfg +} diff --git a/x/cellarfees/client/cli/query.go b/x/cellarfees/client/cli/query.go index c8385121..7ea6eab1 100644 --- a/x/cellarfees/client/cli/query.go +++ b/x/cellarfees/client/cli/query.go @@ -14,7 +14,7 @@ import ( // "github.com/cosmos/cosmos-sdk/client/flags" // sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/peggyjv/sommelier/v4/x/cellarfees/types" + "github.com/peggyjv/sommelier/v5/x/cellarfees/types" ) // GetQueryCmd returns the cli query commands for this module diff --git a/x/cellarfees/client/cli/tx.go b/x/cellarfees/client/cli/tx.go index 86d9b311..0ac2be29 100644 --- a/x/cellarfees/client/cli/tx.go +++ b/x/cellarfees/client/cli/tx.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" // "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/peggyjv/sommelier/v4/x/cellarfees/types" + "github.com/peggyjv/sommelier/v5/x/cellarfees/types" ) var ( diff --git a/x/cellarfees/handler.go b/x/cellarfees/handler.go index eaa6ce0a..97ffbfae 100644 --- a/x/cellarfees/handler.go +++ b/x/cellarfees/handler.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/peggyjv/sommelier/v4/x/cellarfees/keeper" + "github.com/peggyjv/sommelier/v5/x/cellarfees/keeper" ) // NewHandler returns a handler for "cellarfees" type messages. diff --git a/x/cellarfees/keeper/genesis.go b/x/cellarfees/keeper/genesis.go index 000616a6..c3f6425d 100644 --- a/x/cellarfees/keeper/genesis.go +++ b/x/cellarfees/keeper/genesis.go @@ -4,7 +4,7 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/peggyjv/sommelier/v4/x/cellarfees/types" + "github.com/peggyjv/sommelier/v5/x/cellarfees/types" ) // InitGenesis initializes the module's state from a provided genesis diff --git a/x/cellarfees/keeper/keeper.go b/x/cellarfees/keeper/keeper.go index 7f7fd263..c020b0d6 100644 --- a/x/cellarfees/keeper/keeper.go +++ b/x/cellarfees/keeper/keeper.go @@ -9,7 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/peggyjv/sommelier/v4/x/cellarfees/types" + "github.com/peggyjv/sommelier/v5/x/cellarfees/types" ) type Keeper struct { diff --git a/x/cellarfees/keeper/query_server.go b/x/cellarfees/keeper/query_server.go index cc4efacf..3b60edf8 100644 --- a/x/cellarfees/keeper/query_server.go +++ b/x/cellarfees/keeper/query_server.go @@ -4,7 +4,7 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/peggyjv/sommelier/v4/x/cellarfees/types" + "github.com/peggyjv/sommelier/v5/x/cellarfees/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) diff --git a/x/cellarfees/module.go b/x/cellarfees/module.go index f43acdc4..d0c193b9 100644 --- a/x/cellarfees/module.go +++ b/x/cellarfees/module.go @@ -13,9 +13,9 @@ import ( sim "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/peggyjv/sommelier/v4/x/cellarfees/client/cli" - "github.com/peggyjv/sommelier/v4/x/cellarfees/keeper" - "github.com/peggyjv/sommelier/v4/x/cellarfees/types" + "github.com/peggyjv/sommelier/v5/x/cellarfees/client/cli" + "github.com/peggyjv/sommelier/v5/x/cellarfees/keeper" + "github.com/peggyjv/sommelier/v5/x/cellarfees/types" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" ) diff --git a/x/cellarfees/types/genesis.pb.go b/x/cellarfees/types/genesis.pb.go index 2434e935..a205b9ba 100644 --- a/x/cellarfees/types/genesis.pb.go +++ b/x/cellarfees/types/genesis.pb.go @@ -86,9 +86,9 @@ var fileDescriptor_856aa03b4cb6eca9 = []byte{ 0xd4, 0xc9, 0xe7, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x8c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x0b, 0x52, 0xd3, 0xd3, 0x2b, 0xb3, 0xca, - 0xf4, 0x8b, 0xf3, 0x73, 0x73, 0x53, 0x73, 0x32, 0x53, 0x8b, 0xf4, 0xcb, 0x8c, 0xf5, 0x2b, 0xf4, + 0xf4, 0x8b, 0xf3, 0x73, 0x73, 0x53, 0x73, 0x32, 0x53, 0x8b, 0xf4, 0xcb, 0x4c, 0xf5, 0x2b, 0xf4, 0x91, 0x1c, 0x57, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x76, 0x99, 0x31, 0x20, 0x00, 0x00, - 0xff, 0xff, 0xf2, 0xfa, 0x5f, 0xbf, 0xf9, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xbc, 0xf4, 0xe3, 0xba, 0xf9, 0x00, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/cellarfees/types/params.pb.go b/x/cellarfees/types/params.pb.go index 332b3171..a20403a7 100644 --- a/x/cellarfees/types/params.pb.go +++ b/x/cellarfees/types/params.pb.go @@ -75,8 +75,8 @@ var fileDescriptor_f3220ed6f8663c98 = []byte{ 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x28, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0xbf, 0x20, 0x35, 0x3d, 0xbd, 0x32, 0xab, 0x4c, 0xbf, 0x38, 0x3f, 0x37, 0x37, 0x35, 0x27, 0x33, 0xb5, - 0x48, 0xbf, 0xcc, 0x58, 0xbf, 0x42, 0x1f, 0xc9, 0x31, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, - 0x60, 0x4b, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x5c, 0x48, 0xeb, 0xef, 0xa7, 0x00, 0x00, + 0x48, 0xbf, 0xcc, 0x54, 0xbf, 0x42, 0x1f, 0xc9, 0x31, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, + 0x60, 0x4b, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x12, 0x46, 0x57, 0xea, 0xa7, 0x00, 0x00, 0x00, } diff --git a/x/cellarfees/types/query.pb.go b/x/cellarfees/types/query.pb.go index 9eaf14e3..9db5a471 100644 --- a/x/cellarfees/types/query.pb.go +++ b/x/cellarfees/types/query.pb.go @@ -203,29 +203,29 @@ var fileDescriptor_6f4742d3026cf20c = []byte{ // 392 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xcf, 0x8a, 0xd3, 0x40, 0x18, 0x4f, 0x8a, 0x16, 0x9c, 0xaa, 0x87, 0xb1, 0x82, 0xc6, 0x92, 0xda, 0x5c, 0xb4, 0x15, 0x32, - 0xa4, 0x7d, 0x01, 0xdb, 0xa3, 0x28, 0x68, 0x8f, 0x5e, 0xca, 0x24, 0xfd, 0x1c, 0x23, 0x49, 0x26, - 0xcd, 0x4c, 0x42, 0x7b, 0xf5, 0x09, 0x04, 0x6f, 0x1e, 0x7c, 0x9e, 0x1e, 0x0b, 0x5e, 0x3c, 0x2d, - 0x4b, 0xbb, 0x0f, 0xb2, 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c0, 0x6b, 0xd4, 0xd6, 0x0d, 0xf0, 0xe0, 0xac, 0xd8, 0xcd, 0x89, 0x96, 0x73, 0x1b, 0x45, 0xa7, + 0x3b, 0xaf, 0x7e, 0xfc, 0xbd, 0xfc, 0xd5, 0x1a, 0xe0, 0x3e, 0x11, 0x3c, 0x8e, 0x21, 0x0a, 0x21, + 0x23, 0x4d, 0x6f, 0x89, 0x7f, 0x9b, 0xe8, 0x71, 0x7d, 0x01, 0x1e, 0x36, 0xf9, 0x37, 0xbe, 0x81, + 0x35, 0xba, 0x0b, 0xb5, 0xaa, 0xe4, 0xa9, 0x4a, 0x6f, 0xf0, 0xf0, 0x58, 0x49, 0x9c, 0x75, 0x8a, + 0x95, 0x72, 0x41, 0x2b, 0xe9, 0xec, 0xc3, 0x76, 0x6f, 0x9b, 0xbb, 0xbd, 0x6d, 0x5e, 0xec, 0x6d, + 0xf3, 0xe7, 0xc1, 0x36, 0x76, 0x07, 0xdb, 0xf8, 0x77, 0xb0, 0x8d, 0x2f, 0x63, 0x16, 0xca, 0x6f, + 0xb9, 0xef, 0x06, 0x3c, 0x26, 0x29, 0x30, 0xb6, 0xf9, 0x5e, 0x9c, 0x2c, 0x2d, 0xde, 0x92, 0xf5, + 0xa9, 0xb5, 0xdc, 0xa4, 0x20, 0xfc, 0xb6, 0xfa, 0x6f, 0x26, 0x57, 0x01, 0x00, 0x00, 0xff, 0xff, + 0x92, 0x71, 0x35, 0xb7, 0xdf, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/cellarfees/types/query.pb.gw.go b/x/cellarfees/types/query.pb.gw.go index 2e608e08..8aa74d3d 100644 --- a/x/cellarfees/types/query.pb.gw.go +++ b/x/cellarfees/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -70,12 +72,14 @@ func local_request_Query_ModuleAccounts_0(ctx context.Context, marshaler runtime // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -83,6 +87,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -96,6 +101,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_ModuleAccounts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -103,6 +110,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_ModuleAccounts_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/x/cork/client/cli/query.go b/x/cork/client/cli/query.go index 0e824d2a..4cecfc5e 100644 --- a/x/cork/client/cli/query.go +++ b/x/cork/client/cli/query.go @@ -4,7 +4,7 @@ import ( "strconv" "github.com/cosmos/cosmos-sdk/client" - "github.com/peggyjv/sommelier/v4/x/cork/types" + "github.com/peggyjv/sommelier/v5/x/cork/types" "github.com/spf13/cobra" ) diff --git a/x/cork/client/cli/tx.go b/x/cork/client/cli/tx.go index 17912c80..9d68cc70 100644 --- a/x/cork/client/cli/tx.go +++ b/x/cork/client/cli/tx.go @@ -11,7 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/version" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/ethereum/go-ethereum/common" - types "github.com/peggyjv/sommelier/v4/x/cork/types" + types "github.com/peggyjv/sommelier/v5/x/cork/types" "github.com/spf13/cobra" ) diff --git a/x/cork/client/cli/tx_test.go b/x/cork/client/cli/tx_test.go index 5b5874f0..0ae6a2c8 100644 --- a/x/cork/client/cli/tx_test.go +++ b/x/cork/client/cli/tx_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/cosmos/cosmos-sdk/simapp/params" - "github.com/peggyjv/sommelier/v4/x/cork/types" + "github.com/peggyjv/sommelier/v5/x/cork/types" "github.com/cosmos/cosmos-sdk/testutil" "github.com/stretchr/testify/require" diff --git a/x/cork/client/proposal_handler.go b/x/cork/client/proposal_handler.go index 5831a663..bad7194c 100644 --- a/x/cork/client/proposal_handler.go +++ b/x/cork/client/proposal_handler.go @@ -2,8 +2,8 @@ package client import ( govclient "github.com/cosmos/cosmos-sdk/x/gov/client" - "github.com/peggyjv/sommelier/v4/x/cork/client/cli" - "github.com/peggyjv/sommelier/v4/x/cork/client/rest" + "github.com/peggyjv/sommelier/v5/x/cork/client/cli" + "github.com/peggyjv/sommelier/v5/x/cork/client/rest" ) var ( diff --git a/x/cork/client/rest/rest.go b/x/cork/client/rest/rest.go index 9c7aae1d..56f68162 100644 --- a/x/cork/client/rest/rest.go +++ b/x/cork/client/rest/rest.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/rest" govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/peggyjv/sommelier/v4/x/cork/types" + "github.com/peggyjv/sommelier/v5/x/cork/types" ) // AddProposalRESTHandler returns a ProposalRESTHandler that exposes add managed cellar IDs REST handler with a given sub-route. diff --git a/x/cork/handler.go b/x/cork/handler.go index 3218a4a0..488923bf 100644 --- a/x/cork/handler.go +++ b/x/cork/handler.go @@ -6,8 +6,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/peggyjv/sommelier/v4/x/cork/keeper" - "github.com/peggyjv/sommelier/v4/x/cork/types" + "github.com/peggyjv/sommelier/v5/x/cork/keeper" + "github.com/peggyjv/sommelier/v5/x/cork/types" ) // NewHandler returns a handler for "oracle" type messages. diff --git a/x/cork/keeper/abci.go b/x/cork/keeper/abci.go index ab896192..23166425 100644 --- a/x/cork/keeper/abci.go +++ b/x/cork/keeper/abci.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" gravitytypes "github.com/peggyjv/gravity-bridge/module/v2/x/gravity/types" - "github.com/peggyjv/sommelier/v4/x/cork/types" + "github.com/peggyjv/sommelier/v5/x/cork/types" ) // BeginBlocker is called at the beginning of every block diff --git a/x/cork/keeper/genesis.go b/x/cork/keeper/genesis.go index 9b885250..a86acac5 100644 --- a/x/cork/keeper/genesis.go +++ b/x/cork/keeper/genesis.go @@ -2,7 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/peggyjv/sommelier/v4/x/cork/types" + "github.com/peggyjv/sommelier/v5/x/cork/types" ) // InitGenesis initialize default parameters diff --git a/x/cork/keeper/keeper.go b/x/cork/keeper/keeper.go index b18b782c..2f02fa19 100644 --- a/x/cork/keeper/keeper.go +++ b/x/cork/keeper/keeper.go @@ -9,7 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/ethereum/go-ethereum/common" - "github.com/peggyjv/sommelier/v4/x/cork/types" + "github.com/peggyjv/sommelier/v5/x/cork/types" "github.com/tendermint/tendermint/libs/log" ) diff --git a/x/cork/keeper/keeper_test.go b/x/cork/keeper/keeper_test.go deleted file mode 100644 index 75e365b7..00000000 --- a/x/cork/keeper/keeper_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package keeper - -import ( - "testing" - - sdktypes "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" - "github.com/peggyjv/sommelier/v4/x/cork/types" - "github.com/stretchr/testify/require" -) - -type ValCellar struct { - Val sdktypes.ValAddress - Cork types.Cork -} - -type VoteCalculatorTestCase struct { - title string - description string - CellarID common.Address - ValCellars []ValCellar - WinningVotes []types.Cork -} - -var ( - vallAddrA, _ = sdktypes.ValAddressFromHex("24ep6yqkhpwnfdrrapu6fzmjp3xrpsgca11ab1e") - - exampleAddrA = common.HexToAddress("0xc0ffee254729296a45a3885639AC7E10F9d54979") -) - -func TestGetWinningVotes(t *testing.T) { - testCases := []VoteCalculatorTestCase{ - {title: "Single voter", - description: "Check that a single voter returns it's vote", - CellarID: exampleAddrA, - ValCellars: []ValCellar{ - {Val: vallAddrA, - Cork: types.Cork{ - TargetContractAddress: exampleAddrA.String(), - EncodedContractCall: []byte{33}, - }, - }, - }, - WinningVotes: []types.Cork{ - { - TargetContractAddress: exampleAddrA.String(), - EncodedContractCall: []byte{33}, - }, - }, - }, - } - - for _, test := range testCases { - input := CreateTestEnv(t) - ctx := input.Context - t.Logf(test.title) - - for _, vc := range test.ValCellars { - commit := types.Cork{ - TargetContractAddress: exampleAddrA.String(), - EncodedContractCall: []byte{33}, - } - - input.corkKeeper.SetCork(ctx, vc.Val, commit) - } - - winningVotes := input.corkKeeper.GetApprovedCorks(ctx, sdktypes.MustNewDecFromStr("0.66")) - require.Lenf(t, winningVotes, 1, test.description) - } -} diff --git a/x/cork/keeper/msg_server.go b/x/cork/keeper/msg_server.go index 36c189b4..9c9c51ab 100644 --- a/x/cork/keeper/msg_server.go +++ b/x/cork/keeper/msg_server.go @@ -9,7 +9,7 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/ethereum/go-ethereum/common" - "github.com/peggyjv/sommelier/v4/x/cork/types" + "github.com/peggyjv/sommelier/v5/x/cork/types" ) var _ types.MsgServer = Keeper{} diff --git a/x/cork/keeper/proposal_handler.go b/x/cork/keeper/proposal_handler.go index a67b13fa..61a93961 100644 --- a/x/cork/keeper/proposal_handler.go +++ b/x/cork/keeper/proposal_handler.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" - "github.com/peggyjv/sommelier/v4/x/cork/types" + "github.com/peggyjv/sommelier/v5/x/cork/types" ) // HandleAddManagedCellarsProposal is a handler for executing a passed community cellar addition proposal diff --git a/x/cork/keeper/query_server.go b/x/cork/keeper/query_server.go index 3fbea91e..e892614a 100644 --- a/x/cork/keeper/query_server.go +++ b/x/cork/keeper/query_server.go @@ -8,7 +8,7 @@ import ( "google.golang.org/grpc/status" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/peggyjv/sommelier/v4/x/cork/types" + "github.com/peggyjv/sommelier/v5/x/cork/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/cork/keeper/test_common.go b/x/cork/keeper/test_common.go index e8be1c94..28b1f69b 100644 --- a/x/cork/keeper/test_common.go +++ b/x/cork/keeper/test_common.go @@ -52,7 +52,7 @@ import ( "github.com/peggyjv/gravity-bridge/module/v2/x/gravity" gravitykeeper "github.com/peggyjv/gravity-bridge/module/v2/x/gravity/keeper" gravitytypes "github.com/peggyjv/gravity-bridge/module/v2/x/gravity/types" - "github.com/peggyjv/sommelier/v4/x/cork/types" + "github.com/peggyjv/sommelier/v5/x/cork/types" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" diff --git a/x/cork/module.go b/x/cork/module.go index 65660d0f..6e768321 100644 --- a/x/cork/module.go +++ b/x/cork/module.go @@ -13,9 +13,9 @@ import ( sim "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/peggyjv/sommelier/v4/x/cork/client/cli" - "github.com/peggyjv/sommelier/v4/x/cork/keeper" - "github.com/peggyjv/sommelier/v4/x/cork/types" + "github.com/peggyjv/sommelier/v5/x/cork/client/cli" + "github.com/peggyjv/sommelier/v5/x/cork/keeper" + "github.com/peggyjv/sommelier/v5/x/cork/types" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" ) diff --git a/x/cork/types/cork.pb.go b/x/cork/types/cork.pb.go index 4f21f586..e4929891 100644 --- a/x/cork/types/cork.pb.go +++ b/x/cork/types/cork.pb.go @@ -246,25 +246,25 @@ var fileDescriptor_79882ab39b78d896 = []byte{ // 334 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xc1, 0x4a, 0xf3, 0x40, 0x14, 0x85, 0x3b, 0x7f, 0xcb, 0x2f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eb, 0xa2, 0xaf, 0xad, + 0x8b, 0xde, 0x73, 0xb7, 0xb6, 0xc9, 0xdd, 0xda, 0x67, 0xee, 0xd6, 0x5e, 0x2e, 0xa2, 0xc4, 0xc4, + 0xab, 0x99, 0xc7, 0x20, 0x25, 0x4b, 0x11, 0x45, 0xeb, 0xd7, 0x8c, 0x68, 0x48, 0x53, 0x21, 0x13, + 0xa1, 0x48, 0x76, 0x45, 0xde, 0xec, 0x1d, 0x89, 0x59, 0x2f, 0x85, 0x9e, 0xfd, 0xb7, 0xa7, 0xba, + 0xfc, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xd3, 0x88, 0x44, 0x15, 0xe4, 0x01, 0x00, 0x00, } func (m *Cork) Marshal() (dAtA []byte, err error) { diff --git a/x/cork/types/genesis.pb.go b/x/cork/types/genesis.pb.go index 79f6b05b..1ead1482 100644 --- a/x/cork/types/genesis.pb.go +++ b/x/cork/types/genesis.pb.go @@ -158,33 +158,33 @@ func init() { proto.RegisterFile("cork/v1/genesis.proto", fileDescriptor_ec09bf5 var fileDescriptor_ec09bf5ff5694398 = []byte{ // 430 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x52, 0xbf, 0x6a, 0xdb, 0x40, - 0x18, 0xb7, 0x62, 0xc7, 0x25, 0xe7, 0x36, 0x69, 0x8f, 0x24, 0x98, 0x0c, 0xb2, 0xd1, 0x50, 0x3c, - 0xc4, 0x3a, 0x92, 0x0c, 0xa5, 0x5d, 0x0a, 0x4e, 0x68, 0xc8, 0x52, 0x82, 0x5c, 0x3a, 0x74, 0x31, - 0x8a, 0xee, 0x43, 0xbe, 0x5a, 0xd2, 0x27, 0xee, 0x2e, 0x22, 0x7e, 0x8b, 0x4e, 0x7d, 0x8f, 0xbe, - 0x45, 0xc6, 0x8c, 0xa5, 0x83, 0x29, 0xf6, 0x1b, 0xe4, 0x09, 0x8a, 0xee, 0x24, 0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c9, 0xf1, 0xd3, 0x6a, 0x40, 0x97, 0x61, 0x9a, 0x7c, 0xf0, 0x1a, 0xa2, 0x17, 0x90, 0x12, 0xdd, + 0x18, 0x40, 0x33, 0xb2, 0x6f, 0x34, 0x3d, 0x97, 0xa0, 0xe6, 0x98, 0x70, 0xb3, 0xa0, 0xbd, 0xc9, + 0x55, 0xb9, 0x8a, 0x3f, 0xab, 0xc1, 0xeb, 0x58, 0xe8, 0xf9, 0xdd, 0xad, 0x1f, 0x61, 0xca, 0x22, + 0x54, 0x29, 0xaa, 0xea, 0x33, 0x56, 0x7c, 0xc1, 0xf4, 0x32, 0x07, 0xe5, 0x5f, 0x42, 0xf4, 0xb4, + 0x1a, 0x1c, 0x35, 0x9a, 0xb6, 0xd3, 0xbc, 0xe0, 0x45, 0x49, 0x7c, 0xa9, 0xf1, 0xe4, 0xd3, 0xc3, + 0xda, 0x75, 0x1e, 0xd7, 0xae, 0xf3, 0x77, 0xed, 0x3a, 0x3f, 0x36, 0x6e, 0xeb, 0x71, 0xe3, 0xb6, 0x7e, 0x6f, 0xdc, 0xd6, 0xb7, 0xd3, 0x46, 0x53, 0x0e, 0x71, 0xbc, 0xfc, 0x5e, 0x30, 0x85, 0x69, - 0x0a, 0x89, 0x00, 0xc9, 0x8a, 0x0b, 0xf6, 0x60, 0x4e, 0xc5, 0x76, 0xde, 0x75, 0xcd, 0x6d, 0x5c, - 0xfc, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x5e, 0xf1, 0x78, 0xce, 0x79, 0x02, 0x00, 0x00, + 0x0a, 0x89, 0x00, 0xc9, 0x8a, 0xb7, 0xec, 0xde, 0x9c, 0x8a, 0xed, 0xbc, 0xed, 0x9a, 0xdb, 0x78, + 0xf3, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xde, 0xab, 0x89, 0xbc, 0x79, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/cork/types/proposal.pb.go b/x/cork/types/proposal.pb.go index 37fd70ff..cbfaa9af 100644 --- a/x/cork/types/proposal.pb.go +++ b/x/cork/types/proposal.pb.go @@ -298,26 +298,26 @@ func init() { proto.RegisterFile("cork/v1/proposal.proto", fileDescriptor_55632a var fileDescriptor_55632a565c114c4a = []byte{ // 323 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4b, 0xce, 0x2f, 0xca, - 0xd6, 0x2f, 0x33, 0xd4, 0x2f, 0x28, 0xca, 0x2f, 0xc8, 0x2f, 0x4e, 0xcc, 0xd1, 0x2b, 0x28, 0xca, - 0x2f, 0xc9, 0x17, 0x62, 0x07, 0x89, 0xeb, 0x95, 0x19, 0x4a, 0x49, 0x26, 0xe7, 0x17, 0xe7, 0xe6, - 0x17, 0xc7, 0x83, 0x85, 0xf5, 0x21, 0x1c, 0x88, 0x1a, 0x29, 0x21, 0x98, 0x5e, 0xb0, 0x5a, 0xb0, - 0x98, 0x52, 0x17, 0x23, 0x97, 0xb4, 0x63, 0x4a, 0x8a, 0x6f, 0x62, 0x5e, 0x62, 0x7a, 0x6a, 0x8a, - 0x73, 0x6a, 0x4e, 0x4e, 0x62, 0x91, 0xa7, 0x4b, 0x71, 0x00, 0xd4, 0x74, 0x21, 0x11, 0x2e, 0xd6, - 0x92, 0xcc, 0x92, 0x9c, 0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x08, 0x47, 0x48, 0x81, - 0x8b, 0x3b, 0x25, 0xb5, 0x38, 0xb9, 0x28, 0xb3, 0xa0, 0x24, 0x33, 0x3f, 0x4f, 0x82, 0x09, 0x2c, - 0x87, 0x2c, 0x24, 0x64, 0xcc, 0xc5, 0x95, 0x0c, 0x36, 0x2c, 0x3e, 0x33, 0xa5, 0x58, 0x82, 0x59, - 0x81, 0x51, 0x83, 0xdb, 0x48, 0x44, 0x0f, 0xea, 0x48, 0x3d, 0x98, 0x3d, 0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0x46, 0x0d, 0xd9, 0x74, 0x47, 0x90, 0x33, 0xe2, 0x12, 0x52, 0x48, 0x04, 0xb9, + 0x25, 0x06, 0x1f, 0x40, 0x0d, 0x42, 0x0a, 0x41, 0x62, 0x21, 0xd8, 0x84, 0xcb, 0xed, 0x70, 0x59, + 0xbd, 0xcb, 0x2c, 0xbb, 0xeb, 0x61, 0x5e, 0x41, 0x10, 0x6c, 0x05, 0x1f, 0xc8, 0x32, 0xa5, 0xa5, + 0x24, 0x2f, 0x22, 0xee, 0xe5, 0x20, 0x58, 0xa4, 0xb0, 0xd1, 0xf2, 0xff, 0xe7, 0x9f, 0x99, 0x8f, + 0x61, 0xe8, 0x4e, 0x84, 0xfa, 0x9e, 0x67, 0x1d, 0xae, 0x34, 0x2a, 0x34, 0x61, 0x12, 0x28, 0x8d, + 0x16, 0xbd, 0xca, 0xb7, 0x1f, 0x64, 0x9d, 0xc6, 0x6e, 0x84, 0x26, 0x45, 0x33, 0x74, 0x36, 0xcf, + 0x45, 0x9e, 0x69, 0x78, 0x45, 0xaf, 0xcb, 0x3a, 0xaf, 0xf5, 0x44, 0xe8, 0xde, 0xa9, 0x10, 0x97, + 0xe1, 0x24, 0x8c, 0x41, 0x9c, 0x43, 0x92, 0x84, 0xba, 0xdf, 0x33, 0x57, 0xcb, 0xe9, 0x5e, 0x9d, + 0x6e, 0x59, 0x69, 0x13, 0xf0, 0x49, 0x93, 0xb4, 0xab, 0x83, 0x5c, 0x78, 0x4d, 0x5a, 0x13, 0x60, + 0x22, 0x2d, 0x95, 0x95, 0x38, 0xf1, 0x37, 0x5c, 0x6d, 0xd5, 0xf2, 0xba, 0x94, 0x46, 0x6e, 0xd8, + 0x50, 0x0a, 0xe3, 0x97, 0x9b, 0xa4, 0x5d, 0x3b, 0xae, 0x07, 0x4b, 0xc8, 0xa0, 0xd8, 0x73, 0x0d, + 0x76, 0x50, 0xcd, 0x73, 0x7d, 0x61, 0x5a, 0xaf, 0x84, 0x1e, 0xac, 0x81, 0xb9, 0x91, 0x76, 0xdc, + 0x03, 0x85, 0x46, 0xda, 0x5f, 0x73, 0xed, 0xff, 0xe0, 0x2a, 0xb7, 0xab, 0x2b, 0x04, 0x9e, 0x4f, + 0x2b, 0x22, 0xdf, 0xe0, 0x6f, 0xba, 0xe6, 0x42, 0xb6, 0x9e, 0x09, 0x65, 0x03, 0x48, 0x31, 0x83, + 0xff, 0x71, 0xab, 0x37, 0x42, 0x0f, 0xd7, 0xf3, 0xfc, 0xe5, 0xb9, 0xce, 0x2e, 0xde, 0xe7, 0x8c, + 0xcc, 0xe6, 0x8c, 0x7c, 0xce, 0x19, 0x79, 0x59, 0xb0, 0xd2, 0x6c, 0xc1, 0x4a, 0x1f, 0x0b, 0x56, + 0xba, 0x3d, 0x8a, 0xa5, 0x1d, 0x3f, 0x8c, 0x82, 0x08, 0x53, 0xae, 0x20, 0x8e, 0xa7, 0x77, 0x19, + 0x37, 0x98, 0xa6, 0x90, 0x48, 0xd0, 0x3c, 0x3b, 0xe1, 0x8f, 0xee, 0x3f, 0xb9, 0x9d, 0x2a, 0x30, + 0xa3, 0x6d, 0xf7, 0xa6, 0xdd, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x15, 0x23, 0x61, 0xf8, 0x02, 0x00, 0x00, } diff --git a/x/cork/types/query.pb.go b/x/cork/types/query.pb.go index 48a845fe..f064c2cd 100644 --- a/x/cork/types/query.pb.go +++ b/x/cork/types/query.pb.go @@ -661,53 +661,53 @@ var fileDescriptor_4ee46790c91f0468 = []byte{ // 784 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x4d, 0x6f, 0xd3, 0x4a, 0x14, 0x8d, 0xfb, 0xf5, 0x5e, 0x27, 0xfd, 0x50, 0xa7, 0x1f, 0x2f, 0x75, 0x53, 0xb7, 0x71, 0xdb, - 0xf7, 0xa2, 0xbc, 0x12, 0x93, 0x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 0x02, 0x63, 0x86, 0xfe, - 0x4f, 0x1f, 0xfc, 0x08, 0x00, 0x00, 0xff, 0xff, 0x82, 0xfe, 0xf6, 0xde, 0x6d, 0x08, 0x00, 0x00, + 0x74, 0x85, 0xa0, 0x20, 0xcd, 0xf2, 0xff, 0xbf, 0x84, 0xe5, 0x1e, 0xab, 0xd4, 0xe3, 0x3e, 0x2c, + 0x8d, 0xf5, 0x98, 0xca, 0x3d, 0xfc, 0x24, 0x81, 0xed, 0xeb, 0x62, 0x09, 0x6f, 0x8e, 0x1b, 0x91, + 0xe8, 0x3e, 0x90, 0x2b, 0xbf, 0x71, 0x82, 0xbb, 0xaf, 0x53, 0xf7, 0x07, 0xf0, 0xee, 0xf5, 0x13, + 0x6e, 0x1a, 0x83, 0xd4, 0x6b, 0x68, 0xcf, 0x93, 0x4f, 0x2f, 0x6a, 0xf7, 0xcf, 0x2e, 0x14, 0xe9, + 0xfc, 0x42, 0x91, 0xbe, 0x5d, 0x28, 0xd2, 0xbb, 0x4b, 0x25, 0x73, 0x7e, 0xa9, 0x64, 0xbe, 0x5c, + 0x2a, 0x99, 0xa7, 0xfb, 0x96, 0x4d, 0xda, 0x3d, 0xa3, 0x6c, 0x62, 0x47, 0xf3, 0x90, 0x65, 0x0d, + 0x9e, 0xf5, 0x13, 0x72, 0xfd, 0xdb, 0xda, 0x29, 0xd3, 0x24, 0x03, 0x0f, 0x05, 0xc6, 0x0c, 0xfd, + 0x9f, 0xbe, 0xf5, 0x23, 0x00, 0x00, 0xff, 0xff, 0x02, 0xa4, 0x07, 0xac, 0x6d, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -726,7 +726,7 @@ type QueryClient interface { QueryParams(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) // QuerySubmittedCorks queries the submitted corks awaiting vote QuerySubmittedCorks(ctx context.Context, in *QuerySubmittedCorksRequest, opts ...grpc.CallOption) (*QuerySubmittedCorksResponse, error) - // QueryVotePeriod queries the heights for the current voting period (current, start and end) + // QueryCommitPeriod queries the heights for the current voting period (current, start and end) QueryCommitPeriod(ctx context.Context, in *QueryCommitPeriodRequest, opts ...grpc.CallOption) (*QueryCommitPeriodResponse, error) // QueryCellarIDs returns all cellars and current tick ranges QueryCellarIDs(ctx context.Context, in *QueryCellarIDsRequest, opts ...grpc.CallOption) (*QueryCellarIDsResponse, error) @@ -815,7 +815,7 @@ type QueryServer interface { QueryParams(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) // QuerySubmittedCorks queries the submitted corks awaiting vote QuerySubmittedCorks(context.Context, *QuerySubmittedCorksRequest) (*QuerySubmittedCorksResponse, error) - // QueryVotePeriod queries the heights for the current voting period (current, start and end) + // QueryCommitPeriod queries the heights for the current voting period (current, start and end) QueryCommitPeriod(context.Context, *QueryCommitPeriodRequest) (*QueryCommitPeriodResponse, error) // QueryCellarIDs returns all cellars and current tick ranges QueryCellarIDs(context.Context, *QueryCellarIDsRequest) (*QueryCellarIDsResponse, error) diff --git a/x/cork/types/query.pb.gw.go b/x/cork/types/query.pb.gw.go index e0c2e638..cb097268 100644 --- a/x/cork/types/query.pb.gw.go +++ b/x/cork/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join func request_Query_QueryParams_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -196,12 +198,14 @@ func local_request_Query_QueryScheduledCorksByBlockHeight_0(ctx context.Context, // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_QueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -209,6 +213,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueryParams_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -222,6 +227,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QuerySubmittedCorks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -229,6 +236,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QuerySubmittedCorks_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -242,6 +250,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueryCommitPeriod_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -249,6 +259,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueryCommitPeriod_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -262,6 +273,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueryCellarIDs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -269,6 +282,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueryCellarIDs_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -282,6 +296,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueryScheduledCorks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -289,6 +305,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueryScheduledCorks_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -302,6 +319,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueryScheduledBlockHeights_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -309,6 +328,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueryScheduledBlockHeights_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -322,6 +342,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueryScheduledCorksByBlockHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -329,6 +351,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueryScheduledCorksByBlockHeight_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/x/cork/types/tx.pb.go b/x/cork/types/tx.pb.go index e1f2aa4a..588d1017 100644 --- a/x/cork/types/tx.pb.go +++ b/x/cork/types/tx.pb.go @@ -230,28 +230,29 @@ func init() { func init() { proto.RegisterFile("cork/v1/tx.proto", fileDescriptor_cfad1a5454058218) } var fileDescriptor_cfad1a5454058218 = []byte{ - // 336 bytes of a gzipped FileDescriptorProto + // 337 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x51, 0x4d, 0x4e, 0xc2, 0x40, 0x18, 0x65, 0x84, 0x60, 0x1c, 0x30, 0x31, 0x13, 0xe5, 0xa7, 0x89, 0x23, 0xb0, 0x62, 0x61, 0x3a, - 0x01, 0x6e, 0xa0, 0x89, 0x31, 0x31, 0x2c, 0xc0, 0x9d, 0x1b, 0x62, 0xeb, 0x38, 0xad, 0xb4, 0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0xff, 0x8a, 0x70, 0x71, 0x28, 0x05, 0xb9, 0xc1, 0xf8, 0x67, 0x30, 0x39, 0xfd, - 0x1e, 0xf0, 0xd7, 0xdf, 0x18, 0x74, 0x97, 0x9c, 0x85, 0x92, 0x11, 0xae, 0xae, 0x97, 0x91, 0xb3, - 0x0d, 0xff, 0xf6, 0xf3, 0x8d, 0xd6, 0x6e, 0x43, 0x16, 0x79, 0x71, 0xf5, 0xb6, 0xa2, 0x68, 0xb9, - 0xa2, 0xe8, 0x63, 0x45, 0xd1, 0x4b, 0x42, 0x0b, 0xcb, 0x84, 0x16, 0xde, 0x13, 0x5a, 0xb8, 0x3b, - 0x17, 0xae, 0x72, 0x22, 0xcb, 0xb4, 0xc1, 0x67, 0x01, 0x17, 0x62, 0xf1, 0x14, 0x33, 0x09, 0xbe, - 0xcf, 0x3d, 0x97, 0x87, 0x2c, 0x1e, 0xb0, 0xb9, 0x3e, 0x37, 0x53, 0x8b, 0x80, 0x4b, 0xab, 0xac, - 0xaf, 0x3e, 0xf8, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x44, 0xcf, 0x37, 0x9e, 0x5c, 0x02, 0x00, 0x00, + 0x01, 0xe3, 0x05, 0x34, 0x31, 0x26, 0x86, 0x05, 0xb8, 0x73, 0x43, 0x6c, 0x1d, 0xa7, 0x95, 0x96, + 0xaf, 0x76, 0xa6, 0x0d, 0xdc, 0xc2, 0x4b, 0x78, 0x17, 0x97, 0x2c, 0x5d, 0x1a, 0x7a, 0x11, 0xd3, + 0x69, 0x55, 0x10, 0x59, 0xb8, 0x7c, 0x3f, 0x79, 0xef, 0xcd, 0x7c, 0xf8, 0xc0, 0x86, 0x70, 0xc2, + 0xe2, 0x1e, 0x53, 0x33, 0x33, 0x08, 0x41, 0x01, 0xd9, 0x4d, 0x19, 0x33, 0xee, 0x19, 0x4d, 0x1b, + 0xa4, 0x0f, 0x72, 0xac, 0x69, 0x96, 0x81, 0xcc, 0x63, 0x34, 0x05, 0x80, 0xf0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 0x55, 0x4e, 0x64, 0x99, 0x36, 0xf8, 0x2c, 0xe0, 0x42, 0xcc, 0x9f, 0x62, 0x26, 0xc1, + 0xf7, 0xb9, 0xe7, 0xf2, 0x90, 0xc5, 0xe7, 0x6c, 0xa6, 0xcf, 0xcd, 0xd4, 0x3c, 0xe0, 0xd2, 0x2a, + 0xeb, 0xab, 0x9f, 0x7d, 0x06, 0x00, 0x00, 0xff, 0xff, 0xc4, 0x95, 0xc6, 0xec, 0x5c, 0x02, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/incentives/client/cli/query.go b/x/incentives/client/cli/query.go new file mode 100644 index 00000000..2026dc67 --- /dev/null +++ b/x/incentives/client/cli/query.go @@ -0,0 +1,81 @@ +package cli + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/peggyjv/sommelier/v5/x/incentives/types" + "github.com/spf13/cobra" +) + +func GetQueryCmd() *cobra.Command { + incentivesQueryCmd := &cobra.Command{ + Use: "incentives", + Short: "Querying commands for the incentives module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + incentivesQueryCmd.AddCommand([]*cobra.Command{ + CmdQueryParams(), + CmdQueryAPY(), + }...) + + return incentivesQueryCmd +} + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Args: cobra.NoArgs, + Short: "query incentive params", + RunE: func(cmd *cobra.Command, _ []string) error { + ctx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(ctx) + req := &types.QueryParamsRequest{} + + res, err := queryClient.QueryParams(context.Background(), req) + if err != nil { + return err + } + + return ctx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryAPY() *cobra.Command { + cmd := &cobra.Command{ + Use: "apy", + Args: cobra.NoArgs, + Short: "query incentives APY", + RunE: func(cmd *cobra.Command, _ []string) error { + ctx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(ctx) + req := &types.QueryAPYRequest{} + + res, err := queryClient.QueryAPY(cmd.Context(), req) + if err != nil { + return err + } + + return ctx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/incentives/handler.go b/x/incentives/handler.go new file mode 100644 index 00000000..016c0bd8 --- /dev/null +++ b/x/incentives/handler.go @@ -0,0 +1,20 @@ +package incentives + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/peggyjv/sommelier/v5/x/incentives/keeper" +) + +// NewHandler returns a handler for "incentive" type messages. +func NewHandler(k keeper.Keeper) sdk.Handler { + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + ctx = ctx.WithEventManager(sdk.NewEventManager()) + switch msg := msg.(type) { + default: + return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized incentives message type: %T", msg) + } + } +} diff --git a/x/incentives/keeper/abci.go b/x/incentives/keeper/abci.go new file mode 100644 index 00000000..345259bc --- /dev/null +++ b/x/incentives/keeper/abci.go @@ -0,0 +1,41 @@ +package keeper + +import ( + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) BeginBlocker(ctx sdk.Context) {} + +// EndBlocker defines Distribution of incentives to stakers +// +// 1) Get the amount of coins to distribute +// +// 2) Send the coins to the distribution module + +func (k Keeper) EndBlocker(ctx sdk.Context) { + incentivesParams := k.GetParamSet(ctx) + // check if incentives are enabled + if uint64(ctx.BlockHeight()) >= incentivesParams.IncentivesCutoffHeight || incentivesParams.DistributionPerBlock.IsZero() { + return + } + + distPerBlockCoins := sdk.NewCoins(incentivesParams.DistributionPerBlock) + feePool := k.DistributionKeeper.GetFeePool(ctx) + newPool, negative := feePool.CommunityPool.SafeSub(sdk.NewDecCoinsFromCoins(distPerBlockCoins...)) + if negative { + k.Logger(ctx).Error("Insufficient coins in community to distribute", "community pool", feePool.CommunityPool) + return + } + + // Send to fee collector for distribution + err := k.BankKeeper.SendCoinsFromModuleToModule(ctx, distributiontypes.ModuleName, authtypes.FeeCollectorName, distPerBlockCoins) + if err != nil { + panic(err) + } + + feePool.CommunityPool = newPool + k.DistributionKeeper.SetFeePool(ctx, feePool) +} diff --git a/x/incentives/keeper/abci_test.go b/x/incentives/keeper/abci_test.go new file mode 100644 index 00000000..47c54c31 --- /dev/null +++ b/x/incentives/keeper/abci_test.go @@ -0,0 +1,58 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + distributionTypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + "github.com/peggyjv/sommelier/v5/app/params" + incentivesTypes "github.com/peggyjv/sommelier/v5/x/incentives/types" +) + +func (suite *KeeperTestSuite) TestEndBlockerIncentivesDisabledDoesNothing() { + ctx, incentivesKeeper := suite.ctx, suite.incentivesKeeper + require := suite.Require() + + incentivesParams := incentivesTypes.DefaultParams() + incentivesKeeper.SetParams(ctx, incentivesParams) + + // By not mocking any other calls, the test will panic and fail if an unmocked keeper function is called, + // implying that the function isn't exiting early as designed. + + require.NotPanics(func() { incentivesKeeper.BeginBlocker(ctx) }) + require.NotPanics(func() { incentivesKeeper.EndBlocker(ctx) }) + + incentivesParams.DistributionPerBlock = sdk.NewCoin(params.BaseCoinUnit, sdk.OneInt()) + incentivesKeeper.SetParams(ctx, incentivesParams) + + require.NotPanics(func() { incentivesKeeper.BeginBlocker(ctx) }) + require.NotPanics(func() { incentivesKeeper.EndBlocker(ctx) }) + + incentivesParams.DistributionPerBlock = sdk.NewCoin(params.BaseCoinUnit, sdk.ZeroInt()) + incentivesParams.IncentivesCutoffHeight = 1500 + incentivesKeeper.SetParams(ctx, incentivesParams) + + require.NotPanics(func() { incentivesKeeper.BeginBlocker(ctx) }) + require.NotPanics(func() { incentivesKeeper.EndBlocker(ctx) }) +} + +func (suite *KeeperTestSuite) TestEndBlockerInsufficientCommunityPoolBalance() { + ctx, incentivesKeeper := suite.ctx, suite.incentivesKeeper + require := suite.Require() + distributionPerBlock := sdk.NewCoin(params.BaseCoinUnit, sdk.NewInt(1000)) + + incentivesParams := incentivesTypes.DefaultParams() + incentivesParams.DistributionPerBlock = distributionPerBlock + incentivesParams.IncentivesCutoffHeight = 100 + incentivesKeeper.SetParams(ctx, incentivesParams) + + // mocks + pool := distributionTypes.FeePool{ + CommunityPool: sdk.NewDecCoins(sdk.NewDecCoin(params.BaseCoinUnit, sdk.NewInt(999))), + } + suite.distributionKeeper.EXPECT().GetFeePool(ctx).Return(pool) + + // By not mocking the bank SendModuleToModule call, the test will panic and fail if the community pool balance + // check branch isn't taken as intended. + + require.NotPanics(func() { incentivesKeeper.BeginBlocker(ctx) }) + require.NotPanics(func() { incentivesKeeper.EndBlocker(ctx) }) +} diff --git a/x/incentives/keeper/genesis.go b/x/incentives/keeper/genesis.go new file mode 100644 index 00000000..ff07f431 --- /dev/null +++ b/x/incentives/keeper/genesis.go @@ -0,0 +1,18 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/peggyjv/sommelier/v5/x/incentives/types" +) + +// InitGenesis initialize default parameters +// and the keeper's address to pubkey map +func InitGenesis(ctx sdk.Context, k Keeper, gs types.GenesisState) { + k.SetParams(ctx, gs.Params) +} + +func ExportGenesis(ctx sdk.Context, k Keeper) types.GenesisState { + return types.GenesisState{ + Params: k.GetParamSet(ctx), + } +} diff --git a/x/incentives/keeper/keeper.go b/x/incentives/keeper/keeper.go new file mode 100644 index 00000000..c8ed9362 --- /dev/null +++ b/x/incentives/keeper/keeper.go @@ -0,0 +1,81 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/peggyjv/sommelier/v5/x/incentives/types" + "github.com/tendermint/tendermint/libs/log" +) + +// Keeper of the incentives store +type Keeper struct { + storeKey sdk.StoreKey + cdc codec.BinaryCodec + paramSpace paramtypes.Subspace + DistributionKeeper types.DistributionKeeper + BankKeeper types.BankKeeper + MintKeeper types.MintKeeper +} + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey sdk.StoreKey, + paramSpace paramtypes.Subspace, + distributionKeeper types.DistributionKeeper, + bankKeeper types.BankKeeper, + mintKeeper types.MintKeeper, +) Keeper { + if !paramSpace.HasKeyTable() { + paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) + } + + return Keeper{ + storeKey: storeKey, + cdc: cdc, + paramSpace: paramSpace, + DistributionKeeper: distributionKeeper, + BankKeeper: bankKeeper, + MintKeeper: mintKeeper, + } +} + +//////////// +// Params // +//////////// + +// GetParamSet returns the parameters +func (k Keeper) GetParamSet(ctx sdk.Context) types.Params { + var p types.Params + k.paramSpace.GetParamSet(ctx, &p) + return p +} + +// setParams sets the parameters in the store +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramSpace.SetParamSet(ctx, ¶ms) +} + +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", "x/"+types.ModuleName) +} + +//////////// +// APY // +//////////// + +func (k Keeper) GetAPY(ctx sdk.Context) sdk.Dec { + incentivesParams := k.GetParamSet(ctx) + // check if incentives are enabled + if uint64(ctx.BlockHeight()) >= incentivesParams.IncentivesCutoffHeight || incentivesParams.DistributionPerBlock.IsZero() { + return sdk.ZeroDec() + } + + mintParams := k.MintKeeper.GetParams(ctx) + bondedRatio := k.MintKeeper.BondedRatio(ctx) + totalCoins := k.MintKeeper.StakingTokenSupply(ctx) + annualRewards := incentivesParams.DistributionPerBlock.Amount.Mul(sdk.NewInt(int64(mintParams.BlocksPerYear))) + + return annualRewards.ToDec().Quo(totalCoins.ToDec()).Quo(bondedRatio) +} diff --git a/x/incentives/keeper/keeper_test.go b/x/incentives/keeper/keeper_test.go new file mode 100644 index 00000000..95aec6f9 --- /dev/null +++ b/x/incentives/keeper/keeper_test.go @@ -0,0 +1,102 @@ +package keeper + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + mintTypes "github.com/cosmos/cosmos-sdk/x/mint/types" + paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" + "github.com/golang/mock/gomock" + "github.com/peggyjv/sommelier/v5/app/params" + moduletestutil "github.com/peggyjv/sommelier/v5/testutil" + incentivestestutil "github.com/peggyjv/sommelier/v5/x/incentives/testutil" + incentivesTypes "github.com/peggyjv/sommelier/v5/x/incentives/types" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + tmtime "github.com/tendermint/tendermint/types/time" +) + +type KeeperTestSuite struct { + suite.Suite + + ctx sdk.Context + incentivesKeeper Keeper + distributionKeeper *incentivestestutil.MockDistributionKeeper + bankKeeper *incentivestestutil.MockBankKeeper + mintKeeper *incentivestestutil.MockMintKeeper + + encCfg moduletestutil.TestEncodingConfig +} + +func (suite *KeeperTestSuite) SetupTest() { + key := sdk.NewKVStoreKey(incentivesTypes.StoreKey) + tkey := sdk.NewTransientStoreKey("transient_test") + testCtx := testutil.DefaultContext(key, tkey) + ctx := testCtx.WithBlockHeader(tmproto.Header{Height: 5, Time: tmtime.Now()}) + encCfg := moduletestutil.MakeTestEncodingConfig() + + // gomock initializations + ctrl := gomock.NewController(suite.T()) + defer ctrl.Finish() + + suite.distributionKeeper = incentivestestutil.NewMockDistributionKeeper(ctrl) + suite.bankKeeper = incentivestestutil.NewMockBankKeeper(ctrl) + suite.mintKeeper = incentivestestutil.NewMockMintKeeper(ctrl) + suite.ctx = ctx + + params := paramskeeper.NewKeeper( + encCfg.Codec, + codec.NewLegacyAmino(), + key, + tkey, + ) + + params.Subspace(incentivesTypes.ModuleName) + subSpace, found := params.GetSubspace(incentivesTypes.ModuleName) + suite.Assertions.True(found) + + suite.incentivesKeeper = NewKeeper( + encCfg.Codec, + key, + subSpace, + suite.distributionKeeper, + suite.bankKeeper, + suite.mintKeeper, + ) + + suite.encCfg = encCfg +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} + +func (suite *KeeperTestSuite) TestGetAPY() { + ctx, incentivesKeeper := suite.ctx, suite.incentivesKeeper + require := suite.Require() + distributionPerBlock := sdk.NewCoin(params.BaseCoinUnit, sdk.OneInt()) + blocksPerYear := 365 * 6 + bondedRatio := sdk.MustNewDecFromStr("0.2") + stakingTotalSupply := sdk.NewInt(10_000_000) + + incentivesKeeper.SetParams(ctx, incentivesTypes.DefaultParams()) + suite.mintKeeper.EXPECT().GetParams(ctx).Return(mintTypes.Params{ + BlocksPerYear: uint64(blocksPerYear), + MintDenom: params.BaseCoinUnit, + }) + suite.mintKeeper.EXPECT().BondedRatio(ctx).Return(bondedRatio) + suite.mintKeeper.EXPECT().StakingTokenSupply(ctx).Return(stakingTotalSupply) + + // incentives disabled + require.Equal(sdk.ZeroDec(), incentivesKeeper.GetAPY(ctx)) + + // incentives enabled + incentivesKeeper.SetParams(ctx, incentivesTypes.Params{ + DistributionPerBlock: distributionPerBlock, + IncentivesCutoffHeight: 1000, + }) + expected := distributionPerBlock.Amount.Mul(sdk.NewInt(int64(blocksPerYear))).ToDec().Quo(stakingTotalSupply.ToDec().Mul(bondedRatio)) + require.Equal(expected, incentivesKeeper.GetAPY(ctx)) +} diff --git a/x/incentives/keeper/query_server.go b/x/incentives/keeper/query_server.go new file mode 100644 index 00000000..f300ea0c --- /dev/null +++ b/x/incentives/keeper/query_server.go @@ -0,0 +1,23 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/peggyjv/sommelier/v5/x/incentives/types" +) + +var _ types.QueryServer = Keeper{} + +// QueryParams implements QueryServer +func (k Keeper) QueryParams(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + return &types.QueryParamsResponse{ + Params: k.GetParamSet(sdk.UnwrapSDKContext(c)), + }, nil +} + +func (k Keeper) QueryAPY(c context.Context, _ *types.QueryAPYRequest) (*types.QueryAPYResponse, error) { + return &types.QueryAPYResponse{ + Apy: k.GetAPY(sdk.UnwrapSDKContext(c)).String(), + }, nil +} diff --git a/x/incentives/keeper/query_server_test.go b/x/incentives/keeper/query_server_test.go new file mode 100644 index 00000000..10652f6c --- /dev/null +++ b/x/incentives/keeper/query_server_test.go @@ -0,0 +1,39 @@ +package keeper + +import ( + "github.com/peggyjv/sommelier/v5/app/params" + "github.com/peggyjv/sommelier/v5/x/incentives/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + mintTypes "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +func (suite *KeeperTestSuite) TestQueriesHappyPath() { + ctx, incentivesKeeper := suite.ctx, suite.incentivesKeeper + require := suite.Require() + blocksPerYear := 365 * 6 + bondedRatio := sdk.MustNewDecFromStr("0.2") + stakingTotalSupply := sdk.NewInt(100_000_000_000) + + incentivesParams := types.DefaultParams() + incentivesParams.DistributionPerBlock = sdk.NewCoin(params.BaseCoinUnit, sdk.NewInt(2_000_000)) + incentivesParams.IncentivesCutoffHeight = 1500 + incentivesKeeper.SetParams(ctx, incentivesParams) + + // mocks + suite.mintKeeper.EXPECT().GetParams(ctx).Return(mintTypes.Params{ + BlocksPerYear: uint64(blocksPerYear), + MintDenom: params.BaseCoinUnit, + }) + suite.mintKeeper.EXPECT().BondedRatio(ctx).Return(bondedRatio) + suite.mintKeeper.EXPECT().StakingTokenSupply(ctx).Return(stakingTotalSupply) + + paramsResult, err := incentivesKeeper.QueryParams(sdk.WrapSDKContext(ctx), &types.QueryParamsRequest{}) + require.Nil(err) + require.Equal(incentivesParams, paramsResult.Params) + + APYResult, err := incentivesKeeper.QueryAPY(sdk.WrapSDKContext(ctx), &types.QueryAPYRequest{}) + require.Nil(err) + expectedAPY := incentivesParams.DistributionPerBlock.Amount.Mul(sdk.NewInt(int64(blocksPerYear))).ToDec().Quo(stakingTotalSupply.ToDec()).Quo(bondedRatio) + require.Equal(expectedAPY.String(), APYResult.Apy) +} diff --git a/x/incentives/module.go b/x/incentives/module.go new file mode 100644 index 00000000..34c0f76a --- /dev/null +++ b/x/incentives/module.go @@ -0,0 +1,181 @@ +package incentives + +import ( + "context" + "encoding/json" + "math/rand" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + sim "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/peggyjv/sommelier/v5/x/incentives/client/cli" + "github.com/peggyjv/sommelier/v5/x/incentives/keeper" + "github.com/peggyjv/sommelier/v5/x/incentives/types" + "github.com/spf13/cobra" + abci "github.com/tendermint/tendermint/abci/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleSimulation = AppModule{} +) + +// AppModuleBasic defines the basic application module used by the incentives module. +type AppModuleBasic struct{} + +// Name returns the incentives module's name +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec doesn't support amino +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} + +// DefaultGenesis returns default genesis state as raw bytes for the incentives +// module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + gs := types.DefaultGenesisState() + return cdc.MustMarshalJSON(&gs) +} + +// ValidateGenesis performs genesis state validation for the incentives module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var gs types.GenesisState + if err := cdc.UnmarshalJSON(bz, &gs); err != nil { + return err + } + return gs.Validate() +} + +// RegisterRESTRoutes doesn't support legacy REST routes. +// We don't want to support the legacy rest server here +func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} + +// GetTxCmd returns the root tx command for the incentives module. +func (AppModuleBasic) GetTxCmd() *cobra.Command { + return nil +} + +// GetQueryCmd returns the root query command for the incentives module. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the incentives module. +// also implements app modeul basic +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) +} + +// RegisterInterfaces implements app module basic +func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + +// AppModule implements an application module for the incentives module. +type AppModule struct { + AppModuleBasic + keeper keeper.Keeper + distributionKeeper types.DistributionKeeper + bankKeeper types.BankKeeper + mintKeeper types.MintKeeper + cdc codec.Codec +} + +// NewAppModule creates a new AppModule object +func NewAppModule(keeper keeper.Keeper, distributionKeeper types.DistributionKeeper, + bankKeeper types.BankKeeper, mintKeeper types.MintKeeper, cdc codec.Codec) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{}, + keeper: keeper, + distributionKeeper: distributionKeeper, + bankKeeper: bankKeeper, + mintKeeper: mintKeeper, + cdc: cdc, + } +} + +// Name returns the incentives module's name. +func (AppModule) Name() string { return types.ModuleName } + +// RegisterInvariants performs a no-op. +func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// Route returns the message routing key for the incentives module. +func (am AppModule) Route() sdk.Route { return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) } + +// QuerierRoute returns the incentives module's querier route name. +func (AppModule) QuerierRoute() string { return types.QuerierRoute } + +// LegacyQuerierHandler returns a nil Querier. +func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { + return nil +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { + return 1 +} + +func (am AppModule) WeightedOperations(simState module.SimulationState) []sim.WeightedOperation { + return nil +} + +// RegisterServices registers module services. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// InitGenesis performs genesis initialization for the incentives module. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + cdc.MustUnmarshalJSON(data, &genesisState) + keeper.InitGenesis(ctx, am.keeper, genesisState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the incentives +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genesisState := keeper.ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(&genesisState) +} + +// BeginBlock returns the begin blocker for the incentives module. +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { + am.keeper.BeginBlocker(ctx) +} + +// EndBlock returns the end blocker for the incentives module. +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + am.keeper.EndBlocker(ctx) + return []abci.ValidatorUpdate{} +} + +// AppModuleSimulation functions + +// GenerateGenesisState creates a randomized GenState of the distribution module. +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { +} + +// ProposalContents returns all the distribution content functions used to +// simulate governance proposals. +func (am AppModule) ProposalContents(_ module.SimulationState) []sim.WeightedProposalContent { + return nil +} + +// RandomizedParams creates randomized distribution param changes for the simulator. +func (AppModule) RandomizedParams(r *rand.Rand) []sim.ParamChange { + return nil +} + +// RegisterStoreDecoder registers a decoder for distribution module's types +func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { +} diff --git a/x/incentives/testutil/expected_keepers_mocks.go b/x/incentives/testutil/expected_keepers_mocks.go new file mode 100644 index 00000000..4f6cad0a --- /dev/null +++ b/x/incentives/testutil/expected_keepers_mocks.go @@ -0,0 +1,263 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: /Users/atro/source/work/sommelier/x/incentives/types/expected_keepers.go + +// Package mock_types is a generated GoMock package. +package mock_types + +import ( + reflect "reflect" + + types "github.com/cosmos/cosmos-sdk/types" + types0 "github.com/cosmos/cosmos-sdk/x/distribution/types" + types1 "github.com/cosmos/cosmos-sdk/x/mint/types" + gomock "github.com/golang/mock/gomock" +) + +// MockDistributionKeeper is a mock of DistributionKeeper interface. +type MockDistributionKeeper struct { + ctrl *gomock.Controller + recorder *MockDistributionKeeperMockRecorder +} + +// MockDistributionKeeperMockRecorder is the mock recorder for MockDistributionKeeper. +type MockDistributionKeeperMockRecorder struct { + mock *MockDistributionKeeper +} + +// NewMockDistributionKeeper creates a new mock instance. +func NewMockDistributionKeeper(ctrl *gomock.Controller) *MockDistributionKeeper { + mock := &MockDistributionKeeper{ctrl: ctrl} + mock.recorder = &MockDistributionKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockDistributionKeeper) EXPECT() *MockDistributionKeeperMockRecorder { + return m.recorder +} + +// GetFeePool mocks base method. +func (m *MockDistributionKeeper) GetFeePool(ctx types.Context) types0.FeePool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetFeePool", ctx) + ret0, _ := ret[0].(types0.FeePool) + return ret0 +} + +// GetFeePool indicates an expected call of GetFeePool. +func (mr *MockDistributionKeeperMockRecorder) GetFeePool(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFeePool", reflect.TypeOf((*MockDistributionKeeper)(nil).GetFeePool), ctx) +} + +// SetFeePool mocks base method. +func (m *MockDistributionKeeper) SetFeePool(ctx types.Context, feePool types0.FeePool) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetFeePool", ctx, feePool) +} + +// SetFeePool indicates an expected call of SetFeePool. +func (mr *MockDistributionKeeperMockRecorder) SetFeePool(ctx, feePool interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetFeePool", reflect.TypeOf((*MockDistributionKeeper)(nil).SetFeePool), ctx, feePool) +} + +// MockBankKeeper is a mock of BankKeeper interface. +type MockBankKeeper struct { + ctrl *gomock.Controller + recorder *MockBankKeeperMockRecorder +} + +// MockBankKeeperMockRecorder is the mock recorder for MockBankKeeper. +type MockBankKeeperMockRecorder struct { + mock *MockBankKeeper +} + +// NewMockBankKeeper creates a new mock instance. +func NewMockBankKeeper(ctrl *gomock.Controller) *MockBankKeeper { + mock := &MockBankKeeper{ctrl: ctrl} + mock.recorder = &MockBankKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockBankKeeper) EXPECT() *MockBankKeeperMockRecorder { + return m.recorder +} + +// BlockedAddr mocks base method. +func (m *MockBankKeeper) BlockedAddr(addr types.AccAddress) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BlockedAddr", addr) + ret0, _ := ret[0].(bool) + return ret0 +} + +// BlockedAddr indicates an expected call of BlockedAddr. +func (mr *MockBankKeeperMockRecorder) BlockedAddr(addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlockedAddr", reflect.TypeOf((*MockBankKeeper)(nil).BlockedAddr), addr) +} + +// GetAllBalances mocks base method. +func (m *MockBankKeeper) GetAllBalances(ctx types.Context, addr types.AccAddress) types.Coins { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAllBalances", ctx, addr) + ret0, _ := ret[0].(types.Coins) + return ret0 +} + +// GetAllBalances indicates an expected call of GetAllBalances. +func (mr *MockBankKeeperMockRecorder) GetAllBalances(ctx, addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllBalances", reflect.TypeOf((*MockBankKeeper)(nil).GetAllBalances), ctx, addr) +} + +// GetBalance mocks base method. +func (m *MockBankKeeper) GetBalance(ctx types.Context, addr types.AccAddress, denom string) types.Coin { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetBalance", ctx, addr, denom) + ret0, _ := ret[0].(types.Coin) + return ret0 +} + +// GetBalance indicates an expected call of GetBalance. +func (mr *MockBankKeeperMockRecorder) GetBalance(ctx, addr, denom interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBalance", reflect.TypeOf((*MockBankKeeper)(nil).GetBalance), ctx, addr, denom) +} + +// LockedCoins mocks base method. +func (m *MockBankKeeper) LockedCoins(ctx types.Context, addr types.AccAddress) types.Coins { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "LockedCoins", ctx, addr) + ret0, _ := ret[0].(types.Coins) + return ret0 +} + +// LockedCoins indicates an expected call of LockedCoins. +func (mr *MockBankKeeperMockRecorder) LockedCoins(ctx, addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LockedCoins", reflect.TypeOf((*MockBankKeeper)(nil).LockedCoins), ctx, addr) +} + +// SendCoinsFromAccountToModule mocks base method. +func (m *MockBankKeeper) SendCoinsFromAccountToModule(ctx types.Context, senderAddr types.AccAddress, recipientModule string, amt types.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendCoinsFromAccountToModule", ctx, senderAddr, recipientModule, amt) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendCoinsFromAccountToModule indicates an expected call of SendCoinsFromAccountToModule. +func (mr *MockBankKeeperMockRecorder) SendCoinsFromAccountToModule(ctx, senderAddr, recipientModule, amt interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromAccountToModule", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromAccountToModule), ctx, senderAddr, recipientModule, amt) +} + +// SendCoinsFromModuleToAccount mocks base method. +func (m *MockBankKeeper) SendCoinsFromModuleToAccount(ctx types.Context, senderModule string, recipientAddr types.AccAddress, amt types.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendCoinsFromModuleToAccount", ctx, senderModule, recipientAddr, amt) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendCoinsFromModuleToAccount indicates an expected call of SendCoinsFromModuleToAccount. +func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToAccount(ctx, senderModule, recipientAddr, amt interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromModuleToAccount", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromModuleToAccount), ctx, senderModule, recipientAddr, amt) +} + +// SendCoinsFromModuleToModule mocks base method. +func (m *MockBankKeeper) SendCoinsFromModuleToModule(ctx types.Context, senderModule, recipientModule string, amt types.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendCoinsFromModuleToModule", ctx, senderModule, recipientModule, amt) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendCoinsFromModuleToModule indicates an expected call of SendCoinsFromModuleToModule. +func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToModule(ctx, senderModule, recipientModule, amt interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromModuleToModule", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromModuleToModule), ctx, senderModule, recipientModule, amt) +} + +// SpendableCoins mocks base method. +func (m *MockBankKeeper) SpendableCoins(ctx types.Context, addr types.AccAddress) types.Coins { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SpendableCoins", ctx, addr) + ret0, _ := ret[0].(types.Coins) + return ret0 +} + +// SpendableCoins indicates an expected call of SpendableCoins. +func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpendableCoins", reflect.TypeOf((*MockBankKeeper)(nil).SpendableCoins), ctx, addr) +} + +// MockMintKeeper is a mock of MintKeeper interface. +type MockMintKeeper struct { + ctrl *gomock.Controller + recorder *MockMintKeeperMockRecorder +} + +// MockMintKeeperMockRecorder is the mock recorder for MockMintKeeper. +type MockMintKeeperMockRecorder struct { + mock *MockMintKeeper +} + +// NewMockMintKeeper creates a new mock instance. +func NewMockMintKeeper(ctrl *gomock.Controller) *MockMintKeeper { + mock := &MockMintKeeper{ctrl: ctrl} + mock.recorder = &MockMintKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMintKeeper) EXPECT() *MockMintKeeperMockRecorder { + return m.recorder +} + +// BondedRatio mocks base method. +func (m *MockMintKeeper) BondedRatio(ctx types.Context) types.Dec { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BondedRatio", ctx) + ret0, _ := ret[0].(types.Dec) + return ret0 +} + +// BondedRatio indicates an expected call of BondedRatio. +func (mr *MockMintKeeperMockRecorder) BondedRatio(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BondedRatio", reflect.TypeOf((*MockMintKeeper)(nil).BondedRatio), ctx) +} + +// GetParams mocks base method. +func (m *MockMintKeeper) GetParams(ctx types.Context) types1.Params { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetParams", ctx) + ret0, _ := ret[0].(types1.Params) + return ret0 +} + +// GetParams indicates an expected call of GetParams. +func (mr *MockMintKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetParams", reflect.TypeOf((*MockMintKeeper)(nil).GetParams), ctx) +} + +// StakingTokenSupply mocks base method. +func (m *MockMintKeeper) StakingTokenSupply(ctx types.Context) types.Int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StakingTokenSupply", ctx) + ret0, _ := ret[0].(types.Int) + return ret0 +} + +// StakingTokenSupply indicates an expected call of StakingTokenSupply. +func (mr *MockMintKeeperMockRecorder) StakingTokenSupply(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StakingTokenSupply", reflect.TypeOf((*MockMintKeeper)(nil).StakingTokenSupply), ctx) +} diff --git a/x/incentives/types/codec.go b/x/incentives/types/codec.go new file mode 100644 index 00000000..662e96ba --- /dev/null +++ b/x/incentives/types/codec.go @@ -0,0 +1,8 @@ +package types + +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" +) + +// RegisterInterfaces registers the incentives proto files +func RegisterInterfaces(registry codectypes.InterfaceRegistry) {} diff --git a/x/incentives/types/errors.go b/x/incentives/types/errors.go new file mode 100644 index 00000000..5b4d88b9 --- /dev/null +++ b/x/incentives/types/errors.go @@ -0,0 +1,9 @@ +package types + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var ( + ErrInvalidDistributionPerBlock = sdkerrors.Register(ModuleName, 1, "invalid distribution per block") +) diff --git a/x/incentives/types/expected_keepers.go b/x/incentives/types/expected_keepers.go new file mode 100644 index 00000000..fe62f7fb --- /dev/null +++ b/x/incentives/types/expected_keepers.go @@ -0,0 +1,36 @@ +//go:generate mockgen -destination=../testutil/expected_keepers_mocks.go -package=keeper github.com/peggyjv/sommelier/v5/x/incentives/types AccountKeeper,DistributionKeeper,BankKeeper,MintKeeper + +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +// DistributionKeeper defines the expected distribution keeper methods +type DistributionKeeper interface { + GetFeePool(ctx sdk.Context) (feePool distributiontypes.FeePool) + SetFeePool(ctx sdk.Context, feePool distributiontypes.FeePool) +} + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin + LockedCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + + SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) error + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + + BlockedAddr(addr sdk.AccAddress) bool +} + +// MintKeeper defines the expected mint keeper methods +type MintKeeper interface { + GetParams(ctx sdk.Context) minttypes.Params + StakingTokenSupply(ctx sdk.Context) sdk.Int + BondedRatio(ctx sdk.Context) sdk.Dec +} diff --git a/x/incentives/types/genesis.go b/x/incentives/types/genesis.go new file mode 100644 index 00000000..67ed2d2e --- /dev/null +++ b/x/incentives/types/genesis.go @@ -0,0 +1,19 @@ +package types + +const DefaultParamspace = ModuleName + +// DefaultGenesisState get raw genesis raw message for testing +func DefaultGenesisState() GenesisState { + return GenesisState{ + Params: DefaultParams(), + } +} + +// Validate performs a basic stateless validation of the genesis fields. +func (gs GenesisState) Validate() error { + if err := gs.Params.ValidateBasic(); err != nil { + return err + } + + return nil +} diff --git a/x/incentives/types/genesis.pb.go b/x/incentives/types/genesis.pb.go new file mode 100644 index 00000000..226e87c7 --- /dev/null +++ b/x/incentives/types/genesis.pb.go @@ -0,0 +1,539 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: incentives/v1/genesis.proto + +package types + +import ( + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_179cfb82d3e2b395, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// Params incentives parameters +type Params struct { + // DistributionPerBlock defines the coin to be sent to the distribution module from the community pool every block + DistributionPerBlock types.Coin `protobuf:"bytes,1,opt,name=distribution_per_block,json=distributionPerBlock,proto3" json:"distribution_per_block"` + // IncentivesCutoffHeight defines the block height after which the incentives module will stop sending coins to the distribution module from + // the community pool + IncentivesCutoffHeight uint64 `protobuf:"varint,2,opt,name=incentives_cutoff_height,json=incentivesCutoffHeight,proto3" json:"incentives_cutoff_height,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_179cfb82d3e2b395, []int{1} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetDistributionPerBlock() types.Coin { + if m != nil { + return m.DistributionPerBlock + } + return types.Coin{} +} + +func (m *Params) GetIncentivesCutoffHeight() uint64 { + if m != nil { + return m.IncentivesCutoffHeight + } + return 0 +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "incentives.v1.GenesisState") + proto.RegisterType((*Params)(nil), "incentives.v1.Params") +} + +func init() { proto.RegisterFile("incentives/v1/genesis.proto", fileDescriptor_179cfb82d3e2b395) } + +var fileDescriptor_179cfb82d3e2b395 = []byte{ + // 310 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0xd0, 0xb1, 0x4f, 0x3a, 0x31, + 0x14, 0x07, 0xf0, 0xeb, 0x2f, 0x84, 0xe1, 0x7e, 0xba, 0x5c, 0x90, 0x20, 0x26, 0x95, 0x30, 0x31, + 0xb5, 0x39, 0x88, 0x89, 0x33, 0x0c, 0x3a, 0x38, 0x10, 0x8c, 0x8b, 0xcb, 0xe5, 0xae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3d, 0x32, 0x68, 0xcc, 0xda, 0x47, 0x9f, 0x94, 0x7c, 0x5f, 0xea, + 0xf8, 0x61, 0xb3, 0xa3, 0x64, 0xbb, 0xa3, 0xe4, 0x67, 0x47, 0xc9, 0xc7, 0x9e, 0x06, 0xdb, 0x3d, + 0x0d, 0xbe, 0xf6, 0x34, 0x78, 0x1e, 0x4a, 0xe5, 0x16, 0xab, 0x8c, 0x09, 0xcc, 0x79, 0x01, 0x52, + 0xae, 0x5f, 0x3d, 0xb7, 0x98, 0xe7, 0xb0, 0x54, 0x60, 0xb8, 0xbf, 0xe1, 0xef, 0xfc, 0xe4, 0xfc, + 0x6e, 0x5d, 0x80, 0xcd, 0x9a, 0xe5, 0xd5, 0x46, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x9b, 0x92, + 0xe8, 0x06, 0x99, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IncentivesCutoffHeight != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.IncentivesCutoffHeight)) + i-- + dAtA[i] = 0x10 + } + { + size, err := m.DistributionPerBlock.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.DistributionPerBlock.Size() + n += 1 + l + sovGenesis(uint64(l)) + if m.IncentivesCutoffHeight != 0 { + n += 1 + sovGenesis(uint64(m.IncentivesCutoffHeight)) + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DistributionPerBlock", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.DistributionPerBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IncentivesCutoffHeight", wireType) + } + m.IncentivesCutoffHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.IncentivesCutoffHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/incentives/types/keys.go b/x/incentives/types/keys.go new file mode 100644 index 00000000..54961b75 --- /dev/null +++ b/x/incentives/types/keys.go @@ -0,0 +1,15 @@ +package types + +const ( + // ModuleName is the module name constant used in many places + ModuleName = "incentives" + + // StoreKey is the store key string for incentives + StoreKey = ModuleName + + // RouterKey is the message route for incentives + RouterKey = ModuleName + + // QuerierRoute is the querier route for incentives + QuerierRoute = ModuleName +) diff --git a/x/incentives/types/params.go b/x/incentives/types/params.go new file mode 100644 index 00000000..249aa460 --- /dev/null +++ b/x/incentives/types/params.go @@ -0,0 +1,71 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/peggyjv/sommelier/v5/app/params" +) + +// Parameter keys +var ( + KeyDistributionPerBlock = []byte("DistributionPerBlock") + KeyIncentivesCutoffHeight = []byte("IncentivesCutoffHeight") +) + +var _ paramtypes.ParamSet = &Params{} + +// ParamKeyTable returns the parameter key table. +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// DefaultParams returns default incentives parameters +func DefaultParams() Params { + return Params{ + DistributionPerBlock: sdk.NewCoin(params.BaseCoinUnit, sdk.ZeroInt()), + // Anything lower than or equal to current height is "off" + IncentivesCutoffHeight: 0, + } +} + +// ParamSetPairs returns the parameter set pairs. +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyDistributionPerBlock, &p.DistributionPerBlock, validateDistributionPerBlock), + paramtypes.NewParamSetPair(KeyIncentivesCutoffHeight, &p.IncentivesCutoffHeight, validateIncentivesCutoffHeight), + } +} + +// ValidateBasic performs basic validation on incentives parameters. +func (p *Params) ValidateBasic() error { + if err := validateDistributionPerBlock(p.DistributionPerBlock); err != nil { + return err + } + return nil +} + +func validateDistributionPerBlock(i interface{}) error { + coinsPerBlock, ok := i.(sdk.Coin) + if !ok { + return sdkerrors.Wrapf(ErrInvalidDistributionPerBlock, "invalid parameter type: %T", i) + } + + if coinsPerBlock.IsNil() { + return sdkerrors.Wrapf(ErrInvalidDistributionPerBlock, "distribution per block cannot be nil") + } + if coinsPerBlock.Amount.IsNegative() { + return sdkerrors.Wrapf(ErrInvalidDistributionPerBlock, "distribution per block cannot be negative") + } + if coinsPerBlock.Denom != params.BaseCoinUnit { + return sdkerrors.Wrapf(ErrInvalidDistributionPerBlock, "distribution per block denom must be %s, got %s", params.BaseCoinUnit, coinsPerBlock.Denom) + } + + return nil +} + +// Since there is no unsigned integer that is an invalid height, this is a no-op. +// Collin: I wasn't sure if it was safe to pass `nil` into the above NewParamSetPair call so I defined this. +func validateIncentivesCutoffHeight(_ interface{}) error { + return nil +} diff --git a/x/incentives/types/query.pb.go b/x/incentives/types/query.pb.go new file mode 100644 index 00000000..aafa5ce6 --- /dev/null +++ b/x/incentives/types/query.pb.go @@ -0,0 +1,868 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: incentives/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is the request type for the QueryParams gRPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a3d66b0ba5a24e28, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsRequest is the response type for the QueryParams gRPC method. +type QueryParamsResponse struct { + // allocation parameters + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a3d66b0ba5a24e28, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// QueryAPYRequest is the request type for the QueryAPY gRPC method. +type QueryAPYRequest struct { +} + +func (m *QueryAPYRequest) Reset() { *m = QueryAPYRequest{} } +func (m *QueryAPYRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAPYRequest) ProtoMessage() {} +func (*QueryAPYRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a3d66b0ba5a24e28, []int{2} +} +func (m *QueryAPYRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAPYRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAPYRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAPYRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAPYRequest.Merge(m, src) +} +func (m *QueryAPYRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAPYRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAPYRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAPYRequest proto.InternalMessageInfo + +// QueryAPYRequest is the response type for the QueryAPY gRPC method. +type QueryAPYResponse struct { + Apy string `protobuf:"bytes,1,opt,name=apy,proto3" json:"apy,omitempty"` +} + +func (m *QueryAPYResponse) Reset() { *m = QueryAPYResponse{} } +func (m *QueryAPYResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAPYResponse) ProtoMessage() {} +func (*QueryAPYResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a3d66b0ba5a24e28, []int{3} +} +func (m *QueryAPYResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAPYResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAPYResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAPYResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAPYResponse.Merge(m, src) +} +func (m *QueryAPYResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAPYResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAPYResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAPYResponse proto.InternalMessageInfo + +func (m *QueryAPYResponse) GetApy() string { + if m != nil { + return m.Apy + } + return "" +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "incentives.v1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "incentives.v1.QueryParamsResponse") + proto.RegisterType((*QueryAPYRequest)(nil), "incentives.v1.QueryAPYRequest") + proto.RegisterType((*QueryAPYResponse)(nil), "incentives.v1.QueryAPYResponse") +} + +func init() { proto.RegisterFile("incentives/v1/query.proto", fileDescriptor_a3d66b0ba5a24e28) } + +var fileDescriptor_a3d66b0ba5a24e28 = []byte{ + // 347 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xcd, 0x4e, 0x3a, 0x31, + 0x14, 0xc5, 0x67, 0xfe, 0x1f, 0x44, 0x4b, 0x8c, 0x58, 0x31, 0xd1, 0x91, 0x14, 0x99, 0x90, 0xe8, + 0x6a, 0x1a, 0x20, 0x3e, 0x80, 0x2c, 0x8d, 0x0b, 0x64, 0xa7, 0xbb, 0x42, 0x9a, 0x5a, 0xc3, 0xb4, + 0x65, 0x5a, 0x26, 0xce, 0xc2, 0x8d, 0x4f, 0x60, 0xe2, 0x4b, 0xb1, 0x24, 0x71, 0xe3, 0xca, 0x18, + 0xf0, 0x25, 0xdc, 0x19, 0x3a, 0x43, 0x60, 0x54, 0xdc, 0xdd, 0xdc, 0x73, 0xf2, 0x3b, 0xf7, 0xb4, + 0xe0, 0x80, 0x8b, 0x3e, 0x15, 0x86, 0xc7, 0x54, 0xe3, 0xb8, 0x81, 0x87, 0x23, 0x1a, 0x25, 0x81, + 0x8a, 0xa4, 0x91, 0x70, 0x6b, 0x29, 0x05, 0x71, 0xc3, 0x2b, 0x33, 0xc9, 0xa4, 0x55, 0xf0, 0x7c, + 0x4a, 0x4d, 0x5e, 0x85, 0x49, 0xc9, 0x06, 0x14, 0x13, 0xc5, 0x31, 0x11, 0x42, 0x1a, 0x62, 0xb8, + 0x14, 0x3a, 0x53, 0x0f, 0xf3, 0x74, 0x46, 0x05, 0xd5, 0x3c, 0x13, 0xfd, 0x32, 0x80, 0x97, 0xf3, + 0xb8, 0x0e, 0x89, 0x48, 0xa8, 0xbb, 0x74, 0x38, 0xa2, 0xda, 0xf8, 0xe7, 0x60, 0x37, 0xb7, 0xd5, + 0x4a, 0x0a, 0x4d, 0x61, 0x0b, 0x14, 0x94, 0xdd, 0xec, 0xbb, 0x47, 0xee, 0x49, 0xb1, 0xb9, 0x17, + 0xe4, 0xae, 0x0b, 0x52, 0x7b, 0xfb, 0xdf, 0xf8, 0xb5, 0xea, 0x74, 0x33, 0xab, 0xbf, 0x03, 0xb6, + 0x2d, 0xeb, 0xac, 0x73, 0xb5, 0xc0, 0xd7, 0x41, 0x69, 0xb9, 0xca, 0xd8, 0x25, 0xf0, 0x97, 0xa8, + 0xc4, 0x82, 0x37, 0xbb, 0xf3, 0xb1, 0xf9, 0xe1, 0x82, 0xff, 0xd6, 0x06, 0xef, 0x41, 0x71, 0xe5, + 0x1c, 0x58, 0xfb, 0x12, 0xfb, 0xbd, 0x80, 0xe7, 0xff, 0x66, 0x49, 0x13, 0xfd, 0xe3, 0x87, 0xe7, + 0xf7, 0xa7, 0x3f, 0x35, 0x58, 0xc5, 0x5a, 0x86, 0x21, 0x1d, 0x70, 0x1a, 0xe1, 0xfc, 0x53, 0xa5, + 0x0d, 0xe0, 0x10, 0x6c, 0x2c, 0xce, 0x85, 0xe8, 0x27, 0xf0, 0xb2, 0x9a, 0x57, 0x5d, 0xab, 0x67, + 0xa9, 0x75, 0x9b, 0x8a, 0x60, 0x65, 0x6d, 0x2a, 0x51, 0x49, 0xfb, 0x62, 0x3c, 0x45, 0xee, 0x64, + 0x8a, 0xdc, 0xb7, 0x29, 0x72, 0x1f, 0x67, 0xc8, 0x99, 0xcc, 0x90, 0xf3, 0x32, 0x43, 0xce, 0x75, + 0x93, 0x71, 0x73, 0x33, 0xea, 0x05, 0x7d, 0x19, 0x62, 0x45, 0x19, 0x4b, 0x6e, 0xe3, 0x15, 0x52, + 0x7c, 0x8a, 0xef, 0x56, 0x71, 0x26, 0x51, 0x54, 0xf7, 0x0a, 0xf6, 0xaf, 0x5b, 0x9f, 0x01, 0x00, + 0x00, 0xff, 0xff, 0x7a, 0x9d, 0xc2, 0x52, 0x68, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // QueryParams queries the allocation module parameters. + QueryParams(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // QueryAPY queries the APY returned from the incentives module. + QueryAPY(ctx context.Context, in *QueryAPYRequest, opts ...grpc.CallOption) (*QueryAPYResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) QueryParams(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/incentives.v1.Query/QueryParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) QueryAPY(ctx context.Context, in *QueryAPYRequest, opts ...grpc.CallOption) (*QueryAPYResponse, error) { + out := new(QueryAPYResponse) + err := c.cc.Invoke(ctx, "/incentives.v1.Query/QueryAPY", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // QueryParams queries the allocation module parameters. + QueryParams(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // QueryAPY queries the APY returned from the incentives module. + QueryAPY(context.Context, *QueryAPYRequest) (*QueryAPYResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) QueryParams(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryParams not implemented") +} +func (*UnimplementedQueryServer) QueryAPY(ctx context.Context, req *QueryAPYRequest) (*QueryAPYResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryAPY not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_QueryParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/incentives.v1.Query/QueryParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryParams(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_QueryAPY_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAPYRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryAPY(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/incentives.v1.Query/QueryAPY", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryAPY(ctx, req.(*QueryAPYRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "incentives.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "QueryParams", + Handler: _Query_QueryParams_Handler, + }, + { + MethodName: "QueryAPY", + Handler: _Query_QueryAPY_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "incentives/v1/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryAPYRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAPYRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAPYRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryAPYResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAPYResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAPYResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Apy) > 0 { + i -= len(m.Apy) + copy(dAtA[i:], m.Apy) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Apy))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAPYRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryAPYResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Apy) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAPYRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAPYRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAPYRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAPYResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAPYResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAPYResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Apy", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Apy = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/incentives/types/query.pb.gw.go b/x/incentives/types/query.pb.gw.go new file mode 100644 index 00000000..110369d2 --- /dev/null +++ b/x/incentives/types/query.pb.gw.go @@ -0,0 +1,218 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: incentives/v1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_QueryParams_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.QueryParams(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryParams_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.QueryParams(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_QueryAPY_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAPYRequest + var metadata runtime.ServerMetadata + + msg, err := client.QueryAPY(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryAPY_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAPYRequest + var metadata runtime.ServerMetadata + + msg, err := server.QueryAPY(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_QueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_QueryParams_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_QueryAPY_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_QueryAPY_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryAPY_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_QueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_QueryParams_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_QueryAPY_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_QueryAPY_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryAPY_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_QueryParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sommelier", "incentives", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryAPY_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sommelier", "incentives", "v1", "apy"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_QueryParams_0 = runtime.ForwardResponseMessage + + forward_Query_QueryAPY_0 = runtime.ForwardResponseMessage +)