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

Return Weight in the TxIn/TxOut weight() methods #1970

Merged
merged 1 commit into from Aug 2, 2023

Conversation

danielabrozzoni
Copy link
Contributor

No description provided.

Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

ACK 40c37ad

Thanks!

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 40c37ad

@apoelstra apoelstra merged commit 48be537 into rust-bitcoin:master Aug 2, 2023
29 checks passed
@yancyribbens
Copy link
Contributor

I had put in this same PR a few months ago:
#1831

Here is why it wasn't merged then:

The return type is intentionally usize because it's error-prone to blindly sum them. (Although usize doesn't signal that well...)

Has there been a change of opinion about this or was it only @Kixunil that had these objections? Seems so since it was merged.

@apoelstra
Copy link
Member

I think it was a combination of us forgetting about Kix's opposition (I remembered there being some controversy about using Weight more broadly, but this case seemed harmless enough by itself) and us fast-tracking changes that come from the BDK developers because we're trying to get them up to date with the latest rust-bitcoin.

cc @tcharding I wonder if we should put a 1-week delay (or even 2 weeks) on API changes, even if they have multiple ACKs?

@danielabrozzoni
Copy link
Contributor Author

I didn't see #1831 and when I noticed that those methods returned a usize I thought it was an oversight. I should have checked better, sorry. It's ok for me to revert this one if you prefer, legacy_weight and segwit_weight work just fine with usize :)

@yancyribbens
Copy link
Contributor

I also thought it was an oversight :) Anyway, I still don't fully understand why it should be usize really.

@apoelstra
Copy link
Member

Personally I don't think Weight is any worse than usize. Neither type really expresses the subtleties associated with computing transaction weight from the weight of their components. So I don't think we should revert this.

But it is a process failure that we had an open issue with a PR, and then merged another PR in parallel which did substantially the same thing, so I'd like to avoid that in future.

@tcharding
Copy link
Member

cc @tcharding I wonder if we should put a 1-week delay (or even 2 weeks) on API changes, even if they have multiple ACKs?

Lets have two weeks.

I think it was a combination of us forgetting about Kix's opposition (I remembered there being some controversy about using Weight more broadly, but this case seemed harmless enough by itself) and us fast-tracking changes that come from the BDK developers because we're trying to get them up to date with the latest rust-bitcoin.

FWIW I just reviewed the code changes and they seemed sane, I have never been personally burned by the weight addition stuff @Kixunil put forward so I'm not surprised I did not remember it.

Going forward, neither the usize nor the Weight give any hint as to this subtlety - we need to improve the API. This is exactly what rust-bitcoin is supposed to do, protect devs from the sharp dangerous bits of Bitcoin.

@tcharding
Copy link
Member

Oh and props to @yancyribbens for noticing this fly past.

@yancyribbens
Copy link
Contributor

Personally I like when changes I make get merged and reviewed quick. That way that don't become stale. Part of the miss here is in my opinion the shift in who is reviewing.

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.

None yet

4 participants