Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the marker module to fix the bank SendEnabled issue. #850

Merged
merged 14 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,6 @@ check-built:
exit 1; \
fi

statik:
$(GO) get -u github.com/rakyll/statik
$(GO) generate ./api/...

linkify:
python ./scripts/linkify.py CHANGELOG.md

Expand All @@ -378,7 +374,7 @@ librdkafka:
scripts/m1_librdkafka_install.sh;\
fi

.PHONY: go-mod-cache go.sum lint clean format check-built statik linkify update-tocs rocksdb cleveldb librdkafka
.PHONY: go-mod-cache go.sum lint clean format check-built linkify update-tocs rocksdb cleveldb librdkafka


validate-go-version: ## Validates the installed version of go against Provenance's minimum requirement.
Expand Down
4 changes: 2 additions & 2 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs
})

// update total supply
bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{})
bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{}, []banktypes.SendEnabled{})
genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis)

stateBytes, err := json.MarshalIndent(genesisState, "", " ")
Expand Down Expand Up @@ -179,7 +179,7 @@ func SetupWithGenesisAccounts(genAccs []authtypes.GenesisAccount, balances ...ba
totalSupply = totalSupply.Add(b.Coins...)
}

bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{})
bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{}, []banktypes.SendEnabled{})
genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis)

stateBytes, err := json.MarshalIndent(genesisState, "", " ")
Expand Down
8 changes: 1 addition & 7 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,7 @@ var handlers = map[string]appUpgrade{
}, // upgrade for pio-testnet-1 from v1.8.0-rc8 to v1.8.0-rc9
},
"kahlua": {}, // upgrade for pio-testnet-1 from v1.8.0-rc9 to v1.8.0
"lava": {
Handler: func(app *App, ctx sdk.Context, plan upgradetypes.Plan) (module.VersionMap, error) {
app.MarkerKeeper.RemoveSendEnabledForMissingMarkers(ctx)
versionMap := app.UpgradeKeeper.GetModuleVersionMap(ctx)
return versionMap, nil
}, // upgrade for 1.10.0
},
"lava": {}, // upgrade for 1.10.0
// TODO - Add new upgrade definitions here.
}

Expand Down
9 changes: 4 additions & 5 deletions client/docs/statik/statik.go

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47424,6 +47424,10 @@ paths:
address:
type: string
title: a string containing the address the name resolves to
restricted:
type: boolean
format: boolean
description: Whether owner signature is required to add sub-names.
description: >-
QueryResolveResponse is the response type for the Query/Resolve
method.
Expand Down Expand Up @@ -69041,6 +69045,11 @@ definitions:
provenance.marker.v1.MsgFinalizeResponse:
type: object
title: MsgFinalizeResponse defines the Msg/Finalize response type
provenance.marker.v1.MsgGrantAllowanceResponse:
type: object
description: >-
MsgGrantAllowanceResponse defines the Msg/GrantAllowanceResponse response
type.
provenance.marker.v1.MsgMintResponse:
type: object
title: MsgMintResponse defines the Msg/Mint response type
Expand Down Expand Up @@ -80137,6 +80146,10 @@ definitions:
address:
type: string
title: a string containing the address the name resolves to
restricted:
type: boolean
format: boolean
description: Whether owner signature is required to add sub-names.
description: QueryResolveResponse is the response type for the Query/Resolve method.
provenance.name.v1.QueryReverseLookupResponse:
type: object
Expand Down
4 changes: 2 additions & 2 deletions contrib/devtools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ proto-tools-stamp:
statik: $(STATIK)
$(STATIK):
@echo "Installing statik..."
@(cd /tmp && go get github.com/rakyll/[email protected])
cd /tmp && go install github.com/rakyll/[email protected]

# Install the runsim binary with a temporary workaround of entering an outside
# directory as the "go get" command ignores the -mod option and will polute the
Expand All @@ -83,7 +83,7 @@ $(STATIK):
runsim: $(RUNSIM)
$(RUNSIM):
@echo "Installing runsim..."
@(cd /tmp && go get github.com/cosmos/tools/cmd/[email protected])
cd /tmp && go install github.com/cosmos/tools/cmd/[email protected]

tools-clean:
rm -f $(STATIK) $(GOLANGCI_LINT) $(RUNSIM)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ replace google.golang.org/grpc => google.golang.org/grpc v1.33.2

replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

replace github.com/cosmos/cosmos-sdk => github.com/provenance-io/cosmos-sdk v0.45.3-pio-2
replace github.com/cosmos/cosmos-sdk => github.com/provenance-io/cosmos-sdk v0.45.4-pio-1

replace github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -975,8 +975,8 @@ github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/tsdb v0.6.2-0.20190402121629-4f204dcbc150/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/provenance-io/cosmos-sdk v0.45.3-pio-2 h1:qLdEQtwLFfHwAwL0505gkBlJ/fO/i2jXG9qQ7EZeHQw=
github.com/provenance-io/cosmos-sdk v0.45.3-pio-2/go.mod h1:PjsF1aATbY6endgLbdNswiOfwoLvrNNZzdJ37kzrNbw=
github.com/provenance-io/cosmos-sdk v0.45.4-pio-1 h1:f8ztQYjSfTzRa66lbwMimPYcotGy+1LOJWZeQvEjYiQ=
github.com/provenance-io/cosmos-sdk v0.45.4-pio-1/go.mod h1:ZeOVyLFgW6jdzLcLak2mYso+tNIpRQXot7D4ZNyG4Zg=
github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ=
github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
Expand Down
9 changes: 7 additions & 2 deletions third_party/proto/cosmos/bank/v1beta1/bank.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types";

// Params defines the parameters for the bank module.
message Params {
option (gogoproto.goproto_stringer) = false;
repeated SendEnabled send_enabled = 1 [(gogoproto.moretags) = "yaml:\"send_enabled,omitempty\""];
option (gogoproto.goproto_stringer) = false;
// Deprecated: Use of SendEnabled in params is deprecated.
// For genesis, use the newly added send_enabled field in the genesis object.
// Storage, lookup, and manipulation of this information is now in the keeper.
// This version only still exists after v0.46 for backwards compatibility of
// genesis files.
repeated SendEnabled send_enabled = 1 [deprecated = true, (gogoproto.moretags) = "yaml:\"send_enabled,omitempty\""];
bool default_send_enabled = 2 [(gogoproto.moretags) = "yaml:\"default_send_enabled,omitempty\""];
}

Expand Down
7 changes: 5 additions & 2 deletions third_party/proto/cosmos/bank/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types";

// GenesisState defines the bank module's genesis state.
message GenesisState {
// params defines all the paramaters of the module.
// params defines all the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false];

// balances is an array containing the balances of all the accounts.
Expand All @@ -20,8 +20,11 @@ message GenesisState {
repeated cosmos.base.v1beta1.Coin supply = 3
[(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.nullable) = false];

// denom_metadata defines the metadata of the differents coins.
// denom_metadata defines the metadata of the different coins.
repeated Metadata denom_metadata = 4 [(gogoproto.moretags) = "yaml:\"denom_metadata\"", (gogoproto.nullable) = false];

// send_enabled defines the denoms where send is enabled or disabled.
repeated SendEnabled send_enabled = 5 [(gogoproto.moretags) = "yaml:\"send_enabled\"", (gogoproto.nullable) = false];
}

// Balance defines an account address and balance pair used in the bank module's
Expand Down
54 changes: 54 additions & 0 deletions third_party/proto/cosmos/bank/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ service Query {
option (google.api.http).get = "/cosmos/bank/v1beta1/balances/{address}";
}

// SpendableBalances queries the spenable balance of all coins for a single
// account.
rpc SpendableBalances(QuerySpendableBalancesRequest) returns (QuerySpendableBalancesResponse) {
option (google.api.http).get = "/cosmos/bank/v1beta1/spendable_balances/{address}";
}

// TotalSupply queries the total supply of all coins.
rpc TotalSupply(QueryTotalSupplyRequest) returns (QueryTotalSupplyResponse) {
option (google.api.http).get = "/cosmos/bank/v1beta1/supply";
Expand All @@ -45,6 +51,15 @@ service Query {
rpc DenomsMetadata(QueryDenomsMetadataRequest) returns (QueryDenomsMetadataResponse) {
option (google.api.http).get = "/cosmos/bank/v1beta1/denoms_metadata";
}

// SendEnabled queries for SendEnabled entries.
//
// This query only returns denominations that have specific SendEnabled settings.
// Any denomination that does not have a specific setting will use the default
// params.default_send_enabled, and will not be returned by this query.
rpc SendEnabled(QuerySendEnabledRequest) returns (QuerySendEnabledResponse) {
option (google.api.http).get = "/cosmos/bank/v1beta1/send_enabled";
}
}

// QueryBalanceRequest is the request type for the Query/Balance RPC method.
Expand Down Expand Up @@ -88,6 +103,30 @@ message QueryAllBalancesResponse {
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QuerySpendableBalancesRequest defines the gRPC request structure for querying
// an account's spendable balances.
message QuerySpendableBalancesRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// address is the address to query spendable balances for.
string address = 1;

// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

// QuerySpendableBalancesResponse defines the gRPC response structure for querying
// an account's spendable balances.
message QuerySpendableBalancesResponse {
// balances is the spendable balances of all the coins.
repeated cosmos.base.v1beta1.Coin balances = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];

// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC
// method.
message QueryTotalSupplyRequest {
Expand Down Expand Up @@ -161,3 +200,18 @@ message QueryDenomMetadataResponse {
// metadata describes and provides all the client information for the requested token.
Metadata metadata = 1 [(gogoproto.nullable) = false];
}

// QuerySendEnabledRequest defines the RPC request for looking up SendEnabled entries.
message QuerySendEnabledRequest {
// denoms is the specific denoms you want look up. Leave empty to get all entries.
repeated string denoms = 1;
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 99;
}

// QuerySendEnabledResponse defines the RPC response of a SendEnable query.
message QuerySendEnabledResponse {
repeated SendEnabled send_enabled = 1;
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 99;
}
1 change: 1 addition & 0 deletions third_party/proto/cosmos/bank/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ message MsgMultiSend {

// MsgMultiSendResponse defines the Msg/MultiSend response type.
message MsgMultiSendResponse {}

2 changes: 1 addition & 1 deletion x/marker/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (k Keeper) SetMarker(ctx sdk.Context, marker types.MarkerAccountI) {
func (k Keeper) RemoveMarker(ctx sdk.Context, marker types.MarkerAccountI) {
store := ctx.KVStore(k.storeKey)
k.authKeeper.RemoveAccount(ctx, marker)
k.removeSendEnabledStatus(ctx, marker.GetDenom())
k.bankKeeper.DeleteSendEnabled(ctx, marker.GetDenom())

store.Delete(types.MarkerStoreKey(marker.GetAddress()))
}
Expand Down
Loading