Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

try-runtime: dynamic storage query sizes #13923

Merged
merged 21 commits into from
Apr 21, 2023
Merged
Changes from 1 commit
Commits
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
48 changes: 31 additions & 17 deletions utils/frame/remote-externalities/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,17 @@ where
})
}

/// Returns the error message or suggestion for possible fixes based on the given RPC error.
fn get_batch_rpc_error_message(e: String) -> String {
// If the error contains "Invalid request ID", the request likely failed
// because the user incorrectly configured their node args
if e.to_string().contains("Invalid request ID") {
"Did you forget to specify `--rpc-max-request-size` or `--rpc-max-response-size` when starting your node? See https://paritytech.github.io/substrate/master/try_runtime_cli/index.html#note-on-nodes-that-respond-to-try-runtime-requests".to_string()
liamaharon marked this conversation as resolved.
Show resolved Hide resolved
} else {
format!("Unexpected RPC error: {}", e.to_string()).to_string()
}
}

/// Get all the keys at `prefix` at `hash` using the paged, safe RPC methods.
async fn rpc_get_keys_paged(
&self,
Expand Down Expand Up @@ -444,18 +455,21 @@ where
.unwrap();
}

let batch_response = rt
let batch_response = match rt
.block_on(thread_client.batch_request::<Option<StorageData>>(batch))
.map_err(|e| {
log::error!(
{
Ok(batch_response) => batch_response,
Err(e) => {
log::debug!(
target: LOG_TARGET,
"failed to execute batch: {:?}. Error: {:?}",
"chunk_keys: {:?}",
chunk_keys.iter().map(HexDisplay::from).collect::<Vec<_>>(),
e
);
"batch failed."
})
.unwrap();
let msg = Self::get_batch_rpc_error_message(e.to_string());
thread_sender.unbounded_send(Message::BatchFailed(msg)).unwrap();
return Default::default()
},
};

// Check if we got responses for all submitted requests.
assert_eq!(chunk_keys.len(), batch_response.len());
Expand Down Expand Up @@ -579,15 +593,15 @@ where
}

let batch_response =
client.batch_request::<Option<StorageData>>(batch_request).await.map_err(|e| {
log::error!(
target: LOG_TARGET,
"failed to execute batch: {:?}. Error: {:?}",
batch_child_key,
e
);
"batch failed."
})?;
match client.batch_request::<Option<StorageData>>(batch_request).await {
Ok(response) => response,
Err(e) => {
log::debug!(target: LOG_TARGET, "batch_child_key: {:?}", batch_child_key,);
let msg = Self::get_batch_rpc_error_message(e.to_string());
log::error!(target: LOG_TARGET, "{}", msg);
return Err("Batch RPC call failed.")
},
};

assert_eq!(batch_child_key.len(), batch_response.len());

Expand Down