Remove subxt (#460)

* Remove subxt

Removes ~20 crates from our Cargo.lock.

Removes downloading the metadata and enables removing the getMetadata RPC route
(relevant to #379).

Moves forward #337.

Done now due to distinctions in the subxt 0.32 API surface which make it
justifiable to not update.

* fmt, update due to deny triggering on a yanked crate

* Correct the handling of substrate_block_notifier now that it's ephemeral, not long-lived

* Correct URL in tests/coordinator from ws to http
This commit is contained in:
Luke Parker
2023-11-28 02:29:50 -05:00
committed by GitHub
parent 571195bfda
commit 695d1f0ecf
30 changed files with 473 additions and 718 deletions

View File

@@ -213,12 +213,12 @@ impl Processor {
// Sleep until the Substrate RPC starts
let serai_rpc = ops.handle(&handles.0).host_port(9944).unwrap();
let serai_rpc = format!("ws://{}:{}", serai_rpc.0, serai_rpc.1);
let serai_rpc = format!("http://{}:{}", serai_rpc.0, serai_rpc.1);
// Bound execution to 60 seconds
for _ in 0 .. 60 {
tokio::time::sleep(Duration::from_secs(1)).await;
let Ok(client) = Serai::new(&serai_rpc).await else { continue };
if client.latest_block_hash().await.is_err() {
let Ok(client) = Serai::new(serai_rpc.clone()).await else { continue };
if client.latest_finalized_block_hash().await.is_err() {
continue;
}
break;
@@ -371,7 +371,7 @@ impl Processor {
}
pub async fn serai(&self) -> Serai {
Serai::new(&self.serai_rpc).await.unwrap()
Serai::new(self.serai_rpc.clone()).await.unwrap()
}
/// Send a message to the coordinator as a processor.

View File

@@ -176,7 +176,7 @@ pub async fn batch(
let batch = SignedBatch { batch, signature };
let serai = processors[0].serai().await;
let mut last_serai_block = serai.latest_block().await.unwrap().number();
let mut last_serai_block = serai.latest_finalized_block().await.unwrap().number();
for (i, processor) in processors.iter_mut().enumerate() {
if i == excluded_signer {
@@ -194,9 +194,9 @@ pub async fn batch(
tokio::time::sleep(Duration::from_secs(6)).await;
}
while last_serai_block <= serai.latest_block().await.unwrap().number() {
while last_serai_block <= serai.latest_finalized_block().await.unwrap().number() {
let batch_events = serai
.as_of(serai.block_by_number(last_serai_block).await.unwrap().unwrap().hash())
.as_of(serai.finalized_block_by_number(last_serai_block).await.unwrap().unwrap().hash())
.in_instructions()
.batch_events()
.await
@@ -220,7 +220,7 @@ pub async fn batch(
}
// Verify the coordinator sends SubstrateBlock to all processors
let last_block = serai.block_by_number(last_serai_block).await.unwrap().unwrap();
let last_block = serai.finalized_block_by_number(last_serai_block).await.unwrap().unwrap();
for processor in processors {
assert_eq!(
processor.recv_message().await,

View File

@@ -109,7 +109,7 @@ pub async fn key_gen<C: Ciphersuite>(
let network_key = (C::generator() * *network_priv_key).to_bytes().as_ref().to_vec();
let serai = processors[0].serai().await;
let mut last_serai_block = serai.latest_block().await.unwrap().number();
let mut last_serai_block = serai.latest_finalized_block().await.unwrap().number();
wait_for_tributary().await;
for (i, processor) in processors.iter_mut().enumerate() {
@@ -151,9 +151,9 @@ pub async fn key_gen<C: Ciphersuite>(
tokio::time::sleep(Duration::from_secs(6)).await;
}
while last_serai_block <= serai.latest_block().await.unwrap().number() {
while last_serai_block <= serai.latest_finalized_block().await.unwrap().number() {
if !serai
.as_of(serai.block_by_number(last_serai_block).await.unwrap().unwrap().hash())
.as_of(serai.finalized_block_by_number(last_serai_block).await.unwrap().unwrap().hash())
.validator_sets()
.key_gen_events()
.await
@@ -199,7 +199,7 @@ pub async fn key_gen<C: Ciphersuite>(
}
assert_eq!(
serai
.as_of(serai.block_by_number(last_serai_block).await.unwrap().unwrap().hash())
.as_of(serai.finalized_block_by_number(last_serai_block).await.unwrap().unwrap().hash())
.validator_sets()
.keys(set)
.await

View File

@@ -241,7 +241,7 @@ async fn sign_test() {
{
let block_included_in_hash =
serai.block_by_number(block_included_in).await.unwrap().unwrap().hash();
serai.finalized_block_by_number(block_included_in).await.unwrap().unwrap().hash();
let serai = serai.as_of(block_included_in_hash).coins();
assert_eq!(
@@ -284,9 +284,9 @@ async fn sign_test() {
tokio::time::sleep(Duration::from_secs(6)).await;
}
while last_serai_block <= serai.latest_block().await.unwrap().number() {
while last_serai_block <= serai.latest_finalized_block().await.unwrap().number() {
let burn_events = serai
.as_of(serai.block_by_number(last_serai_block).await.unwrap().unwrap().hash())
.as_of(serai.finalized_block_by_number(last_serai_block).await.unwrap().unwrap().hash())
.coins()
.burn_with_instruction_events()
.await
@@ -307,7 +307,8 @@ async fn sign_test() {
}
}
let last_serai_block = serai.block_by_number(last_serai_block).await.unwrap().unwrap();
let last_serai_block =
serai.finalized_block_by_number(last_serai_block).await.unwrap().unwrap();
let last_serai_block_hash = last_serai_block.hash();
let serai = serai.as_of(last_serai_block_hash).coins();
assert_eq!(serai.coin_supply(Coin::Bitcoin).await.unwrap(), Amount(0));