mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 20:21:03 +00:00
Migrate to jsonrpsee v2 (#787)
* POC jsonrpsee v2 * POC update ws client * connect to eth nodes using ws * fix for subscriptions * reverted unncecessary changes * reference jsonrpsee from crates.io * fixed eth port in deployments * fmt * order deps * remove unnecessary comment * clone is no longer required for subscriptions * treat RpcError::Internal as connection error * resubscribe on terminate * Update deployments/bridges/poa-rialto/entrypoints/poa-exchange-tx-generator-entrypoint.sh Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
This commit is contained in:
committed by
Bastian Köcher
parent
6cfd87783e
commit
a2b8bb191b
@@ -9,17 +9,17 @@ subcommands:
|
||||
- eth-host: ð-host
|
||||
long: eth-host
|
||||
value_name: ETH_HOST
|
||||
help: Connect to Ethereum node at given host.
|
||||
help: Connect to Ethereum node websocket server at given host.
|
||||
takes_value: true
|
||||
- eth-port: ð-port
|
||||
long: eth-port
|
||||
value_name: ETH_PORT
|
||||
help: Connect to Ethereum node at given port.
|
||||
help: Connect to Ethereum node websocket server at given port.
|
||||
takes_value: true
|
||||
- sub-host: &sub-host
|
||||
long: sub-host
|
||||
value_name: SUB_HOST
|
||||
help: Connect to Substrate node at given host.
|
||||
help: Connect to Substrate node websocket server at given host.
|
||||
takes_value: true
|
||||
- sub-port: &sub-port
|
||||
long: sub-port
|
||||
|
||||
@@ -62,7 +62,7 @@ pub fn run(params: EthereumDeployContractParams) {
|
||||
} = params;
|
||||
|
||||
let result = local_pool.run_until(async move {
|
||||
let eth_client = EthereumClient::new(eth_params);
|
||||
let eth_client = EthereumClient::new(eth_params).await.map_err(RpcError::Ethereum)?;
|
||||
let sub_client = SubstrateClient::<Rialto>::new(sub_params).await.map_err(RpcError::Substrate)?;
|
||||
|
||||
let (initial_header_id, initial_header) = prepare_initial_header(&sub_client, sub_initial_header).await?;
|
||||
|
||||
@@ -130,8 +130,7 @@ impl RelayClient for EthereumTransactionsSource {
|
||||
type Error = RpcError;
|
||||
|
||||
async fn reconnect(&mut self) -> Result<(), RpcError> {
|
||||
self.client.reconnect();
|
||||
Ok(())
|
||||
self.client.reconnect().await.map_err(Into::into)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +304,7 @@ fn run_single_transaction_relay(params: EthereumExchangeParams, eth_tx_hash: H25
|
||||
} = params;
|
||||
|
||||
let result = local_pool.run_until(async move {
|
||||
let eth_client = EthereumClient::new(eth_params);
|
||||
let eth_client = EthereumClient::new(eth_params).await.map_err(RpcError::Ethereum)?;
|
||||
let sub_client = SubstrateClient::<Rialto>::new(sub_params)
|
||||
.await
|
||||
.map_err(RpcError::Substrate)?;
|
||||
@@ -351,7 +350,8 @@ fn run_auto_transactions_relay_loop(params: EthereumExchangeParams, eth_start_wi
|
||||
} = params;
|
||||
|
||||
let do_run_loop = move || -> Result<(), String> {
|
||||
let eth_client = EthereumClient::new(eth_params);
|
||||
let eth_client = async_std::task::block_on(EthereumClient::new(eth_params))
|
||||
.map_err(|err| format!("Error starting Ethereum client: {:?}", err))?;
|
||||
let sub_client = async_std::task::block_on(SubstrateClient::<Rialto>::new(sub_params))
|
||||
.map_err(|err| format!("Error starting Substrate client: {:?}", err))?;
|
||||
|
||||
|
||||
@@ -54,7 +54,9 @@ pub fn run(params: EthereumExchangeSubmitParams) {
|
||||
} = params;
|
||||
|
||||
let result: Result<_, String> = local_pool.run_until(async move {
|
||||
let eth_client = EthereumClient::new(eth_params);
|
||||
let eth_client = EthereumClient::new(eth_params)
|
||||
.await
|
||||
.map_err(|err| format!("error connecting to Ethereum node: {:?}", err))?;
|
||||
|
||||
let eth_signer_address = secret_to_address(ð_sign.signer);
|
||||
let sub_recipient_encoded = sub_recipient;
|
||||
|
||||
@@ -122,8 +122,7 @@ impl RelayClient for EthereumHeadersSource {
|
||||
type Error = RpcError;
|
||||
|
||||
async fn reconnect(&mut self) -> Result<(), RpcError> {
|
||||
self.client.reconnect();
|
||||
Ok(())
|
||||
self.client.reconnect().await.map_err(Into::into)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,8 +258,8 @@ pub fn run(params: EthereumSyncParams) -> Result<(), RpcError> {
|
||||
instance,
|
||||
} = params;
|
||||
|
||||
let eth_client = EthereumClient::new(eth_params);
|
||||
let sub_client = async_std::task::block_on(async { SubstrateClient::<Rialto>::new(sub_params).await })?;
|
||||
let eth_client = async_std::task::block_on(EthereumClient::new(eth_params))?;
|
||||
let sub_client = async_std::task::block_on(SubstrateClient::<Rialto>::new(sub_params))?;
|
||||
|
||||
let sign_sub_transactions = match sync_params.target_tx_mode {
|
||||
TargetTransactionMode::Signed | TargetTransactionMode::Backup => true,
|
||||
|
||||
@@ -123,8 +123,7 @@ impl RelayClient for EthereumHeadersTarget {
|
||||
type Error = RpcError;
|
||||
|
||||
async fn reconnect(&mut self) -> Result<(), RpcError> {
|
||||
self.client.reconnect();
|
||||
Ok(())
|
||||
self.client.reconnect().await.map_err(Into::into)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,8 +173,8 @@ pub fn run(params: SubstrateSyncParams) -> Result<(), RpcError> {
|
||||
metrics_params,
|
||||
} = params;
|
||||
|
||||
let eth_client = EthereumClient::new(eth_params);
|
||||
let sub_client = async_std::task::block_on(async { SubstrateClient::<Rialto>::new(sub_params).await })?;
|
||||
let eth_client = async_std::task::block_on(EthereumClient::new(eth_params))?;
|
||||
let sub_client = async_std::task::block_on(SubstrateClient::<Rialto>::new(sub_params))?;
|
||||
|
||||
let target = EthereumHeadersTarget::new(eth_client, eth_contract_address, eth_sign);
|
||||
let source = SubstrateHeadersSource::new(sub_client);
|
||||
|
||||
Reference in New Issue
Block a user