Claim a gossip block's slot and proposer before its stateful checks

未關閉
#840 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 6 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
48/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
rust

研究方向

Start with crates/net/p2p/src/beacon/verdict.rs and gossip::block::cheap_checks, then trace the stateful checks run on spawn_blocking under gossip_validation_permits. Review payload_hash::tests::verify_block_cost for the hash cost and the validation behavior described in docs/spec_deviations.md. Add a concurrent test for two signed blocks with the same (slot, proposer) and confirm only one is hashed; the issue leaves the fix design open.

由索引模型根據 Issue 內容生成。

描述

Beacon gossip records a block's (slot, proposer) in P2PServer::seen_blocks only when its verdict reaches the p2p actor (settle in crates/net/p2p/src/beacon/verdict.rs). The stateful checks run before that, on spawn_blocking threads under gossip_validation_permits (128). So several distinct blocks for one slot and proposer that arrive together all pass the cheap checks' AlreadySeen rule (gossip::block::cheap_checks) and are each checked in full:

  • the parent-state lookup and the proposer's BLS signature (on main already);
  • since lambdaclass/ethlambda#770, the payload block hash on an Accept: a transactions trie and keccak, measured at up to 0.6 s for a block at the 10 MiB gossip limit filled with 1,048,576 tiny transactions (payload_hash::tests::verify_block_cost).

It takes the slot's proposer signing equivocations (slashable) and sending them directly, since honest peers relay only the first. The work is bounded by the permit count: past it, blocks are forwarded unchecked under Overloaded. lambdaclass/ethlambda#770 documents the window in docs/spec_deviations.md and leaves the fix out, because it changes how every block is validated, not only the hash.

Possible fixes:

  • A shared claim set keyed by (slot, proposer) (an LRU sized like SEEN_BLOCKS_CAPACITY), taken by the blocking task before its signature check, or at least before the hash. A second block for a claimed key answers Ignore(AlreadySeen) without further work. A claim is released when its block fails its signature or an earlier rule, so it never stands for an invalid block, which keeps the specification's "first block with a valid signature".
  • Independently, a transaction-count budget above which block_verdict does not hash, leaving the block to the execution client. Mainnet's gas limit allows a few thousand transactions, so a cap such as 2^14 would bound the trie without touching real blocks.

A test should send two signed blocks for one key through the stateful checks at once and assert that only one is hashed.

主要語言
Rust
星號
86
分支
34
平均合併
9 天 20 小時
30 天內合併 PR
77

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

lambdaclass/ethlambda 的其他 Issue

查看 lambdaclass/ethlambda 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。