Skip to content

Commit

Permalink
fix: multiple connection estability fixes (#1402)
Browse files Browse the repository at this point in the history
Co-authored-by: Ignacio Duart <[email protected]>
  • Loading branch information
netsirius and iduartgomez authored Feb 13, 2025
1 parent 88ae3bd commit f9e4a31
Show file tree
Hide file tree
Showing 18 changed files with 620 additions and 225 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/cross-compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Build and Cross-Compile

on:
workflow_dispatch:
pull_request:

jobs:
build-x86_64:
name: Build for x86_64-unknown-linux-gnu

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- uses: Swatinem/rust-cache@v2

- name: Install cross
run: cargo install cross

- name: Compile for x86_64-unknown-linux-gnu
run: cargo build --release

- name: Upload freenet binary
uses: actions/upload-artifact@v4
with:
name: binaries-x86_64-freenet
path: target/release/freenet

- name: Upload fdev binary
uses: actions/upload-artifact@v4
with:
name: binaries-x86_64-fdev
path: target/release/fdev

build-arm64:
name: Build for aarch64-unknown-linux-gnu

runs-on: ubuntu-24.04-arm

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- uses: Swatinem/rust-cache@v2

- name: Compile for aarch64-unknown-linux-gnu
run: cargo build --release

- name: Upload freenet binary
uses: actions/upload-artifact@v4
with:
name: binaries-arm64-freenet
path: target/release/freenet

- name: Upload fdev binary
uses: actions/upload-artifact@v4
with:
name: binaries-arm64-fdev
path: target/release/fdev
46 changes: 45 additions & 1 deletion Cargo.lock

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

3 changes: 2 additions & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "freenet"
version = "0.1.0-rc1"
version = "0.1.0-rc2"
edition = "2021"
rust-version = "1.80"
publish = true
Expand Down Expand Up @@ -95,6 +95,7 @@ httptest = "0.16"
pico-args = "0.5"
statrs = "0.18"
tempfile = "3"
test-log = "*"
tracing = "0.1"
# console-subscriber = { version = "0.4" }

Expand Down
5 changes: 4 additions & 1 deletion crates/core/src/client_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use freenet_stdlib::{
};
use futures::stream::FuturesUnordered;
use futures::{future::BoxFuture, FutureExt, StreamExt};
use std::collections::HashSet;
use std::fmt::Display;
use std::sync::atomic::AtomicUsize;
use std::sync::Arc;
Expand Down Expand Up @@ -454,7 +455,9 @@ async fn process_open_request(
);
})?;

if let Err(err) = get::request_get(&op_manager, op, vec![]).await {
if let Err(err) =
get::request_get(&op_manager, op, HashSet::new()).await
{
tracing::error!("get::request_get error: {}", err);
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/contract/executor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Contract executor.
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use std::fmt::Display;
use std::future::Future;
use std::path::PathBuf;
Expand Down Expand Up @@ -371,7 +371,7 @@ impl ComposeNetworkMessage<operations::get::GetOp> for GetContract {
}

async fn resume_op(op: operations::get::GetOp, op_manager: &OpManager) -> Result<(), OpError> {
operations::get::request_get(op_manager, op, vec![]).await
operations::get::request_get(op_manager, op, HashSet::new()).await
}
}

Expand Down
16 changes: 8 additions & 8 deletions crates/core/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
//! - in-memory: a simplifying node used for emulation purposes mainly.
//! - inter-process: similar to in-memory, but can be rana cross multiple processes, closer to the real p2p impl
use anyhow::Context;
use either::Either;
use freenet_stdlib::{
client_api::{ClientRequest, ErrorKind},
prelude::ContractKey,
};
use std::collections::HashSet;
use std::{
borrow::Cow,
fmt::Display,
Expand All @@ -19,13 +26,6 @@ use std::{
time::Duration,
};

use anyhow::Context;
use either::Either;
use freenet_stdlib::{
client_api::{ClientRequest, ErrorKind},
prelude::ContractKey,
};

use rsa::pkcs8::DecodePublicKey;
use serde::{Deserialize, Serialize};
use tracing::Instrument;
Expand Down Expand Up @@ -649,7 +649,7 @@ pub async fn subscribe(
Err(OpError::ContractError(ContractError::ContractNotFound(key))) => {
tracing::info!(%key, "Trying to subscribe to a contract not present, requesting it first");
let get_op = get::start_op(key, true);
if let Err(error) = get::request_get(&op_manager, get_op, vec![]).await {
if let Err(error) = get::request_get(&op_manager, get_op, HashSet::new()).await {
tracing::error!(%key, %error, "Failed getting the contract while previously trying to subscribe; bailing");
return Err(error);
}
Expand Down
Loading

0 comments on commit f9e4a31

Please sign in to comment.