Skip to content

Commit

Permalink
deps: bump asynchronous-codec from 0.6.2 to 0.7.0
Browse files Browse the repository at this point in the history
Pull-Request: #4636.
  • Loading branch information
dependabot[bot] authored Nov 14, 2023
1 parent cddc306 commit b6eb2bf
Show file tree
Hide file tree
Showing 25 changed files with 69 additions and 95 deletions.
62 changes: 26 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ resolver = "2"
rust-version = "1.73.0"

[workspace.dependencies]
asynchronous-codec = { version = "0.7.0" }
futures-bounded = { version = "0.2.1", path = "misc/futures-bounded" }
libp2p = { version = "0.53.0", path = "libp2p" }
libp2p-allow-block-list = { version = "0.3.0", path = "misc/allow-block-list" }
Expand Down Expand Up @@ -119,6 +120,7 @@ prometheus-client = "0.22.0"
quick-protobuf-codec = { version = "0.2.0", path = "misc/quick-protobuf-codec" }
quickcheck = { package = "quickcheck-ext", path = "misc/quickcheck-ext" }
rw-stream-sink = { version = "0.4.0", path = "misc/rw-stream-sink" }
unsigned-varint = { version = "0.8.0" }

[patch.crates-io]

Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ serde = { version = "1", optional = true, features = ["derive"] }
smallvec = "1.11.2"
thiserror = "1.0"
tracing = "0.1.37"
unsigned-varint = "0.7"
unsigned-varint = { workspace = true }
void = "1"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion misc/multistream-select/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ futures = "0.3"
tracing = "0.1.37"
pin-project = "1.1.3"
smallvec = "1.11.2"
unsigned-varint = "0.7"
unsigned-varint = { workspace = true }

[dev-dependencies]
async-std = { version = "1.6.2", features = ["attributes"] }
Expand Down
4 changes: 2 additions & 2 deletions misc/quick-protobuf-codec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ keywords = ["networking"]
categories = ["asynchronous"]

[dependencies]
asynchronous-codec = { version = "0.6" }
asynchronous-codec = { workspace = true }
bytes = { version = "1" }
thiserror = "1.0"
unsigned-varint = { version = "0.7", features = ["asynchronous_codec"] }
unsigned-varint = { workspace = true, features = ["asynchronous_codec"] }
quick-protobuf = "0.8"

# Passing arguments to the docsrs builder in order to properly document cfg's.
Expand Down
4 changes: 2 additions & 2 deletions misc/quick-protobuf-codec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ impl<In, Out> Codec<In, Out> {
}

impl<In: MessageWrite, Out> Encoder for Codec<In, Out> {
type Item = In;
type Item<'a> = In;
type Error = Error;

fn encode(&mut self, item: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error> {
fn encode(&mut self, item: Self::Item<'_>, dst: &mut BytesMut) -> Result<(), Self::Error> {
let mut encoded_msg = Vec::new();
let mut writer = Writer::new(&mut encoded_msg);
item.write_message(&mut writer)
Expand Down
3 changes: 1 addition & 2 deletions misc/webrtc-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ version = "0.1.0"
publish = true

[dependencies]
asynchronous-codec = "0.6"
asynchronous-codec = { workspace = true }
bytes = "1"
futures = "0.3"
hex = "0.4"
Expand All @@ -29,7 +29,6 @@ tracing = "0.1.37"

[dev-dependencies]
hex-literal = "0.4"
unsigned-varint = { version = "0.7", features = ["asynchronous_codec"] }

[lints]
workspace = true
15 changes: 3 additions & 12 deletions misc/webrtc-utils/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,9 @@ where
#[cfg(test)]
mod tests {
use super::*;
use crate::stream::framed_dc::codec;
use asynchronous_codec::Encoder;
use bytes::BytesMut;
use quick_protobuf::{MessageWrite, Writer};
use unsigned_varint::codec::UviBytes;

#[test]
fn max_data_len() {
Expand All @@ -275,21 +274,13 @@ mod tests {
message: Some(message.to_vec()),
};

let mut encoded_msg = Vec::new();
let mut writer = Writer::new(&mut encoded_msg);
protobuf
.write_message(&mut writer)
.expect("Encoding to succeed");
assert_eq!(encoded_msg.len(), message.len() + PROTO_OVERHEAD);
let mut codec = codec();

let mut uvi = UviBytes::default();
let mut dst = BytesMut::new();
uvi.encode(encoded_msg.as_slice(), &mut dst).unwrap();
codec.encode(protobuf, &mut dst).unwrap();

// Ensure the varint prefixed and protobuf encoded largest message is no longer than the
// maximum limit specified in the libp2p WebRTC specification.
assert_eq!(dst.len(), MAX_MSG_LEN);

assert_eq!(dst.len() - encoded_msg.len(), VARINT_LEN);
}
}
9 changes: 5 additions & 4 deletions misc/webrtc-utils/src/stream/framed_dc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ pub(crate) fn new<T>(inner: T) -> FramedDc<T>
where
T: AsyncRead + AsyncWrite,
{
let mut framed = Framed::new(
inner,
quick_protobuf_codec::Codec::new(MAX_MSG_LEN - VARINT_LEN),
);
let mut framed = Framed::new(inner, codec());
// If not set, `Framed` buffers up to 131kB of data before sending, which leads to "outbound
// packet larger than maximum message size" error in webrtc-rs.
framed.set_send_high_water_mark(MAX_DATA_LEN);
framed
}

pub(crate) fn codec() -> quick_protobuf_codec::Codec<Message, Message> {
quick_protobuf_codec::Codec::new(MAX_MSG_LEN - VARINT_LEN)
}
4 changes: 2 additions & 2 deletions muxers/mplex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ categories = ["network-programming", "asynchronous"]
[dependencies]
bytes = "1"
futures = "0.3.29"
asynchronous-codec = "0.6"
asynchronous-codec = { workspace = true }
libp2p-core = { workspace = true }
libp2p-identity = { workspace = true }
nohash-hasher = "0.2"
parking_lot = "0.12"
rand = "0.8"
smallvec = "1.11.2"
tracing = "0.1.37"
unsigned-varint = { version = "0.7", features = ["asynchronous_codec"] }
unsigned-varint = { workspace = true, features = ["asynchronous_codec"] }

[dev-dependencies]
async-std = { version = "1.7.0", features = ["attributes"] }
Expand Down
4 changes: 2 additions & 2 deletions muxers/mplex/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ impl Decoder for Codec {
}

impl Encoder for Codec {
type Item = Frame<LocalStreamId>;
type Item<'a> = Frame<LocalStreamId>;
type Error = io::Error;

fn encode(&mut self, item: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error> {
fn encode(&mut self, item: Self::Item<'_>, dst: &mut BytesMut) -> Result<(), Self::Error> {
let (header, data) = match item {
Frame::Open { stream_id } => (stream_id.num << 3, Bytes::new()),
Frame::Data {
Expand Down
2 changes: 1 addition & 1 deletion protocols/autonat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ quick-protobuf = "0.8"
rand = "0.8"
tracing = "0.1.37"
quick-protobuf-codec = { workspace = true }
asynchronous-codec = "0.6.2"
asynchronous-codec = { workspace = true }

[dev-dependencies]
async-std = { version = "1.10", features = ["attributes"] }
Expand Down
Loading

0 comments on commit b6eb2bf

Please sign in to comment.