alloy-rs / alloy-rs/alloy

[Bug] Blob type being stack allocated leads to easy stack overflows

Đang mở
#2,772 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
Rust
Star
1.3k
Fork
668
Merge trung bình
2 ngày 2 giờ
Pull request đã merge (30 ngày)
29

Mô tả

### Component

consensus, eips, genesis

### What version of Alloy are you on?

1.0.24

### Operating System

None

### Describe the bug

I noticed some stack overflows with some tests I had written. The culprit is from this type in alloy-eips
```
/// A Blob serialized as 0x-prefixed hex string
pub type Blob = FixedBytes;
```
With `BYTES_PER_BLOB = 131_072` and FixedBytes being stack allocated it seems like alot to put on the stack and can easily overflow it in some situations especially if it ends up getting cloned a couple times. This simple test below will stack overflow on Arch and MacOs ive tested(in debug mode)

```
use alloy_rpc_types_engine::BlobsBundleV2;
use ssz::Encode as _;

#[test]
fn test() {
let blobs_bundle = BlobsBundleV2 {
commitments: vec![Default::default()],
proofs: vec![Default::default()],
blobs: vec![Default::default()],
};

let bytes = blobs_bundle.as_ssz_bytes();
// following line will stack overflow
let blob: BlobsBundleV2 = ssz::Decode::from_ssz_bytes(&bytes).unwrap();
}
```

Maybe we can Box<> this type to avoid these overflows?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

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.