Skip to content

Commit 5c17e86

Browse files
pepyakinrphmeier
authored andcommitted
shim: refactor the sugondat rpc client
This changeset makes a couple of fixes and changes: 1. Now the client strives to provide a peristent connection. See thrumdev#68. 1. Fix the greedy polling (See thrumdev#37). Now, only a single task polls for the finalized header. 1. Extracts the timestamp from the extrinsics instead of getting it from the storage. 1. Also sprinkles more documentation, clarifies some assumptions. 1. Now checks whether the subxt codegen matches the runtime metadata. If not, then we assume that the node is still useable, but still warn the user. 1. If the RPC node is not available, instead of bailing out, we keep reconnecting. I imagine this should be useful in cases where we spin up a local network and the shim started up before the sugondat node (plausible IMO). Closes thrumdev#68 Closes thrumdev#56 Closes thrumdev#37
1 parent 8c884c7 commit 5c17e86

File tree

6 files changed

+432
-75
lines changed

6 files changed

+432
-75
lines changed

Cargo.lock

Lines changed: 10 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sugondat-shim/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ subxt = { version = "0.32.1" }
2323
subxt-signer = {version = "0.32.1", features = ["subxt"] }
2424
sha2 = "0.10.8"
2525
hex = "0.4.3"
26+
url = "2.5.0"
2627

2728
[dev-dependencies]
2829
temp-dir = "0.1.11"

sugondat-shim/src/dock/rollkit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl RollkitRPCServer for RollkitDock {
3333
namespace, height
3434
);
3535
let namespace = parse_namespace(&namespace).map_err(|_| err::bad_namespace())?;
36-
let block_hash = self.client.wait_finalized_height(height).await.unwrap();
36+
let block_hash = self.client.wait_finalized_height(height).await;
3737
let block = self.client.get_block_at(block_hash).await.unwrap();
3838
let mut blobs = vec![];
3939
for blob in block.blobs {

sugondat-shim/src/dock/sovereign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl SovereignRPCServer for SovereignDock {
3333
namespace: sugondat_nmt::Namespace,
3434
) -> Result<Block, ErrorObjectOwned> {
3535
info!("get_block({})", height);
36-
let block_hash = self.client.wait_finalized_height(height).await.unwrap();
36+
let block_hash = self.client.wait_finalized_height(height).await;
3737
let block = self.client.get_block_at(block_hash).await.unwrap();
3838
let proof = make_namespace_proof(&block, namespace);
3939
let blobs = block

0 commit comments

Comments
 (0)