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: ADR-005: Support multisig chain link #708

Merged
merged 46 commits into from
Jan 14, 2022

Conversation

dadamu
Copy link
Contributor

@dadamu dadamu commented Dec 22, 2021

Description

Closes: #633
This PR implements ADR-005.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@github-actions github-actions bot added kind/build Related to the build of the project x/CLI x/profiles Module that allows to create and manage decentralized social profiles labels Dec 22, 2021
@dadamu dadamu force-pushed the paul/adr-005-multisig-chainlink-impl branch from e2f37e7 to 7bb7535 Compare December 22, 2021 04:31
@dadamu dadamu force-pushed the paul/adr-005-multisig-chainlink-impl branch from 7bb7535 to b476e11 Compare December 22, 2021 04:35
@dadamu
Copy link
Contributor Author

dadamu commented Dec 22, 2021

Hi, @RiccardoM @bragaz
It seems that we can not use SignatureDescriptor_Data in the Proof directly, The error happens when msg.GetSignBytes() is called, which is

--- FAIL: TestMsgLinkChainAccount_GetSignBytes (0.00s)
panic: Unregistered interface signing.isSignatureDescriptor_Data_Sum [recovered]
        panic: Unregistered interface signing.isSignatureDescriptor_Data_Sum

because signing.isSignatureDescriptor_Data_Sum is not registered to the AnimoCodec. In addition, the interface is a private interface generated by proto automatically so we can't register it into the codec in x/profiles.

I propose that we can convert it to hex string from the proto, instead.

What do you think?

@RiccardoM
Copy link
Contributor

@dadamu What if we use the SignatureData interface instead, and encode it using an Any instance the same way we do with MsgLinkChainAccount#AddressData?

@dadamu
Copy link
Contributor Author

dadamu commented Dec 22, 2021

@RiccardoM Unfortunately, SignatureData doesn't implement proto.Message. Besides, the structs of it are not the proto as well.
So it can not be used in the Proof proto object.

@RiccardoM
Copy link
Contributor

@dadamu I have just finished experimenting with this problem, and I think that we can do as follows:

1. Create a new interface called SignatureData that extends proto.Message and has a isSignatureDataMethod
2. Create two new Proto definitions: SingleSignatureData and MultiSignatureData that contain the same fields of the Cosmos ones. The only difference is that our MultiSignatureData will have its Signatures field that is going to be an array of codectypes.Any rather than an array of signing.SignatureData.
3. Add a method called SignatureDataToCosmosSinatureData that takes a SignatureData interface instance and returns a signing.SignatureData instance.

Then, we only need to register the new SignatureData interface and its implementations inside our Amino instance and everything should work fine.

This will allow us to use proto.Any as the Signature type inside the Proof object, and serialize it both using Amino and Protobuf.

I have tried implementing all of this and pushed the changes to a new branch named riccardo/adr-005-multisig-chainlink-impl-test. You can take a look at it and pull the changes in your branch if you find them good enough

@dadamu
Copy link
Contributor Author

dadamu commented Jan 5, 2022

@RiccardoM Okay, got it. will extend the interface with the same way as AddressData to solve the issue.

@codecov
Copy link

codecov bot commented Jan 10, 2022

Codecov Report

Merging #708 (9eb1093) into master (2da9a43) will decrease coverage by 5.41%.
The diff coverage is 66.74%.

❗ Current head 9eb1093 differs from pull request most recent head 78be05b. Consider uploading reports for the commit 78be05b to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #708      +/-   ##
==========================================
- Coverage   84.23%   78.81%   -5.42%     
==========================================
  Files          91       53      -38     
  Lines        6624     4320    -2304     
==========================================
- Hits         5580     3405    -2175     
+ Misses        833      737      -96     
+ Partials      211      178      -33     
Impacted Files Coverage Δ
x/profiles/client/cli/cli_app_links.go 34.16% <ø> (ø)
x/profiles/client/cli/cli_params.go 70.00% <ø> (ø)
x/profiles/client/cli/cli_relationships.go 75.51% <ø> (ø)
x/profiles/client/utils/utils.go 56.25% <ø> (ø)
x/profiles/keeper/alias_functions.go 90.47% <ø> (ø)
x/profiles/keeper/genesis.go 84.61% <ø> (ø)
x/profiles/keeper/invariants.go 100.00% <ø> (ø)
x/profiles/keeper/keeper_blocks.go 85.50% <ø> (ø)
x/profiles/keeper/keeper_chain_links.go 84.74% <ø> (ø)
x/profiles/keeper/keeper_dtag_transfers.go 89.09% <ø> (ø)
... and 62 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 61ace0f...78be05b. Read the comment docs.

@@ -0,0 +1,345 @@
package v230
Copy link
Contributor Author

Choose a reason for hiding this comment

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

v230 is the copy paste of the latest chain link file for the v210 store_test.

@@ -87,6 +88,7 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command {

// RegisterInterfaces registers interfaces and implementations of the profiles module.
func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
v230.RegisterInterfaces(registry)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is for v210 store_test as mentioned in v230 files.

@dadamu dadamu requested a review from leobragaz January 12, 2022 04:42
@dadamu dadamu requested a review from leobragaz January 12, 2022 09:48
dadamu and others added 5 commits January 12, 2022 17:53
Signed-off-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
…mos-labs/desmos into paul/adr-005-multisig-chainlink-impl

� Conflicts:
�	app/desmos/cmd/chainlink/create_json.go
�	app/desmos/cmd/chainlink/create_json_test.go
Signed-off-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
@RiccardoM
Copy link
Contributor

@dadamu I've improved the code organization by splitting apart the various getters and creating a new builder interface. The multi-sig chain link test is however failing. Can you check why please? I didn't change pretty much anything except forcing the Sequence and AccountNumber to 0 when building the SignatureData instance

@dadamu
Copy link
Contributor Author

dadamu commented Jan 13, 2022

@RiccardoM Fixed.
Also improve minor things. move provider folder outside of builder, and fix the multi provider to builder.

}

// Get the sign mode
signMode := signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON
Copy link
Contributor

Choose a reason for hiding this comment

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

One thing I don't understand if it's correct or not is this line: the transaction could be signed using SIGN_MODE_DIRECT as well from what I know. Isn't this valid for multi-sig transactions as well? Or are they all signed using the SIGN_MODE_LEGACY_AMINO_JSON?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are all signed in SIGN_MODE_LEGACY_AMINO_JSON if it is the multi-sig tx as well as the ledger tx.

Reference

Copy link
Contributor

Choose a reason for hiding this comment

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

@dadamu Perfect, thanks for the reference link as well! 🙏

…f05b7a4cb1707af73655c.yaml

Co-authored-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
@dadamu dadamu requested a review from RiccardoM January 14, 2022 06:18
Signed-off-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
…impl' into paul/adr-005-multisig-chainlink-impl
Copy link
Contributor

@RiccardoM RiccardoM left a comment

Choose a reason for hiding this comment

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

I've just updated the create-chain-link-json documentation to include extensive explanation on what it's required when using it with multi-sig accounts. I've also added the missing docs to the generatePubKeyAndMultiSignatureData testing method.

I think the implementation is correct and ready to go.

Copy link
Contributor

@leobragaz leobragaz left a comment

Choose a reason for hiding this comment

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

Ready to ship

@RiccardoM RiccardoM added the automerge Automatically merge PR once all prerequisites pass label Jan 14, 2022
@mergify mergify bot merged commit 23cb923 into master Jan 14, 2022
@mergify mergify bot deleted the paul/adr-005-multisig-chainlink-impl branch January 14, 2022 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Automatically merge PR once all prerequisites pass kind/build Related to the build of the project x/CLI x/profiles Module that allows to create and manage decentralized social profiles
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support multisig address inside MsgCreateChainLink
3 participants