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

Refactor batch payer #639

Merged
merged 40 commits into from
Jan 20, 2023
Merged

Refactor batch payer #639

merged 40 commits into from
Jan 20, 2023

Conversation

rvermootenct
Copy link
Contributor

@rvermootenct rvermootenct commented Dec 16, 2022


name: Pull Request
about: Create a pull request to make a contribution
labels:


IMPORTANT NOTICE:
I read and understood the guidelines for contributions to the TRD. The contribution may qualify for being compensated by the TRD grant if approved by the maintainers.

Please be aware that the failing tests can be seen on master as well atm..

This PR resolves the issue 641. The following steps were performed:

  • Analysis: The batch payer class is very tough to work with and has no unit tests. It requires a huge refactor but needs initial building blocks before that will be possible. There is a lot of technical debt in this class that needs to be paid.

  • Solution: BatchPayer needs to have functions pulled out and unit tested. Naming conventions need to be better.

  • Implementation: Pulled out a bunch of little functions into a utils file. Renamed a number of vars within the class for better understanding. Wrote tests.

  • Performed tests: Tests should pass no problem and I was able to test locally on ghostnet that the batch payer acted as expected.

Work effort: 20h

GIF TAX:

@jdsika
Copy link
Contributor

jdsika commented Dec 17, 2022

I merged #623 in order to have a solution for the release.

@jdsika jdsika added this to the v11.5 (Lima) milestone Dec 18, 2022
@jdsika jdsika added the enhancement New feature or request label Dec 18, 2022
src/pay/pay_constants.py Outdated Show resolved Hide resolved
pymnt/cfg/tz1iZ9LkpAhN8X1L6RpBtfy3wxpEWzFrXz8j.yaml Outdated Show resolved Hide resolved
src/Constants.py Outdated Show resolved Hide resolved
src/Constants.py Outdated Show resolved Hide resolved
@rvermootenct rvermootenct changed the title WIP: Refactor batch payer Refactor batch payer Jan 10, 2023
@rvermootenct rvermootenct requested a review from jdsika January 10, 2023 18:36
jdsika
jdsika previously approved these changes Jan 14, 2023
Copy link
Contributor

@jdsika jdsika left a comment

Choose a reason for hiding this comment

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

LGTM, I will let @dansan566 make 1 payment with this branch and merge afterwards

@dansan566
Copy link
Contributor

dansan566 commented Jan 17, 2023

Did a dry run, and got this:

Error, response ->Failed to parse the request body: Malformed value<-
2023-01-17 17:22:19,980 - consumer0 - ERROR - Error in run_operation
2023-01-17 17:22:19,980 - consumer0 - INFO - Payment to KT1XGnEMZYXJWKgwNCctGNzPYT7hXVSSMABe script could not be processed. Possible reason: liquidated contract. Skipping. Think about redirecting the payout to the owner address using the maps rules. Please refer to the TRD documentation or to one of the TRD maintainers.
2023-01-17 17:22:19,981 - consumer0 - ERROR - Error, request ->POST http://127.0.0.1:8732/chains/main/blocks/head/helpers/scripts/run_operation<-, params ->None<-,

Payouts to the address worked on the main branch, and the contract is not liquidated!
https://tzkt.io/KT1XGnEMZYXJWKgwNCctGNzPYT7hXVSSMABe/operations/

I had this error on more than 30 addresses, all of them KT1... (smart contracts)

@jdsika
Copy link
Contributor

jdsika commented Jan 17, 2023

@dansan566 ok thank you for the insight! retry failed payments on master and we will investigate

@dansan566
Copy link
Contributor

@jdsika, there are no failed payments if skipped!

@jdsika
Copy link
Contributor

jdsika commented Jan 18, 2023

Did a dry run, and got this:

Error, response ->Failed to parse the request body: Malformed value<-
2023-01-17 17:22:19,980 - consumer0 - ERROR - Error in run_operation
2023-01-17 17:22:19,980 - consumer0 - INFO - Payment to KT1XGnEMZYXJWKgwNCctGNzPYT7hXVSSMABe script could not be processed. Possible reason: liquidated contract. Skipping. Think about redirecting the payout to the owner address using the maps rules. Please refer to the TRD documentation or to one of the TRD maintainers.
2023-01-17 17:22:19,981 - consumer0 - ERROR - Error, request ->POST http://127.0.0.1:8732/chains/main/blocks/head/helpers/scripts/run_operation<-, params ->None<-,

Payouts to the address worked on the main branch, and the contract is not liquidated! https://tzkt.io/KT1XGnEMZYXJWKgwNCctGNzPYT7hXVSSMABe/operations/

I had this error on more than 30 addresses, all of them KT1... (smart contracts)

Two issues.

  • First it should be FAILED instead of SKIPPED
  • Parsing should be working

@rvermootenct
Copy link
Contributor Author

Diff of calculations on dry run mainnet between master and this branch:
Screenshot 2023-01-20 at 13 08 42

Diff of payments on dry run mainnet between master and this branch

Screenshot 2023-01-20 at 13 11 21

NOTE: On the payments there is a diff but it is only the position of the entry, the entry itself is identical.

@dansan566
Copy link
Contributor

@jdsika I did a dry run on the branch, and it worked so the error has been fixed by @rvermootenct
The next payout will be on this one!
My help with debugging: 1.5h

@jdsika
Copy link
Contributor

jdsika commented Jan 20, 2023

Diff of calculations on dry run mainnet between master and this branch: Screenshot 2023-01-20 at 13 08 42

Diff of payments on dry run mainnet between master and this branch

Screenshot 2023-01-20 at 13 11 21

NOTE: On the payments there is a diff but it is only the position of the entry, the entry itself is identical.

Please create a follow up ticket why the heck those sortings are non-deterministic. This is killing my test engineering soul

@jdsika jdsika merged commit 07144ae into master Jan 20, 2023
@jdsika jdsika deleted the refactor-batch-payer branch January 20, 2023 12:53
@nicolasochem
Copy link
Contributor

🔥 🔥

@nicolasochem
Copy link
Contributor

You know what else is "unmanageable" (per #641)?
The producer/consumer pattern.
See points made in #491

TRD would be so much simpler if it was doing what it needs to do in order, without a central "bus" of tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants