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

Fix interaction with max and unbounded overdraft #474

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Azorlogh
Copy link
Contributor

@Azorlogh Azorlogh commented Dec 20, 2023

Fixes #473

Bug explanation:
Each source is associated with an optional fallback account that is used to fund any missing amount from that source.
When using the max source, it will use the OP_TAKE_MAX instruction to cap the subsource's funding.
OP_TAKE_MAX returns the amount missing to max out (or 0), and the amount remaining if it was already maxed out.
When the subsource has no fallback, the amount missing is simply discarded
When the subsource has a fallback, the amount missing should be taken from it unconditionally to max out the funding, which should be done with the OP_TAKE_ALWAYS instruction.

@flemzord flemzord changed the base branch from main to release/v1.10 December 20, 2023 21:12
@flemzord flemzord self-requested a review as a code owner December 20, 2023 21:12
@flemzord flemzord changed the base branch from release/v1.10 to main December 20, 2023 21:13
@edwardmp
Copy link
Contributor

@flemzord hope this bugfix can be merged soon :)

@flemzord
Copy link
Member

@edwardmp Yes, this PR will be merged into the v2 ledger. However, we need another fix for the v1 ledger.

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

Successfully merging this pull request may close these issues.

NumScript max operator doesn't work correctly when source account has negative balance
3 participants