Skip to content

Commit

Permalink
feat: Municipal Inflation (#162)
Browse files Browse the repository at this point in the history
* feat: Municipal Inflation MVP (#153)

* fix: Municipal Inflation: list->map & cli command printout (#154)

* fix: Municipal Inflation: grpc query error check (#155)

* fix: Municipal Inflation: cli tests for query with denom (#156)

* fix: [WIP] Municipal Inflation determinism(map->list), cache redesign (#159)

* [Cosmetic]: Municipal Inflation Cache: update code comment (#163)

* fix: [Cosmetic] Go linting (#164)

* fix: [Cosmetic] Go linting
* CI test run - setting golang v1.18.10

* fix: Municipal Inflation: protobuf yaml tag naming (#165)

* fix: Municipal Inflation: cache redesign atomic + simtest (#166)

* feat: Municipal Inflation: Handler optimisation & Validation fix (#167)

---------

Co-authored-by: void* <peter.bukva@gmail.com>
  • Loading branch information
Jonathansumner and pbukva authored Aug 12, 2023
1 parent 1d996e8 commit 43f6e51
Show file tree
Hide file tree
Showing 34 changed files with 2,626 additions and 731 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.18.10
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
version: v1.53.3
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.18
go-version: 1.18.10
- name: Display go version
run: go version
- name: install tparse
Expand All @@ -33,7 +33,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.18
go-version: 1.18.10
- uses: technote-space/get-diff-action@v4
id: git_diff
with:
Expand All @@ -52,7 +52,7 @@ jobs:
# - uses: actions/checkout@v2
# - uses: actions/setup-go@v2.1.3
# with:
# go-version: 1.18
# go-version: 1.18.10
# - name: Display go version
# run: go version
# - uses: technote-space/get-diff-action@v4
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.18
go-version: 1.18.10
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
Expand Down Expand Up @@ -183,7 +183,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.18
go-version: 1.18.10
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
Expand Down Expand Up @@ -232,7 +232,7 @@ jobs:
# - uses: actions/checkout@v2
# - uses: actions/setup-go@v2.1.3
# with:
# go-version: 1.18
# go-version: 1.18.10
# - uses: technote-space/get-diff-action@v4
# id: git_diff
# with:
Expand Down
38 changes: 29 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ GO_MINOR_VERSION := $(shell echo $(GO_VERSION) | cut -d. -f2)
GO_MICRO_VERSION := $(shell echo $(GO_VERSION) | cut -d. -f3)
SUPPORTED_GO_VERSION = 1.18.10

IS_SUPPORTED_VERSION := $(shell expr "$(GO_VERSION)" "==" "$(SUPPORTED_GO_VERSION)")
ifeq "$(IS_SUPPORTED_VERSION)" "1"
$(info Go version is supported: $(GO_VERSION))
ifeq ($(GO_VERSION), $(SUPPORTED_GO_VERSION))
$(info Go version $(GO_VERSION) is supported)
else
$(info WARN: Go version not supported, some tests might fail without version $(SUPPORTED_GO_VERSION))
$(info WARN: Go version $(GO_VERSION) is not supported, some tests might fail on different version than supported $(SUPPORTED_GO_VERSION))
endif

export GO111MODULE = on
Expand Down Expand Up @@ -167,7 +166,7 @@ clean:
###############################################################################

go.sum: go.mod
echo "Ensure dependencies have not been modified ..." >&2
@echo "Ensure dependencies have not been modified ..." >&2
go mod verify
go mod tidy

Expand Down Expand Up @@ -321,23 +320,44 @@ benchmark:
### Linting ###
###############################################################################

golangCliLintVersion=v1.53.3

containerMarkdownLintImage=tmknom/markdownlint
containerMarkdownLint=cosmos-sdk-markdownlint
containerMarkdownLintFix=cosmos-sdk-markdownlint-fix
containerGolangCliLint=golangci/golangci-lint:$(golangCliLintVersion)

golangci_lint_cmd=go run github.com/golangci/golangci-lint/cmd/golangci-lint
#golangci_lint_cmd_shared_cache=$(DOCKER) run --rm -v $(CURDIR):/work -v ./.cache/golangci-lint/$(golangCliLintVersion):/root/.cache -w /work $(containerGolangCliLint) golangci-lint
golangci_lint_cmd=$(DOCKER) run --rm -v $(CURDIR):/work -w /work $(containerGolangCliLint) golangci-lint

lint: lint-go
lint: lint-go-diff
@#if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerMarkdownLint}$$"; then docker start -a $(containerMarkdownLint); else docker run --name $(containerMarkdownLint) -i -v "$(CURDIR):/work" $(markdownLintImage); fi
docker run -i --rm -v "$(CURDIR):/work" $(containerMarkdownLintImage) .

lint-fix:
@#if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerMarkdownLintFix}$$"; then docker start -a $(containerMarkdownLintFix); else docker run --name $(containerMarkdownLintFix) -i -v "$(CURDIR):/work" $(markdownLintImage) . --fix; fi
docker run -i --rm -v "$(CURDIR):/work" $(containerMarkdownLintImage) --fix .

lint-go:
lint-go-diff:
echo $(GIT_DIFF)
$(golangci_lint_cmd) run --out-format=tab $(GIT_DIFF)
#$(golangci_lint_cmd) run --out-format=tab $(GIT_DIFF)
#
#mkdir -p ./.cache/golangci-lint/$(golangCliLintVersion)
#$(golangci_lint_cmd_shared_cache) run -v --out-format=tab $(GIT_DIFF)
#
$(golangci_lint_cmd) run -v --out-format=tab $(GIT_DIFF)

lint-go:
#mkdir -p ./.cache/golangci-lint/$(golangCliLintVersion)
#$(golangci_lint_cmd_shared_cache) run -v --out-format=tab
#
$(golangci_lint_cmd) run -v --out-format=tab

lint-go-fix:
#mkdir -p ./.cache/golangci-lint/$(golangCliLintVersion)
#$(golangci_lint_cmd_shared_cache) run -v --fix --out-format=tab
#
$(golangci_lint_cmd) run -v --fix --out-format=tab

.PHONY: lint lint-fix

Expand Down
17 changes: 0 additions & 17 deletions baseapp/testutil/buf.lock

This file was deleted.

2 changes: 1 addition & 1 deletion docs/architecture/adr-023-protobuf-naming.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ or significantly alter the package in the near future
significantly refactor/rework the functionality in the near future but not remove it
* modules _can and should_ have types in both stable (i.e. `v1` or `v2`) and unstable (`alpha` or `beta`) packages.

*`alpha` and `beta` should not be used to avoid responsibility for maintaining compatibility.*
_`alpha` and `beta` should not be used to avoid responsibility for maintaining compatibility._
Whenever code is released into the wild, especially on a blockchain, there is a high cost to changing things. In some
cases, for instance with immutable smart contracts, a breaking change may be impossible to fix.

Expand Down
75 changes: 75 additions & 0 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@

- [cosmos/mint/v1beta1/mint.proto](#cosmos/mint/v1beta1/mint.proto)
- [Minter](#cosmos.mint.v1beta1.Minter)
- [MunicipalInflation](#cosmos.mint.v1beta1.MunicipalInflation)
- [MunicipalInflationPair](#cosmos.mint.v1beta1.MunicipalInflationPair)
- [Params](#cosmos.mint.v1beta1.Params)

- [cosmos/mint/v1beta1/genesis.proto](#cosmos/mint/v1beta1/genesis.proto)
Expand All @@ -404,6 +406,8 @@
- [QueryAnnualProvisionsResponse](#cosmos.mint.v1beta1.QueryAnnualProvisionsResponse)
- [QueryInflationRequest](#cosmos.mint.v1beta1.QueryInflationRequest)
- [QueryInflationResponse](#cosmos.mint.v1beta1.QueryInflationResponse)
- [QueryMunicipalInflationRequest](#cosmos.mint.v1beta1.QueryMunicipalInflationRequest)
- [QueryMunicipalInflationResponse](#cosmos.mint.v1beta1.QueryMunicipalInflationResponse)
- [QueryParamsRequest](#cosmos.mint.v1beta1.QueryParamsRequest)
- [QueryParamsResponse](#cosmos.mint.v1beta1.QueryParamsResponse)

Expand Down Expand Up @@ -5748,6 +5752,45 @@ Minter represents the minting state.
| ----- | ---- | ----- | ----------- |
| `inflation` | [string](#string) | | current annual inflation rate |
| `annual_provisions` | [string](#string) | | current annual expected provisions |
| `municipal_inflation` | [MunicipalInflationPair](#cosmos.mint.v1beta1.MunicipalInflationPair) | repeated | |






<a name="cosmos.mint.v1beta1.MunicipalInflation"></a>

### MunicipalInflation
Inflation holds parameters for individual native token inflation


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `target_address` | [string](#string) | | address where inflation induced new tokens will be minted |
| `value` | [string](#string) | | current ANNUAL inflation rate |






<a name="cosmos.mint.v1beta1.MunicipalInflationPair"></a>

### MunicipalInflationPair
Pair representing denom -> inflation mapping.
This pair-like structure will be used in `repeating MunicipalInflationPair`
type, what will have the same Protobuf binary representation on wire as the
`map<string, MunicipalInflation>` type.
This means that what is serialised as `repeating MunicipalInflationPair` on
one end can be deserialised as `map<string, MunicipalInflation>` on the other
end, and other vice versa.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `denom` | [string](#string) | | token denomination |
| `inflation` | [MunicipalInflation](#cosmos.mint.v1beta1.MunicipalInflation) | | Structure representing municipal inflation for the the given `denom` |



Expand Down Expand Up @@ -5872,6 +5915,37 @@ method.



<a name="cosmos.mint.v1beta1.QueryMunicipalInflationRequest"></a>

### QueryMunicipalInflationRequest
QueryMunicipalInflationRequest is the request type for the Query/MunicipalInflation RPC method.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `denom` | [string](#string) | optional | |






<a name="cosmos.mint.v1beta1.QueryMunicipalInflationResponse"></a>

### QueryMunicipalInflationResponse
QueryInflationResponse is the response type for the Query/Inflation RPC
method.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `inflations` | [MunicipalInflationPair](#cosmos.mint.v1beta1.MunicipalInflationPair) | repeated | inflation is the current minting inflation value. |






<a name="cosmos.mint.v1beta1.QueryParamsRequest"></a>

### QueryParamsRequest
Expand Down Expand Up @@ -5912,6 +5986,7 @@ Query provides defines the gRPC querier service.
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `Params` | [QueryParamsRequest](#cosmos.mint.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#cosmos.mint.v1beta1.QueryParamsResponse) | Params returns the total set of minting parameters. | GET|/cosmos/mint/v1beta1/params|
| `Inflation` | [QueryInflationRequest](#cosmos.mint.v1beta1.QueryInflationRequest) | [QueryInflationResponse](#cosmos.mint.v1beta1.QueryInflationResponse) | Inflation returns the current minting inflation value. | GET|/cosmos/mint/v1beta1/inflation|
| `MunicipalInflation` | [QueryMunicipalInflationRequest](#cosmos.mint.v1beta1.QueryMunicipalInflationRequest) | [QueryMunicipalInflationResponse](#cosmos.mint.v1beta1.QueryMunicipalInflationResponse) | Inflation returns the current minting inflation value. | GET|/cosmos/mint/v1beta1/municipal_inflation|
| `AnnualProvisions` | [QueryAnnualProvisionsRequest](#cosmos.mint.v1beta1.QueryAnnualProvisionsRequest) | [QueryAnnualProvisionsResponse](#cosmos.mint.v1beta1.QueryAnnualProvisionsResponse) | AnnualProvisions current minting annual provisions value. | GET|/cosmos/mint/v1beta1/annual_provisions|

<!-- end services -->
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/gogo/protobuf v1.3.3
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.2
github.com/golangci/golangci-lint v1.48.0
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
Expand Down Expand Up @@ -52,8 +53,6 @@ require (
gopkg.in/yaml.v2 v2.4.0
)

require github.com/golangci/golangci-lint v1.48.0

require (
4d63.com/gochecknoglobals v0.1.0 // indirect
filippo.io/edwards25519 v1.0.0-beta.2 // indirect
Expand Down
24 changes: 24 additions & 0 deletions proto/cosmos/mint/v1beta1/mint.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,30 @@ message Minter {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];

repeated MunicipalInflationPair municipal_inflation = 3;
}

// Inflation holds parameters for individual native token inflation
message MunicipalInflation {
// address where inflation induced new tokens will be minted
string target_address = 2 [(gogoproto.moretags) = "yaml:\"target_address\""];
// current ANNUAL inflation rate
string value = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
}

// Pair representing denom -> inflation mapping.
// This pair-like structure will be used in `repeating MunicipalInflationPair`
// type, what will have the same Protobuf binary representation on wire as the
// `map<string, MunicipalInflation>` type.
// This means that what is serialised as `repeating MunicipalInflationPair` on
// one end can be deserialised as `map<string, MunicipalInflation>` on the other
// end, and other vice versa.
message MunicipalInflationPair {
// token denomination
string denom = 1;
// Structure representing municipal inflation for the the given `denom`
MunicipalInflation inflation = 2;
}

// Params holds parameters for the mint module.
Expand Down
17 changes: 17 additions & 0 deletions proto/cosmos/mint/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ service Query {
option (google.api.http).get = "/cosmos/mint/v1beta1/inflation";
}

// Inflation returns the current minting inflation value.
rpc MunicipalInflation(QueryMunicipalInflationRequest) returns (QueryMunicipalInflationResponse) {
option (google.api.http).get = "/cosmos/mint/v1beta1/municipal_inflation";
}

// AnnualProvisions current minting annual provisions value.
rpc AnnualProvisions(QueryAnnualProvisionsRequest) returns (QueryAnnualProvisionsResponse) {
option (google.api.http).get = "/cosmos/mint/v1beta1/annual_provisions";
Expand All @@ -37,13 +42,25 @@ message QueryParamsResponse {
// QueryInflationRequest is the request type for the Query/Inflation RPC method.
message QueryInflationRequest {}

// QueryMunicipalInflationRequest is the request type for the Query/MunicipalInflation RPC method.
message QueryMunicipalInflationRequest {
optional string denom = 1;
}

// QueryInflationResponse is the response type for the Query/Inflation RPC
// method.
message QueryInflationResponse {
// inflation is the current minting inflation value.
bytes inflation = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
}

// QueryInflationResponse is the response type for the Query/Inflation RPC
// method.
message QueryMunicipalInflationResponse {
// inflation is the current minting inflation value.
repeated MunicipalInflationPair inflations = 1;
}

// QueryAnnualProvisionsRequest is the request type for the
// Query/AnnualProvisions RPC method.
message QueryAnnualProvisionsRequest {}
Expand Down
Loading

0 comments on commit 43f6e51

Please sign in to comment.