Skip to content

Commit 60f7b7a

Browse files
greged93frisitano
andauthored
fix: bitmap (#280)
* feat: use BitVec in place of Vec<u8> for skipped l1 messages bitmap * test: add test for failing skipped bitmap * fix lints * fix lints --------- Co-authored-by: frisitano <[email protected]>
1 parent 9642498 commit 60f7b7a

File tree

14 files changed

+113
-15
lines changed

14 files changed

+113
-15
lines changed

.github/workflows/lint.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ jobs:
128128
- type: wasm
129129
target: wasm32-unknown-unknown
130130
exclude: |
131-
scroll-engine,scroll-wire,rollup-node,scroll-network,rollup-node-manager,rollup-node-watcher,scroll-db,scroll-migration,rollup-node-chain-orchestrator,scroll-codec,scroll-derivation-pipeline,rollup-node-providers,rollup-node-sequencer,rollup-node-signer,tests
131+
scroll-engine,scroll-wire,rollup-node,scroll-network,rollup-node-manager,rollup-node-watcher,scroll-db,scroll-migration,rollup-node-chain-orchestrator,scroll-codec,scroll-derivation-pipeline,rollup-node-providers,rollup-node-sequencer,rollup-node-signer,scroll-l1,tests
132132
- type: riscv
133133
target: riscv32imac-unknown-none-elf
134134
exclude: |
135-
scroll-engine,scroll-wire,rollup-node,scroll-network,rollup-node-manager,rollup-node-watcher,scroll-db,scroll-migration,rollup-node-chain-orchestrator,scroll-codec,scroll-derivation-pipeline,rollup-node-providers,rollup-node-sequencer,rollup-node-signer,tests
135+
scroll-engine,scroll-wire,rollup-node,scroll-network,rollup-node-manager,rollup-node-watcher,scroll-db,scroll-migration,rollup-node-chain-orchestrator,scroll-codec,scroll-derivation-pipeline,rollup-node-providers,rollup-node-sequencer,rollup-node-signer,scroll-l1,tests
136136
steps:
137137
- uses: actions/checkout@v5
138138
- uses: rui314/setup-mold@v1

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ scroll-migration = { path = "crates/database/migration" }
189189
arbitrary = { version = "1.4", default-features = false }
190190
async-trait = "0.1"
191191
auto_impl = "1.2"
192+
bitvec = { version = "1.0", default-features = false }
192193
clap = { version = "4", features = ["derive", "env"] }
193194
derive_more = { version = "2.0", default-features = false }
194195
eyre = "0.6"

crates/codec/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ alloy-sol-types.workspace = true
1515
scroll-l1.workspace = true
1616

1717
# misc
18+
bitvec.workspace = true
1819
derive_more = { version = "2.0", default-features = false }
1920
eyre = { workspace = true, optional = true }
2021
thiserror = { version = "2.0", default-features = false }

crates/codec/src/decoding/payload.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use crate::L2Block;
44
use alloy_primitives::B256;
5+
use bitvec::vec::BitVec;
56
use std::vec::Vec;
67

78
/// The payload data on the L1.
@@ -12,7 +13,7 @@ pub struct PayloadData {
1213
/// Contains information about the current state of the L1 message queue.
1314
pub l1_message_queue_info: L1MessageQueueInfo,
1415
/// Contains the skipped L1 message bitmap if present.
15-
pub skipped_l1_message_bitmap: Option<Vec<u8>>,
16+
pub skipped_l1_message_bitmap: Option<BitVec>,
1617
}
1718

1819
/// Information about the state of the L1 message queue.

crates/codec/src/decoding/v0/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub fn decode_v0(calldata: &[u8]) -> Result<Batch, DecodingError> {
6464
let payload = PayloadData {
6565
blocks: l2_blocks,
6666
l1_message_queue_info: l1_message_start_index.into(),
67-
skipped_l1_message_bitmap: call.skipped_l1_message_bitmap(),
67+
skipped_l1_message_bitmap: call.skipped_l1_message_bitmap()?,
6868
};
6969

7070
Ok(Batch::new(call.version(), Some(chunks_block_count), payload))

crates/codec/src/decoding/v1/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::{
1313
use std::vec::Vec;
1414

1515
use alloy_primitives::bytes::Buf;
16+
use bitvec::vec::BitVec;
1617
use scroll_l1::abi::calls::CommitBatchCall;
1718

1819
/// The max amount of chunks per batch for V1 codec.
@@ -54,7 +55,7 @@ pub fn decode_v1(calldata: &[u8], blob: &[u8]) -> Result<Batch, DecodingError> {
5455

5556
decode_v1_chunk(
5657
call.version(),
57-
call.skipped_l1_message_bitmap(),
58+
call.skipped_l1_message_bitmap()?,
5859
l1_message_start_index,
5960
chunks,
6061
buf,
@@ -64,7 +65,7 @@ pub fn decode_v1(calldata: &[u8], blob: &[u8]) -> Result<Batch, DecodingError> {
6465
/// Decode the provided chunks and blob data into [`L2Block`].
6566
pub(crate) fn decode_v1_chunk(
6667
version: u8,
67-
skipped_l1_message_bitmap: Option<Vec<u8>>,
68+
skipped_l1_message_bitmap: Option<BitVec>,
6869
l1_message_start_index: u64,
6970
chunks: Vec<&[u8]>,
7071
blob: &[u8],

crates/codec/src/decoding/v2/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub fn decode_v2(calldata: &[u8], blob: &[u8]) -> Result<Batch, DecodingError> {
5252

5353
decode_v1_chunk(
5454
call.version(),
55-
call.skipped_l1_message_bitmap(),
55+
call.skipped_l1_message_bitmap()?,
5656
l1_message_start_index,
5757
chunks,
5858
buf,

crates/codec/src/decoding/v4/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub fn decode_v4(calldata: &[u8], blob: &[u8]) -> Result<Batch, DecodingError> {
4848

4949
decode_v1_chunk(
5050
call.version(),
51-
call.skipped_l1_message_bitmap(),
51+
call.skipped_l1_message_bitmap()?,
5252
l1_message_start_index,
5353
chunks,
5454
buf,

crates/codec/src/error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use alloy_primitives::U256;
2+
use scroll_l1::abi::calls::InvalidCommitBatchCall;
23

34
/// An error occurring during the codec process.
45
#[derive(Debug, thiserror::Error)]
@@ -27,6 +28,8 @@ pub enum DecodingError {
2728
InvalidCalldataFormat,
2829
#[error("invalid parent header format")]
2930
InvalidParentHeaderFormat,
31+
#[error(transparent)]
32+
InvalidCommitBatchCall(#[from] InvalidCommitBatchCall),
3033
#[error("end of file")]
3134
Eof,
3235
#[error("decoding error occurred: {0}")]

0 commit comments

Comments
 (0)