-
Notifications
You must be signed in to change notification settings - Fork 217
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
Run multiple coin selections to estimate fees #1653
Conversation
8123a1c
to
ea99f42
Compare
ea99f42
to
5d33ab3
Compare
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.
Hi Rodney
I've not looked into the statistics yet, but this looks very reasonable.
I do have a question regarding backwards compatibility.
The approach taken (so far) is to add a pair of fields to the existing ApiFee
type:
- newtype ApiFee = ApiFee
- { amount :: !(Quantity "lovelace" Natural) }
+ data ApiFee = ApiFee
+ { amount :: !(Quantity "lovelace" Natural)
+ , estimatedMin :: !(Quantity "lovelace" Natural)
+ , estimatedMax :: !(Quantity "lovelace" Natural)
+ }
Values of this type are returned by the following endpoint:
POST /wallets/{id}/payment-fees
As an alternative to modifying this endpoint, have you considered introducing a new endpoint and new type? Something like:
POST /wallets/{id}/payment-fee-estimates
With the following type:
data ApiFeeEstimate = ApiFeeEstimate
{ estimatedMin :: !(Quantity "lovelace" Natural)
, estimatedMax :: !(Quantity "lovelace" Natural)
}
3954256
to
7d1bb4f
Compare
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.
Hi @rvl
Given the requirements as stated, this PR looks very sensible to me!
Ideally, we'd have some experimental data available to indicate the time and space costs of making multiple coin selections for different kinds of UTxO distributions. Unfortunately we don't have such data yet. (Though I'd very much like to create such a benchmark in future.)
Having said that, our current coin selection property tests do give us some (limited) information. With our current configuration, we're able to generate around 1,000 coin selections per second on our test machine. But this time includes the time taken to generate arbitrary UTxO sets. We currently generate UTxOs with between 1 and 256 entries, chosen according to a uniform random distribution. If we were to start with the same UTxO every time (to match what this PR is doing), this would almost certainly reduce the calculation time.
Assuming 100 samples from a similarly-sized UTxO set, the fee estimation endpoint could take around 1/10 second on a similar machine. So this seems reasonable as a starting point. 👍
If we wanted to err on the side of caution, then we could watch the clock while taking samples, and stop prematurely if we've taken too long. (Though perhaps that could be a future PR.)
As for the rest of the PR: I only have a minor request, which is to fix a couple of formatting issues (see comments with suggested changes included).
Also, I have a question regarding the property test (relating to the fee maximum).
Apart from that, all looks good!
lib/byron/test/integration/Test/Integration/Byron/Scenario/CLI/Transactions.hs
Outdated
Show resolved
Hide resolved
lib/byron/test/integration/Test/Integration/Byron/Scenario/CLI/Transactions.hs
Outdated
Show resolved
Hide resolved
We are going to change the estimate-fees api without making it backwards compatible. |
d5bbb3d
to
840e210
Compare
Thanks - rebased and squashed. bors merge |
1653: Run multiple coin selections to estimate fees r=rvl a=rvl ### Issue Number Relates to ADP-283 / #1648. ### Overview - Extends `POST /wallets/{id}/payment-fees` API endpoint with a "better" estimation. Adds fields for expected minimum and maximum fees. ### Comments - [x] decide on whether the api change should be breaking or backwards compatible - [x] also do similar fee estimation for delegation transactions - [x] better handling of coin selection errors while sampling - [ ] determine how many samples to take, or a criteria for stopping sampling. - [x] decide on quantile calculation method (currently using median). - [x] unit test `estimateFeeForCoinSelection` Co-authored-by: Rodney Lorrimar <[email protected]>
Build failed |
840e210
to
c602532
Compare
bors r+ |
1653: Run multiple coin selections to estimate fees r=KtorZ a=rvl ### Issue Number Relates to ADP-283 / #1648. ### Overview - Extends `POST /wallets/{id}/payment-fees` API endpoint with a "better" estimation. Adds fields for expected minimum and maximum fees. ### Comments - [x] decide on whether the api change should be breaking or backwards compatible - [x] also do similar fee estimation for delegation transactions - [x] better handling of coin selection errors while sampling - [ ] determine how many samples to take, or a criteria for stopping sampling. - [x] decide on quantile calculation method (currently using median). - [x] unit test `estimateFeeForCoinSelection` Co-authored-by: Rodney Lorrimar <[email protected]>
Build failed |
bors rety |
bors retry |
Build succeeded |
Issue Number
Relates to ADP-283 / #1648.
Overview
POST /wallets/{id}/payment-fees
API endpoint with a "better" estimation. Adds fields for expected minimum and maximum fees.Comments
estimateFeeForCoinSelection