tezos-reward-distributor-organization / tezos-reward-distributor

Tezos Reward Distributor (TRD): A reward distribution software for tezos bakers.
https://tezos-reward-distributor-organization.github.io/tezos-reward-distributor/
GNU General Public License v3.0
87 stars 51 forks source link

Show batch payment operation hash #234

Open songproducer opened 3 years ago

songproducer commented 3 years ago

Is your feature request related to a problem? Please describe.

When doing payouts with an address on the ledger there is no hash printed to compare with the hash on the Ledger screen.

Describe the solution you'd like Show a operation hash for each batch payment

utdrmac commented 3 years ago

I'm not seeing this behavior:

2020-07-23 17:44:29,889 - consumer0 - Operation hash is oo8Y6t9Q4mxULzdPyL3Gpr52LE4JM7pWeb1Xnh6EjZXGiBZZXpe
2020-07-23 17:44:29,889 - consumer0 - Waiting for operation oo8Y6t9Q4mxULzdPyL3Gpr52LE4JM7pWeb1Xnh6EjZXGiBZZXpe to be included. Please be patient until the block has 1 confirmation(s)
2020-07-23 17:46:26,826 - consumer0 - Operation oo8Y6t9Q4mxULzdPyL3Gpr52LE4JM7pWeb1Xnh6EjZXGiBZZXpe is included
2020-07-23 17:46:26,830 - consumer0 - Payment of batch 2 is complete, in 1 attempt(s)
2020-07-23 17:46:26,834 - consumer0 - Processing completed for 285 payment items.

Can you provide some output? Can you try running TRD with -V option and see if that prints what you want?

songproducer commented 3 years ago

I ran with -V This is what I see before confirming the tx operation on ledger: Screenshot from 2020-07-27 01-41-57

This is what I see after confirming the tx operation on the ledger:

Screenshot from 2020-07-27 01-42-34

The operation shown on the ledger screen does not start with 'oo' and it also shows the words 'unrecognised operation'.

utdrmac commented 3 years ago

What does it show on your ledger? Also, please zip and upload logs/app.log after running with -V

songproducer commented 3 years ago

Unfortunately I didn't take a picture of the ledger, it was just 'UNRECOGNIZED OPERATION' 'Sign Hash' and a long hash of letters and numbers. applog.zip

utdrmac commented 3 years ago

@songproducer Can you confirm this is still an issue? We have many people using ledgers without any issues. What version of ledger wallet do you have installed? Have you pulled the latest TRD code? Are you using tezos-signer?

songproducer commented 3 years ago

@utdrmac Yes, still an issue. I am using the latest Ledger firmware version on a Ledger Nano X.

Tezos wallet version 2.2.5 SE 21.2.4-4 Microcontroller 2.10 Bootloader 1.4

I am not doing anything special with tezos-signer but I assume TRD uses it?

I just pulled an update for TRD so will see if it's still an issue and update here on the next cycle.

utdrmac commented 3 years ago

Next time, please provide the first 4-8 chars of what is displayed on the ledger so I can determine what exactly the ledger is asking you to confirm. The ophash is not generated until after injection, which happens after signing.

songproducer commented 3 years ago

7QPKmhsB

utdrmac commented 3 years ago

@songproducer Finally got a ledger setup with my testing environment. The issue apparently has something to do with the Ledger wallet app not recognizing batch transactions. If I configure TRD to send 1 reward payment, ledger shows everything correctly. It decodes the bytes to show you source, destination, fee, etc.

But if I change TRD to send 2+ in a single operation, the ledger doesn't know how to decode the bytes in such a way to present all that info to you. So it says it's unrecognized and shows you the signature of the decoded bytes TRD is requesting you to sign.

This will be an issue with the new tezos-client v8 as well since it supports creating bulk operations.

I'll try to figure out what the ledger app is decoding and at least try to present the same info on the terminal as on the device.

utdrmac commented 3 years ago

Reverse engineering the Ledger source code is proving to be extremely difficult. Looks like there's some blake2b hashing going on along with some base58 conversions, etc.

This is certainly not something that can be "fixed" from the TRD side of things. TRD calculates the bytes of the operation using RPC forge_operations. Those bytes are then sent to tezos-client for signing. If the address is set up via ledger, then tezos-client calls ledger libraries to send it those bytes. Ledger software decodes those bytes into info to display on the screen for confirmation.

utdrmac commented 3 years ago

@songproducer @jdsika Thoughts on my analysis?

jdsika commented 3 years ago

Can you create an issue in the Tezos Ledger App GitHub repository copying your analysis, please? We can reference the issue afterwards here in order to see when it is resolved. I will set the issue to blocked.

utdrmac commented 3 years ago

Referenced upstream issue: https://github.com/obsidiansystems/ledger-app-tezos/issues/154

songproducer commented 3 years ago

Would adding --verbose-signing as an argument in main.py for the Tezos client help?

utdrmac commented 3 years ago

@songproducer No, as this is not a TRD issue. TRD creates the batch operation, sends it to the ledger (via tezos-client or tezos-signer, it does not matter which), and it is the ledger itself that is unable to understand the batch operation. So it tells you this. You accept anyways, ledger signs the operation which comes back to TRD as a signature. TRD then injects this to block chain and gets back an ophash which is displayed on the TRD console.