storage: a short delta frame or an undecodable block header still panics a state rebuild
維護者通常 6 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
Start with beacon_state_delta.rs at unframe and state_writer.rs at reconstruct_beacon_state_bytes and fold_beacon_state_deltas; then trace block slot decoding through store.rs at try_block_slot_in and peek_beacon_block_slot. Check the additional BlockHeader::from_ssz_bytes(..).expect("valid header") reads in store.rs to decide the fix's scope. Done means truncated StateDiffs and BlockHeaders rows read through get_state return errors instead of panicking, with tests covering both cases.
由索引模型根據 Issue 內容生成。
描述
lambdaclass/ethlambda#788 changed get_state's rebuild to return Error::CorruptState, rather than panic, when a stored state, delta or diff does not decode. A few decodes of disk-sourced bytes on the same path still panic. Line numbers are at #788's head (4fe2f243):
- Delta frame header.
beacon_state_delta::unframe(crates/storage/src/beacon_state_delta.rs:111) slicesbytes[0..32],[32..40]and[40..48]without checking the length. AStateDiffsrow shorter than its 48-byte header therefore panics instead of reading back asCorruptState. On the rebuild path it is called byreconstruct_beacon_state_bytes(crates/storage/src/state_writer.rs:548) andfold_beacon_state_deltas(state_writer.rs:601). The writer'snearest_snapshot_root(state_writer.rs:580) calls it too. - Block slot lookup. Every hop of a rebuild reads its slot through
try_block_slot_in(crates/storage/src/store.rs:1121). Its beacon arm,peek_beacon_block_slot(store.rs:1073), indexes the row by its SSZ offset with no bounds check. Its lean arm.expect("valid header")s (store.rs:1132).reconstruct_state's final header read (state_writer.rs:679) does the same.
This was out of #788's scope because these panics already exist on main and that PR's docs name them. The header decode is also not specific to the rebuild:
block_slot,beacon_block_slotandnearest_snapshot_rootshare it.- Four more
BlockHeader::from_ssz_bytes(..).expect("valid header")reads sit elsewhere instore.rs(2702, 3026, 3074, 3138).
Making only the rebuild tolerate a corrupt header row would leave the next header read panicking. #306 is related but covers backend Results swallowed by .expect(), not bytes that read back fine and then fail to decode.
A fix:
- Add a
try_unframe(split_at_checked(48)) whose error the rebuild maps toCorruptState, and keepunframeas the panicking wrapper for frames the writer just built. - Add a fallible beacon slot peek and lean header decode, so that
try_block_slot_inreturns the crate'sErrorwith a decode failure asCorruptState(or a newCorruptBlockHeader { root }). - Decide whether the other header reads follow.
- Tests: a truncated
StateDiffsrow and a truncatedBlockHeadersrow each read back fromget_stateas an error, not a panic.
- 主要語言
- Rust
- 星號
- 86
- 分支
- 34
- 平均合併
- 9 天 20 小時
- 30 天內合併 PR
- 77
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
lambdaclass/ethlambda 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 76/100
lambdaclass/ethlambda#850 ·
維護者通常 6 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
lambdaclass/ethlambda#777 · 1 個 reaction ·
維護者通常 6 天內回覆
-
Run all gossip validation tests可能重新可做 @dicethedev 於 9 天前認領,目前沒有進行中的 PR。 未關閉
難度 2/5 1-3 小時 新手友好度 62/100
lambdaclass/ethlambda#725 · 2 則留言 ·
維護者通常 6 天內回覆
-
Handle malformed DB data可能重新可做 @dicethedev 於 115 天前認領,目前沒有進行中的 PR。 未關閉
難度 2/5 1-3 小時 新手友好度 76/100
lambdaclass/ethlambda#529 · 4 則留言 ·
維護者通常 6 天內回覆
-
Document architectural choices可能重新可做 @dicethedev 於 115 天前認領,目前沒有進行中的 PR。 未關閉
難度 2/5 1-3 小時 新手友好度 68/100
lambdaclass/ethlambda#521 · 2 則留言 ·
維護者通常 6 天內回覆
查看 lambdaclass/ethlambda 的全部 Issue
相似的 Issue
-
難度 1/5 1 小時以內 新手友好度 88/100
bytecodealliance/wrpc#1785 ·
維護者通常 1 天內回覆
-
2 advisory ignore entries no longer match anything (`quick-xml` already patched in `Cargo.lock`)未關閉
難度 1/5 1 小時以內 新手友好度 85/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
longbridge/nsh#2758 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 84/100
antithesishq/bombadil#473 ·
維護者通常 2 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
libracoder/kiri#669 ·
維護者通常 1 天內回覆