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

feat: adding proto files for fee payment middleware #272

Merged
merged 27 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fb29909
feat: adding proto files for fee payment middleware
seantking Jul 20, 2021
c0c88e9
grammar
seantking Jul 20, 2021
4d4a8b9
fix: remove generated .pb files
seantking Jul 20, 2021
65be512
fix: comment
seantking Jul 20, 2021
092f9e9
feat: adding PacketId type
seantking Jul 20, 2021
ddc6410
refactor: fee / genesis
seantking Jul 21, 2021
4565657
refactor: escrowed fees map
seantking Jul 21, 2021
ba0e3dc
Apply suggestions from code review
seantking Jul 21, 2021
0bfa303
Update proto/ibc/applications/middleware/fee/v1/tx.proto
seantking Jul 21, 2021
7cc97fa
Update proto/ibc/applications/middleware/fee/v1/tx.proto
seantking Jul 21, 2021
85032f9
Update proto/ibc/applications/middleware/fee/v1/tx.proto
seantking Jul 21, 2021
3e48f92
refactor: use packetID + minor changes
seantking Jul 22, 2021
6671611
feat: adding query for all incentivized packets + some fixes
seantking Jul 22, 2021
ac52989
feat: adding pagination to incentivized query
seantking Jul 22, 2021
3e29dab
fix: removing generated ibc directory + adding import/yaml
seantking Jul 22, 2021
fd267d0
fix: naming
seantking Jul 22, 2021
44c4cdb
increase max depth for proto file searching and make proto all
AdityaSripal Jul 22, 2021
488244a
Update proto/ibc/applications/middleware/fee/v1/fee.proto
seantking Jul 22, 2021
0cedbe5
refactor: remove file imports/add yaml/add argument for requests
seantking Jul 22, 2021
42cd7d1
refactor: updating IdentifiedPacketFee
seantking Jul 22, 2021
0b93645
fix: remove hidden file
seantking Jul 22, 2021
985a801
removing middleware dir & adding query
seantking Jul 26, 2021
1be683d
remove junk file and update query rpcs
AdityaSripal Jul 26, 2021
583e52e
Merge branch 'ics29-fee-middleware' into feat/fee-middleware-proto
AdityaSripal Jul 26, 2021
b74ccd5
Apply suggestions from code review
colin-axner Jul 26, 2021
a0b837e
Apply suggestions from code review
colin-axner Jul 26, 2021
11fba68
remove query yaml, make proto-all
colin-axner Jul 26, 2021
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
18 changes: 18 additions & 0 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
- [Counterparty](#ibc.core.channel.v1.Counterparty)
- [IdentifiedChannel](#ibc.core.channel.v1.IdentifiedChannel)
- [Packet](#ibc.core.channel.v1.Packet)
- [PacketId](#ibc.core.channel.v1.PacketId)
- [PacketState](#ibc.core.channel.v1.PacketState)

- [Order](#ibc.core.channel.v1.Order)
Expand Down Expand Up @@ -785,6 +786,23 @@ Packet defines a type that carries data across different chains through IBC

seantking marked this conversation as resolved.
Show resolved Hide resolved


<a name="ibc.core.channel.v1.PacketId"></a>

### PacketId
PacketId is an identifer for a unique Packet


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `port_id` | [string](#string) | | channel port identifier. |
| `channel_id` | [string](#string) | | channel unique identifier. |
| `sequence` | [uint64](#uint64) | | packet sequence. |






<a name="ibc.core.channel.v1.PacketState"></a>

### PacketState
Expand Down
358 changes: 299 additions & 59 deletions modules/core/04-channel/types/channel.pb.go

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions proto/ibc/applications/middleware/fee/v1/fee.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
syntax = "proto3";

colin-axner marked this conversation as resolved.
Show resolved Hide resolved
package ibc.applications.middleware.fee.v1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this package name, it differs from how I did the code layout. It is important to note that proto package names are hard to change, so whatever we choose, it should be intentional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I like this also.

I considered ibc.applications.middleware.v1.fee.v1 also as potentially the middleware spec could change but 🤷

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proto versioning should be independent of the specs. A v2 middleware spec could use the exact same proto definitions which would still be v1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm starting to think we should drop the middleware. Unless we changed our implementation layout and the ICS layout, I don't see why we should differ. It seems possible a module is partially middleware and then we have to have decide whether it is or isn't a middleware module. Also, at some point in the future these proto files should live in cosmos/ibc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, fair points. I think this makes sense. @AdityaSripal thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated this


// Fee interface
// See Fee Payment Middleware spec:
// https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middleware-contract
message Fee {
// the token denomination the fee will be paid in
string denom = 1;
// the token amount to be transferred
uint64 amount = 2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is only written on source side, we can use SDK structs here. Should change this to just use sdk.Coins. And I believe we can make this multidenom. cc: @colin-axner @ethanfrey

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this. Can you double-check? What do you mean by making this multdenom?

}
8 changes: 8 additions & 0 deletions proto/ibc/applications/middleware/fee/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";

package ibc.applications.middleware.fee.v1;

import "gogoproto/gogo.proto";

// GenesisState defines the fee middleware genesis state
message GenesisState {}
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
77 changes: 77 additions & 0 deletions proto/ibc/applications/middleware/fee/v1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
syntax = "proto3";

package ibc.applications.middleware.fee.v1;

import "gogoproto/gogo.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "ibc/applications/middleware/fee/v1/fee.proto";
import "google/api/annotations.proto";

// Query provides defines the gRPC querier service.
service Query {
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
// Gets the fee expected for submitting ReceivePacket msg for the given packet
rpc ReceiveFee(QueryReceiveFeeRequest) returns (QueryReceiveFeeResponse) {
option (google.api.http).get = "/ibc/apps/middleware/fee/v1/receive_fee";
}

// Gets the fee expected for submitting AcknowledgePacket msg for the given packet
rpc AckFee(QueryAckFeeRequest) returns (QueryAckFeeResponse) {
option (google.api.http).get = "/ibc/apps/middleware/fee/v1/ack_fee";
}

// Gets the fee expected for submitting TimeoutPacket msg for the given packet
rpc TimeoutFee(QueryTimeoutFeeRequest) returns (QueryTimeoutFeeResponse) {
option (google.api.http).get = "/ibc/apps/middleware/fee/v1/timeout_fee";
}
}

// QueryReceiveRequestFee is the request type for quering the receive fee
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
message QueryReceiveFeeRequest {
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
// Source Port ID
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just replace these with a PacketID?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""];
// Source Channel ID
string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""];
// Packet sequence
string sequence = 3 [(gogoproto.moretags) = "yaml:\"sequence\""];
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
// Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s).
string relayer_address = 4 [(gogoproto.moretags) = "yaml:\"relayer_address\""];
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
}

// QueryRequestFeeResponse is the response type for the ReceiveFee RPC
seantking marked this conversation as resolved.
Show resolved Hide resolved
message QueryReceiveFeeResponse {
ibc.applications.middleware.fee.v1.Fee fee = 1 [(gogoproto.moretags) = "yaml:\"fee\""];
}

// QueryAckRequestFee is the request type for quering the acknowledgement fee
seantking marked this conversation as resolved.
Show resolved Hide resolved
message QueryAckFeeRequest {
// Source Port ID
string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

// Source Channel ID
string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""];
// Packet sequence
string sequence = 3 [(gogoproto.moretags) = "yaml:\"sequence\""];
// Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s).
string relayer_address = 4 [(gogoproto.moretags) = "yaml:\"relayer_address\""];
}

// QueryAckFeeResponse is the response type for the AckFee RPC
message QueryAckFeeResponse {
ibc.applications.middleware.fee.v1.Fee fee = 1 [(gogoproto.moretags) = "yaml:\"fee\""];
}

// QueryTimeoutFee is the request type for quering the timeout fee
seantking marked this conversation as resolved.
Show resolved Hide resolved
message QueryTimeoutFeeRequest {
// Source Port ID
string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

// Source Channel ID
string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""];
// Packet sequence
string sequence = 3 [(gogoproto.moretags) = "yaml:\"sequence\""];
// Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s).
string relayer_address = 4 [(gogoproto.moretags) = "yaml:\"relayer_address\""];
}

// QueryTimeoutFeeResponse is the response type for the timeout RPC
message QueryTimeoutFeeResponse {
ibc.applications.middleware.fee.v1.Fee fee = 1 [(gogoproto.moretags) = "yaml:\"fee\""];
}
70 changes: 70 additions & 0 deletions proto/ibc/applications/middleware/fee/v1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
syntax = "proto3";

package ibc.applications.middleware.fee.v1;

import "gogoproto/gogo.proto";
import "ibc/applications/middleware/fee/v1/fee.proto";
import "ibc/core/channel/v1/channel.proto";

// Msg defines the ibc/fee Msg service.
service Msg {
// RegisterCounterPartyAddress defines a rpc handler method for MsgRegisterCounterPartyAddress
seantking marked this conversation as resolved.
Show resolved Hide resolved
// RegisterCounterpartyAddress is called by the relayer on each channelEnd and allows them to specify their
// counterparty address before relaying This ensures they will be properly compensated for forward relaying since
// destination chain must send back relayer's source address (counterparty address) in acknowledgement This function
// may be called more than once by a relayer, in which case, latest counterparty address is always used.
rpc RegisterCounterPartyAddress(MsgRegisterCounterPartyAddress) returns (MsgRegisterCounterPartyAddressResponse);
// EscrowPacketFee defines a rpc handler method for MsgEscrowPacketFee
// EscrowPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to
// incentivize the relaying of the given packet.
rpc EscrowPacketFee(MsgEscrowPacketFee) returns (MsgEscrowPacketFeeResponse);
// PayFee defines a rpc handler method for MsgPayFee
// PayFee is a callback implemented by fee module called by the ICS-4 AcknowledgePacket handler.
rpc PayFee(MsgPayFee) returns (MsgPayFeeResponse);
// PayTimeoutFee defines a rpc handler method for MsgPayTimeoutFee
// PayFee is a callback implemented by fee module called by the ICS-4 TimeoutPacket handler.
rpc PayTimeoutFee(MsgPayTimeoutFee) returns (MsgPayTimeoutFeeResponse);
Copy link
Member

@AdityaSripal AdityaSripal Jul 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should not be rpcs because they are not called by users. But are functions within the module that are called during IBC packet callbacks. The PayFee rpcs need to be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. Makes sense.

}

// MsgRegisterCounterPartyAddress is the request type for registering the counter party address
seantking marked this conversation as resolved.
Show resolved Hide resolved
message MsgRegisterCounterPartyAddress {
seantking marked this conversation as resolved.
Show resolved Hide resolved
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string address = 1 [(gogoproto.moretags) = "yaml:\"address\""];
string counterparty_address = 2 [(gogoproto.moretags) = "yaml:\"address\""];
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
}

// MsgRegisterCounterPartyAddressResponse defines the Msg/RegisterCounteryPartyAddress response type
message MsgRegisterCounterPartyAddressResponse {}
AdityaSripal marked this conversation as resolved.
Show resolved Hide resolved

// MsgEscrowPacketFee defines the request type EscrowPacketFee RPC
message MsgEscrowPacketFee {
ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.moretags) = "yaml:\"packet_id\""];
ibc.applications.middleware.fee.v1.Fee receive_fee = 2 [(gogoproto.moretags) = "yaml:\"receive_fee\""];
ibc.applications.middleware.fee.v1.Fee ack_fee = 3 [(gogoproto.moretags) = "yaml:\"ack_fee\""];
ibc.applications.middleware.fee.v1.Fee timeout_fee = 4 [(gogoproto.moretags) = "yaml:\"timeout_fee\""];
repeated string relayers = 5 [(gogoproto.moretags) = "yaml:\"relayers\""];
}

// MsgEscrowPacketFeeResponse defines the response type for Msg/EscrowPacketFee
message MsgEscrowPacketFeeResponse {}
AdityaSripal marked this conversation as resolved.
Show resolved Hide resolved

// MsgPayFee defines the request type for PayFee the RPC
message MsgPayFee {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed, as should its response

ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.moretags) = "yaml:\"packet_id\""];
string forward_relayer = 2 [(gogoproto.moretags) = "yaml:\"forward_relayer\""];
string reverse_relayer = 3 [(gogoproto.moretags) = "yaml:\"reverse_relayer\""];
}

// MsgPayFeeResponse defines the response type for Msg/PayFee
message MsgPayFeeResponse {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto


// MsgPayTimmeout defines the request type for the PayTimeoutFee RPC
message MsgPayTimeoutFee {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed along with response

ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.moretags) = "yaml:\"packet_id\""];
string timeout_relayer = 2 [(gogoproto.moretags) = "yaml:\"timeout_relayer\""];
}

// MsgPayTimeoutFeeResponse defines the response type for Msg/PayTimeoutFee
message MsgPayTimeoutFeeResponse {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

12 changes: 12 additions & 0 deletions proto/ibc/core/channel/v1/channel.proto
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ message PacketState {
bytes data = 4;
}

// PacketId is an identifer for a unique Packet
message PacketId {
option (gogoproto.goproto_getters) = false;

// channel port identifier.
string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""];
// channel unique identifier.
string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for consistency we should always specify this is source port and channel. cc: @colin-axner @ethanfrey

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would mean a packet is only uniquely identifiable on the source chain, which is the case for 29-fee, but then this seems less compelling to bring into 04-channel since then this is really packet id as identified on the source chain

Why can't the destination chain refer to a packet using the destination port and channel?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean both sides get access to source and dest port and channelID. So I think both sides using the same semantics will avoid confusion.

Even a destination chain can refer to packet using its source (counterparty) port/channel. It's mainly about keeping very consistent semantics

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see what you're saying, it's possible for collisions on dest chains. So we should make the semantics that the portID/channelID of the PacketID always refers to the port/channel on the chain in question

So source chains refer to packets by source port/channel
dest chains refer to packets by dest port/channel.

Yea let's make this the consistent rule. Good catch @colin-axner

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the comment

// packet sequence.
seantking marked this conversation as resolved.
Show resolved Hide resolved
uint64 sequence = 3;
}

// Acknowledgement is the recommended acknowledgement format to be used by
// app-specific protocols.
// NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental
Expand Down