Skip to content

Commit 31ee4d0

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 2f78133 + 9f071a9 commit 31ee4d0

File tree

11 files changed

+93
-28
lines changed

11 files changed

+93
-28
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ jobs:
1414

1515
runs-on: ubuntu-latest
1616

17-
strategy:
18-
matrix:
19-
args: ["--all-features"]
2017
env:
2118
FREENET_LOG: error
2219
CARGO_TARGET_DIR: ${{ github.workspace }}/target
@@ -37,7 +34,7 @@ jobs:
3734
- uses: Swatinem/rust-cache@v2
3835

3936
- name: Test - features
40-
run: cargo test --workspace ${{ matrix.args }}
37+
run: cargo test --workspace --features contract,net,testing,trace
4138

4239
build_targets:
4340
name: Build targets
@@ -112,6 +109,7 @@ jobs:
112109
- uses: dtolnay/rust-toolchain@stable
113110
with:
114111
toolchain: stable
112+
components: rustfmt
115113

116114
- name: Check code formatting
117115
run: cargo fmt -- --check

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## [0.1.14] - 2025-09-04
4+
5+
### Changed
6+
- Updated `tokio-tungstenite` from 0.26.1 to 0.27.0
7+
- Updated `rand` from 0.8 to 0.9 (dev dependency)
8+
- Fixed `from_entropy()` to use `from_os_rng()` for rand 0.9 compatibility
9+
10+
### Note
11+
- [AI-assisted debugging and comment]
12+
- This release updates dependencies to support freenet-core dependency updates
13+
314
## [0.1.9] - 2025-06-19
415

516
### Added

rust/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "freenet-stdlib"
3-
version = "0.1.11"
3+
version = "0.1.22"
44
edition = "2021"
55
rust-version = "1.71.1"
66
publish = true
@@ -32,7 +32,7 @@ freenet-macros = { path = "../rust-macros", version = "0.1.0-rc1" }
3232

3333
[target.'cfg(any(unix, windows))'.dependencies]
3434
tokio = { version = "1", optional = true, features = ["macros", "parking_lot", "rt-multi-thread", "sync", "time"] }
35-
tokio-tungstenite = { version = "0.26.1", optional = true }
35+
tokio-tungstenite = { version = "0.27.0", optional = true }
3636
serde_with = { version = "3" }
3737

3838
[target.'cfg(target_family = "wasm")'.dependencies]
@@ -59,7 +59,7 @@ optional = true
5959
[target.'cfg(any(unix, windows))'.dev-dependencies]
6060
bincode = "1"
6161
wasmer = { version = "5.0.4", features = [ "sys-default"] }
62-
rand = { version = "0.8", features = ["small_rng"] }
62+
rand = { version = "0.9", features = ["small_rng"] }
6363
arbitrary = { version = "1", features = ["derive"] }
6464

6565
[features]
@@ -70,3 +70,4 @@ freenet-main-contract = []
7070
net = ["dep:tokio", "dep:tokio-tungstenite", "dep:wasm-bindgen", "dep:web-sys", "dep:js-sys", "dep:serde-wasm-bindgen"]
7171
testing = ["dep:arbitrary"]
7272
trace = []
73+
wasmer-tests = []

rust/src/client_api/browser.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,12 @@ impl WebApi {
8888
conn.set_onerror(Some(onerror_callback.as_ref().unchecked_ref()));
8989
onerror_callback.forget();
9090

91-
let onopen_callback = Closure::<dyn FnOnce()>::once(move || {
92-
onopen_handler();
93-
});
91+
let onopen_handler = Rc::new(RefCell::new(Some(onopen_handler)));
92+
let onopen_callback = Closure::wrap(Box::new(move || {
93+
if let Some(handler) = onopen_handler.borrow_mut().take() {
94+
handler();
95+
}
96+
}) as Box<dyn FnMut()>);
9497
// conn.add_event_listener_with_callback("open", onopen_callback.as_ref().unchecked_ref());
9598
conn.set_onopen(Some(onopen_callback.as_ref().unchecked_ref()));
9699
onopen_callback.forget();

rust/src/client_api/client_events.rs

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ use crate::{
5454

5555
use super::WsApiError;
5656

57-
#[derive(Debug, Serialize, Deserialize)]
57+
#[derive(Debug, Serialize, Deserialize, Clone)]
5858
pub struct ClientError {
5959
kind: Box<ErrorKind>,
6060
}
@@ -321,7 +321,7 @@ impl ClientRequest<'_> {
321321
matches!(self, Self::Disconnect { .. })
322322
}
323323

324-
pub fn try_decode_fbs(msg: &[u8]) -> Result<ClientRequest, WsApiError> {
324+
pub fn try_decode_fbs(msg: &[u8]) -> Result<ClientRequest<'_>, WsApiError> {
325325
let req = {
326326
match root_as_client_request(msg) {
327327
Ok(client_request) => match client_request.client_request_type() {
@@ -707,7 +707,7 @@ impl<'a> TryFromFbs<&FbsDelegateRequest<'a>> for DelegateRequest<'a> {
707707
}
708708

709709
/// A response to a previous [`ClientRequest`]
710-
#[derive(Serialize, Deserialize, Debug)]
710+
#[derive(Serialize, Deserialize, Debug, Clone)]
711711
#[non_exhaustive]
712712
pub enum HostResponse<T = WrappedState> {
713713
ContractResponse(#[serde(bound(deserialize = "T: DeserializeOwned"))] ContractResponse<T>),
@@ -722,11 +722,12 @@ pub enum HostResponse<T = WrappedState> {
722722

723723
type Peer = String;
724724

725-
#[derive(Serialize, Deserialize, Debug)]
725+
#[derive(Serialize, Deserialize, Debug, Clone)]
726726
pub enum QueryResponse {
727727
ConnectedPeers { peers: Vec<(Peer, SocketAddr)> },
728728
NetworkDebug(NetworkDebugInfo),
729729
NodeDiagnostics(NodeDiagnosticsResponse),
730+
ProximityCache(ProximityCacheInfo),
730731
}
731732

732733
#[derive(Serialize, Deserialize, Debug, Clone)]
@@ -806,6 +807,57 @@ pub enum NodeQuery {
806807
/// Diagnostic configuration specifying what information to collect
807808
config: NodeDiagnosticsConfig,
808809
},
810+
/// Phase 3: Query proximity cache information for update propagation
811+
ProximityCacheInfo,
812+
}
813+
814+
/// Phase 3: Proximity cache information for update propagation
815+
#[derive(Serialize, Deserialize, Debug, Clone)]
816+
pub struct ProximityCacheInfo {
817+
/// Contracts this node is currently caching
818+
pub my_cache: Vec<ContractCacheEntry>,
819+
/// What we know about neighbor caches
820+
pub neighbor_caches: Vec<NeighborCacheInfo>,
821+
/// Proximity propagation statistics
822+
pub stats: ProximityStats,
823+
}
824+
825+
#[derive(Serialize, Deserialize, Debug, Clone)]
826+
pub struct ContractCacheEntry {
827+
/// Full contract key as string
828+
pub contract_key: String,
829+
/// 32-bit hash for proximity matching
830+
pub cache_hash: u32,
831+
/// When this contract was cached (Unix timestamp)
832+
pub cached_since: u64,
833+
}
834+
835+
#[derive(Serialize, Deserialize, Debug, Clone)]
836+
pub struct NeighborCacheInfo {
837+
/// Peer identifier
838+
pub peer_id: String,
839+
/// Contract hashes this neighbor is known to cache
840+
pub known_contracts: Vec<u32>,
841+
/// Last update received from this neighbor (Unix timestamp)
842+
pub last_update: u64,
843+
/// Number of updates received from this neighbor
844+
pub update_count: u64,
845+
}
846+
847+
#[derive(Serialize, Deserialize, Debug, Clone)]
848+
pub struct ProximityStats {
849+
/// Number of cache announcements sent
850+
pub cache_announces_sent: u64,
851+
/// Number of cache announcements received
852+
pub cache_announces_received: u64,
853+
/// Updates forwarded via proximity (not subscription)
854+
pub updates_via_proximity: u64,
855+
/// Updates forwarded via subscription
856+
pub updates_via_subscription: u64,
857+
/// False positives due to hash collisions
858+
pub false_positive_forwards: u64,
859+
/// Average number of contracts per neighbor
860+
pub avg_neighbor_cache_size: f32,
809861
}
810862

811863
#[derive(Serialize, Deserialize, Debug, Clone)]

rust/src/contract_interface.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,11 +1554,11 @@ pub(crate) mod wasm_interface {
15541554
mod test {
15551555
use super::*;
15561556
use once_cell::sync::Lazy;
1557-
use rand::{rngs::SmallRng, Rng, SeedableRng};
1557+
use rand::{rng, rngs::SmallRng, Rng, SeedableRng};
15581558

15591559
static RND_BYTES: Lazy<[u8; 1024]> = Lazy::new(|| {
15601560
let mut bytes = [0; 1024];
1561-
let mut rng = SmallRng::from_entropy();
1561+
let mut rng = SmallRng::from_rng(&mut rng());
15621562
rng.fill(&mut bytes);
15631563
bytes
15641564
});

rust/src/delegate_interface.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ impl Delegate<'_> {
4040
&self.key
4141
}
4242

43-
pub fn code(&self) -> &DelegateCode {
43+
pub fn code(&self) -> &DelegateCode<'_> {
4444
&self.data
4545
}
4646

4747
pub fn code_hash(&self) -> &CodeHash {
4848
&self.data.code_hash
4949
}
5050

51-
pub fn params(&self) -> &Parameters {
51+
pub fn params(&self) -> &Parameters<'_> {
5252
&self.parameters
5353
}
5454

rust/src/generated/client_request_generated.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4707,7 +4707,7 @@ pub mod client_request {
47074707
/// `root_as_client_request_unchecked`.
47084708
pub fn root_as_client_request(
47094709
buf: &[u8],
4710-
) -> Result<ClientRequest, flatbuffers::InvalidFlatbuffer> {
4710+
) -> Result<ClientRequest<'_>, flatbuffers::InvalidFlatbuffer> {
47114711
flatbuffers::root::<ClientRequest>(buf)
47124712
}
47134713
#[inline]
@@ -4719,7 +4719,7 @@ pub mod client_request {
47194719
/// `size_prefixed_root_as_client_request_unchecked`.
47204720
pub fn size_prefixed_root_as_client_request(
47214721
buf: &[u8],
4722-
) -> Result<ClientRequest, flatbuffers::InvalidFlatbuffer> {
4722+
) -> Result<ClientRequest<'_>, flatbuffers::InvalidFlatbuffer> {
47234723
flatbuffers::size_prefixed_root::<ClientRequest>(buf)
47244724
}
47254725
#[inline]
@@ -4752,14 +4752,14 @@ pub mod client_request {
47524752
/// Assumes, without verification, that a buffer of bytes contains a ClientRequest and returns it.
47534753
/// # Safety
47544754
/// Callers must trust the given bytes do indeed contain a valid `ClientRequest`.
4755-
pub unsafe fn root_as_client_request_unchecked(buf: &[u8]) -> ClientRequest {
4755+
pub unsafe fn root_as_client_request_unchecked(buf: &[u8]) -> ClientRequest<'_> {
47564756
flatbuffers::root_unchecked::<ClientRequest>(buf)
47574757
}
47584758
#[inline]
47594759
/// Assumes, without verification, that a buffer of bytes contains a size prefixed ClientRequest and returns it.
47604760
/// # Safety
47614761
/// Callers must trust the given bytes do indeed contain a valid size prefixed `ClientRequest`.
4762-
pub unsafe fn size_prefixed_root_as_client_request_unchecked(buf: &[u8]) -> ClientRequest {
4762+
pub unsafe fn size_prefixed_root_as_client_request_unchecked(buf: &[u8]) -> ClientRequest<'_> {
47634763
flatbuffers::size_prefixed_root_unchecked::<ClientRequest>(buf)
47644764
}
47654765
#[inline]

rust/src/generated/host_response_generated.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3338,7 +3338,7 @@ pub mod host_response {
33383338
/// `root_as_host_response_unchecked`.
33393339
pub fn root_as_host_response(
33403340
buf: &[u8],
3341-
) -> Result<HostResponse, flatbuffers::InvalidFlatbuffer> {
3341+
) -> Result<HostResponse<'_>, flatbuffers::InvalidFlatbuffer> {
33423342
flatbuffers::root::<HostResponse>(buf)
33433343
}
33443344
#[inline]
@@ -3350,7 +3350,7 @@ pub mod host_response {
33503350
/// `size_prefixed_root_as_host_response_unchecked`.
33513351
pub fn size_prefixed_root_as_host_response(
33523352
buf: &[u8],
3353-
) -> Result<HostResponse, flatbuffers::InvalidFlatbuffer> {
3353+
) -> Result<HostResponse<'_>, flatbuffers::InvalidFlatbuffer> {
33543354
flatbuffers::size_prefixed_root::<HostResponse>(buf)
33553355
}
33563356
#[inline]
@@ -3383,14 +3383,14 @@ pub mod host_response {
33833383
/// Assumes, without verification, that a buffer of bytes contains a HostResponse and returns it.
33843384
/// # Safety
33853385
/// Callers must trust the given bytes do indeed contain a valid `HostResponse`.
3386-
pub unsafe fn root_as_host_response_unchecked(buf: &[u8]) -> HostResponse {
3386+
pub unsafe fn root_as_host_response_unchecked(buf: &[u8]) -> HostResponse<'_> {
33873387
flatbuffers::root_unchecked::<HostResponse>(buf)
33883388
}
33893389
#[inline]
33903390
/// Assumes, without verification, that a buffer of bytes contains a size prefixed HostResponse and returns it.
33913391
/// # Safety
33923392
/// Callers must trust the given bytes do indeed contain a valid size prefixed `HostResponse`.
3393-
pub unsafe fn size_prefixed_root_as_host_response_unchecked(buf: &[u8]) -> HostResponse {
3393+
pub unsafe fn size_prefixed_root_as_host_response_unchecked(buf: &[u8]) -> HostResponse<'_> {
33943394
flatbuffers::size_prefixed_root_unchecked::<HostResponse>(buf)
33953395
}
33963396
#[inline]

rust/src/memory/buf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ fn __frnt__initiate_buffer(capacity: u32) -> i64 {
340340
buffer as i64
341341
}
342342

343-
#[cfg(all(test, any(unix, windows)))]
343+
#[cfg(all(test, any(unix, windows), feature = "wasmer-tests"))]
344344
mod test {
345345
use super::*;
346346
use wasmer::{

0 commit comments

Comments
 (0)