mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 08:01:09 +00:00
chore(deps): Update smoldot to the latest version (#1400)
* Update smoldot to 0.17 and smoldot-light to 0.15
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* Update cargo lock
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* lightclient: Add generic platform for AddedChain
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* debug: Finalized heads
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* lightclient: Use generic TPlat for chainSuccess
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* lightclient: Trim response for logs
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* Backup
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* tests/lightclient: Switch to localnode for testing
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* cargo: Point smoldot to crates.io
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* Solve merge conflicts
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* Add subxt macro for tests
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* lightclient/wasm: Impl log of the PlatformRef
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* Use git dep
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* Revert "tests/lightclient: Switch to localnode for testing" + max log
size
This reverts commit 74dd9d7cff.
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* tests: Comment chainspec
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* lightclient/wasm: Import IpAddr from core::net
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* tests: Enable all tests again
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* tests/wasm: Update cargo lock
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* tests: Add trace logs to easily reproduce problems
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* cargo: Use released smoldot version
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* lightclient: Use chainspec and optionally make use of unstable backend
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* lightclient: Fix clippy
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* lightclient: Better trimming for log messages
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* lightclient: Remove max log size
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* lightclient: Use both backends for testing
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* Update Cargo.toml
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
* Update Cargo.toml
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
* Update testing/integration-tests/src/light_client/mod.rs
* Update testing/integration-tests/src/light_client/mod.rs
---------
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
This commit is contained in:
@@ -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>,
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
@@ -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> {
|
||||
@@ -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 {
|
||||
@@ -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 }) => {
|
||||
|
||||
Reference in New Issue
Block a user