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: let sign-batch read multiple files #13454

Merged
merged 7 commits into from
Oct 7, 2022
Merged

feat: let sign-batch read multiple files #13454

merged 7 commits into from
Oct 7, 2022

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Oct 5, 2022

Description

With this change, the command behaves identically when given multiple files or passed one file containing multiples transactions. Works with --append too.

$ simd tx sign-batch tx1.json tx2.json --from alice
# will return the same than
$ cat tx1.json > tx12.json
$ cat tx2.json >> tx12.json
$ simd tx sign-batch tx12.json --from alice

I believe it closes: #13066 without adding an extra command.

Refactored duplicated code too to improve readability.


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)

x/auth/client/tx.go Fixed Show resolved Hide resolved
appendMessagesToSingleMsg, _ := cmd.Flags().GetBool(flagAppend)
if appendMessagesToSingleMsg {
// It will combine all tx msgs and create single signed transaction
appendMessagesToSingleTx, _ := cmd.Flags().GetBool(flagAppend)

Check warning

Code scanning / gosec

Returned error is not propagated up the stack.

Returned error is not propagated up the stack.
@codecov
Copy link

codecov bot commented Oct 5, 2022

Codecov Report

Merging #13454 (e90fa16) into main (2151427) will decrease coverage by 0.47%.
The diff coverage is 0.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #13454      +/-   ##
==========================================
- Coverage   54.47%   54.00%   -0.48%     
==========================================
  Files         676      648      -28     
  Lines       57952    55429    -2523     
==========================================
- Hits        31570    29934    -1636     
+ Misses      23735    23094     -641     
+ Partials     2647     2401     -246     
Impacted Files Coverage Δ
x/auth/client/cli/tx_multisign.go 0.00% <0.00%> (ø)
x/auth/client/cli/tx_sign.go 0.00% <0.00%> (ø)
x/auth/client/tx.go 30.84% <0.00%> (-5.83%) ⬇️
orm/encoding/ormkv/seq.go
orm/model/ormtable/batch.go
orm/encoding/ormkv/unique_key.go
orm/encoding/ormkv/primary_key.go
orm/encoding/ormfield/bool.go
... and 39 more

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

utACK 👏

@julienrbrt julienrbrt enabled auto-merge (squash) October 7, 2022 14:58
@julienrbrt julienrbrt merged commit 6efbedb into main Oct 7, 2022
@julienrbrt julienrbrt deleted the julien/authtx branch October 7, 2022 15:12
@ChienDuong
Copy link

The how can I broadcast the combine singed_batch file?
I get the error: " cannot unmarshal object into Go value of type []uint8:"

Note:
i was succesfully do tx broadcast with tx sign

@julienrbrt
Copy link
Member Author

julienrbrt commented Oct 19, 2022

I get the error: " cannot unmarshal object into Go value of type []uint8:"

Hey @ChienDuong, can you open an issue about it?
Stating which Cosmos SDK version you use, and the content of the file (anonymized if you want)?

@ChienDuong
Copy link

ChienDuong commented Oct 19, 2022

Let me clarify it @julienrbrt . If it can not be solved quickly I will open an issue.
What I normally do successfully:

Generate a transaction, then tx sign offline mode, then do "tx broadcast"
=> sometimes I face mismatch sequence error

Now I try:
Generate transaction, then sign with tx sign-batch offline mode, then do tx broadcast
I got the problem

Error: json: cannot unmarshal object into Go value of type []uint8: tx parse error

I found that the structure of the signed files between tx sign-batch and tx sign are differents. Thus, I can not broadcast successfully with tx sign-batch. I don't know how to broadcast tx sign-batch

tx sign-batch return 2 line

 {"signatures}:[{"public_key":... etc
 {"signatures}:[{"public_key":.... etc

tx sign return one line
{"body}:{"message"}:[{"@type": ....

@alexanderbez
Copy link
Contributor

I found that the structure of the signed files between tx sign-batch and tx sign are differents. Thus, I can not broadcast successfully with tx sign-batch. I don't know how to broadcast tx sign-batch

@julienrbrt this doesn't sound right. Both should return/write a single JSON object with 1 or more messages and 1 or more signatures.

@julienrbrt
Copy link
Member Author

julienrbrt commented Oct 19, 2022

Which version are you using? @ChienDuong

I'd rather move that to an issue tbh. Which specify the sdk version and steps to reproduce.

@ChienDuong
Copy link

ChienDuong commented Oct 19, 2022

More detail
tx sign-batch signs two transactions

{"signatures":[{"public_key":{"@type":"/cosmos.crypto.secp256k1.PubKey","key":""},"data":{"single":{"mode":"SIGN_MODE_DIRECT","signature":""}},"sequence":""}]}
{"signatures":[{"public_key":{"@type":"/cosmos.crypto.secp256k1.PubKey","key":""},"data":{"single":{"mode":"SIGN_MODE_DIRECT","signature":""}},"sequence":""}]}

tx sign only signs one transaction
{"body":{"messages":[{"@type":"/cosmos.bank.v1beta1.MsgSend","from_address":"","to_address":"","amount":[{"denom":"","amount":""}]}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[{"public_key":{"@type":"/cosmos.crypto.secp256k1.PubKey","key":""},"mode_info":{"single":{"mode":"SIGN_MODE_DIRECT"}},"sequence":""}],"fee":{"amount":[],"gas_limit":"","payer":"","granter":""},"tip":null},"signatures":[""]}

I am using Cosmos SDK v0.46.x @julienrbrt

@julienrbrt
Copy link
Member Author

Okay, can you reproduce building from main?

@ChienDuong
Copy link

Is there any way that I can DM you? @julienrbrt

@julienrbrt
Copy link
Member Author

Is there any way that I can DM you? @julienrbrt

You can on discord julienrbrt#0001, but I am still advocating that you should open an issue (as you have this problem in 0.46 anyway)

@ChienDuong
Copy link

ChienDuong commented Oct 19, 2022 via email

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.

CLI: Add support for multi-messages for each tx
3 participants