Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): Update smoldot to the latest version #1400

Merged
merged 38 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
bf3c7f3
Update smoldot to 0.17 and smoldot-light to 0.15
lexnv Jan 26, 2024
1231920
Update cargo lock
lexnv Jan 26, 2024
ab0f67f
lightclient: Add generic platform for AddedChain
lexnv Jan 26, 2024
b948044
Merge remote-tracking branch 'origin/master' into lexnv/update-smoldot
lexnv Jan 30, 2024
f14bf9a
debug: Finalized heads
lexnv Jan 30, 2024
644626f
Merge remote-tracking branch 'origin/master' into lexnv/update-smoldot
lexnv Apr 3, 2024
b91742a
lightclient: Use generic TPlat for chainSuccess
lexnv Apr 3, 2024
75ace42
lightclient: Trim response for logs
lexnv Apr 3, 2024
c8020c9
Backup
lexnv Apr 8, 2024
6c9088e
Merge remote-tracking branch 'origin/master' into lexnv/update-smoldot
lexnv Apr 9, 2024
74dd9d7
tests/lightclient: Switch to localnode for testing
lexnv Apr 9, 2024
1c96d5e
cargo: Point smoldot to crates.io
lexnv Apr 9, 2024
03c629a
Merge remote-tracking branch 'origin/master' into lexnv/update-smoldot
lexnv Apr 9, 2024
1de5a06
Solve merge conflicts
lexnv Apr 9, 2024
c74e4ad
Add subxt macro for tests
lexnv Apr 9, 2024
b517adf
lightclient/wasm: Impl log of the PlatformRef
lexnv Apr 9, 2024
67ca3ec
Use git dep
lexnv Apr 15, 2024
c776229
Merge remote-tracking branch 'origin/master' into lexnv/update-smoldot
lexnv Jun 25, 2024
c4fe110
Revert "tests/lightclient: Switch to localnode for testing" + max log
lexnv Jun 25, 2024
6cca6f9
tests: Comment chainspec
lexnv Jun 25, 2024
2e7bacd
lightclient/wasm: Import IpAddr from core::net
lexnv Jun 26, 2024
c587309
Merge remote-tracking branch 'origin/master' into lexnv/update-smoldot
lexnv Jun 26, 2024
a6d7055
tests: Enable all tests again
lexnv Jun 26, 2024
3412cb6
tests/wasm: Update cargo lock
lexnv Jun 26, 2024
b6bdd06
tests: Add trace logs to easily reproduce problems
lexnv Jun 26, 2024
2779faf
cargo: Use released smoldot version
lexnv Jun 26, 2024
4612da3
Merge remote-tracking branch 'origin/master' into lexnv/update-smoldot
lexnv Sep 3, 2024
648b4f9
lightclient: Use chainspec and optionally make use of unstable backend
lexnv Sep 3, 2024
3b81de0
lightclient: Fix clippy
lexnv Sep 3, 2024
b69cba7
lightclient: Better trimming for log messages
lexnv Sep 6, 2024
f222db1
lightclient: Remove max log size
lexnv Sep 6, 2024
1a02662
lightclient: Use both backends for testing
lexnv Sep 6, 2024
f3c6179
Update Cargo.toml
lexnv Sep 6, 2024
8b34dcd
Update Cargo.toml
lexnv Sep 6, 2024
30c81b8
Merge remote-tracking branch 'origin/master' into lexnv/update-smoldot
lexnv Sep 6, 2024
7a41bf7
Merge branch 'master' into lexnv/update-smoldot
niklasad1 Sep 6, 2024
0b611f5
Update testing/integration-tests/src/light_client/mod.rs
niklasad1 Sep 6, 2024
43bd4db
Update testing/integration-tests/src/light_client/mod.rs
niklasad1 Sep 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 63 additions & 64 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ sc-executor = "0.40.0"
sc-executor-common = "0.35.0"

# Light client support:
smoldot = { version = "0.16.0", default-features = false }
smoldot-light = { version = "0.14.0", default-features = false }
smoldot = { version = "0.18.0", default-features = false }
smoldot-light = { version = "0.16.2", default-features = false }
tokio-stream = "0.1.15"
futures-util = "0.3.30"
rand = "0.8.5"
Expand Down
27 changes: 20 additions & 7 deletions lightclient/src/background.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl BackgroundTaskHandle {
/// coming to/from Smoldot.
#[allow(clippy::type_complexity)]
pub struct BackgroundTask<TPlatform: PlatformRef, TChain> {
channels: BackgroundTaskChannels,
channels: BackgroundTaskChannels<TPlatform>,
data: BackgroundTaskData<TPlatform, TChain>,
}

Expand All @@ -117,7 +117,7 @@ impl<TPlatform: PlatformRef, TChain> BackgroundTask<TPlatform, TChain> {
pub(crate) fn new(
client: SharedClient<TPlatform, TChain>,
chain_id: smoldot_light::ChainId,
from_back: smoldot_light::JsonRpcResponses,
from_back: smoldot_light::JsonRpcResponses<TPlatform>,
) -> (BackgroundTask<TPlatform, TChain>, BackgroundTaskHandle) {
let (tx, rx) = mpsc::unbounded_channel();

Expand Down Expand Up @@ -176,10 +176,11 @@ impl<TPlatform: PlatformRef, TChain> BackgroundTask<TPlatform, TChain> {
tracing::trace!(target: LOG_TARGET, "Smoldot RPC responses channel closed");
break;
};

tracing::trace!(
target: LOG_TARGET,
"Received smoldot RPC chain {:?} result {:?}",
chain_id, back_message
"Received smoldot RPC chain {chain_id:?} result {}",
trim_message(&back_message),
);

data.handle_rpc_response(back_message);
Expand All @@ -191,11 +192,11 @@ impl<TPlatform: PlatformRef, TChain> BackgroundTask<TPlatform, TChain> {
}
}

struct BackgroundTaskChannels {
struct BackgroundTaskChannels<TPlatform: PlatformRef> {
/// Messages sent into this background task from the front end.
from_front: UnboundedReceiverStream<Message>,
/// Messages sent into the background task from Smoldot.
from_back: smoldot_light::JsonRpcResponses,
from_back: smoldot_light::JsonRpcResponses<TPlatform>,
}

struct BackgroundTaskData<TPlatform: PlatformRef, TChain> {
Expand Down Expand Up @@ -242,6 +243,18 @@ struct ActiveSubscription {
unsubscribe_method: String,
}

fn trim_message(s: &str) -> &str {
const MAX_SIZE: usize = 512;
if s.len() < MAX_SIZE {
return s;
}

match s.char_indices().nth(MAX_SIZE) {
None => s,
Some((idx, _)) => &s[..idx],
}
}

impl<TPlatform: PlatformRef, TChain> BackgroundTaskData<TPlatform, TChain> {
/// Fetch and increment the request ID.
fn next_id(&mut self) -> usize {
Expand Down Expand Up @@ -359,7 +372,7 @@ impl<TPlatform: PlatformRef, TChain> BackgroundTaskData<TPlatform, TChain> {
/// Parse the response received from the light client and sent it to the appropriate user.
fn handle_rpc_response(&mut self, response: String) {
let chain_id = self.chain_id;
tracing::trace!(target: LOG_TARGET, "Received from smoldot response='{response}' chain={chain_id:?}");
tracing::trace!(target: LOG_TARGET, "Received from smoldot response='{}' chain={chain_id:?}", trim_message(&response));

match RpcResponse::from_str(&response) {
Ok(RpcResponse::Method { id, result }) => {
Expand Down
2 changes: 1 addition & 1 deletion lightclient/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl LightClientRpc {
pub(crate) fn new_raw<TPlat, TChain>(
client: impl Into<SharedClient<TPlat, TChain>>,
chain_id: smoldot_light::ChainId,
rpc_responses: smoldot_light::JsonRpcResponses,
rpc_responses: smoldot_light::JsonRpcResponses<TPlat>,
) -> Self
where
TPlat: smoldot_light::platform::PlatformRef + Send + 'static,
Expand Down
Loading
Loading