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 RegisterPayee rpc to ics29 fee middleware #1491

Merged
merged 8 commits into from
Jun 8, 2022

Conversation

damiannolan
Copy link
Member

@damiannolan damiannolan commented Jun 6, 2022

Description

  • Adding new rpc endpoint RegisterPayee to ics29 fee middleware

NOTE: this is one of many PRs to complete the feature work referenced in: #1477


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@codecov-commenter
Copy link

codecov-commenter commented Jun 6, 2022

Codecov Report

Merging #1491 (3b2ccda) into main (46f5eee) will increase coverage by 0.05%.
The diff coverage is 97.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1491      +/-   ##
==========================================
+ Coverage   80.36%   80.42%   +0.05%     
==========================================
  Files         166      166              
  Lines       12105    12176      +71     
==========================================
+ Hits         9728     9792      +64     
- Misses       1920     1926       +6     
- Partials      457      458       +1     
Impacted Files Coverage Δ
modules/apps/29-fee/types/msgs.go 90.75% <93.54%> (+0.98%) ⬆️
modules/apps/29-fee/keeper/keeper.go 92.82% <100.00%> (+0.42%) ⬆️
modules/apps/29-fee/keeper/msg_server.go 96.00% <100.00%> (+0.83%) ⬆️
modules/apps/29-fee/types/keys.go 97.14% <100.00%> (+0.47%) ⬆️
...les/apps/27-interchain-accounts/host/ibc_module.go 100.00% <0.00%> (ø)
.../apps/27-interchain-accounts/host/keeper/events.go 0.00% <0.00%> (ø)

Copy link
Contributor

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

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

Awesome! Once we merge these PRs for the distribution address, we can cut a new beta tag and share with crypto.com.

@@ -241,6 +241,24 @@ func (k Keeper) DeleteForwardRelayerAddress(ctx sdk.Context, packetID channeltyp
store.Delete(key)
}

// GetDistributionAddress retrieves the fee distribution address stored in state given the provided channel identifier and relayer address
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a nit, but should we add these functions next to the ones to get and set the counterparty address?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, done! I've moved to above counterparty getter/setter funcs. And also re-ordered the rpc definitions in proto so RegisterPayee comes before RegisterCounterpartyPayee

@@ -16,4 +16,5 @@ var (
ErrFeeNotEnabled = sdkerrors.Register(ModuleName, 9, "fee module is not enabled for this channel. If this error occurs after channel setup, fee module may not be enabled")
ErrRelayerNotFoundForAsyncAck = sdkerrors.Register(ModuleName, 10, "relayer address must be stored for async WriteAcknowledgement")
ErrFeeModuleLocked = sdkerrors.Register(ModuleName, 11, "the fee module is currently locked, a severe bug has been detected")
ErrDistributionAddressEmpty = sdkerrors.Register(ModuleName, 12, "distribution address must not be empty")
Copy link
Contributor

Choose a reason for hiding this comment

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

Also a nit: since we haven't released fee yet, should we put this error next to ErrCounterpartyAddressEmpty?

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed this error as its obsolete now that we check the payee field directly using sdk.AccAddressFromBech32 in ValidateBasic.

// the fee distribution address
string distribution_address = 2 [(gogoproto.moretags) = "yaml:\"distribution_address\""];
// unique port identifier
string port_id = 3 [(gogoproto.moretags) = "yaml:\"port_id\""];
Copy link
Contributor

Choose a reason for hiding this comment

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

Also a nit: should we change the order of the parameters to port_id, channel_id, address, distribution_address? Also for the register counterparty address command. I think in other messages the port and channel are the first parameters...

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

Comment on lines 74 to 77
_, err := sdk.AccAddressFromBech32(msg.Address)
if err != nil {
return sdkerrors.Wrap(err, "failed to convert msg.Address into sdk.AccAddress")
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I need to add the same for msg.DistributionAddress

Copy link
Member

Choose a reason for hiding this comment

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

its also worth checking here that msg.Address != msg.DistributionAddress since that is a waste of a message/mapping

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@AdityaSripal AdityaSripal left a comment

Choose a reason for hiding this comment

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

We should also check that addresses in ValidateBasic are different, everything else looks good!

Comment on lines 74 to 77
_, err := sdk.AccAddressFromBech32(msg.Address)
if err != nil {
return sdkerrors.Wrap(err, "failed to convert msg.Address into sdk.AccAddress")
}
Copy link
Member

Choose a reason for hiding this comment

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

its also worth checking here that msg.Address != msg.DistributionAddress since that is a waste of a message/mapping


// GetSigners implements sdk.Msg
func (msg MsgRegisterDistributionAddress) GetSigners() []sdk.AccAddress {
signer, err := sdk.AccAddressFromBech32(msg.Address)
Copy link
Member

Choose a reason for hiding this comment

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

Yup, this is already the correct and sufficient authentication

option (gogoproto.goproto_getters) = false;

// the relayer address
string address = 1;
Copy link
Member

Choose a reason for hiding this comment

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

rename to relayer_address?

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also rename it like this in the register counterparty message?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, will do this in a follow up PR tomorrow to reduce the number of changes! We will rename to RegisterCounterpartyPayee and align the same field names..etc 👍

@damiannolan damiannolan changed the title feat: adding RegisterDistributionAddress rpc feat: adding RegisterPayee rpc to ics29 fee middleware Jun 7, 2022
Copy link
Member

@AdityaSripal AdityaSripal left a comment

Choose a reason for hiding this comment

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

Nice work!

@damiannolan damiannolan enabled auto-merge (squash) June 8, 2022 13:23
@damiannolan damiannolan merged commit 040f2ea into main Jun 8, 2022
@damiannolan damiannolan deleted the damian/1477-ics29-register-distaddr branch June 8, 2022 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants