Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: 4844 SidecarBuilder #250

Merged
merged 7 commits into from
Mar 15, 2024
Merged

Feat: 4844 SidecarBuilder #250

merged 7 commits into from
Mar 15, 2024

Conversation

prestwich
Copy link
Member

Motivation

There is currently no convenient way to construct valid sidecars from data

Solution

Add a sidecar builder that ingests arbitrary data, blobs it, and builds into a sidecar

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@prestwich prestwich added the enhancement New feature or request label Mar 5, 2024
@prestwich prestwich self-assigned this Mar 5, 2024
@prestwich prestwich requested review from mattsse and removed request for gakonst, Evalir and DaniPopes March 5, 2024 19:24
@prestwich prestwich marked this pull request as draft March 5, 2024 19:48
@prestwich prestwich marked this pull request as ready for review March 9, 2024 18:52
Copy link
Contributor

@Rjected Rjected left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks generally good, the API makes sense to me, but need a few questions answered before I can lgtm

crates/consensus/src/transaction/eip4844/builder.rs Outdated Show resolved Hide resolved
crates/consensus/src/transaction/eip4844/builder.rs Outdated Show resolved Hide resolved
/// Returns `Err(())` if there is an error.
fn decode_one<'a>(mut fes: impl Iterator<Item = WholeFe<'a>>) -> Result<Option<Vec<u8>>, ()> {
let first = fes.next().ok_or(())?;
let mut num_bytes = u64::from_be_bytes(first.as_ref()[1..9].try_into().unwrap()) as usize;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to have a method on WholeFe that does the array ref conversion, documented with assumptions about how WholeFe is constructed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to omit, as reading from a WholeFe is generally not advisable. These should be a coder implementation detail, basically

crates/consensus/src/transaction/eip4844/builder.rs Outdated Show resolved Hide resolved
@prestwich prestwich force-pushed the prestwich/sidecar-builder branch from ace8a37 to 5dccace Compare March 13, 2024 17:41
@prestwich prestwich requested a review from onbjerg as a code owner March 13, 2024 17:41
@prestwich prestwich force-pushed the prestwich/sidecar-builder branch from f64f1d4 to 249fb99 Compare March 13, 2024 20:40
@prestwich prestwich requested a review from Rjected March 13, 2024 21:19
test: test ingestion

feat: trim and inspect builder

wip

feat: modulus in 4844

feat: simple coder and ingestion strategies

fix: required_fes in ingestion strategy

refactor: names

fix: clippy and doclinks

fix: more doclinks and clippy

fix: remove deref impls

fix: delegate len and is_empty

refactor: mutable sidecar coder
@prestwich prestwich force-pushed the prestwich/sidecar-builder branch from 6fe0b12 to 6fef96a Compare March 13, 2024 22:26
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blob math looks kinda cursed -.-

did not look at the math

crates/consensus/src/transaction/eip4844/builder.rs Outdated Show resolved Hide resolved
Comment on lines 35 to 38
/// Create a new builder with a given capacity.
pub fn with_capacity(capacity: usize) -> Self {
let mut blobs = Vec::with_capacity(capacity);
blobs.push(Blob::new([0u8; BYTES_PER_BLOB]));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this also adds a new blob,
looking at the other function, I think this is intended

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, the intention is to never allow the blobs vec to be empty

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've improved instantiation quite a bit now :)

Copy link
Contributor

@Rjected Rjected left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left a note on with_capacity docs

crates/consensus/src/transaction/eip4844/builder.rs Outdated Show resolved Hide resolved
@prestwich prestwich merged commit 889bc61 into main Mar 15, 2024
15 checks passed
@prestwich prestwich deleted the prestwich/sidecar-builder branch March 15, 2024 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants