use ratios instead of percentages in campaign mix

Đang mở
#509 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
52/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
rust
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu từ các định nghĩa campaign được liên kết trong issue và tìm kiếm CampaignMixEntry, ResolvedMixEntry và share_pct để tìm mọi điểm vào bị ảnh hưởng. Theo dõi cách các mix rate được tính toán, sau đó xác minh rằng các đầu vào dựa trên tỷ lệ phân bổ total rate như mô tả và sử dụng số nguyên không dấu trong toàn bộ quá trình; issue lưu ý rằng việc làm tròn có thể để lại một phần dư nhỏ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement

Is your feature request related to a problem? Please describe.

Regarding campaign definitions, mix_pct (percentage) forces the user to manually sum up each mix's percentage to get the right ratio, which can be error-prone and tedious in campaigns with lots of mixes.

Describe the solution you'd like

Use ratios instead.

  • in CampaignMixEntry and ResolvedMixEntry, change share_pct to ratio
  • use unsigned ints instead of signed

Example:

mix_ratio_A = 2
mix_ratio_B = 1
total_tps = 100

Mix A would then produce 67 tps, and Mix B would produce 33, because A ≈ 2B.

Example:

mix_ratio_A = 1
mix_ratio_B = 1
mix_ratio_C = 1
mix_ratio_D = 1
total_tps = 100

Each mix would produce 25 tps.

Here's how I'd work out the final rate of each mix_ratio $\large m_i$ given total spam rate (tps/tpb) $\large t$:
$$\Large spamRate(m_i) = \frac{t * m_i}{\sum_{k=1}^n m_k}$$

or in code:

fn mix_spam_rate(ratio: u64, ratios: &[u64], total_rate: u64) -> u64 {
    (total_rate * ratio) / ratios.iter().sum::<u64>()
}

Using unsigned ints in this formula sometimes creates conditions where the sum of the individual rates doesn't meet the total desired rate (e.g. you get 99 tps instead of 100 because of a round-down), but it gets close enough.

Using floating point integers at the intake (CampaignMixEntry) could solve this (allowing us to round more intelligently before casting to unsigned) but not sure it's worth the effort. Users can always just increase the total_rate a little bit to compensate if they need to exactly hit the target spam rate.

Ngôn ngữ chính
Rust
Star
144
Fork
58
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của flashbots/contender

Tất cả issue của flashbots/contender

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.