Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chainHead based backend implementation #1161

Merged
merged 24 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ name: Daily compatibility check against latest substrate

on:
schedule:
# Run at 8am every day
# Run at 8am every day, well after the new binary is built
- cron: "0 8 * * *"


env:
CARGO_TERM_COLOR: always
# Use latest substrate for nightly runs:
SUBSTRATE_URL: https://releases.parity.io/substrate/x86_64-debian:bullseye/latest/substrate/substrate

jobs:
tests:
Expand All @@ -19,13 +17,19 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v4

- name: Download Substrate
- 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
run: |
curl $SUBSTRATE_URL --output substrate-node --location
chmod +x substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
mv substrate-node ~/.local/bin
chmod u+x ./substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
cp ./substrate-node ~/.local/bin

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
Expand All @@ -43,8 +47,7 @@ jobs:
command: test
args: --all-targets --workspace

# If the previous step fails, create a new Github issue
# to nofity us about it.
# If any previous step fails, create a new Github issue to notify us about it.
- if: ${{ failure() }}
uses: JasonEtco/create-an-issue@e27dddc79c92bc6e4562f268fffa5ed752639abd # v2.9.1
env:
Expand Down
184 changes: 129 additions & 55 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ concurrency:

env:
CARGO_TERM_COLOR: always
# TODO: Currently pointing at latest substrate; is there a suitable binary we can pin to here?
SUBSTRATE_URL: https://releases.parity.io/substrate/x86_64-debian:bullseye/latest/substrate/substrate
# Increase wasm test timeout from 20 seconds (default) to 1 minute.
WASM_BINDGEN_TEST_TIMEOUT: 60

Expand All @@ -31,13 +29,19 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v4

- name: Download Substrate
- 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
run: |
curl $SUBSTRATE_URL --output substrate-node --location
chmod +x substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
mv substrate-node ~/.local/bin
chmod u+x ./substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
cp ./substrate-node ~/.local/bin

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -137,13 +141,19 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v4

- name: Download Substrate
- 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
run: |
curl $SUBSTRATE_URL --output substrate-node --location
chmod +x substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
mv substrate-node ~/.local/bin
chmod u+x ./substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
cp ./substrate-node ~/.local/bin

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
Expand All @@ -165,19 +175,25 @@ jobs:
args: --doc

tests:
name: "Test non-wasm"
name: "Test (Native)"
runs-on: ubuntu-latest-16-cores
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Download Substrate
- 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
run: |
curl $SUBSTRATE_URL --output substrate-node --location
chmod +x substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
mv substrate-node ~/.local/bin
chmod u+x ./substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
cp ./substrate-node ~/.local/bin

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
Expand All @@ -198,21 +214,26 @@ jobs:
command: nextest
args: run --workspace

light_client_tests:
name: "Test Light Client"
unstable_backend_tests:
name: "Test (Unstable Backend)"
runs-on: ubuntu-latest-16-cores
timeout-minutes: 25
steps:
- name: Checkout sources
uses: actions/checkout@v4
uses: actions/checkout@v3

- name: Download Substrate
- 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
run: |
curl $SUBSTRATE_URL --output substrate-node --location
chmod +x substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
mv substrate-node ~/.local/bin
chmod u+x ./substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
cp ./substrate-node ~/.local/bin

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
Expand All @@ -222,48 +243,57 @@ jobs:
override: true

- name: Rust Cache
uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0
uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2

- name: Install cargo-nextest
run: cargo install cargo-nextest

- name: Run tests
uses: actions-rs/[email protected]
with:
command: test
args: --release --package integration-tests --features unstable-light-client
command: nextest
args: run --workspace --features unstable-backend-client

clippy:
name: Cargo clippy
runs-on: ubuntu-latest
light_client_tests:
name: "Test (Light Client)"
runs-on: ubuntu-latest-16-cores
timeout-minutes: 25
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Download Substrate
- 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
run: |
curl $SUBSTRATE_URL --output substrate-node --location
chmod +x substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
mv substrate-node ~/.local/bin
chmod u+x ./substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
cp ./substrate-node ~/.local/bin

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
override: true

- name: Rust Cache
uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0

- name: Run clippy
uses: actions-rs/cargo@v1
- name: Run tests
uses: actions-rs/cargo@v1.0.3
with:
command: clippy
args: --all-targets -- -D warnings
command: test
args: --release --package integration-tests --features unstable-light-client

wasm_tests:
name: Test wasm
name: Test (WASM)
runs-on: ubuntu-latest

steps:
Expand All @@ -281,13 +311,19 @@ jobs:
- name: Rust Cache
uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0

- name: Download Substrate
- 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
run: |
curl $SUBSTRATE_URL --output substrate-node --location
chmod +x substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
mv substrate-node ~/.local/bin
chmod u+x ./substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
cp ./substrate-node ~/.local/bin

- name: Run subxt WASM tests
run: |
Expand All @@ -314,3 +350,41 @@ jobs:
wasm-pack test --headless --firefox
wasm-pack test --headless --chrome
working-directory: signer/wasm-tests

clippy:
name: Cargo clippy
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- 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
run: |
chmod u+x ./substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
cp ./substrate-node ~/.local/bin

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
override: true

- name: Rust Cache
uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0

- name: Run clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets -- -D warnings
1 change: 0 additions & 1 deletion metadata/src/utils/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ pub fn get_custom_value_hash(
pub fn get_storage_hash(pallet: &PalletMetadata, entry_name: &str) -> Option<[u8; HASH_LEN]> {
let storage = pallet.storage()?;
let entry = storage.entry_by_name(entry_name)?;

let hash = get_storage_entry_hash(pallet.types, entry, &mut HashMap::new());
Some(hash)
}
Expand Down
2 changes: 1 addition & 1 deletion subxt/examples/tx_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

// Build a balance transfer extrinsic.
let dest = dev::bob().public_key().into();
let balance_transfer_tx = polkadot::tx().balances().transfer(dest, 10_000);
let balance_transfer_tx = polkadot::tx().balances().transfer_allow_death(dest, 10_000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: What is the advantage of transfer_allow_death over the normal transfer here?

Copy link
Collaborator Author

@jsdw jsdw Sep 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transfer actually disappeared from the recent version of the balances pallet, and was replaced with two functions: transfer_keep_alive and transfer_allow_death.

transfer_keep_alive will reject doing a transfer that would bring your balance below the existential deposit (ED) amount (which, if happens, would allow the account to be repeaed, ie disappear entirely with any remaining balance going away)

transfer_allow_death is the same as the old transfer call afaiu, and will allow the transfer to occur even if it leads to the acoucnt being reaped :)

And so, I just renamed all uses of transfer that I found to transfer_allow_death to keep the same logic as before to make CI happy. (well, happier)


// Submit the balance transfer extrinsic from Alice, and wait for it to be successful
// and in a finalized block. We get back the extrinsic events if all is well.
Expand Down
2 changes: 1 addition & 1 deletion subxt/examples/tx_status_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

// Build a balance transfer extrinsic.
let dest = dev::bob().public_key().into();
let balance_transfer_tx = polkadot::tx().balances().transfer(dest, 10_000);
let balance_transfer_tx = polkadot::tx().balances().transfer_allow_death(dest, 10_000);

// Submit the balance transfer extrinsic from Alice, and then monitor the
// progress of it.
Expand Down
2 changes: 1 addition & 1 deletion subxt/examples/tx_with_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

// Build a balance transfer extrinsic.
let dest = dev::bob().public_key().into();
let tx = polkadot::tx().balances().transfer(dest, 10_000);
let tx = polkadot::tx().balances().transfer_allow_death(dest, 10_000);

let latest_block = api.blocks().at_latest().await?;

Expand Down
2 changes: 1 addition & 1 deletion subxt/examples/unstable_light_client_tx_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

// Build a balance transfer extrinsic.
let dest = dev::bob().public_key().into();
let balance_transfer_tx = polkadot::tx().balances().transfer(dest, 10_000);
let balance_transfer_tx = polkadot::tx().balances().transfer_allow_death(dest, 10_000);

// Submit the balance transfer extrinsic from Alice, and wait for it to be successful
// and in a finalized block. We get back the extrinsic events if all is well.
Expand Down
Loading