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

Improve fee estimation in internal wallet #1315

Merged
merged 5 commits into from
Feb 21, 2024
Merged

Conversation

ch1bo
Copy link
Member

@ch1bo ch1bo commented Feb 21, 2024

🪙 Using the cardano-ledger we improve the fee estimation to be within 0.1 ADA of the minimum fee.

🪙 Practically, this reduces cost of initializing and aborting a single party head from about 6.4 ADA to only 3.7 ADA.

🪙 There is still some overestimation in coverFees, however this is only due to the commit transaction requiring (usually) two witnesses, while all other txs would only be fine with one.


  • CHANGELOG updated or not needed
  • Documentation updated or not needed
  • Haddocks updated or not needed
  • No new TODOs introduced or explained herafter
    • An XXX note how to address the witness overestimation / make commit more flexible in the future.

@ch1bo ch1bo force-pushed the ch1bo/wallet-use-min-fee branch 3 times, most recently from bbf908d to 949aaff Compare February 21, 2024 14:56
@ch1bo ch1bo changed the title Improve fee estimate in internal wallet Improve fee estimation in internal wallet Feb 21, 2024
@ch1bo ch1bo marked this pull request as ready for review February 21, 2024 15:01
@ch1bo ch1bo requested a review from a team February 21, 2024 15:02
Copy link

github-actions bot commented Feb 21, 2024

Transactions Costs

Sizes and execution budgets for Hydra protocol transactions. Note that unlisted parameters are currently using arbitrary values and results are not fully deterministic and comparable to previous runs.

Metadata
Generated at 2024-02-21 17:53:48.067432512 UTC
Max. memory units 14000000
Max. CPU units 10000000000
Max. tx size (kB) 16384

Script summary

Name Hash Size (Bytes)
νInitial 985245919fcc6c0c5cd116023cd2c947c43e80dcbb5075fe12433fbb 4072
νCommit 7cb20fa71eb4c563ca283566ebe0aa65859d96c3f8cba35c52c181fd 2043
νHead 7a36661f5c15e9f1783aeaab890812c59b7286cbbc6de762d3110772 8816
μHead 8b111ac12274e46314769295a1c5dcab1d260096fc469fd698065463* 3851
  • The minting policy hash is only usable for comparison. As the script is parameterized, the actual script is unique per Head.

Cost of Init Transaction

Parties Tx size % max Mem % max CPU Min fee ₳
1 4432 10.25 3.95 0.46
2 4633 12.85 4.95 0.49
3 4835 14.89 5.72 0.52
5 5241 19.33 7.40 0.59
10 6240 30.41 11.60 0.75
41 12475 99.12 37.64 1.77

Cost of Commit Transaction

This is using ada-only outputs for better comparability.

UTxO Tx size % max Mem % max CPU Min fee ₳
1 591 11.37 4.44 0.30
2 781 15.04 6.07 0.35
3 972 18.85 7.75 0.40
5 1338 26.90 11.27 0.51
10 2278 49.55 20.97 0.80
19 3965 99.43 41.75 1.43

Cost of CollectCom Transaction

Parties UTxO (bytes) Tx size % max Mem % max CPU Min fee ₳
1 57 544 21.78 8.51 0.41
2 114 654 34.21 13.47 0.55
3 170 764 45.96 18.29 0.69
4 227 874 59.41 23.86 0.84
5 283 984 77.21 31.09 1.04
6 339 1099 93.03 37.74 1.22

Cost of Close Transaction

Parties Tx size % max Mem % max CPU Min fee ₳
1 595 16.64 7.66 0.37
2 736 18.09 8.99 0.39
3 857 19.45 10.27 0.42
5 1267 22.82 13.49 0.49
10 2130 30.93 21.19 0.65
50 7809 89.55 76.04 1.77

Cost of Contest Transaction

Parties Tx size % max Mem % max CPU Min fee ₳
1 644 20.27 8.99 0.41
2 773 21.76 10.32 0.43
3 937 23.78 12.02 0.47
5 1346 28.29 15.82 0.55
10 1977 35.82 22.43 0.69
47 7456 98.76 76.94 1.83

Cost of Abort Transaction

Some variation because of random mixture of still initial and already committed outputs.

Parties Tx size % max Mem % max CPU Min fee ₳
1 4223 15.19 6.26 0.50
2 4513 31.87 13.91 0.71
3 4541 45.05 19.64 0.86
4 4650 58.34 25.41 1.01
5 4807 74.26 32.31 1.19

Cost of FanOut Transaction

Involves spending head output and burning head tokens. Uses ada-only UTxO for better comparability.

Parties UTxO UTxO (bytes) Tx size % max Mem % max CPU Min fee ₳
5 0 0 4266 7.63 3.19 0.42
5 1 57 4299 8.86 3.96 0.44
5 5 285 4436 13.77 7.00 0.51
5 10 570 4605 20.13 10.90 0.59
5 20 1139 4945 32.43 18.53 0.76
5 30 1709 5286 44.73 26.16 0.93
5 40 2277 5624 56.83 33.70 1.10
5 50 2846 5963 69.35 41.43 1.27
5 75 4268 6811 99.95 60.45 1.69

End-To-End Benchmark Results

This page is intended to collect the latest end-to-end benchmarks results produced by Hydra's Continuous Integration system from the latest master code.

Please take those results with a grain of salt as they are currently produced from very limited cloud VMs and not controlled hardware. Instead of focusing on the absolute results, the emphasis should be on relative results, eg. how the timings for a scenario evolve as the code changes.

Generated at 2024-02-21 17:57:17.038809719 UTC

Baseline Scenario

Number of nodes 3
Number of txs 9000
Avg. Confirmation Time (ms) 23.159508195
P99 113.35773657000003ms
P95 32.2337339ms
P50 20.1000715ms
Number of Invalid txs 0

Baseline Scenario

Number of nodes 1
Number of txs 3000
Avg. Confirmation Time (ms) 4.616345710
P99 9.658092109999993ms
P95 6.277151649999996ms
P50 4.2871555ms
Number of Invalid txs 0

Copy link

Test Results

416 tests  ±0   409 ✅ ±0   13m 47s ⏱️ +2s
139 suites ±0     7 💤 ±0 
  5 files   ±0     0 ❌ ±0 

Results for commit b15b69f. ± Comparison against base commit 4463d6f.

@ch1bo ch1bo disabled auto-merge February 21, 2024 17:45
@ch1bo ch1bo enabled auto-merge February 21, 2024 17:46
auto-merge was automatically disabled February 21, 2024 17:47

Base branch was modified

This is not exactly minimum fee as this is quite hard to estimate
correctly (high fees on a tx will increase fees) and an overestimation
of 0.1 ADA is acceptable.
Using the cardano-ledger api we improve the fee estimation to be within
0.1 ADA of the minimum fee.
This is needed as we will sign the transaction after coverFee and the
fee need to be high enough to also cover the additional tx size cost.
@ch1bo ch1bo force-pushed the ch1bo/wallet-use-min-fee branch from b15b69f to 2759d2f Compare February 21, 2024 17:48
@ch1bo ch1bo enabled auto-merge February 21, 2024 17:48
@ch1bo ch1bo merged commit a49f7d3 into master Feb 21, 2024
20 checks passed
@ch1bo ch1bo deleted the ch1bo/wallet-use-min-fee branch February 21, 2024 17:59
@ch1bo ch1bo added this to the 0.16.0 milestone Apr 3, 2024
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.

2 participants