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

Fiber Network Support #809

Open
poor-defined opened this issue Jan 7, 2025 · 7 comments
Open

Fiber Network Support #809

poor-defined opened this issue Jan 7, 2025 · 7 comments
Assignees
Labels

Comments

@poor-defined
Copy link
Contributor

poor-defined commented Jan 7, 2025

Is your feature request related to a problem? Please describe.
To support Fiber network in CKB explorer, we are going to show there data, statistic info and so on in CKB explorer.

Describe the solution you'd like
Here's the PRD link.

  • 4 more pages will be added
  • Menu bar is going to be adjusted with Icon Version
  • Some Charts & Lists are needed

Describe alternatives you've considered
Another proposal is to show only the data without some info, however, add some info and picture about Fiber Network wont take too long , and will disclosure more about Fiber Network.

Additional context
Image

@poor-defined poor-defined moved this to 🆕 New in CKB Explorer Jan 7, 2025
@poor-defined poor-defined moved this from 🆕 New to 🎨 Designing in CKB Explorer Jan 10, 2025
@poor-defined
Copy link
Contributor Author

PRD updated
https://vs0cjf.axshare.com/?id=989vno&g=14&p=fiber_network_support&sc=3
Log:

  • Add [node detail] Page

@Keith-CY cc @Kirl70

@Kirl70
Copy link

Kirl70 commented Jan 10, 2025

@rabbitz
Copy link

rabbitz commented Jan 17, 2025

  1. graph nodes / channels 目前同步频率为 5m, Total Liquidity Provide, Total Channels, Total Nodes 这些改成按天统计? 一天内同步的数量如果波动较大这个会有影响吗?
  • 图中 1 标注的 mean 和 medium 是对应所有的 channels 的 均值&中位数 指标?按图中展示是有 4 个值?

    • 均值:总资金(或其他指标) / 通道总数
    • 中位数:总资金(或其他指标)按顺序排列后获得的中位数;包含 2 中情况: 如果数据的数量是奇数,中位数就是中间的那个值; 如果数据的数量是偶数,中位数就是位于中间的两个数的平均值
  • 图中 2 标注的曲线统计方式是什么?

Image

  1. tvl 是所有 channel 中 capacity 累加按天统计?

Image

  1. Total Fee Earned 和 饼状图中的 数据是怎么计算的?1 个 channel 有 2 个 fee rate (fee_rate_of_node1和 fee_rate_of_node2)

Image

  1. 图中标注的值是怎么获取的?其中 fee rpc 中没有, fee rate 包含 2 个 (fee_rate_of_node1和 fee_rate_of_node2)

Image

@poor-defined
Copy link
Contributor Author

  1. graph nodes / channels 目前同步频率为 5m, Total Liquidity Provide, Total Channels, Total Nodes 这些改成按天统计? 一天内同步的数量如果波动较大这个会有影响吗?

不需要5m,大概改成4小时的话我觉得比较合适。

  • 图中 1 标注的 mean 和 medium 是对应所有的 channels 的 均值&中位数 指标?按图中展示是有 4 个值?

    • 均值:总资金(或其他指标) / 通道总数
    • 中位数:总资金(或其他指标)按顺序排列后获得的中位数;包含 2 中情况: 如果数据的数量是奇数,中位数就是中间的那个值; 如果数据的数量是偶数,中位数就是位于中间的两个数的平均值

这里包括文档上应该都指的是单个Channel的。总和就不存在均值和中位数了。

  • 图中 2 标注的曲线统计方式是什么?

Image

是 Total Channel 按时间(天)统计的变化曲线

  1. tvl 是所有 channel 中 capacity 累加按天统计?

Image

是的。关于用词可以改成“Total Capacity”

  1. Total Fee Earned 和 饼状图中的 数据是怎么计算的?1 个 channel 有 2 个 fee rate (fee_rate_of_node1和 fee_rate_of_node2)

Image

这个我确认下。

  1. 图中标注的值是怎么获取的?其中 fee rpc 中没有, fee rate 包含 2 个 (fee_rate_of_node1和 fee_rate_of_node2)

Image

同上,这个我也确认下。

@poor-defined
Copy link
Contributor Author

  1. graph nodes / channels 目前同步频率为 5m, Total Liquidity Provide, Total Channels, Total Nodes 这些改成按天统计? 一天内同步的数量如果波动较大这个会有影响吗?

不需要5m,大概改成4小时的话我觉得比较合适。

  • 图中 1 标注的 mean 和 medium 是对应所有的 channels 的 均值&中位数 指标?按图中展示是有 4 个值?

    • 均值:总资金(或其他指标) / 通道总数
    • 中位数:总资金(或其他指标)按顺序排列后获得的中位数;包含 2 中情况: 如果数据的数量是奇数,中位数就是中间的那个值; 如果数据的数量是偶数,中位数就是位于中间的两个数的平均值

这里包括文档上应该都指的是单个Channel的。总和就不存在均值和中位数了。

  • 图中 2 标注的曲线统计方式是什么?

Image

是 Total Channel 按时间(天)统计的变化曲线

  1. tvl 是所有 channel 中 capacity 累加按天统计?

Image

是的。关于用词可以改成“Total Capacity”

  1. Total Fee Earned 和 饼状图中的 数据是怎么计算的?1 个 channel 有 2 个 fee rate (fee_rate_of_node1和 fee_rate_of_node2)

Image

这个我确认下。

  1. 图中标注的值是怎么获取的?其中 fee rpc 中没有, fee rate 包含 2 个 (fee_rate_of_node1和 fee_rate_of_node2)

Image

同上,这个我也确认下。

Based on the Readme file of Fiber network

fee_rate_of_node1 - The fee rate set by node 1. This is the fee rate for node 1 to forward TLCs sent from node 2 to node 1.
fee_rate_of_node2 - The fee rate set by node 2. This is the fee rate for node 2 to forward TLCs sent from node 1 to node 2

The total fee earned = 统计时间段内每一笔交易的传输金额(可以确认下是不是TLC amount)* (fee_rate_of_node1+fee_rate_of_node2)/精度

@rabbitz
Copy link

rabbitz commented Jan 26, 2025

  1. 按天分段统计:
  • 每天以整点为单位,每隔 4 小时同步一次 Fiber Graph 的节点和通道数据。例如,统计时间段为 04 时、48 时等。对同步的数据进行以下统计分析:
    • total_nodes: 节点总数
    • total_channels: 通道总数
    • total_liquidity: 通道中 capacity 字段的总和
    • mean_value_locked: 通道中 capacity 字段的平均值
    • mean_fee_rate: 通道中 fee_rate_of_node1 和 fee_rate_of_node2 的平均值
    • medium_value_locked: 通道中 capacity 字段的中位数
    • medium_fee_rate: 通道中分别计算 fee_rate_of_node1 和 fee_rate_of_node2 的中位数后,再取两者的中位数
  1. 实时通道状态监控: 每隔 5 分钟检查所有 open channels 是否已变更为 closed 状态,并进行同步处理
  2. 接口:
  • /api/v2/fiber/statistics 按照统计时间倒序返回 7 天内的统计结果, 结构示例如下:
    {
        "data": [
            {
                "total_nodes": "15",
                "total_channels": "340",
                "total_liquidity": "181512860000011",
                "mean_value_locked": "533861352941",
                "mean_fee_rate": "2000",
                "medium_value_locked": "62600000000",
                "medium_fee_rate": "1000",
                "created_at_unixtimestamp": "1737849600"
            }
        ]
    }
  • /api/v2/fiber/statistics/{indicator} indicator 枚举可选参数为 total_nodes|total_channels|total_liquidity, 结构示例如下:
    # total_nodes
    {
      "data": [
          {
              "total_nodes": "15",
              "created_at_unixtimestamp": "1737849600"
          }
      ]
    }
    # total_channels
    {
      "data": [
          {
              "total_channels": "340",
              "created_at_unixtimestamp": "1737849600"
          }
      ]
    }
    # total_liquidity
    {
      "data": [
          {
              "total_liquidity": "181512860000011",
              "created_at_unixtimestamp": "1737849600"
          }
      ]
    }

@Keith-CY
Copy link
Member

Keith-CY commented Feb 7, 2025

For the animation

Image

we have api https://ckb-explorer-api-staging.magickbase.com/api/v2/fiber/graph_nodes/addresses to get all public fiber nodes

unlike ckb node that nodes will communicate with each other, fiber nodes will only connect to specific nodes, so we need one more api/fields to get the connections to draw lines between nodes.

Either of the solutions should work

  1. in the graph_node/addresses API, add a connections fields such like
{
"node_id": "035f3df0c78092c24ea71e8e6538c8e45ac998e074a1a640d881eb58e2ea975131",
"addresses": [
  "[/ip4/52.45.221.66/tcp/28228/p2p/QmXkYqAfESfjNSTd2tLZV5wSE5hZh8SdQhxSAGtjTLBYLz](https://ckb-explorer-api-staging.magickbase.com/ip4/52.45.221.66/tcp/28228/p2p/QmXkYqAfESfjNSTd2tLZV5wSE5hZh8SdQhxSAGtjTLBYLz)"
  ],
  "connections": ["other_node_id_1", "other_node_id_2"]
}
  1. add a new API for the connections, such as an unpaged API to get graph channels

@rabbitz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🎨 Designing
Development

No branches or pull requests

4 participants