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

feat: (experimental) optional fee estimator with different algorithms #4477

Conversation

yangby-cryptape
Copy link
Collaborator

@yangby-cryptape yangby-cryptape commented Jun 4, 2024

What problem does this PR solve?

Warning

This feature is experimental.
I have done lots of manual tests before submit this PR, but more production environment tests are still required.

Add an optional fee estimator with different algorithms and a RPC method for it.

Description

  • I do lots manual tests for several day, I don't sure which algorithm is better, so I just submit both of them.

    Let's make choice after collect more data in production environment (both mainnet and testnet).

  • Only 4 levels of priorities for the fee estimator.

    Different algorithms have different APIs, I just use some constants as default parameters to avoid specialized parameters, to make the public API more generic.

Current, there are 2 built-in algorithms:

  • Confirmation Fraction

    Migrated from this CKB PR.

    👉🏼 Sometimes, it returns unreasonable result, I haven't figured it out yet, since I couldn't reproduce it manually.

  • Weight-Units Flow

    A variant of the Weight-Units Flow Fee Estimator for Bitcoin.

    The main difference is I use the block interval to replace the time interval, to avoid unit conversion with random distributions, since our APIs require blocks as the target unit for estimation.

    The details of this algorithm are written in the head section of that source code file.

Merged fallback fee estimates algorithm from #4465.

Usage

Append the following content to ckb.toml:

[fee_estimator]
# Specifies the fee estimates algorithm. Current algorithms: ConfirmationFraction, WeightUnitsFlow.
algorithm = "WeightUnitsFlow"

And enable JSON-RPC API module Experiment.

After the CKB node started, try the following command:

echo '{ "id": 1, "jsonrpc": "2.0", "method": "estimate_fee_rate", "params": [] }' \
    | curl -s -H "Content-Type: application/json" -d @- "http://localhost:8114" \
    | jq

An example of result is:

{
  "jsonrpc": "2.0",
  "result":"0x3e8",
  "id": 1
}

What is changed and how it works?

What's Changed:

Related changes

  • PR to update owner/repo:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test

Release note

Title Only: Include only the PR title in the release note.

@yangby-cryptape yangby-cryptape requested a review from a team as a code owner June 4, 2024 06:55
@yangby-cryptape yangby-cryptape requested review from quake, chenyukang, zhangsoledad and eval-exec and removed request for a team June 4, 2024 06:55
@eval-exec eval-exec added t:enhancement Type: Feature, refactoring. b:rpc Break RPC interface m:tx-pool labels Sep 22, 2024
@yangby-cryptape yangby-cryptape requested review from quake and zhangsoledad and removed request for quake and zhangsoledad October 23, 2024 00:58
quake
quake previously approved these changes Oct 23, 2024
eval-exec
eval-exec previously approved these changes Oct 23, 2024
@quake quake added this pull request to the merge queue Oct 23, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 23, 2024
@yangby-cryptape yangby-cryptape added this pull request to the merge queue Oct 24, 2024
Merged via the queue into nervosnetwork:develop with commit 7f24e60 Oct 24, 2024
32 checks passed
@doitian doitian mentioned this pull request Nov 18, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
b:rpc Break RPC interface m:tx-pool t:enhancement Type: Feature, refactoring.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants