Skip to content

Commit

Permalink
Clean up Msgs and Codecs. (#1957)
Browse files Browse the repository at this point in the history
* [1760]: Rename all the msg.go files (and their relatives) to msgs.go.

* [1760]: Standardize all the msg and codec definition to use a public AllRequestMsgs list used to, at the very least, register all the msg interfaces.

* [1760]: Create RunGetSignersTests to standardize checking signers-related stuff for all our msgs.

* [1760]: Switch the exchange GetSigners test over to the new RunGetSignersTests helper.

* [1760]: Switch the metadata GetSigners test over to the new RunGetSignersTests helper.

* [1760]: For the legacy test runner, just make sure the panic contains the expected panic in case it's being wrapped with other info.

* [1760]: Add GetSigners tests to the attribute module.

* [1760]: Streamline the exchange GetSigners maker definitions.

* [1760]: Change ExpPanic fields to ExpInErr since the new stuff isn't supposed to panic like the old stuff.

* [1760]: Add a GetSigners tests to the ibchooks module, and fix the MsgEmitIBCAck that was missing a signers option.

* [1760]: Add GetSigners tests to the ibcratelimit module.

* [1760]: GetSigners Tests on all the marker Msgs, and fix MsgCancelRequest that had the wrong signer option in the proto.

* [1760]: Switch to RunGetSignersTests in the msgfees module.

* [1760]: Switch to RunGetSignersTests in the name module.

* [1760]: Switch to RunGetSignersTests in the oracle module.

* [1760]: Switch to RunGetSignersTests for the quarantine module.

* [1760]: Switch to RunGetSignersTests for the sanction module.

* [1760]: Switch to RunGetSignersTests for the trigger module.

* [1760]: Get rid of most of the GetSigners methods (the ones that weren't called directly).

* [1760]: Remove the marker module's GetSigners methods, and update the handful of places where those were being called directly.

* [1760]: Remove the GetSigners() methods from the metadata module.

* [1760]: Get rid of some ibchooks msg methods that used to be required for sdk.Msg, but aren't anymore.

* [1760]: Reorder the stuff in marker/types/msgs.go to match the order they're in in the proto.

* [1760]: Reorder the stuff in names msgs.go to match the proto ordering.

* [1760]: Reorganize the metadata msgs.go stuff.

* [1760]: Clean up the attribute and ibchooks protos a little.

* [1760]: Get rid of most of the yaml tags from the protos. Only ones left are ones that rename a field.

* [1760]: Remove the rest of the uses of gogoproto.moretags.

* [1760]: Clean up some unneeded gogoproto.goproto_stringer options from the protos.

* [1760]: Update all the Coins fields in the protos to match the same options the sdk uses.

* [1760]: Remove all uses of any ModuleCdc variables, and delete them all.

* [1760]: In GetFeePayerUsingFeeGrant, cast the feePayer and feeGranter back to sdk.AccAddress variables since they're now being returned as []byte, but we want them treated as AccAddresses everywhere in there. Specifically, the error message isn't right when they are just []byte.

* [1760]: Get rid of all the String() methods that just do yaml conversion, and switch them to an auto-generated version.

* [1760]: Refactor the MetadataAddress.Format method to handle more casses in better ways. Specifically, %v will now output the bech32 string so that the other .String() methods have the bech32 there instead of the hex bytes.

* [1760]: Remove a private unused function: stringsToAccAddresses

* [1760]: Switch to sigs.k8s.io/yaml (from gopkg.in/yaml.v2) in the last remaining place.

* [1760]: Move DefineCustomGetSigners to the top of the file.

* [1760]: Add changelog entries.

* [1760]: Move now-indirect require of gopkg.in/yaml.v2 to the indirect section.

* [1760]: Tweak the MetadataAddress.Format method: add some comments and remove the p and T cases which never get actually used.
  • Loading branch information
SpicyLemon authored and nullpointer0x00 committed May 15, 2024
1 parent 1f118c7 commit 6ddf1b0
Show file tree
Hide file tree
Showing 148 changed files with 5,491 additions and 6,633 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Removes sync-info code for sdk v0.50 [#1760](https://github.com/provenance-io/provenance/issues/1760).
* Fix most of the failing unit tests [#1943](https://github.com/provenance-io/provenance/pull/1943)
* Clean up ReadFromClient [#1760](https://github.com/provenance-io/provenance/issues/1760).
* Remove all `GetSigners()` methods [#1957](https://github.com/provenance-io/provenance/pull/1957).
* Ensure all `Msg`s have correctly identified `signer` fields [#1957](https://github.com/provenance-io/provenance/pull/1957).
* Clean up all the module codecs [#1957](https://github.com/provenance-io/provenance/pull/1957).
* Switch to auto-generated `String` and `Equal` methods for most proto messages [#1957](https://github.com/provenance-io/provenance/pull/1957).

### Dependencies

Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

134 changes: 79 additions & 55 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69847,43 +69847,50 @@ paths:
properties:
msg_type_url:
type: string
description: >-
msg_type_url is the type-url of the message with the
added fee, e.g. "/cosmos.bank.v1beta1.MsgSend".
additional_fee:
title: >-
additional_fee can pay in any Coin( basically a Denom
and Amount, Amount can be zero)
description: >-
additional_fee is the extra fee that is required for the
given message type (can be in any denom).
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an amount.


NOTE: The amount field is an Int which implements the
custom method

signatures required by gogoproto.
recipient:
type: string
description: >-
recipient is an option address that will receive a
portion of the additional fee.

There can only be a recipient if the
recipient_basis_points is not zero.
recipient_basis_points:
type: integer
format: int64
title: >-
MsgFee is the core of what gets stored on the blockchain
description: >-
recipient_basis_points is an optional portion of the
additional fee to be sent to the recipient.

it consists of four parts
Must be between 0 and 10,000 (inclusive).

1. the msg type url, i.e. /cosmos.bank.v1beta1.MsgSend

2. minimum additional fees(can be of any denom)
If there is a recipient, this must not be zero. If there
is not a recipient, this must be zero.

3. optional recipient of fee based on
`recipient_basis_points`

4. if recipient is declared they will recieve the basis
points of the fee (0-10,000)
The recipient will receive additional_fee *
recipient_basis_points / 10,000.

The fee collector will receive the rest, i.e.
additional_fee * (10,000 - recipient_basis_points) /
10,000.
description: >-
MsgFee is the core of what gets stored on the blockchain to
define a msg-based fee.
pagination:
description: pagination defines an optional pagination for the request.
type: object
Expand Down Expand Up @@ -116675,39 +116682,49 @@ definitions:
properties:
msg_type_url:
type: string
description: >-
msg_type_url is the type-url of the message with the added fee, e.g.
"/cosmos.bank.v1beta1.MsgSend".
additional_fee:
title: >-
additional_fee can pay in any Coin( basically a Denom and Amount,
Amount can be zero)
description: >-
additional_fee is the extra fee that is required for the given message
type (can be in any denom).
type: object
properties:
denom:
type: string
amount:
type: string
description: |-
Coin defines a token with a denomination and an amount.

NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
recipient:
type: string
description: >-
recipient is an option address that will receive a portion of the
additional fee.

There can only be a recipient if the recipient_basis_points is not
zero.
recipient_basis_points:
type: integer
format: int64
title: >-
MsgFee is the core of what gets stored on the blockchain
description: >-
recipient_basis_points is an optional portion of the additional fee to
be sent to the recipient.

Must be between 0 and 10,000 (inclusive).

it consists of four parts

1. the msg type url, i.e. /cosmos.bank.v1beta1.MsgSend
If there is a recipient, this must not be zero. If there is not a
recipient, this must be zero.

2. minimum additional fees(can be of any denom)

3. optional recipient of fee based on `recipient_basis_points`
The recipient will receive additional_fee * recipient_basis_points /
10,000.

4. if recipient is declared they will recieve the basis points of the fee
(0-10,000)
The fee collector will receive the rest, i.e. additional_fee * (10,000
- recipient_basis_points) / 10,000.
description: >-
MsgFee is the core of what gets stored on the blockchain to define a
msg-based fee.
provenance.msgfees.v1.Params:
type: object
properties:
Expand Down Expand Up @@ -116750,42 +116767,49 @@ definitions:
properties:
msg_type_url:
type: string
description: >-
msg_type_url is the type-url of the message with the added fee,
e.g. "/cosmos.bank.v1beta1.MsgSend".
additional_fee:
title: >-
additional_fee can pay in any Coin( basically a Denom and
Amount, Amount can be zero)
description: >-
additional_fee is the extra fee that is required for the given
message type (can be in any denom).
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an amount.


NOTE: The amount field is an Int which implements the custom
method

signatures required by gogoproto.
recipient:
type: string
description: >-
recipient is an option address that will receive a portion of
the additional fee.

There can only be a recipient if the recipient_basis_points is
not zero.
recipient_basis_points:
type: integer
format: int64
title: >-
MsgFee is the core of what gets stored on the blockchain
description: >-
recipient_basis_points is an optional portion of the additional
fee to be sent to the recipient.

Must be between 0 and 10,000 (inclusive).

it consists of four parts

1. the msg type url, i.e. /cosmos.bank.v1beta1.MsgSend
If there is a recipient, this must not be zero. If there is not
a recipient, this must be zero.

2. minimum additional fees(can be of any denom)

3. optional recipient of fee based on `recipient_basis_points`
The recipient will receive additional_fee *
recipient_basis_points / 10,000.

4. if recipient is declared they will recieve the basis points of
the fee (0-10,000)
The fee collector will receive the rest, i.e. additional_fee *
(10,000 - recipient_basis_points) / 10,000.
description: >-
MsgFee is the core of what gets stored on the blockchain to define a
msg-based fee.
pagination:
description: pagination defines an optional pagination for the request.
type: object
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de
google.golang.org/grpc v1.63.2
google.golang.org/protobuf v1.34.1
gopkg.in/yaml.v2 v2.4.0
sigs.k8s.io/yaml v1.4.0
)

require (
Expand Down Expand Up @@ -201,11 +201,11 @@ require (
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
nhooyr.io/websocket v1.8.10 // indirect
pgregory.net/rapid v1.1.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace (
Expand Down
4 changes: 2 additions & 2 deletions internal/antewrapper/provenance_fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ func (dfd ProvenanceDeductFeeDecorator) checkDeductBaseFee(ctx sdk.Context, feeT
}

func GetFeePayerUsingFeeGrant(ctx sdk.Context, feegrantKeeper msgfeestypes.FeegrantKeeper, feeTx sdk.FeeTx, fee sdk.Coins, msgs []sdk.Msg) (sdk.AccAddress, error) {
feePayer := feeTx.FeePayer()
feeGranter := feeTx.FeeGranter()
feePayer := sdk.AccAddress(feeTx.FeePayer())
feeGranter := sdk.AccAddress(feeTx.FeeGranter())
deductFeesFrom := feePayer

// if feegranter set deduct base fee from feegranter account.
Expand Down
17 changes: 13 additions & 4 deletions proto/cosmos/quarantine/v1beta1/events.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
syntax = "proto3";
package cosmos.quarantine.v1beta1;

import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
Expand All @@ -20,13 +21,21 @@ message EventOptOut {
// EventFundsQuarantined is an event emitted when funds are quarantined.
message EventFundsQuarantined {
string to_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated cosmos.base.v1beta1.Coin coins = 2
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
repeated cosmos.base.v1beta1.Coin coins = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(amino.dont_omitempty) = true,
(amino.encoding) = "legacy_coins"
];
}

// EventFundsReleased is an event emitted when quarantined funds are accepted and released.
message EventFundsReleased {
string to_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated cosmos.base.v1beta1.Coin coins = 2
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
repeated cosmos.base.v1beta1.Coin coins = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(amino.dont_omitempty) = true,
(amino.encoding) = "legacy_coins"
];
}
17 changes: 13 additions & 4 deletions proto/cosmos/quarantine/v1beta1/quarantine.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
syntax = "proto3";
package cosmos.quarantine.v1beta1;

import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
Expand All @@ -14,8 +15,12 @@ message QuarantinedFunds {
// unaccepted_from_addresses are the senders that have not been part of an accept yet for these coins.
repeated string unaccepted_from_addresses = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// coins is the amount currently in quarantined for the two addresses.
repeated cosmos.base.v1beta1.Coin coins = 3
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
repeated cosmos.base.v1beta1.Coin coins = 3 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(amino.dont_omitempty) = true,
(amino.encoding) = "legacy_coins"
];
// declined is true if these funds were previously declined.
bool declined = 4;
}
Expand Down Expand Up @@ -61,8 +66,12 @@ message QuarantineRecord {
// accepted_from_addresses are the senders that have already been part of an accept for these coins.
repeated bytes accepted_from_addresses = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
// coins is the amount that has been quarantined.
repeated cosmos.base.v1beta1.Coin coins = 3
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
repeated cosmos.base.v1beta1.Coin coins = 3 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(amino.dont_omitempty) = true,
(amino.encoding) = "legacy_coins"
];
// declined is whether these funds have been declined.
bool declined = 4;
}
Expand Down
9 changes: 7 additions & 2 deletions proto/cosmos/quarantine/v1beta1/tx.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
syntax = "proto3";
package cosmos.quarantine.v1beta1;

import "amino/amino.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/msg/v1/msg.proto";
Expand Down Expand Up @@ -69,8 +70,12 @@ message MsgAccept {
// MsgAcceptResponse defines the Msg/Accept response type.
message MsgAcceptResponse {
// funds_released is the amount that was quarantined but has now been released and sent to the requester.
repeated cosmos.base.v1beta1.Coin funds_released = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
repeated cosmos.base.v1beta1.Coin funds_released = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(amino.dont_omitempty) = true,
(amino.encoding) = "legacy_coins"
];
}

// MsgDecline represents a message for declining quarantined funds.
Expand Down
17 changes: 13 additions & 4 deletions proto/cosmos/sanction/v1beta1/sanction.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
syntax = "proto3";
package cosmos.sanction.v1beta1;

import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
Expand All @@ -13,15 +14,23 @@ message Params {
// If this is zero, immediate sanctioning is not available.
// Otherwise, if a sanction governance proposal is issued with a deposit at least this large, a temporary sanction
// will be immediately issued that will expire when voting ends on the governance proposal.
repeated cosmos.base.v1beta1.Coin immediate_sanction_min_deposit = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
repeated cosmos.base.v1beta1.Coin immediate_sanction_min_deposit = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(amino.dont_omitempty) = true,
(amino.encoding) = "legacy_coins"
];

// immediate_unsanction_min_deposit is the minimum deposit for an unsanction to happen immediately.
// If this is zero, immediate unsanctioning is not available.
// Otherwise, if an unsanction governance proposal is issued with a deposit at least this large, a temporary
// unsanction will be immediately issued that will expire when voting ends on the governance proposal.
repeated cosmos.base.v1beta1.Coin immediate_unsanction_min_deposit = 2
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
repeated cosmos.base.v1beta1.Coin immediate_unsanction_min_deposit = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(amino.dont_omitempty) = true,
(amino.encoding) = "legacy_coins"
];
}

// TemporaryEntry defines the information involved in a temporary sanction or unsanction.
Expand Down
1 change: 0 additions & 1 deletion proto/provenance/attribute/v1/attribute.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ option java_multiple_files = true;

// Params defines the set of params for the attribute module.
message Params {
option (gogoproto.goproto_stringer) = false;
// maximum length of data to allow in an attribute value
uint32 max_value_length = 1;
}
Expand Down
Loading

0 comments on commit 6ddf1b0

Please sign in to comment.