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

pool: round default min chan amt to nearest unit #151

Merged
merged 1 commit into from
Nov 12, 2020
Merged

pool: round default min chan amt to nearest unit #151

merged 1 commit into from
Nov 12, 2020

Conversation

wpaulino
Copy link
Contributor

@wpaulino wpaulino commented Nov 9, 2020

Fixes #145.

@wpaulino wpaulino requested review from guggero and Roasbeef November 9, 2020 23:11
@@ -82,6 +82,14 @@ func promptForConfirmation(msg string) bool {
}
}

// roundUp rounds up `n` to the nearest multiple.
func roundUp(n, multiple btcutil.Amount) btcutil.Amount {
Copy link
Member

Choose a reason for hiding this comment

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

Algo looks sound at a glance. If we want to clamp things down further, it shouldn't be too involved to create a testing/quick test to ensure the output of this function, given arbitrary inputs (within our range bounds) should always return something that's a multiple of our unit size. This can likely live where the unit is defined.

Copy link
Member

Choose a reason for hiding this comment

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

Could make this a method on the SupplyUnit itself for easy testing.

Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -82,6 +82,14 @@ func promptForConfirmation(msg string) bool {
}
}

// roundUp rounds up `n` to the nearest multiple.
func roundUp(n, multiple btcutil.Amount) btcutil.Amount {
Copy link
Member

Choose a reason for hiding this comment

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

Could make this a method on the SupplyUnit itself for easy testing.

@wpaulino wpaulino requested a review from Roasbeef November 11, 2020 01:51
Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

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

LGTM, nice test!

@@ -21,6 +21,12 @@ func NewSupplyFromSats(sats btcutil.Amount) SupplyUnit {
return SupplyUnit(uint64(sats) / uint64(BaseSupplyUnit))
}

// RoundToNextSupplyUnit computes and rounds to the next whole number of supply
Copy link
Member

Choose a reason for hiding this comment

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

Can we remove the TODO on L19 or is there still something more to do, @Roasbeef?

Copy link
Member

Choose a reason for hiding this comment

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

Nope this should be good, was just a hunch to revisit to ensure things are consistent. I think we need to do a sweep w.r.t where we use either of these methods, we may want to unify and ensure we always round up.

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 🍥

@@ -21,6 +21,12 @@ func NewSupplyFromSats(sats btcutil.Amount) SupplyUnit {
return SupplyUnit(uint64(sats) / uint64(BaseSupplyUnit))
}

// RoundToNextSupplyUnit computes and rounds to the next whole number of supply
Copy link
Member

Choose a reason for hiding this comment

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

Nope this should be good, was just a hunch to revisit to ensure things are consistent. I think we need to do a sweep w.r.t where we use either of these methods, we may want to unify and ensure we always round up.

@@ -10,7 +10,7 @@ type SupplyUnit uint64
const (
// BaseSupplyUnit is the smallest channel that can be bought or sold in
// the system. These units are expressed in satoshis.
BaseSupplyUnit SupplyUnit = 100_000
BaseSupplyUnit btcutil.Amount = 100_000
Copy link
Member

Choose a reason for hiding this comment

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

Why change? To cutdown on casting somewhere else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It just seemed strange to define it as SupplyUnit as you could then invoke ToSatoshis on it resulting in 100000^2.

Copy link
Contributor

@halseth halseth left a comment

Choose a reason for hiding this comment

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

ACK

@halseth halseth merged commit baedf06 into lightninglabs:master Nov 12, 2020
@wpaulino wpaulino deleted the min-chan-amt-nearest-unit branch November 12, 2020 19:31
positiveblue pushed a commit to positiveblue/pool that referenced this pull request Oct 11, 2022
Fee estimation for batch, deposit and withdrawal transactions
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.

Convertion between satoshi and units issue
4 participants