Skip to content

Commit e136896

Browse files
authored
(hotfix): Check proof length for priliminary checkpoint screening (#976)
* (hotfix): Check proof length for priliminary checkpoint screening * Fix unit tests
1 parent 81a7b65 commit e136896

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

crates/l1tx/src/filter/checkpoint.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use tracing::warn;
66
use super::TxFilterConfig;
77
use crate::envelope::parser::parse_envelope_payloads;
88

9+
const PROOF_SIZE_WITH_PUBLIC_PARAMS: usize = 396;
10+
911
/// Parses envelope from the given transaction. Currently, the only envelope recognizable is
1012
/// the checkpoint envelope.
1113
// TODO: we need to change envelope structure and possibly have envelopes for checkpoints and
@@ -62,6 +64,15 @@ fn validate_checkpoint(
6264
return None;
6365
}
6466

67+
// Also check if the proof has a valid size.
68+
// FIXME: We should actually be checking the validity of proof, but this is done
69+
// for a hotfix.
70+
let proof_size = signed_checkpoint.checkpoint().proof().as_bytes().len();
71+
// We are allowing proof of size 0 because we support empty proofs.
72+
if proof_size != 0 && proof_size < PROOF_SIZE_WITH_PUBLIC_PARAMS {
73+
return None;
74+
}
75+
6576
Some(signed_checkpoint)
6677
}
6778

@@ -76,7 +87,9 @@ mod test {
7687
use strata_test_utils::{l2::gen_params, ArbitraryGenerator};
7788

7889
use super::TxFilterConfig;
79-
use crate::filter::parse_valid_checkpoint_envelopes;
90+
use crate::filter::{
91+
checkpoint::PROOF_SIZE_WITH_PUBLIC_PARAMS, parse_valid_checkpoint_envelopes,
92+
};
8093

8194
const TEST_ADDR: &str = "bcrt1q6u6qyya3sryhh42lahtnz2m7zuufe7dlt8j0j5";
8295

@@ -97,11 +110,12 @@ mod test {
97110
.map(|_| {
98111
let mut gen = ArbitraryGenerator::new();
99112
let chainstate: Chainstate = gen.generate();
113+
let proof = [1; PROOF_SIZE_WITH_PUBLIC_PARAMS].as_slice();
100114
let signed_checkpoint = SignedCheckpoint::new(
101115
Checkpoint::new(
102116
gen.generate(),
103117
gen.generate(),
104-
gen.generate(),
118+
proof.into(),
105119
CheckpointSidecar::new(borsh::to_vec(&chainstate).unwrap()),
106120
),
107121
gen.generate(),

0 commit comments

Comments
 (0)