Skip to content

Commit

Permalink
Merge branch 'main' into fee-payment
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo authored Apr 19, 2024
2 parents 7eb5809 + 47bb083 commit 2960611
Show file tree
Hide file tree
Showing 14 changed files with 214 additions and 26 deletions.
1 change: 1 addition & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ runs:
rustup component add clippy --toolchain nightly-x86_64-unknown-linux-gnu
rustup component add rustfmt --toolchain nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
rustup component add rust-src
rustup show
shell: bash
6 changes: 5 additions & 1 deletion .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
fmt:
Expand Down Expand Up @@ -50,7 +54,7 @@ jobs:
run: echo "CARGO_NET_GIT_FETCH_WITH_CLI=true" >> $GITHUB_ENV

- name: Cargo clippy
run: cargo +nightly clippy -- -D warnings
run: cargo clippy -- -D warnings

- name: Check Code
run: cargo check
4 changes: 4 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Benchmarks
on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
benchmark:
runs-on: ubuntu-22.04
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Test coverage

on:
# Triggers the workflow on push or pull request events but only for the main branch
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
TARPAULIN_VERSION: 0.27.3

jobs:
coverage:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup

- name: Setup SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.GH_TOKEN }}

- name: Use Git CLI for Cargo
run: echo "CARGO_NET_GIT_FETCH_WITH_CLI=true" >> $GITHUB_ENV

- name: Run cargo-tarpaulin
run: |
wget https://github.com/xd009642/tarpaulin/releases/download/${{ env.TARPAULIN_VERSION }}/cargo-tarpaulin-x86_64-unknown-linux-musl.tar.gz
tar -zxvf cargo-tarpaulin-x86_64-unknown-linux-musl.tar.gz -C $HOME/.cargo/bin
cargo tarpaulin --workspace \
-e regionx-node regionx-runtime \
--exclude-files **/mock.rs **/weights/* \
--out xml
- uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: RegionX-Labs/RegionX-Node
10 changes: 5 additions & 5 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
- main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check-dependencies:
runs-on: ubuntu-latest
Expand All @@ -18,11 +22,7 @@ jobs:
- uses: ./.github/actions/setup

- name: Install Rust
run: |
rustup show
rustup toolchain install nightly
cargo install --git https://github.com/paritytech/psvm psvm
run: cargo install --git https://github.com/paritytech/psvm psvm
- name: Check Dependency Versions
run: |
chmod +x ./scripts/check-dependency-versions.sh
Expand Down
21 changes: 11 additions & 10 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@ name: Smoke tests
on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
smoke:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- uses: ./.github/actions/setup

- name: Zombienet setup
run: |
wget https://github.com/paritytech/zombienet/releases/download/v1.3.100/zombienet-linux-x64
Expand All @@ -26,16 +32,11 @@ jobs:
- name: Pull Docker Image
run: docker pull szegoo/regionx-node:latest

- name: Create Container
id: create-container
run: |
container_id=$(docker create szegoo/regionx-node:latest)
echo "::set-output name=container_id::$container_id"

- name: Copy Executable from Container
- name: Compile regionx-node
run: |
docker cp ${{ steps.create-container.outputs.container_id }}:/usr/bin/regionx-node .
cargo build --release
cp ./target/release/regionx-node .
- name: Run smoke test 0001
run: ./zombienet-linux-x64 -p native test ./zombienet_tests/0001-smoke-test.zndsl
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Tests
on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-22.04
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/try_runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Try-runtime
on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
try-runtime:
runs-on: ubuntu-22.04
Expand Down
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ pallet-transaction-payment = { version = "28.0.0", default-features = false }
pallet-asset-tx-payment = { version = "28.0.0", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { version = "28.0.0", default-features = false }
pallet-message-queue = { version = "31.0.0", default-features = false }
pallet-multisig = { version = "28.0.0", default-features = false }
pallet-proxy = { version = "28.0.0", default-features = false }
pallet-utility = { version = "28.0.0", default-features = false }
sp-api = { version = "26.0.0", default-features = false }
sp-blockchain = { version = "28.0.0", default-features = false }
sp-io = { version = "30.0.0", default-features = false }
Expand Down
14 changes: 13 additions & 1 deletion runtime/regionx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ pallet-aura = { workspace = true }
pallet-authorship = { workspace = true }
pallet-balances = { workspace = true }
pallet-message-queue = { workspace = true }
pallet-multisig = { workspace = true }
pallet-proxy = { workspace = true }
pallet-session = { workspace = true }
pallet-sudo = { workspace = true }
pallet-timestamp = { workspace = true }
pallet-transaction-payment = { workspace = true }
pallet-asset-tx-payment = { workspace = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true }
pallet-utility = { workspace = true }
sp-api = { workspace = true }
sp-block-builder = { workspace = true }
sp-consensus-aura = { workspace = true }
Expand Down Expand Up @@ -120,8 +123,11 @@ std = [
"pallet-collator-selection/std",
"pallet-message-queue/std",
"regionx-primitives/std",
"pallet-multisig/std",
"pallet-proxy/std",
"pallet-session/std",
"pallet-sudo/std",
"pallet-utility/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-asset-tx-payment/std",
Expand Down Expand Up @@ -163,11 +169,14 @@ runtime-benchmarks = [
"hex-literal",
"orml-asset-registry/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-asset-tx-payment/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-collator-selection/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-asset-tx-payment/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
Expand Down Expand Up @@ -197,8 +206,11 @@ try-runtime = [
"pallet-balances/try-runtime",
"pallet-collator-selection/try-runtime",
"pallet-message-queue/try-runtime",
"pallet-multisig/try-runtime",
"pallet-proxy/try-runtime",
"pallet-session/try-runtime",
"pallet-sudo/try-runtime",
"pallet-utility/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-asset-tx-payment/try-runtime",
"pallet-transaction-payment/try-runtime",
Expand Down
47 changes: 45 additions & 2 deletions runtime/regionx/src/impls.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use crate::{AccountId, AssetId, Assets, Authorship, Runtime};
use crate::{AssetId, Runtime, RuntimeCall};
use frame_support::traits::InstanceFilter;
use frame_support::traits::{fungibles, Defensive};
use orml_asset_registry::DefaultAssetMetadata;
use orml_traits::asset_registry::AssetProcessor;
use pallet_asset_tx_payment::HandleCredit;
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_runtime::DispatchError;
use sp_runtime::{DispatchError, RuntimeDebug};

#[derive(
Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen,
Expand Down Expand Up @@ -40,6 +41,48 @@ impl HandleCredit<AccountId, Assets> for AssetsToBlockAuthor {
if let Some(author) = Authorship::author() {
// In case of error: Will drop the result triggering the `OnDrop` of the imbalance.
let _ = Assets::resolve(&author, credit).defensive();
}
}
}

/// The type used to represent the kinds of proxying allowed.
#[derive(
Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Encode,
Decode,
RuntimeDebug,
MaxEncodedLen,
scale_info::TypeInfo,
)]
pub enum ProxyType {
/// Fully permissioned proxy. Can execute any call on behalf of _proxied_.
Any,
/// Can execute any call that does not transfer funds or assets.
NonTransfer,
/// Proxy with the ability to reject time-delay proxy announcements.
CancelProxy,
// TODO: add more proxies in future related to coretime trading.
}

impl Default for ProxyType {
fn default() -> Self {
Self::Any
}
}

impl InstanceFilter<RuntimeCall> for ProxyType {
fn filter(&self, c: &RuntimeCall) -> bool {
match self {
ProxyType::Any => true,
ProxyType::NonTransfer =>
!matches!(c, RuntimeCall::Balances { .. } | RuntimeCall::Assets { .. }),
ProxyType::CancelProxy =>
matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })),
}
}
}
Loading

0 comments on commit 2960611

Please sign in to comment.