Skip to content

Commit

Permalink
Merge pull request #489 from paritytech/AndreiEres/without-features
Browse files Browse the repository at this point in the history
Get rid of features
  • Loading branch information
sandreim authored Aug 25, 2023
2 parents af0d2e1 + bb50ffe commit d8112a9
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 80 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/update_metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ jobs:
run: |
cargo install subxt-cli
subxt metadata --format bytes --url wss://rococo-rpc.polkadot.io:443 > essentials/assets/rococo_metadata.scale
subxt metadata --format bytes --url wss://kusama-rpc.polkadot.io:443 > essentials/assets/kusama_metadata.scale
subxt metadata --format bytes --url wss://rpc.polkadot.io:443 > essentials/assets/polkadot_metadata.scale
- name: Commit changes if PR exists
if: ${{ steps.checkout-pr.outputs.switched == 'true' }}
Expand Down
49 changes: 5 additions & 44 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,20 @@ fmt:
<<: *common-refs
script:
- time cargo +nightly fmt --all -- --check
# Remove me when pipeline stabilizes
allow_failure: true

clippy:
stage: lint
<<: *docker-env
<<: *common-refs
script:
- time cargo clippy --no-default-features --all-targets --features=rococo -- -D warnings
- time cargo clippy --no-default-features --all-targets --features=kusama -- -D warnings
- time cargo clippy --no-default-features --all-targets --features=polkadot -- -D warnings
# Remove me when pipeline stabilizes
allow_failure: true
- time cargo clippy --all-targets -- -D warnings

check:
stage: lint
<<: *docker-env
<<: *common-refs
script:
- time cargo check --no-default-features --all-targets --features=rococo --workspace
- time cargo check --no-default-features --all-targets --features=kusama --workspace
- time cargo check --no-default-features --all-targets --features=polkadot --workspace
- time cargo check --all-targets --workspace

#### stage: test

Expand All @@ -104,33 +96,9 @@ test:
script:
- ./scripts/ci/zombienet/zombie.sh setup
- ZOMBIE_WS_PORT=9900 ./scripts/ci/zombienet/zombie.sh run ./scripts/ci/zombienet/network.toml
- WS_URL=ws://127.0.0.1:9900 time cargo test --all-targets --no-default-features --features=rococo --workspace
- WS_URL=ws://127.0.0.1:9900 time cargo test --all-targets --no-default-features --features=kusama --workspace
- WS_URL=ws://127.0.0.1:9900 time cargo test --all-targets --no-default-features --features=polkadot --workspace
- WS_URL=ws://127.0.0.1:9900 time cargo test --all-targets --workspace
- ./scripts/ci/zombienet/zombie.sh shutdown


check-rococo-metadata:
stage: test
<<: *docker-env
<<: *common-refs
script:
- cargo run --features=rococo --bin polkadot-metadata-checker -- --ws=wss://rococo-rpc.polkadot.io:443

check-kusama-metadata:
stage: test
<<: *docker-env
<<: *common-refs
script:
- cargo run --features=kusama --bin polkadot-metadata-checker -- --ws=wss://kusama-rpc.polkadot.io:443

check-polkadot-metadata:
stage: test
<<: *docker-env
<<: *common-refs
script:
- cargo run --features=polkadot --bin polkadot-metadata-checker -- --ws=wss://rpc.polkadot.io:443

#### stage: build

build:
Expand All @@ -140,15 +108,8 @@ build:
<<: *collect-artifacts
script:
- mkdir ./artifacts || echo "dir exists"
- mkdir ./artifacts/rococo || echo "dir exists"
- mkdir ./artifacts/kusama || echo "dir exists"
- mkdir ./artifacts/polkadot || echo "dir exists"
- time cargo build --release --no-default-features --features=rococo
- cp target/release/{polkadot-block-time,polkadot-jaeger,polkadot-kvdb,polkadot-parachain-tracer,polkadot-whois} ./artifacts/rococo/
- time cargo build --release --no-default-features --features=kusama
- cp target/release/{polkadot-block-time,polkadot-jaeger,polkadot-kvdb,polkadot-parachain-tracer,polkadot-whois} ./artifacts/kusama/
- time cargo build --release --no-default-features --features=polkadot
- cp target/release/{polkadot-block-time,polkadot-jaeger,polkadot-kvdb,polkadot-parachain-tracer,polkadot-whois} ./artifacts/polkadot/
- time cargo build --release
- cp target/release/{polkadot-block-time,polkadot-jaeger,polkadot-kvdb,polkadot-parachain-tracer,polkadot-whois} ./artifacts/

# test that image can be built
build-docker:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ The tools utilize data sources such as [subxt](https://github.com/paritytech/sub

## Building

**TODO: the following information is outdated, needs to be edited.**

It is mandatory to specify which `Runtime` the build will target. Currently, the tools can only build for a single runtime version by enabling one of the following features:

- `rococo` - for Rococo and Versi test networks
Expand Down
5 changes: 0 additions & 5 deletions essentials/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,3 @@ tokio-tungstenite = { workspace = true }
typed-builder = { workspace = true }
url = { workspace = true }
warp = { workspace = true }

[features]
rococo = []
kusama = []
polkadot = []
2 changes: 2 additions & 0 deletions essentials/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This repository contains essential components for the Polkadot Introspector tool

## Updating or supporting a new `Runtime`

**TODO: the following information is outdated, needs to be edited.**

The `Runtime` version deployed on a network might be newer and incompatible with the metadata bundled in the repository. To check whether the metadata is up-to-date, we run [polkadot-metadata-checker](../metadata-checker/README.md) on our CI/CD pipelines. In case it fails, to bring the new metadata, we use [subxt-cli](https://github.com/paritytech/subxt/#downloading-metadata-from-a-substrate-node).

Here's an example of how to update the metadata:
Expand Down
Binary file removed essentials/assets/kusama_metadata.scale
Binary file not shown.
Binary file removed essentials/assets/rococo_metadata.scale
Binary file not shown.
5 changes: 0 additions & 5 deletions essentials/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,7 @@ mod tests {
use subxt::config::{substrate::BlakeTwo256, Hasher, Header};

fn rpc_node_url() -> &'static str {
#[cfg(feature = "rococo")]
const RPC_NODE_URL: &str = "wss://rococo-rpc.polkadot.io:443";
#[cfg(feature = "kusama")]
const RPC_NODE_URL: &str = "wss://kusama-rpc.polkadot.io:443";
#[cfg(feature = "polkadot")]
const RPC_NODE_URL: &str = "wss://rpc.polkadot.io:443";

if let Ok(url) = std::env::var("WS_URL") {
return Box::leak(url.into_boxed_str())
Expand Down
1 change: 0 additions & 1 deletion essentials/src/api/subxt_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ pub enum RequestType {
ExtractParaInherent(subxt::blocks::Block<PolkadotConfig, OnlineClient<PolkadotConfig>>),
/// Get the availability core scheduling information at a given block.
GetScheduledParas(<PolkadotConfig as subxt::Config>::Hash),
/// TODO: Fill
/// Get the claim queue scheduling information at a given block.
GetClaimQueue(<PolkadotConfig as subxt::Config>::Hash),
/// Get occupied core information at a given block.
Expand Down
15 changes: 0 additions & 15 deletions essentials/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,6 @@
// along with polkadot-introspector. If not, see <http://www.gnu.org/licenses/>.
//

#[cfg(all(feature = "rococo", feature = "kusama", feature = "polkadot"))]
compile_error!("`rococo`, `kusama`, and `polkadot` are mutually exclusive features");

#[cfg(not(any(feature = "rococo", feature = "kusama", feature = "polkadot")))]
compile_error!("Must build with either `rococo`, `kusama`, `polkadot` features");

#[cfg(feature = "rococo")]
#[subxt::subxt(runtime_metadata_path = "assets/rococo_metadata.scale")]
pub mod polkadot {}

#[cfg(feature = "kusama")]
#[subxt::subxt(runtime_metadata_path = "assets/kusama_metadata.scale")]
pub mod polkadot {}

#[cfg(feature = "polkadot")]
#[subxt::subxt(runtime_metadata_path = "assets/polkadot_metadata.scale")]
pub mod polkadot {}

Expand Down
6 changes: 0 additions & 6 deletions essentials/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ use crate::metadata::{
use parity_scale_codec::{Decode, Encode};
use std::collections::{BTreeMap, VecDeque};
use subxt::utils;

#[cfg(feature = "kusama")]
use subxt_runtime_types::kusama_runtime as runtime;
#[cfg(feature = "polkadot")]
use subxt_runtime_types::polkadot_runtime as runtime;
#[cfg(feature = "rococo")]
use subxt_runtime_types::rococo_runtime as runtime;

pub type BlockNumber = u32;
pub type H256 = utils::H256;
Expand Down
2 changes: 2 additions & 0 deletions metadata-checker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

**For internal use only.**

**TODO: the following information is outdated, needs to be edited.**

The `Runtime` version deployed on a network might be newer and incompatible with the metadata
bundled in the repository. To check whether the metadata is up-to-date, we run `polkadot-metadata-checker` on our CI/CD pipelines:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ RUN apt-get update && apt-get install -y libssl1.1 ca-certificates && \
useradd -m -u 1000 -U -s /bin/sh -d /polkadot-introspector polkadot-introspector && \
rm -rf /var/lib/apt/lists/* && \
# Sanity Check
/polkadot-introspector/${RUNTIME}/polkadot-parachain-tracer --version
/polkadot-introspector/polkadot-parachain-tracer --version

USER polkadot-introspector

ENV RUNTIME="/polkadot-introspector/$RUNTIME/polkadot-parachain-tracer"
ENV RUNTIME="/polkadot-introspector/polkadot-parachain-tracer"
ENTRYPOINT exec $RUNTIME

0 comments on commit d8112a9

Please sign in to comment.