nervosnetwork / ckb

The Nervos CKB is a public permissionless blockchain, and the layer 1 of Nervos network.
https://www.nervos.org
MIT License
1.14k stars 224 forks source link

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

Open yangby-cryptape opened 1 month ago

yangby-cryptape commented 1 month ago

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

Current, there are 2 built-in algorithms:

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

Check List

Tests

Release note

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