-
Notifications
You must be signed in to change notification settings - Fork 667
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: ensure minimum non-dust amount as change output on regtest #5008
fix: ensure minimum non-dust amount as change output on regtest #5008
Conversation
Does this make sense, my brain can't think this through right now 🫠 |
This looks like it should work to me. Do you think you could add a unit test? |
There wasn't one before, so I think I'd merge this without, but if it's not terrible, it would be great to add. |
@janniks there are several test failures that seem to be a result of this change, ex: https://github.com/stacks-network/stacks-core/actions/runs/10102415322/job/27939605277?pr=5008 do these failing tests pass locally? |
I think you have to make changes inside let value = total_consumed - total_to_spend;
if value >= DUST_UTXO_LIMIT {
// Make change output
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call Jeff 👍. After another look, I agree, it does need some changes.
Lol, yeah this is why I initially closed the PR again. Thanks @jbencin -- I think I'll edit the utxo collection condition in serialize, hoping this is okay for the bitcoin regtest controller. |
I think you should have all the logic for this inside |
8ad2128
to
030fa64
Compare
Update based on @jbencin suggestion. Please double check the logic:
Won't be able to get a test done in time, should be small enough to review instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks correct to me now, but integration tests are still failing
Seems several CI tests are still failing |
…as_change_output_on_regtest
|
It's the bitcoind integration tests that are failing, and those are skipped by default. If you want to run one of the failing tests locally, do this: RUST_BACKTRACE=1 BITCOIND_TEST=1 cargo test -- --include-ignored stx_delegate_btc_integration_test |
and to emulate how the test will run in ci, something like this (which uses nextest):
I've run a few the failing tests locally, and this is the error i see:
with the failing tests being:
|
…as_change_output_on_regtest
08da287
to
df7e9e1
Compare
Yup, this looks good to me, but I would appreciate someone who is more familiar with the bitcoin transactions checking the sizes. |
two tests still failing (locally) with same error:
|
I think there are two unknowns that need to be investigated:
|
Thx for these, trying to figure out what's wrong here. Maybe the StackStx estimate is also off, but it seems to be off by a large margin, so I'm not sure.. |
Updated to only force the change output for block commits (according to the from_tx parse code it seems that's the only type which really needs the change output) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
looks good, thanks @janniks still see this failure : |
AddsDUST_UTXO_LIMIT
to theto_spend
amount for selecting utxos of the BitcoinRegtestController -- this ensures there will always be at leastDUST_UTXO_LIMIT
as a change output.total_spend
to the serialize function (which selects utxos), but rather atx_cost
.tx_cost
plus DUST_UTXO_LIMIT.tx_cost
is still used, to ensure a change output >= DUST_UTXO_LIMIT if we force one.380
This might be a quick, good enough fix -- or are there implications for non-regtest code paths?
lmk if anybody has ideas on writing a test for this.