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

fix(derive): fix span batch utils read_tx_data() #170

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions crates/derive/src/types/batch/span_batch/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ pub(crate) fn read_tx_data(r: &mut &[u8]) -> Result<(Vec<u8>, TxType), SpanBatch
r.advance(1);
}

// Copy the reader, as we need to read the header to determine if the payload is a list.
// TODO(clabby): This is horribly inefficient. It'd be nice if we could peek at this rather than
// forcibly having to advance the buffer passed, should read more into the alloy rlp docs to
// see if this is possible.
let r_copy = Vec::from(*r);
let rlp_header = Header::decode(&mut r_copy.as_slice())
// Read the RLP header with a different reader pointer. This prevents the initial pointer from
// being advanced in the case that what we read is invalid.
let rlp_header = Header::decode(&mut (**r).as_ref())
.map_err(|_| SpanBatchError::Decoding(SpanDecodingError::InvalidTransactionData))?;

let tx_payload = if rlp_header.list {
Expand Down
Loading