Skip to content

Commit ffd4c98

Browse files
committed
remove duplicated line on CHANGELOG.md
2 parents 01b63ba + 3591add commit ffd4c98

20 files changed

Lines changed: 299 additions & 236 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ libp2p = { version = "0.56.1", path = "libp2p" }
7878
libp2p-allow-block-list = { version = "0.6.0", path = "misc/allow-block-list" }
7979
libp2p-autonat = { version = "0.15.0", path = "protocols/autonat" }
8080
libp2p-connection-limits = { version = "0.6.0", path = "misc/connection-limits" }
81-
libp2p-core = { version = "0.43.1", path = "core" }
82-
libp2p-dcutr = { version = "0.14.0", path = "protocols/dcutr" }
81+
libp2p-core = { version = "0.43.2", path = "core" }
82+
libp2p-dcutr = { version = "0.14.1", path = "protocols/dcutr" }
8383
libp2p-dns = { version = "0.44.0", path = "transports/dns" }
8484
libp2p-floodsub = { version = "0.47.0", path = "protocols/floodsub" }
8585
libp2p-gossipsub = { version = "0.50.0", path = "protocols/gossipsub" }
@@ -102,10 +102,10 @@ libp2p-rendezvous = { version = "0.17.0", path = "protocols/rendezvous" }
102102
libp2p-request-response = { version = "0.29.0", path = "protocols/request-response" }
103103
libp2p-server = { version = "0.12.7", path = "misc/server" }
104104
libp2p-stream = { version = "0.4.0-alpha", path = "protocols/stream" }
105-
libp2p-swarm = { version = "0.47.0", path = "swarm" }
105+
libp2p-swarm = { version = "0.47.1", path = "swarm" }
106106
libp2p-swarm-derive = { version = "=0.35.1", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required.
107107
libp2p-swarm-test = { version = "0.6.0", path = "swarm-test" }
108-
libp2p-tcp = { version = "0.44.0", path = "transports/tcp" }
108+
libp2p-tcp = { version = "0.44.1", path = "transports/tcp" }
109109
libp2p-tls = { version = "0.6.2", path = "transports/tls" }
110110
libp2p-uds = { version = "0.43.1", path = "transports/uds" }
111111
libp2p-upnp = { version = "0.6.0", path = "protocols/upnp" }
@@ -142,7 +142,7 @@ tracing = "0.1.41"
142142
tracing-subscriber = "0.3.19"
143143
unsigned-varint = { version = "0.8.0" }
144144
web-time = "1.1.0"
145-
hashlink = "0.10.0"
145+
hashlink = "0.11.0"
146146

147147
[patch.crates-io]
148148

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
7878

7979
(In alphabetical order.)
8080

81+
- Elena Frank ([@elenaf9](https://github.com/elenaf9))
8182
- João Oliveira ([@jxs](https://github.com/jxs))
8283

8384
## Notable users

core/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
## 0.43.2
2+
3+
- Add `*_interop` methods to `PeerRecord` for cross-implementation compatibility with Go and JavaScript libp2p.
4+
- `PeerRecord::new_interop()` - Create peer records using standard format
5+
- `PeerRecord::from_signed_envelope_interop()` - Verify peer records using standard format
6+
7+
The standard format uses libp2p-peer-record domain and multicodec identifier (0x0301) for interoperability.
8+
Existing methods (`new()`, `from_signed_envelope()`) maintain backward compatibility with legacy Rust libp2p format.
9+
10+
Use the `*_interop` variants when exchanging peer records with non-Rust libp2p implementations.
11+
12+
See [PR 6230](https://github.com/libp2p/rust-libp2p/pull/6230).
13+
114
## 0.43.1
215
- Remove `once_cell` dependency.
316
See [PR 5913](https://github.com/libp2p/rust-libp2p/pull/5913)

core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "libp2p-core"
33
edition.workspace = true
44
rust-version = { workspace = true }
55
description = "Core traits and structs of libp2p"
6-
version = "0.43.1"
6+
version = "0.43.2"
77
authors = ["Parity Technologies <admin@parity.io>"]
88
license = "MIT"
99
repository = "https://github.com/libp2p/rust-libp2p"

core/src/peer_record.rs

Lines changed: 143 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,30 @@ use web_time::SystemTime;
44

55
use crate::{proto, signed_envelope, signed_envelope::SignedEnvelope, DecodeError, Multiaddr};
66

7-
const PAYLOAD_TYPE: &str = "/libp2p/routing-state-record";
8-
const DOMAIN_SEP: &str = "libp2p-routing-state";
7+
// Legacy constants for backward compatibility with existing Rust libp2p deployments.
8+
const LEGACY_PAYLOAD_TYPE: &str = "/libp2p/routing-state-record";
9+
const LEGACY_DOMAIN_SEP: &str = "libp2p-routing-state";
10+
11+
// Standard constants for cross-implementation compatibility with Go/JS libp2p.
12+
// Defined in https://github.com/multiformats/multicodec/blob/master/table.csv
13+
// and https://github.com/libp2p/specs/blob/master/RFC/0002-signed-envelopes.md.
14+
const STANDARD_PAYLOAD_TYPE: &[u8] = &[0x03, 0x01];
15+
const STANDARD_DOMAIN_SEP: &str = "libp2p-peer-record";
916

1017
/// Represents a peer routing record.
1118
///
1219
/// Peer records are designed to be distributable and carry a signature by being wrapped in a signed
1320
/// envelope. For more information see RFC0003 of the libp2p specifications: <https://github.com/libp2p/specs/blob/master/RFC/0003-routing-records.md>
21+
///
22+
/// ## Cross-Implementation Compatibility
23+
///
24+
/// This implementation provides two formats:
25+
/// - **Legacy format** (default methods): Compatible with existing Rust libp2p deployments.
26+
/// - **Standard format** (`*_interop` methods): Compatible with Go and JavaScript implementations.
27+
///
28+
/// Use the `*_interop` variants (e.g., [`PeerRecord::new_interop`],
29+
/// [`PeerRecord::from_signed_envelope_interop`]) when you need to exchange peer records with
30+
/// non-Rust libp2p implementations.
1431
#[derive(Debug, PartialEq, Eq, Clone)]
1532
pub struct PeerRecord {
1633
peer_id: PeerId,
@@ -25,15 +42,43 @@ pub struct PeerRecord {
2542
}
2643

2744
impl PeerRecord {
28-
/// Attempt to re-construct a [`PeerRecord`] from a [`SignedEnvelope`].
45+
/// Attempt to re-construct a [`PeerRecord`] from a [`SignedEnvelope`] using legacy format.
46+
///
47+
/// Uses the legacy routing-state-record format for backward compatibility with existing
48+
/// Rust libp2p deployments.
2949
///
3050
/// If this function succeeds, the [`SignedEnvelope`] contained a peer record with a valid
3151
/// signature and can hence be considered authenticated.
52+
///
53+
/// For cross-implementation compatibility with Go/JS libp2p, use
54+
/// [`Self::from_signed_envelope_interop`].
3255
pub fn from_signed_envelope(envelope: SignedEnvelope) -> Result<Self, FromEnvelopeError> {
56+
Self::from_signed_envelope_impl(envelope, LEGACY_DOMAIN_SEP, LEGACY_PAYLOAD_TYPE.as_bytes())
57+
}
58+
59+
/// Attempt to re-construct a [`PeerRecord`] from a [`SignedEnvelope`] using standard interop
60+
/// format.
61+
///
62+
/// Uses the standard libp2p-peer-record format for cross-implementation compatibility
63+
/// with Go and JavaScript libp2p implementations.
64+
///
65+
/// If this function succeeds, the [`SignedEnvelope`] contained a peer record with a valid
66+
/// signature and can hence be considered authenticated.
67+
pub fn from_signed_envelope_interop(
68+
envelope: SignedEnvelope,
69+
) -> Result<Self, FromEnvelopeError> {
70+
Self::from_signed_envelope_impl(envelope, STANDARD_DOMAIN_SEP, STANDARD_PAYLOAD_TYPE)
71+
}
72+
73+
fn from_signed_envelope_impl(
74+
envelope: SignedEnvelope,
75+
domain: &str,
76+
payload_type: &[u8],
77+
) -> Result<Self, FromEnvelopeError> {
3378
use quick_protobuf::MessageRead;
3479

3580
let (payload, signing_key) =
36-
envelope.payload_and_signing_key(String::from(DOMAIN_SEP), PAYLOAD_TYPE.as_bytes())?;
81+
envelope.payload_and_signing_key(String::from(domain), payload_type)?;
3782
let mut reader = BytesReader::from_bytes(payload);
3883
let record = proto::PeerRecord::from_reader(&mut reader, payload).map_err(DecodeError)?;
3984

@@ -58,11 +103,43 @@ impl PeerRecord {
58103
})
59104
}
60105

61-
/// Construct a new [`PeerRecord`] by authenticating the provided addresses with the given key.
106+
/// Construct a new [`PeerRecord`] by authenticating the provided addresses with the given key
107+
/// using legacy format.
108+
///
109+
/// Uses the legacy routing-state-record format for backward compatibility with existing
110+
/// Rust libp2p deployments.
62111
///
63112
/// This is the same key that is used for authenticating every libp2p connection of your
64113
/// application, i.e. what you use when setting up your [`crate::transport::Transport`].
114+
///
115+
/// For cross-implementation compatibility with Go/JS libp2p, use [`Self::new_interop`].
65116
pub fn new(key: &Keypair, addresses: Vec<Multiaddr>) -> Result<Self, SigningError> {
117+
Self::new_impl(
118+
key,
119+
addresses,
120+
LEGACY_DOMAIN_SEP,
121+
LEGACY_PAYLOAD_TYPE.as_bytes(),
122+
)
123+
}
124+
125+
/// Construct a new [`PeerRecord`] by authenticating the provided addresses with the given key
126+
/// using standard interop format.
127+
///
128+
/// Uses the standard libp2p-peer-record format for cross-implementation compatibility
129+
/// with Go and JavaScript libp2p implementations.
130+
///
131+
/// This is the same key that is used for authenticating every libp2p connection of your
132+
/// application, i.e. what you use when setting up your [`crate::transport::Transport`].
133+
pub fn new_interop(key: &Keypair, addresses: Vec<Multiaddr>) -> Result<Self, SigningError> {
134+
Self::new_impl(key, addresses, STANDARD_DOMAIN_SEP, STANDARD_PAYLOAD_TYPE)
135+
}
136+
137+
fn new_impl(
138+
key: &Keypair,
139+
addresses: Vec<Multiaddr>,
140+
domain: &str,
141+
payload_type: &[u8],
142+
) -> Result<Self, SigningError> {
66143
use quick_protobuf::MessageWrite;
67144

68145
let seq = SystemTime::now()
@@ -92,12 +169,8 @@ impl PeerRecord {
92169
buf
93170
};
94171

95-
let envelope = SignedEnvelope::new(
96-
key,
97-
String::from(DOMAIN_SEP),
98-
PAYLOAD_TYPE.as_bytes().to_vec(),
99-
payload,
100-
)?;
172+
let envelope =
173+
SignedEnvelope::new(key, String::from(domain), payload_type.to_vec(), payload)?;
101174

102175
Ok(Self {
103176
peer_id,
@@ -154,7 +227,7 @@ mod tests {
154227
const HOME: &str = "/ip4/127.0.0.1/tcp/1337";
155228

156229
#[test]
157-
fn roundtrip_envelope() {
230+
fn roundtrip_envelope_legacy() {
158231
let key = Keypair::generate_ed25519();
159232

160233
let record = PeerRecord::new(&key, vec![HOME.parse().unwrap()]).unwrap();
@@ -166,7 +239,19 @@ mod tests {
166239
}
167240

168241
#[test]
169-
fn mismatched_signature() {
242+
fn roundtrip_envelope_interop() {
243+
let key = Keypair::generate_ed25519();
244+
245+
let record = PeerRecord::new_interop(&key, vec![HOME.parse().unwrap()]).unwrap();
246+
247+
let envelope = record.to_signed_envelope();
248+
let reconstructed = PeerRecord::from_signed_envelope_interop(envelope).unwrap();
249+
250+
assert_eq!(reconstructed, record)
251+
}
252+
253+
#[test]
254+
fn mismatched_signature_legacy() {
170255
use quick_protobuf::MessageWrite;
171256

172257
let addr: Multiaddr = HOME.parse().unwrap();
@@ -195,8 +280,8 @@ mod tests {
195280

196281
SignedEnvelope::new(
197282
&identity_b,
198-
String::from(DOMAIN_SEP),
199-
PAYLOAD_TYPE.as_bytes().to_vec(),
283+
String::from(LEGACY_DOMAIN_SEP),
284+
LEGACY_PAYLOAD_TYPE.as_bytes().to_vec(),
200285
payload,
201286
)
202287
.unwrap()
@@ -207,4 +292,47 @@ mod tests {
207292
Err(FromEnvelopeError::MismatchedSignature)
208293
));
209294
}
295+
296+
#[test]
297+
fn mismatched_signature_interop() {
298+
use quick_protobuf::MessageWrite;
299+
300+
let addr: Multiaddr = HOME.parse().unwrap();
301+
302+
let envelope = {
303+
let identity_a = Keypair::generate_ed25519();
304+
let identity_b = Keypair::generate_ed25519();
305+
306+
let payload = {
307+
let record = proto::PeerRecord {
308+
peer_id: identity_a.public().to_peer_id().to_bytes(),
309+
seq: 0,
310+
addresses: vec![proto::AddressInfo {
311+
multiaddr: addr.to_vec(),
312+
}],
313+
};
314+
315+
let mut buf = Vec::with_capacity(record.get_size());
316+
let mut writer = Writer::new(&mut buf);
317+
record
318+
.write_message(&mut writer)
319+
.expect("Encoding to succeed");
320+
321+
buf
322+
};
323+
324+
SignedEnvelope::new(
325+
&identity_b,
326+
String::from(STANDARD_DOMAIN_SEP),
327+
STANDARD_PAYLOAD_TYPE.to_vec(),
328+
payload,
329+
)
330+
.unwrap()
331+
};
332+
333+
assert!(matches!(
334+
PeerRecord::from_signed_envelope_interop(envelope),
335+
Err(FromEnvelopeError::MismatchedSignature)
336+
));
337+
}
210338
}

examples/autonatv2/Cargo.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,18 @@ tokio = { version = "1.35.1", features = ["macros", "rt-multi-thread"] }
2121
tracing = "0.1.40"
2222
tracing-subscriber = { workspace = true, features = ["env-filter"] }
2323
rand = "0.8.5"
24-
opentelemetry_sdk = { version = "0.21.1", optional = true, features = ["rt-tokio"] }
25-
tracing-opentelemetry = { version = "0.22.0", optional = true }
26-
opentelemetry-jaeger = { version = "0.20.0", optional = true, features = ["rt-tokio"] }
24+
opentelemetry = { version = "0.27.0", optional = true }
25+
opentelemetry_sdk = { version = "0.27.0", optional = true, features = ["rt-tokio"] }
26+
opentelemetry-otlp = { version = "0.27.0", optional = true }
27+
tracing-opentelemetry = { version = "0.28.0", optional = true }
2728
cfg-if = "1.0.0"
2829

2930
[features]
30-
jaeger = ["opentelemetry_sdk", "tracing-opentelemetry", "opentelemetry-jaeger"]
31+
jaeger = ["opentelemetry", "opentelemetry_sdk", "opentelemetry-otlp", "tracing-opentelemetry"]
32+
opentelemetry = ["dep:opentelemetry"]
3133
opentelemetry_sdk = ["dep:opentelemetry_sdk"]
34+
opentelemetry-otlp = ["dep:opentelemetry-otlp"]
3235
tracing-opentelemetry = ["dep:tracing-opentelemetry"]
33-
opentelemetry-jaeger = ["dep:opentelemetry-jaeger"]
3436

3537
[lints]
3638
workspace = true
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
version: '3'
2-
31
services:
42
autonatv2:
53
build:
64
context: ../..
75
dockerfile: examples/autonatv2/Dockerfile
6+
environment:
7+
- OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger:4317
88
ports:
9-
- 4884:4884
9+
- "4884:4884"
10+
depends_on:
11+
- jaeger
1012
jaeger:
1113
image: jaegertracing/all-in-one
14+
environment:
15+
- COLLECTOR_OTLP_ENABLED=true
1216
ports:
13-
- 6831:6831/udp
14-
- 6832:6832/udp
15-
- 16686:16686
16-
- 14268:14268
17+
- "4317:4317"
18+
- "16686:16686"

examples/autonatv2/src/bin/autonatv2_server.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,24 @@ struct Opt {
2424
async fn main() -> Result<(), Box<dyn Error>> {
2525
cfg_if! {
2626
if #[cfg(feature = "jaeger")] {
27+
use opentelemetry::trace::TracerProvider as _;
28+
use opentelemetry::KeyValue;
29+
use opentelemetry_otlp::SpanExporter;
30+
use opentelemetry_sdk::{runtime, trace::TracerProvider};
2731
use tracing_subscriber::layer::SubscriberExt;
28-
use opentelemetry_sdk::runtime::Tokio;
29-
let tracer = opentelemetry_jaeger::new_agent_pipeline()
30-
.with_endpoint("jaeger:6831")
31-
.with_service_name("autonatv2")
32-
.install_batch(Tokio)?;
33-
let telemetry = tracing_opentelemetry::layer().with_tracer(tracer);
32+
33+
let provider = TracerProvider::builder()
34+
.with_batch_exporter(
35+
SpanExporter::builder().with_tonic().build()?,
36+
runtime::Tokio,
37+
)
38+
.with_resource(opentelemetry_sdk::Resource::new(vec![KeyValue::new(
39+
"service.name",
40+
"autonatv2",
41+
)]))
42+
.build();
43+
let telemetry = tracing_opentelemetry::layer()
44+
.with_tracer(provider.tracer("autonatv2"));
3445
let subscriber = tracing_subscriber::Registry::default()
3546
.with(telemetry);
3647
} else {

protocols/dcutr/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.14.1
2+
3+
- Replace `lru::LruCache` with `hashlink::LruCache`.
4+
See [PR #6138](https://github.com/libp2p/rust-libp2p/pull/6138)
5+
16
## 0.14.0
27

38
<!-- Update to libp2p-swarm v0.47.0 -->

0 commit comments

Comments
 (0)