goat-systems / tzpay

tzpay is a configurable batch payment tool for Bakers in the Tezos ecosystem
MIT License
12 stars 10 forks source link

Unable to execute payout due to go-tezos bug #8

Closed leopoldjoy closed 5 years ago

leopoldjoy commented 5 years ago

I am trying to execute the payout subcommand by running:

./payman payout --delegate=tz3NdTPb3Ax2rVW2Kq9QEdzfYFkRwhrQRPhX --cycle=190 --node=https://alphanet.tezrpc.me --fee=0.1 --payout-min=10000 --secret=<edesk...> --password=<password> --network-fee=1420

However, I'm getting this error:

payout.go:133: could not create batch payment: failed to Pre-Apply: could not preapply operation: bad response code 500

I am able to generate a report with the report subcommand without issue. However, I am getting this error when running the payout subcommand on both Alphanet and Mainnet.

I've tracked down the error to this line in go-tezos. It seems that validation fails when comparing the batch payment generated by go-tezos against the node. It appears to also relate to this go-tezos issue.

leopoldjoy commented 5 years ago

@zhanglianghui I believe @DefinitelyNotAGoat is active on the repo, he just added this feature last week. If I can find some time, I'll dig into this problem further.

DefinitelyNotAGoat commented 5 years ago

Thanks for reporting. Yeah I believe @zhanglianghui has reported this issue in Go Tezos. I will try to find some time tomorrow evening to debug what's going on. I apologize for the delay, I'm currently working a part time job in my evenings that's taking a lot of my time.

DefinitelyNotAGoat commented 5 years ago

I tried to reproduce this issue locally and I'm having a really hard time:

./payman payout --delegate=tz3NdTPb3Ax2rVW2Kq9QEdzfYFkRwhrQRPhX --cycle=190 --node=https://alphanet.tezrpc.me --fee=0.1 --payout-min=10000 --secret=edesk1Qx5JbctVnFVHL4A7BXgyExihHfcAHRYXoxkbSBmKqP2Sp92Gg1xcU8mqqu4Qi9TXkXwomMxAfy19sWAgCm --password=abcd1234 --network-fee=1420
2019/05/30 21:12:09 reporting.go:24: Successful operation: "onoxscii3YFU4APADTTcu2Tr4NHhorqdbsyJMRBRsjeVFoTsMDQ"

+--------------------------------------+----------+-----------+----------+-----------+
|               ADDRESS                |  SHARE   |   GROSS   |   FEE    |    NET    |
+--------------------------------------+----------+-----------+----------+-----------+
| KT1Wgq75N1BcwxXVzsLXQDbGmjKhUceK7JvY | 0.004290 |  0.607754 | 0.060775 |  0.546979 |
| KT1MSqpPNTokMdjuZiNySHc4s5KNvZ9LAaj9 | 0.020130 |  2.851542 | 0.285154 |  2.566388 |
| KT1Ug1xAafJyhyFoPoGNTZi2nVxTeeD9fU2Z | 0.121720 | 17.242672 | 1.724267 | 15.518405 |
| KT1RLABRR7xHWhXq246DMaHqWaZTJ4okEdRE | 0.001016 |  0.143862 | 0.014386 |  0.129476 |
| KT1CFABfscnR48qm682WoPYha2HyAGcQinv8 | 0.001118 |  0.158411 | 0.015841 |  0.142570 |
+--------------------------------------+----------+-----------+----------+-----------+
|                                         TOTAL   | 21.004241 | 2.100423 | 18.903818 |
+--------------------------------------+----------+-----------+----------+-----------+

If I can't reproduce I'll just audit the code tomorrow. Can you please share any additional details that you can think of?

DefinitelyNotAGoat commented 5 years ago

@zhanglianghui If your using a the public mainnet nodes, it's because they block those RPC's. But because @leopoldjoy reproduced it on alphanet I don't think that's the issue. I'm unable to reproduce it, but I'm currently adding much better error checking to Go Tezos so that if you reproduce it, we should know exactly where it's at.

DefinitelyNotAGoat commented 5 years ago

@zhanglianghui I'm talking about public nodes that you don't control. The public nodes listed on tzscan.io have proxies in front of them that block certain requests. If your using your own personal mainnet node, then the correct RPC's should be exposed.

DefinitelyNotAGoat commented 5 years ago

You don't have to do anything, all the RPC's you need are exposed.

DefinitelyNotAGoat commented 5 years ago

@zhanglianghui, and @leopoldjoy would you both mind updating to v1.0.5, I bubbled up errors better so you should see the actual response you get not just the status code.

DefinitelyNotAGoat commented 5 years ago

Thanks @zhanglianghui so that's probably your issue, and also explains why I can't reproduce it. The wallet you are using is not revealed to the network yet. You need to run ./tezos-client reveal key for tz1SmnG8bx2obaT9gv6tXajo4ohzpoMBVhfQ.

@leopoldjoy Can you confirm you get the same error?

leopoldjoy commented 5 years ago

@DefinitelyNotAGoat I already revealed my wallet to the network. I am receiving a different error. When I run:

./payman payout --delegate=tz3NdTPb3Ax2rVW2Kq9QEdzfYFkRwhrQRPhX --cycle=190 --node=tezos-dev.cryptonomic-infra.tech --fee=0.1 --payout-min=10000 --secret=edesk1Qx5JbctVnFVHL4A7BXgyExihHfcAHRYXoxkbSBmKqP2Sp92Gg1xcU8mqqu4Qi9TXkXwomMxAfy19sWAgCm --password=abcd1234 --network-fee=1420

I get this error:

2019/06/03 00:00:30 payout.go:133: could not create batch payment: could not forge operation '/chains/main/blocks/head/helpers/forge/operations' with contents '{"contents":
[{"kind":"transaction","source":"tz1SmnG8bx2obaT9gv6tXajo4ohzpoMBVhfQ","fee":"1420","counter":"62304","gas_limit":"10200","storage_limit":"0","amount":"129476","destination":"KT1RLABRR7xHWhXq246DMaHqWaZTJ4okEdRE"},
{"kind":"transaction","source":"tz1SmnG8bx2obaT9gv6tXajo4ohzpoMBVhfQ","fee":"1420","counter":"62305","gas_limit":"10200","storage_limit":"0","amount":"2566388","destination":"KT1MSqpPNTokMdjuZiNySHc4s5KNvZ9LAaj9"},
{"kind":"transaction","source":"tz1SmnG8bx2obaT9gv6tXajo4ohzpoMBVhfQ","fee":"1420","counter":"62306","gas_limit":"10200","storage_limit":"0","amount":"15518405","destination":"KT1Ug1xAafJyhyFoPoGNTZi2nVxTeeD9fU2Z"},
{"kind":"transaction","source":"tz1SmnG8bx2obaT9gv6tXajo4ohzpoMBVhfQ","fee":"1420","counter":"62307","gas_limit":"10200","storage_limit":"0","amount":"142570","destination":"KT1CFABfscnR48qm682WoPYha2HyAGcQinv8"},
{"kind":"transaction","source":"tz1SmnG8bx2obaT9gv6tXajo4ohzpoMBVhfQ","fee":"1420","counter":"62308","gas_limit":"10200","storage_limit":"0","amount":"546979","destination":"KT1Wgq75N1BcwxXVzsLXQDbGmjKhUceK7JvY"}
],"branch":"BDLSqXcuBq4fkeS85oW6UsUNbCx2SRvPTjSGgnbRcmAzn2982X9"}': 405 error: 

It seems that, as discussed earlier in the thread, the batch payment creation is failing.

leopoldjoy commented 5 years ago

@DefinitelyNotAGoat Any idea what might be causing the above error? Also (related), any idea of a rough ETA for a fix for this problem? I'll try to find some time to jump into it also.

DefinitelyNotAGoat commented 5 years ago

@leopoldjoy I'll have time to look into it more this weekend, but with the error code being 405 method not allowed, I suspect that tezos-dev.cryptonomic-infra.tech is blocking the RPC. Have you tried it with a local node in archive mode?

leopoldjoy commented 5 years ago

@DefinitelyNotAGoat I discovered a bug in go-tezos that was causing the problem. I've opened a PR with a super simple fix here: https://github.com/DefinitelyNotAGoat/go-tezos/pull/75. Essentially RPC node endpoints using HTTPS (e.g. TezRPC only accepts HTTPS requests) were not being handled properly—http:// was being prepended to the node endpoint (e.g. resulting in: http://https//alphanet.tezrpc.me).

DefinitelyNotAGoat commented 5 years ago

Awesome man! Thank you! I got it merged. I'll close this ticket in 48 hours, if no issues are reported.

bneiluj commented 5 years ago

Awesome 😀

leopoldjoy commented 5 years ago

Perfect, working properly on alphanet for me now 👍