Merge branch 'tadeohepperle/subxt-metadata-no-std' into tadeohepperle/subxt-core-2

This commit is contained in:
Tadeo hepperle committed 2024-02-02 09:16:06 +01:00
commit 6236c49e3c
35 files changed
+4017 -1232

No files matched your search

@@ -0,0 +1,3 @@
# use-nodes
This action downloads the substrate and polkadot binaries produced from the `build-nodes` workflow and puts them into the `$PATH`.
@@ -0,0 +1,33 @@
name: Use substrate and polkadot binaries
description: Downloads and configures the substrate and polkadot binaries built with `build-nodes`
runs:
using: composite
steps:
- name: Download substrate-node binary
id: download-substrate-binary
uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2.28.0
with:
workflow: build-nodes.yml
name: nightly-substrate-binary
- name: Download polkadot binary
id: download-polkadot-binary
uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2.28.0
with:
workflow: build-nodes.yml
name: nightly-polkadot-binary
- name: Prepare binaries
shell: bash
run: |
chmod u+x ./substrate-node
chmod u+x ./polkadot
chmod u+x ./polkadot-execute-worker
chmod u+x ./polkadot-prepare-worker
./substrate-node --version
./polkadot --version
mkdir -p ~/.local/bin
cp ./substrate-node ~/.local/bin
cp ./polkadot ~/.local/bin
cp ./polkadot-execute-worker ~/.local/bin
cp ./polkadot-prepare-worker ~/.local/bin
@@ -1,3 +0,0 @@
# use-substrate
This action downloads the substrate binary produced from the `build-substrate` workflow and puts it into the `$PATH`.
@@ -1,19 +0,0 @@
name: Use substrate binary
description: Downloads and configures the substrate binary built with build-substrate
runs:
using: composite
steps:
- name: Download substrate-node binary
id: download-artifact
uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2.28.0
with:
workflow: build-substrate.yml
name: nightly-substrate-binary
- name: Prepare substrate-node binary
shell: bash
run: |
chmod u+x ./substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
cp ./substrate-node ~/.local/bin
@@ -1,4 +1,4 @@
name: Build Substrate Binary
name: Build Substrate and Polkadot Binaries
on:
# Allow it to be manually ran to rebuild binary when needed:
@@ -9,7 +9,7 @@ on:
jobs:
tests:
name: Build Substrate
name: Build Substrate and Polkadot Binaries
runs-on: ubuntu-latest-16-cores
steps:
- name: checkout polkadot-sdk
@@ -42,3 +42,20 @@ jobs:
path: target/release/substrate-node
retention-days: 2
if-no-files-found: error
- name: build polkadot binary
uses: actions-rs/cargo@v1
with:
command: build
args: --release --manifest-path polkadot/Cargo.toml
- name: upload polkadot binary
uses: actions/upload-artifact@v3
with:
name: nightly-polkadot-binary
path: |
target/release/polkadot
target/release/polkadot-execute-worker
target/release/polkadot-prepare-worker
retention-days: 2
if-no-files-found: error
+2 -2
View File
@@ -16,8 +16,8 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate-node binary
uses: ./.github/workflows/actions/use-substrate
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
+122 -58
View File
@@ -46,16 +46,50 @@ jobs:
command: fmt
args: --all -- --check
clippy:
name: Cargo clippy
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
machete:
name: "Check unused dependencies"
runs-on: ubuntu-latest
needs: fmt
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate-node binary
uses: ./.github/workflows/actions/use-substrate
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Install cargo-machete
run: cargo install cargo-machete
- name: Check unused dependencies
uses: actions-rs/cargo@v1.0.3
with:
command: machete
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
clippy:
name: Cargo clippy
runs-on: ubuntu-latest
needs: [fmt, machete]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
@@ -69,21 +103,56 @@ jobs:
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Run clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets -- -D warnings
run: |
cargo clippy --all-targets --features unstable-light-client -- -D warnings
cargo clippy -p subxt-lightclient --no-default-features --features web -- -D warnings
cargo clippy -p subxt --no-default-features --features web -- -D warnings
cargo clippy -p subxt --no-default-features --features web,unstable-light-client -- -D warnings
check:
name: Cargo check
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
wasm_clippy:
name: Cargo clippy (WASM)
runs-on: ubuntu-latest
needs: [fmt, clippy]
needs: [fmt, machete]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate-node binary
uses: ./.github/workflows/actions/use-substrate
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: wasm32-unknown-unknown
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Run clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -p subxt --no-default-features --features web,unstable-light-client,jsonrpsee --target wasm32-unknown-unknown -- -D warnings
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
check:
name: Cargo check
runs-on: ubuntu-latest
needs: [fmt, machete]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
@@ -133,10 +202,13 @@ jobs:
- name: Cargo check parachain-example
run: cargo check --manifest-path examples/parachain-example/Cargo.toml
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
wasm_check:
name: Cargo check (WASM)
runs-on: ubuntu-latest
needs: [fmt, clippy]
needs: [fmt, machete]
steps:
- name: Checkout sources
uses: actions/checkout@v4
@@ -157,45 +229,19 @@ jobs:
run: |
cargo check --manifest-path examples/wasm-example/Cargo.toml --target wasm32-unknown-unknown
machete:
name: "Check unused dependencies"
runs-on: ubuntu-latest
needs: [check, wasm_check]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate-node binary
uses: ./.github/workflows/actions/use-substrate
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Install cargo-machete
run: cargo install cargo-machete
- name: Check unused dependencies
uses: actions-rs/cargo@v1.0.3
with:
command: machete
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
docs:
name: Check documentation and run doc tests
runs-on: ubuntu-latest
needs: [check, wasm_check]
needs: [fmt, machete]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate-node binary
uses: ./.github/workflows/actions/use-substrate
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
@@ -216,17 +262,20 @@ jobs:
command: test
args: --doc
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
tests:
name: "Test (Native)"
runs-on: ubuntu-latest-16-cores
needs: [machete, docs]
needs: [clippy, wasm_clippy, check, wasm_check, docs]
timeout-minutes: 30
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate-node binary
uses: ./.github/workflows/actions/use-substrate
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
@@ -247,17 +296,20 @@ jobs:
command: nextest
args: run --workspace
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
unstable_backend_tests:
name: "Test (Unstable Backend)"
runs-on: ubuntu-latest-16-cores
needs: [machete, docs]
needs: [clippy, wasm_clippy, check, wasm_check, docs]
timeout-minutes: 30
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate-node binary
uses: ./.github/workflows/actions/use-substrate
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
@@ -278,17 +330,20 @@ jobs:
command: nextest
args: run --workspace --features unstable-backend-client
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
light_client_tests:
name: "Test (Light Client)"
runs-on: ubuntu-latest
needs: [machete, docs]
needs: [clippy, wasm_clippy, check, wasm_check, docs]
timeout-minutes: 15
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate-node binary
uses: ./.github/workflows/actions/use-substrate
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
@@ -306,10 +361,13 @@ jobs:
command: test
args: --release --package integration-tests --features unstable-light-client
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
wasm_tests:
name: Test (WASM)
runs-on: ubuntu-latest
needs: [machete, docs]
needs: [clippy, wasm_clippy, check, wasm_check, docs]
timeout-minutes: 30
env:
# Set timeout for wasm tests to be much bigger than the default 20 secs.
@@ -330,8 +388,8 @@ jobs:
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Use substrate-node binary
uses: ./.github/workflows/actions/use-substrate
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Run subxt WASM tests
run: |
@@ -359,6 +417,9 @@ jobs:
wasm-pack test --headless --chrome
working-directory: signer/wasm-tests
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
no-std-tests:
name: "Test (no_std)"
runs-on: ubuntu-latest
@@ -384,3 +445,6 @@ jobs:
run: |
cargo run
working-directory: testing/no-std-tests
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
+2 -2
View File
@@ -21,8 +21,8 @@ jobs:
uses: actions/checkout@v4
# We run this (up-to-date) node locally to fetch metadata from it for the artifacts
- name: Use substrate-node binary
uses: ./.github/workflows/actions/use-substrate
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
Generated
-1
View File
@@ -4609,7 +4609,6 @@ version = "0.34.0"
dependencies = [
"assert_matches",
"bitvec",
"cfg-if",
"criterion",
"derive_more",
"frame-metadata 16.0.0",
+7 -5
View File
@@ -32,7 +32,9 @@
"/dns/dot-bootnode.stakeworld.io/tcp/30311/ws/p2p/12D3KooWAb5MyC1UJiEQJk4Hg4B2Vi3AJdqSUhTGYUqSnEqCFMFg",
"/dns/dot-bootnode.stakeworld.io/tcp/30312/wss/p2p/12D3KooWAb5MyC1UJiEQJk4Hg4B2Vi3AJdqSUhTGYUqSnEqCFMFg",
"/dns/dot14.rotko.net/tcp/35214/wss/p2p/12D3KooWPyEvPEXghnMC67Gff6PuZiSvfx3fmziKiPZcGStZ5xff",
"/dns/dot14.rotko.net/tcp/33214/p2p/12D3KooWPyEvPEXghnMC67Gff6PuZiSvfx3fmziKiPZcGStZ5xff"
"/dns/dot14.rotko.net/tcp/33214/p2p/12D3KooWPyEvPEXghnMC67Gff6PuZiSvfx3fmziKiPZcGStZ5xff",
"/dns/ibp-boot-polkadot.luckyfriday.io/tcp/30333/p2p/12D3KooWEjk6QXrZJ26fLpaajisJGHiz6WiQsR8k7mkM9GmWKnRZ",
"/dns/ibp-boot-polkadot.luckyfriday.io/tcp/30334/wss/p2p/12D3KooWEjk6QXrZJ26fLpaajisJGHiz6WiQsR8k7mkM9GmWKnRZ"
],
"chainType": "Live",
"forkBlocks": null,
@@ -41,10 +43,10 @@
},
"id": "polkadot",
"lightSyncState": {
"babeEpochChanges": "0x044736295f5ace57cb8f84fd667e8ed439db12f470d45736d046f67f54bccaada2b69c16010153bae41000000000b3c3e41000000000046646627e2646c3b728990fc968ec647c2170e66b55fbe48365e54557ae43756916a6160101b3c3e4100000000013cde41000000000086441c5d73eef491062ed18d31770e3f8a95eba0a9e78b407d28c706c6f06332775af16010113cde4100000000073d6e41000000000007494065a1f61226b66736add1b00a214e14611c3f78e1ab4d3e0d9c69ae732f875af16010113cde4100000000073d6e410000000000000104736295f5ace57cb8f84fd667e8ed439db12f470d45736d046f67f54bccaada2b69c160101da1d00000000000053bae410000000006009000000000000a50474a0fc84f72a4a9b8493379b7dfc59ca58a261a2e94997600d14b6b444c1475901000000000000009c40155989f6072e82caba245d7db7e40a60f866b403257976b89aba6be2b55b010000000000000014b0a3a620f70ada506d6ef1b7ab099219f2f05689523af7eebc81f9ba258e6001000000000000007067d4c5b492b11e2052a2bb0b4f729a52b3667afbca7dfefa863011254b5272010000000000000072ab87b654d80294c876cbefb534b3344c2f64159b015b89221331ec2145417501000000000000008008c1b7061a2402634fc15d3849e2913863beb9f55024bc8cc7fa7d6e397817010000000000000024a51a9bdb67213626d1b52bd8dbc0e9b94ea88ea417aa17b56212d1cea3e1780100000000000000488d520146f681678e9d229f5e29354edf65e521246b28a4175c0502e060b92001000000000000003ae9dfa8b24faaf16407328ff38a89b25fc7c673c44f9de3de0c011233d4226d01000000000000009e47382505cd1a803bdbe7803d36a61413e58697bd9396ce1607c89a48d1e051010000000000000020352ba0565811731625a8001d26f5d899e5856dedd0f9c6bc3bec2995704e5b01000000000000009cb389c209afbebda2b12113e0266b3d30f46e2a91aaf4451c193d640288357101000000000000004c9886e2e62ee92a6778d6a7928052732044b64fa61969cd8e37f3f7e3406f7201000000000000000c78c9dfc0033ff87657c56b7ab8cec4d1249be2de18729f743f385343af0f160100000000000000002e496e564f088a075525d2f9155aadd1a7eb017fa36f9e16096e9db7e169330100000000000000ae40860237c8f606dfb6974046eaa6b6b96f8d0aef56fbe3ce4865f66646bd260100000000000000f6dddaaaa53b57763610037753656b591d90fa81efbadcabbeddf7378c23602701000000000000003e69835397599a4bf081775f9f42f0f4ee686d67c9af8eacc4a733fdcdb0290b0100000000000000c48c594bb4e173544a0379055b65d995af53256f653d04f2cf4fdf8f3548943901000000000000003a80d898638dccd4aaa472e7948e7394969cc443335c494159948915c097c036010000000000000000b84e6e296de1009aeca95ee09bc5173aec6e91b1145b247d69e477588789720100000000000000466c0e97d043a4b0f4c3ac4849e11f901e9b31b28f8b3e40b7cdb0ba7f77480801000000000000002049288b4dbfb741109778c602f9308daf2e31b3b66e9aa550065e73c6787d7c0100000000000000e67c524e443cda4cd27dfcce70488a5d23a93c8c46a5e83ef5a69eff3a02fa5a010000000000000024a57db63b380456d56d561d8a9da6db13d298045c9672bc4086a2e0a567d55c01000000000000006c50859d9dde209012eb3868c1a3a6e80ae8fa528ace9df68e92dbbae6036820010000000000000078c88041bbca9b2bebd62fde7c46f4dc5e55d8877a113d063a6b525dfd6f7f2a01000000000000002e85d3d2c07aaf1c0a5f63f544c34b87cfa90a98c4f6167e86cee0b74a20cb120100000000000000723f3865d97a772459da8942cbb4757164f1fe7485cbcefb4b206e157ee5ed0201000000000000007c5f58a83f8101943c089dba3ab906c07811e853444aa58dbcc986c4095fbe7c01000000000000005494142902284943201b7cf610306e8665eeeec87c014d607175c3f50f76103b01000000000000001822493200c35242a149070784dca5e7012a8a52b61cd218ec7d65e469e8cc56010000000000000072ed7192625403acef94aa9189f9f179deb89e60478816ca96c79b742f757e750100000000000000d8f30bc2ee88e69f60d0278998414c80f4a130b8e1738e873bcd14ef31e58d36010000000000000042e377034ce6b2a582bfd66c465252ab10ce790e4f0d3bbe99a42ff86b29965c01000000000000000e164f314984e9a172a3a1526d853ff70bd11f3c596f17accbbebe2f7820833c01000000000000007e91ca522b14cbb71b45348c699b7d65c3198516ee771079b672ee3d7cfc577501000000000000004e2753547f6ec0a896bcbc55b9eeab875e8019acdeb10b979210af63f24c4b74010000000000000098faca5e78664fd082bf47f0079de33a5021415c8f5f912941e651a0b7071d1f0100000000000000ca6e63cec4c0801ecd740073da08be68b9cf4c7ff76b740fb6a522a63e838b5a010000000000000042e7851b82d8b7722b9eeb5eead57b21bf533fd25acb10542a52889376fc3920010000000000000028ce9c093ac772f56acb8dfe8b33a3966d4b8699bd41814117352d397195bd5f010000000000000042ad4ba7e8a60af1abcee04fdd82ad02b24f1e2535bdb1abcdde886efbf0fc4301000000000000006ec27dfa7ac9d35eb002c55d3e4d56b4df928dd5c44323ac228305741c9e09360100000000000000b89cbc83a386d6f5d4fed93289ee50fdf69d77369ca0c9a8b962554e3fc0d37e0100000000000000e61da4eefdd14434952c58dd1943f7f63185d03321ccc8835e4216badd16fc19010000000000000012a64d79e44f1adb33c85c4f2bdfcd8d8b38a34d984604f39289c9a7624a442d0100000000000000a20797f3a8669a909adb22a3aee2844dba82d231cc33f5d9be0e2c533cb82a670100000000000000e297620b731b4958e3c6aa06611c6aa5a45f7e116362d64954a0a330d2a98f330100000000000000dc1274e0689c7a3eac31b41ce352719529e65c01f26999f74ce17c9905fce87401000000000000000e5e5f8e89cd8d58ef83abddd3d1c2079691dec4f6965af70436e84411c31f3901000000000000007c21799f6143fa837a8c18bebe3368d60f4e009b114f61490b54e6344034040d0100000000000000e2f4efaa91da8465ac7d109cd80be5c02b9ba7a0603ff372cd77824de17f6c4201000000000000000ef6f09a9e310abb5c57dd7050a94d56d766772b80789b997cbb40f3b40f625d0100000000000000a88864a0dc9e292aa7cc8eddaa8dd8b6be2a4bc7e8f290023c6604e5c4ad1a7a0100000000000000dc68569bLine truncated
"babeFinalizedBlockWeight": 4559738,
"finalizedBlockHeader": "0xd77079fcf54a7a83fb2b75b24bc4c7b8a776c50c5a6ca04fcf5eba857e2a7f5052c05a04443844f2007aff2b5c8afe4731e735126f337ad52776ffd32f586da47451186fd49b29a11d724d4a7e0eba71b2c74ce1f9fe5958264219cf8ec4160346bc6b12080642414245b501036200000052c4e410000000009a76cf5448916664e377946b2cdf61f1afdc50feae99314db4a62b2ecd5fb24c501e3f442fc8eb763a2fe20657380d5e43c7b8223b90137aeafca12dfe65cd01a3c5a3977a9f1d929cd0855d15aa6f8a5d304ad7f1745bcc857e6e69d0a0e9020542414245010186408d036b3647c440fec22006c5386f1eef56c4fb9314e8bcea8bd26c681f04f8910b1bb3332e0bd2ce3b2cb16a3a9cbf53cb7b1c1152b0693ac90b268eca89",
"grandpaAuthoritySet": "0xa5042f8da08bb2421ef844015c3b2ea23464fc66a9dcb4a2215fe0241f892d19afc50100000000000000fff437ff18629bf1490e5c9b3ec6f1515d46bb9b2aeaa6e39e36611f2479b50d01000000000000000334021ff54e46fb7da4bd257cf113519a0c7ee4a2251b66fe48466fed5853520100000000000000d95f04dc8ea4ac05deea7077457f0406fdd152bd03a7480e7d0de0983b959d3c010000000000000047f940bc985355be7187c709ded2b689b66d69e61e293a507f1d4f90bdbeceee01000000000000004a3fc0fe1020c7f460c7bd23d0b657c03368552b2f0a12d80a1c406fd066e0db01000000000000009b992b5e9b99eb2cd3b2b648d6db81ed722a2feb4938d998b58dcb5d159fadfa0100000000000000aee9de3938173700b3e3f4fbf2b200ae296173a0854157f40de2598dd4cad8f10100000000000000e0b1aae640bfbed119730710c584be65ef59abb3e9ee5dc8a754751e1ba163960100000000000000495a0370e02aadf1beff005feceb521a1d9bb0d85e7fe58658b97ec988fb996c0100000000000000b61e9b13e849779be8f5378a670d61991875d8e091f359384d7be73d02d506930100000000000000426b2be4596a759a15028d84e08c5c56440e6cede68d088f47c671cc3387c3e6010000000000000070ba6e5985990ba1b1392713236f1b50df750f10f744cc6eb95fa7c5cfbc687601000000000000005b27660cd4c375f2654c6d923b29fd8abbab7e96ee040c79598be14f832f56ca010000000000000057ae0c85ebaf333a6ec3251f577cab910cce072f238d1e50046322b83bbc0dd5010000000000000072c09c9e2dc9ab20a65cf70e951352f554442514ba2ac7063966ea7bbe3e6cf001000000000000000139b946b46bee4c61be50c986f2a9ef2e76917644e2ecd842c59d61a94ee612010000000000000019a9d56ea35496122fc44fcb5c29d27fbb43520556d6f8d97753767aaa0f228e01000000000000007cd50f6921fade39653f847bddd48360668004225081a6a3ad7997f78debd34c010000000000000053a51c848834661c92e74b3c2492b8de2591f914ab75345d70e61c79be9699d70100000000000000a5b094ae7c156592baa68ce18dab6368d5b665e9a0f07dfc5f54f58309e086c1010000000000000053352e16d2a27fb3525d5d8750d6ad7f46b303a45e434a409ac727d5cb80432b01000000000000008c54298c6f8704498112ecb24f64f7a28ed2289ec573620b0d1e5a9a44f5fa78010000000000000041ef4a31eb7dc1e01f4630604e1908e644d7cdee3f66a60f98d6d59605326f8b010000000000000097743d6364cdb6c4790cd37c4c2ab5fbc6c65e8bb606625e70a6ee04ed1650d9010000000000000008cc1d6c743da905511a39a6f0a68809a6bc32f8ac25e53bb2d6aca4f493fc9b0100000000000000c9dc00c6a757495c50092362d5c70d2a971ae1da4eb67c9da9f4367c9d408c1d0100000000000000049cb09a86d544249f9e11cf6c348bc0561600343ebee89d1c90bbef3d13e517010000000000000086c42c0f6b8f7c06f9ce823eeecf7cf0371bb5b97f3c7af63872f8bbfb353abd0100000000000000d04d64a07f144638f20f081de122b88fed0cc8bda57e4810e7afb38036dd8bbf0100000000000000f26945a8a64032a1defa76e720a99649125b55751b6088205e7acab901de670b0100000000000000684768723f0efc2001562c3b2156b987601ae9431f8aaa6f4199649cba487aea01000000000000005cba2c6f569da1edc3778308da406f266aa53140381dbb3f14f22909ba6e30040100000000000000c9a741ab82126c4d4eaa6a758cfc1209bbd7b29330e89ccd97fb62ae567c8d4301000000000000009b94bc45bf79bb33f70430c82880456cd7bd5fb3ea131c1b26d493d01c5fe7100100000000000000ce8d085d4b0a9502a680280ecc162bd33533a5ebada62f3be19427542189cb5a0100000000000000a1a9debad5e4afb076cf293c2c797f0b5901ffdb8bd01611235e762411a0db3901000000000000006f4855725ebb9eced957bae43ffa7d30657ce7d06b251ce20e2218bcf929e40501000000000000007c10f10bd6eb9c1201b52c6025545fcbc310432781bbe02629b5cc9e5fdd229a0100000000000000b046cf7d24d49b720b28dd2476b36c157262208fb065c077b1b94db1e9ffa6050100000000000000749556da4a259bc1f0b8ea8e3726c2251656b92205c30b635ec9f42038f8defb01000000000000000ce4d93e25fa5302f4b059456f680047f87be428ae88579e0b862502b5ceed600100000000000000c1758f7cbffeb844419bc494a9dc65fb394259f01e9bf23789a75acc29d7d9620100000000000000c1c1ff5f66fefb5c0849e3b2333411d1f7e9dd4888600e334e7a33623f15fa360100000000000000fe240e80ff8a48a77947b394979cf361017cd906ddaab637d72cf72e729d79bf010000000000000006854c73f5703242d31d2576ac2297c93f0b5dc16ade0097c59d5dc0faa43c550100000000000000c650b1a6b34347bd80ed06b48aa4ae1a33adaa507e8ac23bf6c6b94223b63b9d01000000000000008aabd4f6d7ecec7a749c83fc7be33f3b4818cca6f93a4927b4964900df9454e50100000000000000b9186b95c90d2d00a31e7c68066bd37d73408271762604e3608e2f2c983f830901000000000000003948bfd09bbbc2fe6ac5dfe53146e32df50828eecf7b2b18cdcff8dc385cbd7501000000000000001ba602a293ccdb7a77042fb486c6e010d48b13dff2bef0a26c53637312aac7f70100000000000000ba8180cbc0dceb098ee6b22fe89978bf92ebf196a280470b1501bc2138ec02c70100000000000000f6373ec61f3d99dfcd0bcc6a2b5ddb7e9c8a7d8e5777aa58bc2ac949315dee250100000000000000dc1427d14e83926d22f6be25d1bd39cbc82a194f5e9373ecae644f156ae9c62e010000000000000003d105a30087d96b5f0684f6ded76f826b01dab61e4136e1d851a24f0088b5ed010000000000000020d4e595c50bb9558dad9be6a8784492bbbfc754b9c5fae17edf4f8a84e8b47101000000000000006ba031ff146af5199eeb335a4a9c2fd487685a489e1a154ba1d012e965fdd5ba0100000000000000608f61824d3ae16d443cd0fec15c18590c890d4105e9402cad8743fb423e52b401000000000000000ccee96768f9b1d29d5bd9e63afd2be78a90cc89d19653ff1910cb36000b48530100000000000000818a546c630b881c2161588866965649678cda0f4110cccc3533d0f20e5e41200100000000000000088f8736e1cf2ea3d102f0a96ccf51222b8aa1f93d8e42947892f4395cb5477c0100000000000000c3ff25a1743a9df92af4ccd9a7aed5cbc90f64fd538c3df0a9539128f596526701000000000000004e3fbLine truncated
"babeEpochChanges": "0x048524e13c03dabdfcd58bf3a783eb3f8af9f3beb1f83bf64f1edc5661ddbdcc76f44d260101f382f41000000000538cf4100000000004e49e35131f3b10c66f75045405b11e5742a400edb67f0fde4bcfc7a4d70839d94857260101538cf41000000000b395f41000000000048974cd9ebacb99e3425c068b00ff967287bafef687494d06c649cb83d42311079460260101b395f41000000000139ff4100000000000000c8524e13c03dabdfcd58bf3a783eb3f8af9f3beb1f83bf64f1edc5661ddbdcc76f44d260101891f000000000000f382f410000000006009000000000000a50474a0fc84f72a4a9b8493379b7dfc59ca58a261a2e94997600d14b6b444c1475901000000000000009c40155989f6072e82caba245d7db7e40a60f866b403257976b89aba6be2b55b010000000000000014b0a3a620f70ada506d6ef1b7ab099219f2f05689523af7eebc81f9ba258e6001000000000000007067d4c5b492b11e2052a2bb0b4f729a52b3667afbca7dfefa863011254b5272010000000000000072ab87b654d80294c876cbefb534b3344c2f64159b015b89221331ec2145417501000000000000008008c1b7061a2402634fc15d3849e2913863beb9f55024bc8cc7fa7d6e397817010000000000000024a51a9bdb67213626d1b52bd8dbc0e9b94ea88ea417aa17b56212d1cea3e1780100000000000000488d520146f681678e9d229f5e29354edf65e521246b28a4175c0502e060b9200100000000000000c681c1acaa82eddba6e394ddc9a2fd1af34418448d544c34966a31c837667f28010000000000000020352ba0565811731625a8001d26f5d899e5856dedd0f9c6bc3bec2995704e5b01000000000000009cb389c209afbebda2b12113e0266b3d30f46e2a91aaf4451c193d640288357101000000000000004c9886e2e62ee92a6778d6a7928052732044b64fa61969cd8e37f3f7e3406f7201000000000000000c78c9dfc0033ff87657c56b7ab8cec4d1249be2de18729f743f385343af0f160100000000000000da541448a6094ef017385fa5492aefcc1880f3182fc1db64e551143604dcdc00010000000000000060f472588bedcbf6b27b576dcf2ac751e412b377a39fa82bc2b79f72ac9373140100000000000000002e496e564f088a075525d2f9155aadd1a7eb017fa36f9e16096e9db7e169330100000000000000e07afc6e4b429df62183d1e1c417703cf8467e0f1bc61f7e33954d8336c7a9350100000000000000f6dddaaaa53b57763610037753656b591d90fa81efbadcabbeddf7378c23602701000000000000003e69835397599a4bf081775f9f42f0f4ee686d67c9af8eacc4a733fdcdb0290b0100000000000000c48c594bb4e173544a0379055b65d995af53256f653d04f2cf4fdf8f35489439010000000000000024d917b35ee19a72512caea1dbf92fa75f5ac2c247c4a0184d330f477c750543010000000000000000b84e6e296de1009aeca95ee09bc5173aec6e91b1145b247d69e477588789720100000000000000466c0e97d043a4b0f4c3ac4849e11f901e9b31b28f8b3e40b7cdb0ba7f7748080100000000000000aac890275190872d403950ad91e6c6c18538b3d1d65f63609e7317bf1869b40f0100000000000000e67c524e443cda4cd27dfcce70488a5d23a93c8c46a5e83ef5a69eff3a02fa5a010000000000000024a57db63b380456d56d561d8a9da6db13d298045c9672bc4086a2e0a567d55c01000000000000006c50859d9dde209012eb3868c1a3a6e80ae8fa528ace9df68e92dbbae60368200100000000000000a8e470f2339e3ed0da456780dd9207e9c6a02459238ec3057a6ade01fd6cd60a01000000000000007c5f58a83f8101943c089dba3ab906c07811e853444aa58dbcc986c4095fbe7c01000000000000005494142902284943201b7cf610306e8665eeeec87c014d607175c3f50f76103b010000000000000072ed7192625403acef94aa9189f9f179deb89e60478816ca96c79b742f757e750100000000000000d8f30bc2ee88e69f60d0278998414c80f4a130b8e1738e873bcd14ef31e58d36010000000000000042e377034ce6b2a582bfd66c465252ab10ce790e4f0d3bbe99a42ff86b29965c01000000000000007e91ca522b14cbb71b45348c699b7d65c3198516ee771079b672ee3d7cfc577501000000000000004e2753547f6ec0a896bcbc55b9eeab875e8019acdeb10b979210af63f24c4b740100000000000000f44300f7ca18c59e32cb7d396a17c4c3b2a56bdd4aadc93b55922bb94a114a4c010000000000000042e7851b82d8b7722b9eeb5eead57b21bf533fd25acb10542a52889376fc3920010000000000000028ce9c093ac772f56acb8dfe8b33a3966d4b8699bd41814117352d397195bd5f010000000000000042ad4ba7e8a60af1abcee04fdd82ad02b24f1e2535bdb1abcdde886efbf0fc4301000000000000006ec27dfa7ac9d35eb002c55d3e4d56b4df928dd5c44323ac228305741c9e09360100000000000000b89cbc83a386d6f5d4fed93289ee50fdf69d77369ca0c9a8b962554e3fc0d37e0100000000000000e61da4eefdd14434952c58dd1943f7f63185d03321ccc8835e4216badd16fc19010000000000000012a64d79e44f1adb33c85c4f2bdfcd8d8b38a34d984604f39289c9a7624a442d01000000000000009214538470b98cfa7437e630ad2f26ee55bfbd270c0a72d38e26c4f48e049d130100000000000000a20797f3a8669a909adb22a3aee2844dba82d231cc33f5d9be0e2c533cb82a670100000000000000e297620b731b4958e3c6aa06611c6aa5a45f7e116362d64954a0a330d2a98f330100000000000000dc1274e0689c7a3eac31b41ce352719529e65c01f26999f74ce17c9905fce87401000000000000000e5e5f8e89cd8d58ef83abddd3d1c2079691dec4f6965af70436e84411c31f3901000000000000005c0494412a296a92296160ac510697d97288753829a5e9d02eafb5f101e60f5101000000000000007c21799f6143fa837a8c18bebe3368d60f4e009b114f61490b54e6344034040d01000000000000009a6223b8a7aac3a28f958d9f6c6abf55f87a38cd22fa563d6327a4d86da7b64d01000000000000006ca924ff8f8e69b8ea54dc988c67fbfc1d955f357f01e5ff4b8362ad7d756c3701000000000000009e280c8deea88069fe5118eefbb994d01373ff5dc213a65d06e6873b528f6c2f01000000000000002834c706b030a82a81ec43e2faf26a7d00392e1d8f2de8b7a876183ab612cb180100000000000000d0189a530b4048501596c4530054fe89f017360402da0ac197a8100ac693b06e01000000000000000aaa5fa196c5c2583c1cec2aa1c991b582fd819d8bd74e91ab76da894c4a0e3b010000000000000006ced0dafbe316bc507cfa57f506a58ad57bLine truncated
"babeFinalizedBlockWeight": 4816932,
"finalizedBlockHeader": "0xf292bdff983836444cd51784c192c3925d734c7936f309581c817f9f74c51d380e8b9904f4fb3330f79ddda3ffbbce59c7b93774122fe32463d7de711ffc820fa69508525cb2b1a9b578fa9e8dd457f2c904649d00557bb1724bb8d7b313e9a1211eccdd080642414245b501015c000000878ef41000000000c4d48a2a2e5364af41319264fee671a26023eebdb6d98a1687466dc44e8fb239263e94e02749bd0e7c63a41103dd01d531405bf5e18d535a9553bd14816aa7047c2019652e0c689625fb677b0f43de704da3daa485ad1d8a0a1b3b754bdcab0e054241424501017659dc71591dfa2561e074163f1aca684a515928b07bbf63f300beabd8d8b4720ee75fa0a487f1e7ef90840e0caaed103e489eec9a1a3b4f70aff8c76e6e6982",
"grandpaAuthoritySet": "0xa5042f8da08bb2421ef844015c3b2ea23464fc66a9dcb4a2215fe0241f892d19afc50100000000000000fff437ff18629bf1490e5c9b3ec6f1515d46bb9b2aeaa6e39e36611f2479b50d01000000000000000334021ff54e46fb7da4bd257cf113519a0c7ee4a2251b66fe48466fed5853520100000000000000d95f04dc8ea4ac05deea7077457f0406fdd152bd03a7480e7d0de0983b959d3c010000000000000047f940bc985355be7187c709ded2b689b66d69e61e293a507f1d4f90bdbeceee01000000000000004a3fc0fe1020c7f460c7bd23d0b657c03368552b2f0a12d80a1c406fd066e0db01000000000000009b992b5e9b99eb2cd3b2b648d6db81ed722a2feb4938d998b58dcb5d159fadfa0100000000000000aee9de3938173700b3e3f4fbf2b200ae296173a0854157f40de2598dd4cad8f10100000000000000243f110deac5efe8e963d794eb8706a1895ae1942523ab0fe9e1623515b7dea80100000000000000b61e9b13e849779be8f5378a670d61991875d8e091f359384d7be73d02d506930100000000000000426b2be4596a759a15028d84e08c5c56440e6cede68d088f47c671cc3387c3e6010000000000000070ba6e5985990ba1b1392713236f1b50df750f10f744cc6eb95fa7c5cfbc687601000000000000005b27660cd4c375f2654c6d923b29fd8abbab7e96ee040c79598be14f832f56ca0100000000000000d3cc98d4ef2959052d0850c5803739a81b4fb31196cb8602c45e19a7a56977cf0100000000000000577f3db377f6b69115658f17f32323071b8e0c67695057353d0ad9ad2d8eea1a010000000000000057ae0c85ebaf333a6ec3251f577cab910cce072f238d1e50046322b83bbc0dd50100000000000000a15896b8bbf01f757f120813bc2e78b21388eea66db4b0dc2e1afeabd3d46dc001000000000000000139b946b46bee4c61be50c986f2a9ef2e76917644e2ecd842c59d61a94ee612010000000000000019a9d56ea35496122fc44fcb5c29d27fbb43520556d6f8d97753767aaa0f228e01000000000000007cd50f6921fade39653f847bddd48360668004225081a6a3ad7997f78debd34c0100000000000000f1578b8007e34ba6b1c4c480a8249758eaa356a6e5b1be0efbe5c35e802fe3cf0100000000000000a5b094ae7c156592baa68ce18dab6368d5b665e9a0f07dfc5f54f58309e086c1010000000000000053352e16d2a27fb3525d5d8750d6ad7f46b303a45e434a409ac727d5cb80432b0100000000000000f2c819e8ed3ae8aab35a7edb7d21cabc889eb5928dd6a5281b42f3b00f808e1b010000000000000041ef4a31eb7dc1e01f4630604e1908e644d7cdee3f66a60f98d6d59605326f8b010000000000000097743d6364cdb6c4790cd37c4c2ab5fbc6c65e8bb606625e70a6ee04ed1650d9010000000000000008cc1d6c743da905511a39a6f0a68809a6bc32f8ac25e53bb2d6aca4f493fc9b0100000000000000acd71d4269b3ba2a9de822d494c4d841708e1519c08de41d7fc6153eaf48da810100000000000000d04d64a07f144638f20f081de122b88fed0cc8bda57e4810e7afb38036dd8bbf0100000000000000f26945a8a64032a1defa76e720a99649125b55751b6088205e7acab901de670b01000000000000005cba2c6f569da1edc3778308da406f266aa53140381dbb3f14f22909ba6e30040100000000000000c9a741ab82126c4d4eaa6a758cfc1209bbd7b29330e89ccd97fb62ae567c8d4301000000000000009b94bc45bf79bb33f70430c82880456cd7bd5fb3ea131c1b26d493d01c5fe7100100000000000000a1a9debad5e4afb076cf293c2c797f0b5901ffdb8bd01611235e762411a0db3901000000000000006f4855725ebb9eced957bae43ffa7d30657ce7d06b251ce20e2218bcf929e40501000000000000001165cac368b7336c0dfd184027e03ae2945761538b05365611ad4d731f4917fc0100000000000000749556da4a259bc1f0b8ea8e3726c2251656b92205c30b635ec9f42038f8defb01000000000000000ce4d93e25fa5302f4b059456f680047f87be428ae88579e0b862502b5ceed600100000000000000c1758f7cbffeb844419bc494a9dc65fb394259f01e9bf23789a75acc29d7d9620100000000000000c1c1ff5f66fefb5c0849e3b2333411d1f7e9dd4888600e334e7a33623f15fa360100000000000000fe240e80ff8a48a77947b394979cf361017cd906ddaab637d72cf72e729d79bf010000000000000006854c73f5703242d31d2576ac2297c93f0b5dc16ade0097c59d5dc0faa43c550100000000000000c650b1a6b34347bd80ed06b48aa4ae1a33adaa507e8ac23bf6c6b94223b63b9d01000000000000000d2892cca10a62c24727ffacba6a57b1a35b0dea5c9d82d7d6c971e2335ced7001000000000000008aabd4f6d7ecec7a749c83fc7be33f3b4818cca6f93a4927b4964900df9454e50100000000000000b9186b95c90d2d00a31e7c68066bd37d73408271762604e3608e2f2c983f830901000000000000003948bfd09bbbc2fe6ac5dfe53146e32df50828eecf7b2b18cdcff8dc385cbd7501000000000000001ba602a293ccdb7a77042fb486c6e010d48b13dff2bef0a26c53637312aac7f701000000000000002385953f1ac49461b9c243159d9668b26e7322e19fff7bc18d90634f0f767ce80100000000000000ba8180cbc0dceb098ee6b22fe89978bf92ebf196a280470b1501bc2138ec02c70100000000000000070bae15860ce96e4a0cbdcc051c75e37a458c8e6c5ae59681d0ed938e588d4501000000000000003ec37919f9f43a9f85f539edfde3ceebea1b0e8279cb036641d588a9da81a6ad01000000000000005e48598ca89db19a4c279a251216d81e33f6b69e7d2ab4450968a1f9409df4a30100000000000000f510cb6c7032c9134dd3e50014ff6d391cfc91606d003fd4acd37e00f919d8350100000000000000cbd74a646a84b73518eadc73b1983dc9733839739576af9a98c698070a3a4b590100000000000000950459187f6d368ccf940574b1fad05f88aea3303858daaae072443b219410a90100000000000000d2e72b0ab02a001b2e573c0d3b78404a7d3c600c3a9fd8ef38e823cad6ed3d6601000000000000003047f8f7e9c47fda9130ccd57d5dc8d407bd89b8dcf8ecbaccf00da184c73a570100000000000000024743c39cd9e151344dc23c65ee0346132d190a224b687be5c5ae31c5e7bb0a01000000000000004e3fb8c16ad624c1852777456805e5352d0221269de66949c95da4076206b35a010000000000000069a6c84df1d25f855b91040e113a5557da8a89d80644ae7bf8d0ba416ab89b6d0100000000000000cb92ffeace78dbafe6fbf275741b4b38657fb81590712aa0bca7877931f6ad390100000000000000997b3Line truncated
},
"name": "Polkadot",
"properties": {
Binary file not shown.
Binary file not shown.
Binary file not shown.
+83 -30
View File
@@ -43,6 +43,8 @@ pub enum FromSubxt {
Subscription {
/// The method of the request.
method: String,
/// The method to unsubscribe.
unsubscribe_method: String,
/// The parameters of the request.
params: String,
/// Channel used to send back the subscription ID if successful.
@@ -69,18 +71,40 @@ pub struct BackgroundTask<TPlatform: PlatformRef, TChain> {
/// The RPC method request is made in the background and the response should
/// not be sent back to the user.
/// Map the request ID of a RPC method to the frontend `Sender`.
id_to_subscription: HashMap<
(usize, smoldot_light::ChainId),
(
oneshot::Sender<MethodResponse>,
mpsc::UnboundedSender<Box<RawValue>>,
),
>,
id_to_subscription: HashMap<(usize, smoldot_light::ChainId), PendingSubscription>,
/// Map the subscription ID to the frontend `Sender`.
///
/// The subscription ID is entirely generated by the node (smoldot). Therefore, it is
/// possible for two distinct subscriptions of different chains to have the same subscription ID.
subscriptions: HashMap<(usize, smoldot_light::ChainId), mpsc::UnboundedSender<Box<RawValue>>>,
subscriptions: HashMap<(usize, smoldot_light::ChainId), ActiveSubscription>,
}
/// The state needed to resolve the subscription ID and send
/// back the response to frontend.
struct PendingSubscription {
/// Send the method response ID back to the user.
///
/// It contains the subscription ID if successful, or an JSON RPC error object.
sub_id_sender: oneshot::Sender<MethodResponse>,
/// The subscription state that is added to the `subscriptions` map only
/// if the subscription ID is successfully sent back to the user.
subscription_state: ActiveSubscription,
}
impl PendingSubscription {
/// Transforms the pending subscription into an active subscription.
fn into_parts(self) -> (oneshot::Sender<MethodResponse>, ActiveSubscription) {
(self.sub_id_sender, self.subscription_state)
}
}
/// The state of the subscription.
struct ActiveSubscription {
/// Channel to send the subscription notifications back to frontend.
sender: mpsc::UnboundedSender<Box<RawValue>>,
/// The unsubscribe method to call when the user drops the receiver
/// part of the channel.
unsubscribe_method: String,
}
impl<TPlatform: PlatformRef, TChain> BackgroundTask<TPlatform, TChain> {
@@ -152,6 +176,7 @@ impl<TPlatform: PlatformRef, TChain> BackgroundTask<TPlatform, TChain> {
}
FromSubxt::Subscription {
method,
unsubscribe_method,
params,
sub_id,
sender,
@@ -166,8 +191,15 @@ impl<TPlatform: PlatformRef, TChain> BackgroundTask<TPlatform, TChain> {
);
tracing::trace!(target: LOG_TARGET, "Tracking subscription request id={id} chain={chain_id:?}");
let subscription_id_state = PendingSubscription {
sub_id_sender: sub_id,
subscription_state: ActiveSubscription {
sender,
unsubscribe_method,
},
};
self.id_to_subscription
.insert((id, chain_id), (sub_id, sender));
.insert((id, chain_id), subscription_id_state);
let result = self.client.json_rpc_request(request, chain_id);
if let Err(err) = result {
@@ -176,13 +208,14 @@ impl<TPlatform: PlatformRef, TChain> BackgroundTask<TPlatform, TChain> {
"Cannot send RPC request to lightclient {:?}",
err.to_string()
);
let (sub_id, _) = self
let subscription_id_state = self
.id_to_subscription
.remove(&(id, chain_id))
.expect("Channels are inserted above; qed");
// Send the error back to frontend.
if sub_id
if subscription_id_state
.sub_id_sender
.send(Err(LightClientRpcError::Request(err.to_string())))
.is_err()
{
@@ -219,10 +252,11 @@ impl<TPlatform: PlatformRef, TChain> BackgroundTask<TPlatform, TChain> {
"Cannot send method response to id={id} chain={chain_id:?}",
);
}
} else if let Some((sub_id_sender, _)) =
} else if let Some(subscription_id_state) =
self.id_to_subscription.remove(&(id, chain_id))
{
if sub_id_sender
if subscription_id_state
.sub_id_sender
.send(Err(LightClientRpcError::Request(error.to_string())))
.is_err()
{
@@ -247,7 +281,7 @@ impl<TPlatform: PlatformRef, TChain> BackgroundTask<TPlatform, TChain> {
"Cannot send method response to id={id} chain={chain_id:?}",
);
}
} else if let Some((sub_id_sender, sender)) =
} else if let Some(pending_subscription) =
self.id_to_subscription.remove(&(id, chain_id))
{
let Ok(sub_id) = result
@@ -265,15 +299,19 @@ impl<TPlatform: PlatformRef, TChain> BackgroundTask<TPlatform, TChain> {
tracing::trace!(target: LOG_TARGET, "Received subscription id={sub_id} chain={chain_id:?}");
let (sub_id_sender, active_subscription) = pending_subscription.into_parts();
if sub_id_sender.send(Ok(result)).is_err() {
tracing::warn!(
target: LOG_TARGET,
"Cannot send method response to id={id} chain={chain_id:?}",
);
} else {
// Track this subscription ID if send is successful.
self.subscriptions.insert((sub_id, chain_id), sender);
return;
}
// Track this subscription ID if send is successful.
self.subscriptions
.insert((sub_id, chain_id), active_subscription);
} else {
tracing::warn!(
target: LOG_TARGET,
@@ -287,22 +325,37 @@ impl<TPlatform: PlatformRef, TChain> BackgroundTask<TPlatform, TChain> {
return;
};
if let Some(sender) = self.subscriptions.get_mut(&(id, chain_id)) {
// Send the current notification response.
if sender.send(result).is_err() {
tracing::warn!(
target: LOG_TARGET,
"Cannot send notification to subscription id={id} chain={chain_id:?} method={method}",
);
// Remove the sender if the subscription dropped the receiver.
self.subscriptions.remove(&(id, chain_id));
}
} else {
let Some(subscription_state) = self.subscriptions.get_mut(&(id, chain_id)) else {
tracing::warn!(
target: LOG_TARGET,
"Subscription response id={id} chain={chain_id:?} is not tracked",
"Subscription response id={id} chain={chain_id:?} method={method} is not tracked",
);
return;
};
if subscription_state.sender.send(result).is_ok() {
// Nothing else to do, user is informed about the notification.
return;
}
// User dropped the receiver, unsubscribe from the method and remove internal tracking.
let Some(subscription_state) = self.subscriptions.remove(&(id, chain_id)) else {
// State is checked to be some above, so this should never happen.
return;
};
// Make a call to unsubscribe from this method.
let unsub_id = self.next_id(chain_id);
let request = format!(
r#"{{"jsonrpc":"2.0","id":"{}", "method":"{}","params":["{}"]}}"#,
unsub_id, subscription_state.unsubscribe_method, id
);
if let Err(err) = self.client.json_rpc_request(request, chain_id) {
tracing::warn!(
target: LOG_TARGET,
"Failed to unsubscribe id={id:?} chain={chain_id:?} method={:?} err={err:?}", subscription_state.unsubscribe_method
);
} else {
tracing::debug!(target: LOG_TARGET,"Unsubscribe id={id:?} chain={chain_id:?} method={:?}", subscription_state.unsubscribe_method);
}
}
Err(err) => {
+2
View File
@@ -179,6 +179,7 @@ impl LightClientRpc {
&self,
method: String,
params: String,
unsubscribe_method: String,
) -> Result<
(
oneshot::Receiver<MethodResponse>,
@@ -191,6 +192,7 @@ impl LightClientRpc {
self.to_backend.send(FromSubxt::Subscription {
method,
unsubscribe_method,
params,
sub_id,
sender,
+2 -2
View File
@@ -124,14 +124,14 @@ impl PlatformRef for SubxtPlatform {
port,
} => {
let addr = SocketAddr::from((ip, port));
format!("ws://{}", addr.to_string())
format!("ws://{}", addr)
}
Address::WebSocketIp {
ip: IpAddr::V6(ip),
port,
} => {
let addr = SocketAddr::from((ip, port));
format!("ws://{}", addr.to_string())
format!("ws://{}", addr)
}
// The API user of the `PlatformRef` trait is never supposed to open connections of
+1 -1
View File
@@ -111,7 +111,7 @@ impl WasmSocket {
let mut inner = inner.lock().expect("Mutex is poised; qed");
let bytes = js_sys::Uint8Array::new(&buffer).to_vec();
inner.data.extend(bytes.into_iter());
inner.data.extend(bytes);
if let Some(waker) = inner.waker.take() {
waker.wake();
-1
View File
@@ -24,7 +24,6 @@ codec = { package = "parity-scale-codec", workspace = true, default-features = f
sp-core-hashing = { workspace = true }
hashbrown = { workspace = true }
derive_more = { workspace = true }
cfg-if = { workspace = true }
[dev-dependencies]
bitvec = { workspace = true, features = ["alloc"] }
+1 -2
View File
@@ -2,9 +2,8 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::prelude::*;
use alloc::string::String;
use derive_more::Display;
use string::String;
mod v14;
mod v15;
+6 -6
View File
@@ -3,15 +3,15 @@
// see LICENSE for license details.
use super::TryFromError;
use crate::prelude::*;
use crate::Metadata;
use borrow::ToOwned;
use fmt::Write;
use alloc::borrow::ToOwned;
use alloc::string::String;
use alloc::vec;
use alloc::vec::Vec;
use core::fmt::Write;
use frame_metadata::{v14, v15};
use hashbrown::HashMap;
use scale_info::TypeDef;
use string::String;
use vec::Vec;
impl TryFrom<v14::RuntimeMetadataV14> for Metadata {
type Error = TryFromError;
@@ -372,7 +372,7 @@ fn generate_outer_error_enum_type(
return None;
};
// Note: using the `format!` macro like in `let path = format!("{}Error", pallet.name);`
// Note: using the `alloc::format!` macro like in `let path = format!("{}Error", pallet.name);`
// leads to linker errors about extern function `_Unwind_Resume` not being defined.
let mut path = String::new();
write!(path, "{}Error", pallet.name).expect("Cannot panic, qed;");
+2 -2
View File
@@ -3,7 +3,7 @@
// see LICENSE for license details.
use super::TryFromError;
use crate::prelude::*;
use crate::utils::variant_index::VariantIndex;
use crate::{
utils::ordered_map::OrderedMap, ArcStr, ConstantMetadata, ExtrinsicMetadata, Metadata,
@@ -11,7 +11,7 @@ use crate::{
RuntimeApiMethodParamMetadata, SignedExtensionMetadata, StorageEntryMetadata,
StorageEntryModifier, StorageEntryType, StorageHasher, StorageMetadata,
};
use borrow::ToOwned;
use alloc::borrow::ToOwned;
use frame_metadata::v15;
use hashbrown::HashMap;
use scale_info::form::PortableForm;
+6 -6
View File
@@ -17,18 +17,18 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![deny(missing_docs)]
extern crate alloc;
mod from_into;
mod prelude;
mod utils;
use alloc::string::String;
use alloc::sync::Arc;
use alloc::vec::Vec;
use hashbrown::HashMap;
use prelude::*;
use scale_info::{form::PortableForm, PortableRegistry, Variant};
use string::String;
use sync::Arc;
use utils::variant_index::VariantIndex;
use utils::{ordered_map::OrderedMap, validation::outer_enum_hashes::OuterEnumHashes};
use vec::Vec;
type ArcStr = Arc<str>;
@@ -205,7 +205,7 @@ impl Metadata {
// its name to ensure that every unique type has a unique path, too.
if *visited_count > 1 {
if let Some(name) = ty.ty.path.segments.last_mut() {
*name = format!("{name}{visited_count}");
*name = alloc::format!("{name}{visited_count}");
}
}
}
-59
View File
@@ -1,59 +0,0 @@
// Copyright 2019-2023 Parity Technologies (UK) Ltd.
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
#[cfg(not(feature = "std"))]
extern crate alloc;
use cfg_if::cfg_if;
cfg_if! {
if #[cfg(feature = "std")] {
#[allow(unused)]
pub use std::{
any,
borrow,
boxed,
cmp,
collections,
fmt,
format,
hash,
marker,
mem,
num,
ops,
string,
sync,
time,
vec,
rc,
iter,
};
} else {
#[allow(unused)]
pub use alloc::{
borrow,
boxed,
collections,
format,
string,
sync,
vec,
rc
};
#[allow(unused)]
pub use core::{
any,
cmp,
fmt,
hash,
marker,
mem,
num,
ops,
time,
iter,
};
}
}
+6 -6
View File
@@ -2,9 +2,9 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::prelude::*;
use alloc::vec::Vec;
use core::mem;
use hashbrown::HashMap;
use vec::Vec;
/// A minimal ordered map to let one search for
/// things by key or get the values in insert order.
@@ -25,7 +25,7 @@ impl<K, V> Default for OrderedMap<K, V> {
impl<K, V> OrderedMap<K, V>
where
K: PartialEq + Eq + hash::Hash,
K: PartialEq + Eq + core::hash::Hash,
{
/// Create a new, empty [`OrderedMap`].
pub fn new() -> Self {
@@ -80,8 +80,8 @@ where
/// Get an item by its key.
pub fn get_by_key<Q>(&self, key: &Q) -> Option<&V>
where
K: borrow::Borrow<Q>,
Q: hash::Hash + Eq + ?Sized,
K: alloc::borrow::Borrow<Q>,
Q: core::hash::Hash + Eq + ?Sized,
{
self.map.get(key).and_then(|&v| self.values.get(v))
}
@@ -109,7 +109,7 @@ where
impl<K, V> FromIterator<(K, V)> for OrderedMap<K, V>
where
K: PartialEq + Eq + hash::Hash,
K: PartialEq + Eq + core::hash::Hash,
{
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self {
let mut map = OrderedMap::new();
+1 -2
View File
@@ -4,12 +4,11 @@
//! Utility functions to generate a subset of the metadata.
use crate::prelude::*;
use crate::{
ExtrinsicMetadata, Metadata, OuterEnumsMetadata, PalletMetadataInner, RuntimeApiMetadataInner,
StorageEntryType,
};
use collections::BTreeMap;
use alloc::collections::BTreeMap;
use hashbrown::HashSet;
use scale_info::TypeDef;
+1 -2
View File
@@ -4,15 +4,14 @@
//! Utility functions for metadata validation.
use crate::prelude::*;
use crate::{
CustomMetadata, CustomValueMetadata, ExtrinsicMetadata, Metadata, PalletMetadata,
RuntimeApiMetadata, RuntimeApiMethodMetadata, StorageEntryMetadata, StorageEntryType,
};
use alloc::vec::Vec;
use hashbrown::HashMap;
use outer_enum_hashes::OuterEnumHashes;
use scale_info::{form::PortableForm, Field, PortableRegistry, TypeDef, TypeDefVariant, Variant};
use vec::Vec;
pub mod outer_enum_hashes;
+4 -5
View File
@@ -2,11 +2,10 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::prelude::*;
use borrow::ToOwned;
use alloc::borrow::ToOwned;
use alloc::string::String;
use hashbrown::HashMap;
use scale_info::{form::PortableForm, PortableRegistry, TypeDef, Variant};
use string::String;
/// Given some type ID and type registry, build a couple of
/// indexes to look up variants by index or name. If the ID provided
@@ -65,8 +64,8 @@ impl VariantIndex {
types: &'a PortableRegistry,
) -> Option<&'a Variant<PortableForm>>
where
String: borrow::Borrow<K>,
K: hash::Hash + Eq + ?Sized,
String: alloc::borrow::Borrow<K>,
K: core::hash::Hash + Eq + ?Sized,
{
let pos = *self.by_name.get(name)?;
let variants = Self::get(variant_id, types)?;
+3 -3
View File
@@ -10,7 +10,7 @@ use substrate_runner::SubstrateNode;
/// Run with `cargo run --bin artifacts` from the root of the repository.
fn main() {
let mut node_builder = SubstrateNode::builder();
node_builder.binary_paths(["substrate-node", "substrate"]);
node_builder.polkadot();
// Spawn the node and retrieve a ws URL to it:
let proc = node_builder
@@ -37,13 +37,13 @@ fn main() {
// Generate a metadata file that only contains a few pallets that we need for our examples.
run_cmd(
r#"cargo run --bin subxt metadata --file artifacts/polkadot_metadata_full.scale --pallets "Balances,Staking,System,Multisig,Timestamp,ParaInherent""#,
"cargo run --bin subxt metadata --file artifacts/polkadot_metadata_full.scale --pallets Balances,Staking,System,Multisig,Timestamp,ParaInherent",
Some("artifacts/polkadot_metadata_small.scale"),
);
// Generate a metadata file that contains no pallets
run_cmd(
r#"cargo run --bin subxt metadata --file artifacts/polkadot_metadata_full.scale --pallets """#,
"cargo run --bin subxt metadata --file artifacts/polkadot_metadata_full.scale --pallets \"\"",
Some("artifacts/polkadot_metadata_tiny.scale"),
);
+14 -2
View File
@@ -24,11 +24,23 @@ default = ["jsonrpsee", "native"]
# Enable this for native (ie non web/wasm builds).
# Exactly 1 of "web" and "native" is expected.
native = ["jsonrpsee?/async-client", "jsonrpsee?/client-ws-transport-native-tls", "subxt-lightclient?/native", "tokio-util"]
native = [
"jsonrpsee?/async-client",
"jsonrpsee?/client-ws-transport-native-tls",
"subxt-lightclient?/native",
"tokio-util"
]
# Enable this for web/wasm builds.
# Exactly 1 of "web" and "native" is expected.
web = ["jsonrpsee?/async-wasm-client", "jsonrpsee?/client-web-transport", "getrandom/js", "subxt-lightclient?/web", "subxt-macro/web", "instant/wasm-bindgen"]
web = [
"jsonrpsee?/async-wasm-client",
"jsonrpsee?/client-web-transport",
"getrandom/js",
"subxt-lightclient?/web",
"subxt-macro/web",
"instant/wasm-bindgen"
]
# Enable this to use jsonrpsee (allowing for example `OnlineClient::from_url`).
jsonrpsee = ["dep:jsonrpsee"]
+4 -7
View File
@@ -6,11 +6,13 @@ use super::{rpc::LightClientRpc, LightClient, LightClientError};
use crate::backend::rpc::RpcClient;
use crate::client::RawLightClient;
use crate::macros::{cfg_jsonrpsee_native, cfg_jsonrpsee_web};
use crate::utils::validate_url_is_secure;
use crate::{config::Config, error::Error, OnlineClient};
use std::num::NonZeroU32;
use subxt_lightclient::{smoldot, AddedChain};
#[cfg(feature = "jsonrpsee")]
use crate::utils::validate_url_is_secure;
/// Builder for [`LightClient`].
#[derive(Clone, Debug)]
pub struct LightClientBuilder<T: Config> {
@@ -186,16 +188,11 @@ impl<T: Config> LightClientBuilder<T> {
}
/// Raw builder for [`RawLightClient`].
#[derive(Default)]
pub struct RawLightClientBuilder {
chains: Vec<AddedChain>,
}
impl Default for RawLightClientBuilder {
fn default() -> Self {
Self { chains: Vec::new() }
}
}
impl RawLightClientBuilder {
/// Create a new [`RawLightClientBuilder`].
pub fn new() -> RawLightClientBuilder {
+3 -4
View File
@@ -56,8 +56,7 @@ impl LightClientRpc {
pub fn new(
config: smoldot::AddChainConfig<'_, (), impl Iterator<Item = smoldot::ChainId>>,
) -> Result<LightClientRpc, Error> {
let rpc = subxt_lightclient::LightClientRpc::new(config)
.map_err(|err| LightClientError::Rpc(err))?;
let rpc = subxt_lightclient::LightClientRpc::new(config).map_err(LightClientError::Rpc)?;
Ok(LightClientRpc(rpc))
}
@@ -106,7 +105,7 @@ impl RpcClientT for LightClientRpc {
&'a self,
sub: &'a str,
params: Option<Box<RawValue>>,
_unsub: &'a str,
unsub: &'a str,
) -> RawRpcFuture<'a, RawRpcSubscription> {
let client = self.clone();
let chain_id = self.chain_id();
@@ -130,7 +129,7 @@ impl RpcClientT for LightClientRpc {
// Fails if the background is closed.
let (sub_id, notif) = client
.0
.subscription_request(sub.to_string(), params)
.subscription_request(sub.to_string(), params, unsub.to_string())
.map_err(|_| RpcError::ClientError(Box::new(LightClientError::BackgroundClosed)))?;
// Fails if the background is closed.
File diff suppressed because it is too large. Load diff
@@ -258,5 +258,5 @@ async fn build_light_client<T: Config>(proc: &SubstrateNode) -> Result<LightClie
.bootnodes([bootnode.as_str()])
.build_from_url(ws_url.as_str())
.await
.map_err(|e| format!("Failed to construct light client {}", e.to_string()))
.map_err(|e| format!("Failed to construct light client {}", e))
}
-1
View File
@@ -709,7 +709,6 @@ dependencies = [
name = "subxt-metadata"
version = "0.34.0"
dependencies = [
"cfg-if",
"derive_more",
"frame-metadata 16.0.0",
"hashbrown",
+14 -2
View File
@@ -21,7 +21,7 @@ pub struct SubstrateNodeBuilder {
impl Default for SubstrateNodeBuilder {
fn default() -> Self {
Self::new()
SubstrateNodeBuilder::new()
}
}
@@ -29,11 +29,23 @@ impl SubstrateNodeBuilder {
/// Configure a new Substrate node.
pub fn new() -> Self {
SubstrateNodeBuilder {
binary_paths: vec!["substrate-node".into(), "substrate".into()],
binary_paths: vec![],
custom_flags: Default::default(),
}
}
/// Provide "substrate-node" and "substrate" as binary paths
pub fn substrate(&mut self) -> &mut Self {
self.binary_paths = vec!["substrate-node".into(), "substrate".into()];
self
}
/// Provide "polkadot" as binary path.
pub fn polkadot(&mut self) -> &mut Self {
self.binary_paths = vec!["polkadot".into()];
self
}
/// Set the path to the `substrate` binary; defaults to "substrate-node"
/// or "substrate".
pub fn binary_paths<Paths, S>(&mut self, paths: Paths) -> &mut Self