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

Feature/add srd selection #22

Closed
wants to merge 3 commits into from
Closed

Conversation

yancyribbens
Copy link
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.

src/lib.rs Outdated Show resolved Hide resolved
src/single_random_draw.rs Outdated Show resolved Hide resolved
@murchandamus
Copy link

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

src/single_random_draw.rs Outdated Show resolved Hide resolved
@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
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.

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@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
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
src/fee.rs Outdated Show resolved Hide resolved
@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 3 times, most recently from d1c63d7 to 48fc157 Compare February 21, 2023 15:10
@yancyribbens
Copy link
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

@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.

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
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.

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
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
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
Contributor

Choose a reason for hiding this comment

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

SGTM

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).

src/fee.rs Outdated Show resolved Hide resolved
src/single_random_draw.rs Show resolved Hide resolved
@yancyribbens yancyribbens force-pushed the feature/add-srd-selection branch 7 times, most recently from 995eccd to d1d38b1 Compare February 23, 2023 16:36
@yancyribbens yancyribbens force-pushed the feature/add-srd-selection branch 3 times, most recently from 0cdd892 to aef2c7b Compare March 21, 2023 16:10
@murchandamus
Copy link

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
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 yancyribbens force-pushed the feature/add-srd-selection branch 4 times, most recently from 7db7cc8 to 3ab168d Compare July 3, 2023 10:16
@yancyribbens yancyribbens deleted the feature/add-srd-selection branch July 3, 2023 10:21
@yancyribbens
Copy link
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