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

Implementation of construction/payloads and construction/combine endpoints #275

Merged

Conversation

asimm241
Copy link
Contributor

@asimm241 asimm241 commented Oct 2, 2020

@codecov
Copy link

codecov bot commented Oct 2, 2020

Codecov Report

Merging #275 into master will increase coverage by 0.35%.
The diff coverage is 78.37%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #275      +/-   ##
==========================================
+ Coverage   65.16%   65.52%   +0.35%     
==========================================
  Files          53       53              
  Lines        3801     3910     +109     
  Branches      649      672      +23     
==========================================
+ Hits         2477     2562      +85     
- Misses       1321     1345      +24     
  Partials        3        3              
Impacted Files Coverage Δ
src/api/rosetta-constants.ts 100.00% <ø> (ø)
src/api/routes/rosetta/construction.ts 75.69% <73.80%> (-1.23%) ⬇️
src/rosetta-helpers.ts 73.95% <92.59%> (+2.67%) ⬆️

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 8612ea8...66648c5. Read the comment docs.

@asimm241
Copy link
Contributor Author

asimm241 commented Oct 7, 2020

@zone117x Fixed all the issues and updated PR.

amount: new BN(amount),
fee: new BN(fees),
publicKeys: publicKeysStrings,
numSignatures: 2,
Copy link
Member

Choose a reason for hiding this comment

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

This appears to only allow for 2-of-2 multisig transactions, it should support N-of-M

@asimm241 asimm241 force-pushed the feat/rosetta-construction-payloads-combine branch from e40b9a5 to 7a00e7a Compare October 7, 2020 17:53
amount: new BN(amount),
fee: new BN(fees),
publicKeys: publicKeysStrings,
numSignatures: publicKeys.length,
Copy link
Contributor

Choose a reason for hiding this comment

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

did you intend for publicKeys.length to be the value here? This will mean that all of the keys associated with publicKeys will have to eventually sign this tx...

typically the creator of a multi-sig transaction is able to specify what this value should be.

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'm assuming the caller is only specifying keys whose signatures are required. It means the caller is the creator of mulit-sig/single-sig transaction here. I can not find any other param in rosetta which will indicate signatures and public keys can be different.

Copy link
Member

Choose a reason for hiding this comment

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

@asimm241 can you verify that other Rosetta implementations do not support m-of-n multisig transactions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zone117x I haven't found any implementation to support multi-sig for rosetta in other blockchains. I have found this question https://community.rosetta-api.org/t/construction-api-and-multi-sig-accounts/208. This states that they are targeting m-of-n multi-sig for rosetta v1.5.0

Keeping this in view should we postpone the support of multi-sig.

Moreover, BTW rosetta docs do not require public keys in payloads request but makeUnsignedTokenTransferTransaction requires a public key(s), is there any other way to create a transaction without specifying the public key(s)?

Copy link
Member

Choose a reason for hiding this comment

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

This states that they are targeting m-of-n multi-sig for rosetta v1.5.0. Keeping this in view should we postpone the support of multi-sig.

We can postpone m-of-n until then 👍

rosetta docs do not require public keys in payloads request but makeUnsignedTokenTransferTransaction requires a public key(s)

It appears to be not-required to allow support for blockchains that do not need public keys. Is there anywhere that states the endpoint must work when public keys are not provided?

Copy link
Contributor Author

@asimm241 asimm241 Oct 8, 2020

Choose a reason for hiding this comment

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

No, I haven't encountered anything like that so far, I'm searching for it though, I'm also thinking of asking a question on their community forum. Let's see.

src/tests-rosetta/api.ts Outdated Show resolved Hide resolved
src/tests-rosetta/api.ts Outdated Show resolved Hide resolved

if (publicKeys.length !== 1) {
//TODO support multi-sig in the future.
res.status(400).json(RosettaErrors.needOnePublicKey);
Copy link
Member

Choose a reason for hiding this comment

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

Do other rosetta implementations do the same thing when there are more than 1 public keys?

Copy link
Contributor Author

@asimm241 asimm241 Oct 9, 2020

Choose a reason for hiding this comment

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

Other implementations that I have looked at don't require a public key to build an unsigned transaction.

Is there a way we can create a transaction without specifying the public key?
if No, then we need to update metadata and preprocess API to incorporate the public key.
as per these coinbase/mesh-specifications#46, coinbase/mesh-specifications#45

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is the PR containing those changes. #288

Copy link
Member

Choose a reason for hiding this comment

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

PR #288 merged. This PR needs a rebase to fix the conflicting file and then looks good to merge 👍

return;
}

if (signatures.length !== 1) res.status(400).json(RosettaErrors.needOnlyOneSignature);
Copy link
Member

Choose a reason for hiding this comment

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

Same question here -- is this what other Rosetta implementations do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Alright, we should create a github issue for tracking multi-sig support once the Rosetta spec adds it

Copy link
Member

Choose a reason for hiding this comment

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

Created issue #289

@asimm241 asimm241 force-pushed the feat/rosetta-construction-payloads-combine branch from b3b477e to 66648c5 Compare October 12, 2020 15:44
@asimm241 asimm241 requested a review from zone117x October 12, 2020 18:12
@zone117x zone117x merged commit aa73382 into hirosystems:master Oct 12, 2020
@blockstack-devops
Copy link

🎉 This PR is included in version 0.26.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants