[Bug] Blob type being stack allocated leads to easy stack overflows
- Vorherrschende Sprache
- Rust
- Sterne
- 1.3k
- Forks
- 668
- Ø Merge
- 2 T. 1 Std.
- Gemergte PRs (30 T.)
- 29
Beschreibung
### 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?
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.