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

fix: allow insecure connections with subxt #5479

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 11 additions & 3 deletions engine/src/dot/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ macro_rules! refresh_connection_on_error {
);

let new_client =
OnlineClient::<PolkadotConfig>::from_url(&$self.polkadot_network_ws_url).await?;
OnlineClient::<PolkadotConfig>::from_insecure_url(&$self.polkadot_network_ws_url).await?;
let result = new_client.$namespace().$method($($arg,)*).await.map_err(|e| anyhow!("Failed to query {} Polkadot with error: {e}", stringify!($method)));
let mut online_client_guard = $self.online_client.write().await;
*online_client_guard = new_client;
Expand All @@ -53,8 +53,12 @@ macro_rules! refresh_connection_on_error {

impl DotRpcClient {
pub async fn new(polkadot_network_ws_url: &str, http_client: DotHttpRpcClient) -> Result<Self> {
if subxt::utils::validate_url_is_secure(polkadot_network_ws_url).is_err() {
warn!("Using insecure Polkadot websocket endpoint: {polkadot_network_ws_url}");
}

let online_client = Arc::new(RwLock::new(
OnlineClient::<PolkadotConfig>::from_url(polkadot_network_ws_url).await?,
OnlineClient::<PolkadotConfig>::from_insecure_url(polkadot_network_ws_url).await?,
));
Ok(Self {
online_client,
Expand Down Expand Up @@ -186,7 +190,11 @@ async fn create_online_client(
ws_endpoint: &SecretUrl,
expected_genesis_hash: Option<PolkadotHash>,
) -> Result<OnlineClient<PolkadotConfig>> {
let client = OnlineClient::<PolkadotConfig>::from_url(ws_endpoint).await?;
if subxt::utils::validate_url_is_secure(ws_endpoint.as_ref()).is_err() {
warn!("Using insecure Polkadot websocket endpoint: {ws_endpoint}");
}

let client = OnlineClient::<PolkadotConfig>::from_insecure_url(ws_endpoint).await?;

if let Some(expected_genesis_hash) = expected_genesis_hash {
let genesis_hash = client.genesis_hash();
Expand Down
2 changes: 1 addition & 1 deletion utilities/scale-json-event-logger/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async fn main() -> anyhow::Result<()> {
// Any remaining arguments are assumed to be path filters.
let filter = PathFilter(std::env::args().skip(3).collect::<Vec<_>>());

let client = subxt::OnlineClient::<SubstrateConfig>::from_url(url).await.unwrap();
let client = subxt::OnlineClient::<SubstrateConfig>::from_insecure_url(url).await.unwrap();

match hash_opt {
HashOption::Latest => {
Expand Down
Loading