Skip to content

SealedBlock encodable only encodes the body #18002

@mattsse

Description

@mattsse

Describe the feature

these aren't symmetrical:

impl<B: Block> Encodable for SealedBlock<B> {
fn encode(&self, out: &mut dyn BufMut) {
self.body.encode(out);
}
}
impl<B: Block> Decodable for SealedBlock<B> {
fn decode(buf: &mut &[u8]) -> alloy_rlp::Result<Self> {
let block = B::decode(buf)?;
Ok(Self::seal_slow(block))
}
}

we need to fix this so that we encode the header then encode the block

a quick fix for this is .clone().into_block().encode

but this is a bit expensive.
it's a bit tricky because we'd need something like this to make this more efficient

/// Returns the rlp length of the block with the given header and body.
fn rlp_length(header: &Self::Header, body: &Self::Body) -> usize;

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugAn unexpected or incorrect behaviorC-enhancementNew feature or requestS-staleThis issue/PR is stale and will close with no further activity

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions