Skip to content

Commit 3e0b3ec

Browse files
committed
switch to new raptorcast packet builder
1 parent 4e33c3c commit 3e0b3ec

File tree

12 files changed

+877
-1302
lines changed

12 files changed

+877
-1302
lines changed

monad-dataplane/src/udp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub const fn segment_size_for_mtu(mtu: u16) -> u16 {
7676
pub const DEFAULT_SEGMENT_SIZE: u16 = segment_size_for_mtu(DEFAULT_MTU);
7777

7878
const ETHERNET_MTU: u16 = 1500;
79-
const ETHERNET_SEGMENT_SIZE: u16 = segment_size_for_mtu(ETHERNET_MTU);
79+
pub const ETHERNET_SEGMENT_SIZE: u16 = segment_size_for_mtu(ETHERNET_MTU);
8080

8181
fn configure_socket(socket: &UdpSocket, buffer_size: Option<usize>) {
8282
if let Some(size) = buffer_size {

monad-raptor/tests/managed_decoder.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
// Tests the managed Raptor decoder.
1717

18-
use monad_raptor::{Encoder, ManagedDecoder};
18+
use monad_raptor::{Encoder, ManagedDecoder, SOURCE_SYMBOLS_MAX};
1919
use rand::{prelude::SliceRandom, thread_rng, Rng, RngCore};
2020

2121
const SYMBOL_LEN: usize = 4;
@@ -88,3 +88,10 @@ fn test_invalid_symbol_len() {
8888

8989
decoder.received_encoded_symbol(buf.as_slice(), 0);
9090
}
91+
92+
#[test]
93+
fn test_oversized_symbol() {
94+
let num_symbols = SOURCE_SYMBOLS_MAX + 1;
95+
let decoder = ManagedDecoder::new(num_symbols, num_symbols * 2, SYMBOL_LEN);
96+
assert!(decoder.is_err());
97+
}

monad-raptorcast/benches/encode_bench.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use itertools::Itertools as _;
2121
use monad_crypto::certificate_signature::{CertificateSignature, CertificateSignaturePubKey};
2222
use monad_dataplane::udp::DEFAULT_SEGMENT_SIZE;
2323
use monad_raptorcast::{
24-
packet, udp,
24+
packet,
2525
util::{BuildTarget, EpochValidators, Redundancy},
2626
};
2727
use monad_secp::SecpSignature;
@@ -56,21 +56,6 @@ pub fn bench_build_messages(c: &mut Criterion, name: &str, message_size: usize,
5656
_ => panic!("unsupported target"),
5757
};
5858

59-
group.bench_function("udp::build_messages", |b| {
60-
b.iter(|| {
61-
let _ = udp::build_messages(
62-
&author,
63-
DEFAULT_SEGMENT_SIZE, // segment_size
64-
message.clone(),
65-
Redundancy::from_u8(2),
66-
0, // epoch_no
67-
0, // unix_ts_ms
68-
build_target.clone(),
69-
&known_addrs,
70-
);
71-
});
72-
});
73-
7459
group.bench_function("packet::build_messages", |b| {
7560
b.iter(|| {
7661
let _ = packet::build_messages(
@@ -82,7 +67,6 @@ pub fn bench_build_messages(c: &mut Criterion, name: &str, message_size: usize,
8267
0, // unix_ts_ms
8368
build_target.clone(),
8469
&known_addrs,
85-
&mut rand::thread_rng(),
8670
);
8771
});
8872
});

monad-raptorcast/benches/raptor_bench.rs

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use monad_crypto::hasher::{Hasher, HasherType};
2323
use monad_dataplane::udp::DEFAULT_SEGMENT_SIZE;
2424
use monad_raptor::ManagedDecoder;
2525
use monad_raptorcast::{
26-
packet,
27-
udp::{build_messages, parse_message, MAX_REDUNDANCY, SIGNATURE_CACHE_SIZE},
26+
packet::build_messages,
27+
udp::{parse_message, MAX_REDUNDANCY, SIGNATURE_CACHE_SIZE},
2828
util::{BuildTarget, EpochValidators, Redundancy},
2929
};
3030
use monad_secp::{KeyPair, SecpSignature};
@@ -79,49 +79,6 @@ pub fn criterion_benchmark(c: &mut Criterion) {
7979
});
8080
});
8181

82-
group.bench_function("Encoding (new)", |b| {
83-
let keys = (0_u8..100_u8)
84-
.map(|n| {
85-
let mut hasher = HasherType::new();
86-
hasher.update(n.to_le_bytes());
87-
let mut hash = hasher.hash();
88-
KeyPair::from_bytes(&mut hash.0).unwrap()
89-
})
90-
.collect_vec();
91-
92-
let validators = EpochValidators {
93-
validators: keys
94-
.iter()
95-
.map(|key| (NodeId::new(key.pubkey()), Stake::ONE))
96-
.collect(),
97-
};
98-
99-
let known_addresses = keys
100-
.iter()
101-
.map(|key| {
102-
(
103-
NodeId::new(key.pubkey()),
104-
SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 0),
105-
)
106-
})
107-
.collect();
108-
109-
b.iter(|| {
110-
let epoch_validators = validators.view_without(vec![&NodeId::new(keys[0].pubkey())]);
111-
let _ = packet::build_messages::<SecpSignature>(
112-
&keys[0],
113-
DEFAULT_SEGMENT_SIZE, // segment_size
114-
message.clone(),
115-
Redundancy::from_u8(2),
116-
0, // epoch_no
117-
0, // unix_ts_ms
118-
BuildTarget::Raptorcast(epoch_validators),
119-
&known_addresses,
120-
&mut rand::thread_rng(),
121-
);
122-
});
123-
});
124-
12582
group.bench_function("Decoding", |b| {
12683
let keys = (0_u8..100_u8)
12784
.map(|n| {

0 commit comments

Comments
 (0)