Skip to content

Feature/add srd selection#22

Closed
yancyribbens wants to merge 3 commits intomasterfrom
feature/add-srd-selection
Closed

Feature/add srd selection#22
yancyribbens wants to merge 3 commits intomasterfrom
feature/add-srd-selection

Conversation

@yancyribbens
Copy link
Copy Markdown
Collaborator

@yancyribbens yancyribbens commented Jan 11, 2023

I have renamed and moved the random function to it's own module. This feature is similar to SRD in core. Also, I've added effective_value which is used for the sum calculation instead of value. Lastly I did some minor refactoring so that the unit sizes used in the test match core.

@yancyribbens yancyribbens force-pushed the feature/add-srd-selection branch 3 times, most recently from 4d4426f to bb0275b Compare January 11, 2023 12:18
@yancyribbens yancyribbens requested a review from Tibo-lg January 11, 2023 12:24
@yancyribbens yancyribbens force-pushed the feature/add-srd-selection branch from bb0275b to 679ad2e Compare January 11, 2023 13:19
@murchandamus
Copy link
Copy Markdown

BTW, I added this repository to my watch list, so if you ask something here, I should also see.

@yancyribbens yancyribbens force-pushed the feature/add-srd-selection branch 3 times, most recently from 72736d4 to b149195 Compare January 15, 2023 23:14
@yancyribbens yancyribbens force-pushed the feature/add-srd-selection branch 2 times, most recently from 77f88e0 to d07e713 Compare January 24, 2023 17:24
Copy link
Copy Markdown
Contributor

@Tibo-lg Tibo-lg left a comment

Choose a reason for hiding this comment

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

I'm ok with using a struct though I'm not sure if it gives you more than a trait.

@yancyribbens yancyribbens force-pushed the feature/add-srd-selection branch 3 times, most recently from ce627d8 to bd45a30 Compare January 26, 2023 18:04
@yancyribbens
Copy link
Copy Markdown
Collaborator Author

@Tibo-lg I think the only downside to using a Trait instead of a struct is the increased compile time. A monomorphised type has to be constructed at compile time, although the run-time should be the same, so either is probably fine.

@yancyribbens yancyribbens force-pushed the feature/add-srd-selection branch 6 times, most recently from 684474a to 54f01e7 Compare January 31, 2023 09:16
@yancyribbens yancyribbens force-pushed the feature/add-srd-selection branch 4 times, most recently from 4447ebd to a4dd20f Compare February 2, 2023 18:13
@yancyribbens yancyribbens force-pushed the feature/add-srd-selection branch 13 times, most recently from 684b498 to 0fcf9b9 Compare February 11, 2023 15:55
@yancyribbens yancyribbens force-pushed the feature/add-srd-selection branch 5 times, most recently from d1c63d7 to 48fc157 Compare February 21, 2023 15:10
@yancyribbens
Copy link
Copy Markdown
Collaborator Author

I believe this PR is ready to merge. Any objections @Tibo-lg ?

src/fee.rs Outdated

#[test]
fn get_effective_value() {
let fee_rate = 10;
Copy link
Copy Markdown

@murchandamus murchandamus Feb 21, 2023

Choose a reason for hiding this comment

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

If you are going with integers for the feerate, you could consider using ṩ/kvB as the base unit, since it allows you to be more precise than just full satoshi increments. That way you can create transactions with feerates at 1.103 ṩ/vB, instead of needing to pay 2 ṩ/vB if 1 ṩ/vB is insufficient for the priority you want to imbue the transaction with.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I was also about to ask about how you avoid dust outputs, but then I saw the last commit. 👍

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If you are going with integers for the feerate, you could consider using ṩ/kvB as the base unit

Thanks, that's a good point. Wouldn't it be better to use a float for rate?

Otherwise, here would be:

let kv_bytes = weight / 4 /1024;
which means we lose a lot of precision with int division OR kvbytes is a float. It doesn't work to have kvbytes be a float and feerate as an int then.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We don’t use “kibivirtualbytes”, but “kilovirtualbytes“:

1 MvB = 1000 kvB = 1 000 000 vB

We never use floats for consensus relevant calculations in Bitcoin Core to avoid any sort of rounding issues. YMMV.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

How about something like this: d1d38b1

/// Takes as input the fee_rate in $ per Kilovirtualbytes
/// and a size in Kilovirtualbytes and returns the fee amount.
///
/// * fee_rate: $ per kilovirtualbytes $KvB
/// * size: kilovirtualbytes KvB
/// * fee: $

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I just noticed this PR rust-bitcoin/rust-bitcoin#1627. Maybe it would be better to build off FeeRate as defined by Rust Bitcoin.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SGTM

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How about something like this: d1d38b1

/// Takes as input the fee_rate in $ per Kilovirtualbytes
/// and a size in Kilovirtualbytes and returns the fee amount.
///
/// * fee_rate: $ per kilovirtualbytes $KvB
/// * size: kilovirtualbytes KvB
/// * fee: $

It’s not a dollar symbol but an “s” with a dot above and below: ṩ (u+1e69). The symbol for kilo is “k”, not “K”, the latter is the symbol for Kelvin, so it’s kvB, and that makes the feerate ṩ/kvB (which without the slash would be a multiplication rather than a division).

@yancyribbens yancyribbens force-pushed the feature/add-srd-selection branch 2 times, most recently from bca3356 to 882788c Compare February 22, 2023 16:01
@murchandamus
Copy link
Copy Markdown

Hey, this keeps popping up in my notifications but doesn’t seem to be ready for review. I’ll stop following notifications here for the time being. Please feel free to ping me here again when this PR is ready for review.

@yancyribbens
Copy link
Copy Markdown
Collaborator Author

Hey, this keeps popping up in my notifications but doesn’t seem to be ready for review. I’ll stop following notifications here for the time being. Please feel free to ping me here again when this PR is ready for review.

Sorry for all the noise. I think it's about ready now, however there seems to be some unrelated failure with the nightly toolchain I'm trying to figure out. Anyway, I think at this point I'll just close this PR and open a fresh one once I figure out what's going on with CI.

@yancyribbens
Copy link
Copy Markdown
Collaborator Author

@xekyo a new PR is now open here #23 - cheers.

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.

3 participants