threefoldtecharchive / jumpscaleX_threebot

Apache License 2.0
0 stars 3 forks source link

rounding issue in payment #651

Closed zaibon closed 4 years ago

zaibon commented 4 years ago

I think we do have a rounding issue in the payment flow. I made this reservation https://explorer.testnet.grid.tf/explorer/reservations/459798.

The amount asked to be paid was 98.066682 TFT. But if I check the amount transered: https://stellar.expert/explorer/testnet/tx/272318106443776#272318106443777 it only show 98.06668.

waleedhammam commented 4 years ago

I tried the following scenarios, on testnet and using TFT

and in all cases I got it right, couldn't reproduce

Deploy Ubuntu

1


1_1


Deploy minio

2


2_2


3


3_3


Deploy Kubernetes

4


4_4


zaibon commented 4 years ago

The problem has already been reproduced

JSX> amount                                                                                                                                                                     
98.066682

JSX> j.clients.stellar.mywallet.transfer("GDKNF2MV4PH47EZRMJKFYUA5GUEIJFAKIHUFPCU5XFV56W4UCRACTTLR", amount, 'TFT:GA47YZA3PKFUZMPLQ3B5F2E3CJIB57TGGU7SPCQT2WAEYKN766PWIMB3')    
'4adb8833792348bbd514ab3d0d8331f2c7799d52f75e00d1b3ed9878c85d50fb'

https://stellar.expert/explorer/testnet/tx/4adb8833792348bbd514ab3d0d8331f2c7799d52f75e00d1b3ed9878c85d50fb

DylanVerstraete commented 4 years ago

The problem has already been reproduced

JSX> amount                                                                                                                                                                     
98.066682

JSX> j.clients.stellar.mywallet.transfer("GDKNF2MV4PH47EZRMJKFYUA5GUEIJFAKIHUFPCU5XFV56W4UCRACTTLR", amount, 'TFT:GA47YZA3PKFUZMPLQ3B5F2E3CJIB57TGGU7SPCQT2WAEYKN766PWIMB3')    
'4adb8833792348bbd514ab3d0d8331f2c7799d52f75e00d1b3ed9878c85d50fb'

https://stellar.expert/explorer/testnet/tx/4adb8833792348bbd514ab3d0d8331f2c7799d52f75e00d1b3ed9878c85d50fb

Where did you get this amount from? It should be 7 digits precision and not 6

DylanVerstraete commented 4 years ago

Seems like I made a mistake here: https://github.com/threefoldtech/jumpscaleX_libs/blob/59f7230334f3e1cf8f31f7d16ebd86d9890abdb4/JumpscaleLibs/sal/zosv2/billing.py#L26

DylanVerstraete commented 4 years ago

Fixed in: https://github.com/threefoldtech/jumpscaleX_libs/commit/eb47929fb09babc273c078d78feabde8d1ebbdf2

@grimpy @zaibon can you pull libs and check?

grimpy commented 4 years ago

@DylanVerstraete in the scenario above it was reproduced by only using the stelar client, so i doubt your fix solves this one

DylanVerstraete commented 4 years ago

The stellar client does not do any rounding.. It just takes the input as string and submits that in a transaction..

DylanVerstraete commented 4 years ago

@DylanVerstraete in the scenario above it was reproduced by only using the stelar client, so i doubt your fix solves this one

and where did this amount variable come from?

DylanVerstraete commented 4 years ago

Okay some weird stuff happens. We are trying to pay for 1050667160 stropes for a certain reservation in the chatflow. When the actual transaction is submitted we see that the amount in the transaction is correct: 105.066716

transactionXDR: https://laboratory.stellar.org/#xdr-viewer?input=AAAAAEEr%2FdBOouqH5NnBZotG7agINbx7mAoxweKVp5TcOxy0AAAAyAAAC0IAAAAeAAAAAQAAAAAAAAAAAAAAAF6xcD8AAAABAAAABjQ1OTk1NgAAAAAAAgAAAAEAAAAATkUiCsv9ndOJzZgobkR03uUQ%2Bm0kerOA6hJhSStfcFwAAAABAAAAAHvZ22VPVRhwmqVoxByVgzHtJNok33yLrZRqYb95fECoAAAAAVRGVAAAAAAAOfxkG3qLTLHrhsPS6JsSUB7%2BZjU%2FJ4oT1YBMKb%2F3n2QAAAAAPp%2FomAAAAAEAAAAATkUiCsv9ndOJzZgobkR03uUQ%2Bm0kerOA6hJhSStfcFwAAAABAAAAABTmiVhP3xioOZWq822UjRt%2BH5wAdiprBqqLoo%2FqukIdAAAAAVRGVAAAAAAAOfxkG3qLTLHrhsPS6JsSUB7%2BZjU%2FJ4oT1YBMKb%2F3n2QAAAAAAA9CQAAAAAAAAAAC3DsctAAAAEDXhUDI9btUrOkJBDZKZ1AV1YVFNDmbsfHe8YwEntVgvLiCiaTy%2BnlT0Ge3S%2BDfhfOwITXSMKJr62wHGdsRir0LK19wXAAAAECUd1D8k2eQYgtPtAr7rA7jLlbBSuDvydaNE4Ld%2Bu9%2FIWFAEoHN56%2F17vPY%2Bh%2FtjNiqjkENz7h7Vlvo%2BQMzxsoB&type=TransactionEnvelope&network=test

For some reason it transfered only 105.0667 to the escrow account. https://stellar.expert/explorer/testnet/tx/602fa1febee11c396e971185f86fdc7ac980400365158022f3eb534b7a15f112

We checked sending 105.066716 between wallets with the stellar client and all of these transactions (funded and not funded) succeeded. https://stellar.expert/explorer/testnet/tx/3eda67ff47d9bd3ca5b75bdd920d82e6dbd96bed38a788ac71ed9ac9a39f60a1

This might be an issue on Stellar side...

DylanVerstraete commented 4 years ago

followup issue: https://github.com/threefoldfoundation/tft-stellar/issues/127