Skip to content

Commit

Permalink
Merge branch 'manta' into ghzlatarev/whale-blocker
Browse files Browse the repository at this point in the history
  • Loading branch information
ghzlatarev authored Sep 30, 2023
2 parents d3b705d + ba80769 commit 4426549
Show file tree
Hide file tree
Showing 20 changed files with 389 additions and 44 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/run_all_benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
jobs:
run-benchmarks:
timeout-minutes: 720
runs-on: runtime-integration-test
runs-on: runtime-large
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
- name: init
run: |
sudo apt update
sudo apt install -y pkg-config libssl-dev protobuf-compiler
sudo apt install -y pkg-config libssl-dev protobuf-compiler build-essential clang curl llvm libudev-dev libclang-dev
protoc --version
curl -s https://sh.rustup.rs -sSf | sh -s -- -y
source ${HOME}/.cargo/env
Expand All @@ -61,7 +61,7 @@ jobs:
uses: Swatinem/rust-cache@v2
- name: init nodejs && yarn
run: |
curl -s https://deb.nodesource.com/setup_16.x | sudo bash
curl -s https://deb.nodesource.com/setup_18.x | sudo bash
sudo apt install nodejs -y
node -v
sudo npm install --global yarn
Expand All @@ -75,7 +75,7 @@ jobs:
CARGO_TERM_COLOR: always
run: |
source ${HOME}/.cargo/env
RUSTC_BOOTSTRAP=1 cargo build --profile production --features runtime-benchmarks --verbose --timings
RUSTC_BOOTSTRAP=1 cargo build --profile production --features runtime-benchmarks --timings
- name: create-chainspec
run: |
${{ github.workspace }}/target/production/manta build-spec --chain $CHAIN_SPEC --disable-default-bootnode --raw > ${{ github.workspace }}/tests/data/fork.json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
source ${HOME}/.cargo/env
rustup toolchain install nightly-2023-03-13
rustup default nightly-2023-03-13
cargo install taplo-cli
cargo install taplo-cli --locked
- name: cache cargo
uses: Swatinem/rust-cache@v2
- name: Check Formatting
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# CHANGELOG

## v4.4.0-1
### Added
- [\#1240](https://github.com/Manta-Network/Manta/pull/1240) :sparkle: org `arc-runner` patch 1 [MACA]
- [\#1241](https://github.com/Manta-Network/Manta/pull/1241) :bug: arc-runner patch 1.1 [MACA]
- [\#1238](https://github.com/Manta-Network/Manta/pull/1238) localdev tests [MA]
- [\#1242](https://github.com/Manta-Network/Manta/pull/1242) :rocket: arc runner migration patch 2.1 [MACA]
- [\#1244](https://github.com/Manta-Network/Manta/pull/1244) more lottery tests [MACA]
- [\#1250](https://github.com/Manta-Network/Manta/pull/1250) :wrench: allow all benchmarks to be triggered on feature branch
- [\#1249](https://github.com/Manta-Network/Manta/pull/1249) Add zombienet examples

### Fixed
- [\#1234](https://github.com/Manta-Network/Manta/pull/1234) Serialize/deserialize vfr key [MACA]
- [\#1191](https://github.com/Manta-Network/Manta/pull/1191) Fix metadata diff checker workflow [MACA]
- [\#1243](https://github.com/Manta-Network/Manta/pull/1243) Add manta docker image to publish
- [\#1253](https://github.com/Manta-Network/Manta/pull/1253) Fix benchmark [CA]

## v4.4.0
### Added
- [\#1083](https://github.com/Manta-Network/Manta/pull/1083) tx fees diff support [MACA]
Expand Down
2 changes: 1 addition & 1 deletion pallets/asset-manager/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ benchmarks! {
let metadata = AssetRegistryMetadata::<Balance>::testing_default();
Pallet::<T>::register_asset(RawOrigin::Root.into(), location, metadata.clone())?;
let some_valid_asset_id = <T as Config>::AssetId::from(assets_count);
}: _(RawOrigin::Root, some_valid_asset_id, metadata.metadata.clone())
}: _(RawOrigin::Root, some_valid_asset_id, metadata.clone())
verify {
assert_last_event::<T>(crate::Event::AssetMetadataUpdated { asset_id: some_valid_asset_id, metadata }.into());
}
Expand Down
25 changes: 5 additions & 20 deletions pallets/asset-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,15 +541,14 @@ pub mod pallet {
///
/// * `origin`: Caller of this extrinsic, the access control is specified by `ForceOrigin`.
/// * `asset_id`: AssetId to be updated.
/// * `metadata`: new `metadata` to be associated with `asset_id`, note `is_frozen`
/// flag in metadata will have no effect and and cannot be changed.
/// * `metadata`: new `metadata` to be associated with `asset_id`.
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::update_asset_metadata())]
#[transactional]
pub fn update_asset_metadata(
origin: OriginFor<T>,
asset_id: T::AssetId,
metadata: AssetStorageMetadata,
metadata: AssetRegistryMetadata<Balance>,
) -> DispatchResult {
T::ModifierOrigin::ensure_origin(origin)?;
ensure!(
Expand All @@ -562,25 +561,11 @@ pub mod pallet {
);
<T::AssetConfig as AssetConfig<T>>::AssetRegistry::update_asset_metadata(
&asset_id,
metadata.clone(),
metadata.clone().into(),
)?;

let mut registered_metadata =
AssetIdMetadata::<T>::get(asset_id).ok_or(Error::<T>::UpdateNonExistentAsset)?;
let new_metadata = AssetStorageMetadata {
name: metadata.name,
symbol: metadata.symbol,
decimals: metadata.decimals,
// is frozen flag doesn't do anything in metadata
is_frozen: registered_metadata.metadata.is_frozen,
};
registered_metadata.metadata = new_metadata;

AssetIdMetadata::<T>::insert(asset_id, &registered_metadata);
Self::deposit_event(Event::<T>::AssetMetadataUpdated {
asset_id,
metadata: registered_metadata,
});
AssetIdMetadata::<T>::insert(asset_id, &metadata);
Self::deposit_event(Event::<T>::AssetMetadataUpdated { asset_id, metadata });
Ok(())
}

Expand Down
8 changes: 4 additions & 4 deletions pallets/asset-manager/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn wrong_modifier_origin_should_not_work() {
AssetManager::update_asset_metadata(
RuntimeOrigin::signed([3u8; 32].into()),
0,
asset_metadata.metadata
asset_metadata
),
BadOrigin
);
Expand Down Expand Up @@ -174,14 +174,14 @@ fn update_asset() {
AssetManager::update_asset_metadata(
RuntimeOrigin::root(),
native_asset_id,
new_metadata.metadata.clone(),
new_metadata.clone(),
),
Error::<Runtime>::CannotUpdateNativeAssetMetadata
);
assert_ok!(AssetManager::update_asset_metadata(
RuntimeOrigin::root(),
asset_id,
new_metadata.metadata.clone(),
new_metadata.clone(),
),);
assert_eq!(Assets::name(&asset_id), new_name);
assert_eq!(Assets::symbol(&asset_id), new_symbol);
Expand Down Expand Up @@ -213,7 +213,7 @@ fn update_asset() {
AssetManager::update_asset_metadata(
RuntimeOrigin::root(),
next_asset_id,
new_metadata.metadata.clone()
new_metadata.clone(),
),
Error::<Runtime>::UpdateNonExistentAsset
);
Expand Down
2 changes: 1 addition & 1 deletion runtime/calamari/src/diff_tx_fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ fn calculate_all_current_extrinsic_tx_fee() -> (
let call =
crate::RuntimeCall::AssetManager(pallet_asset_manager::Call::update_asset_metadata {
asset_id: 1,
metadata: AssetRegistryMetadata::testing_default().into(),
metadata: AssetRegistryMetadata::testing_default(),
});
let (dispatch_info, call_len) = get_call_details(&call);
calamari_runtime_calls.push((
Expand Down
13 changes: 3 additions & 10 deletions runtime/calamari/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("calamari"),
impl_name: create_runtime_str!("calamari"),
authoring_version: 2,
spec_version: 4400,
spec_version: 4401,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 15,
transaction_version: 16,
state_version: 0,
};

Expand Down Expand Up @@ -245,10 +245,6 @@ impl Contains<RuntimeCall> for BaseFilter {
| pallet_democracy::Call::cancel_proposal {..}
| pallet_democracy::Call::clear_public_proposals {..})
| RuntimeCall::Treasury(_) // Treasury calls are filtered while it is accumulating funds.
// Everything except transfer() is filtered out until it is practically needed:
| RuntimeCall::XTokens(
orml_xtokens::Call::transfer_with_fee {..}
| orml_xtokens::Call::transfer_multiasset {..})
// Filter callables from XCM pallets, we use XTokens exclusively
| RuntimeCall::XcmpQueue(_) | RuntimeCall::DmpQueue(_) => false,

Expand Down Expand Up @@ -306,10 +302,7 @@ impl Contains<RuntimeCall> for BaseFilter {
| RuntimeCall::MantaPay(_)
| RuntimeCall::MantaSbt(_)
| RuntimeCall::NameService(_)
| RuntimeCall::XTokens(orml_xtokens::Call::transfer {..}
| orml_xtokens::Call::transfer_multicurrencies {..}
| orml_xtokens::Call::transfer_multiassets {..}
| orml_xtokens::Call::transfer_multiasset_with_fee {..})
| RuntimeCall::XTokens(_)
| RuntimeCall::TransactionPause(_)
| RuntimeCall::ZenlinkProtocol(_)
| RuntimeCall::Farming(_)
Expand Down
2 changes: 1 addition & 1 deletion runtime/manta/src/diff_tx_fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ fn calculate_all_current_extrinsic_tx_fee() -> (
let call =
crate::RuntimeCall::AssetManager(pallet_asset_manager::Call::update_asset_metadata {
asset_id: 1,
metadata: AssetRegistryMetadata::testing_default().into(),
metadata: AssetRegistryMetadata::testing_default(),
});
let (dispatch_info, call_len) = get_call_details(&call);
calamari_runtime_calls.push((
Expand Down
4 changes: 2 additions & 2 deletions runtime/manta/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("manta"),
impl_name: create_runtime_str!("manta"),
authoring_version: 1,
spec_version: 4400,
spec_version: 4401,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 4,
transaction_version: 5,
state_version: 1,
};

Expand Down
72 changes: 72 additions & 0 deletions zombienet/examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Manta's zombienet examples

## Docs and examples
- docs: https://paritytech.github.io/zombienet/
- examples:
- https://github.com/paritytech/zombienet/tree/main/examples
- https://github.com/paritytech/cumulus/tree/master/zombienet
- https://github.com/paritytech/polkadot/tree/master/zombienet_tests

## Install zombienet

According to your platform, download the latest pre-compiled binary from [zombinet](https://github.com/paritytech/zombienet/releases) repository.

## Start network

### Start one paracahin network locally by zombienet
1. Go to [small-network](./small-network.toml), make the `command` point to the polkadot binary and manta binary.
2. Start the network.
```shell
zombienet spawn --provider native small-network.toml
```
After a while, the network will be started.

### Start two parachains
1. Go to [two-parachains](./two-parachains.toml), make the `command` point to the polkadot binary and manta binary.
2. Start the network.
```shell
zombienet spawn --provider native two-parachains.toml
```
After a while, two paracahins(`2084` and `2104`) will be started.

## Testing

Zombienet supports testing as well, but you have to write test cases with a special dsl: `zndsl`.
Please take a look at this [doc](https://paritytech.github.io/zombienet/cli/test-dsl-definition-spec.html) to see more details about how to write test cases.

### Runtime upgrade(not ready)
1. Go to [runtime-upgrade](./runtime-upgrade.toml), make the `command` point to the polkadot binary and manta binary. And go to [runtime upgrade test case](./runtime-upgrade.zndsl), make sure `line 6` point to the correct wasm binary.
2. Run runtime upgrade.
```shell
zombienet -f --provider native test runtime-upgrade.zndsl
```
This test case would take minutes to be finished.

### Run you own customized test script
1. Go to [custom-script](./custom-script.toml), make the `command` point to the polkadot binary and manta binary.
2. Define and implement a function named `run` in your script.
```ts
async function run(nodeName, networkInfo, args) {
return 2084;
}
```
3. Go to the [custom-script test case](./custom-script.zndsl), make sure `line 8` point to your script, and compare the expected value.
```
Dave: js-script ./custom-script.js return is equal to 2084 within 300 seconds
```
4. Start the test.
```shell
zombienet -f --provider native test custom-script.zndsl
```

## Tips:
1. When run the network, please do not use the same node name for relaychain and parachain.
For example: if one relaychain node takes `Alice`, so you cannot use `Alice` for any parachain nodes, but you can use `alice`.
2. Please be careful the node name in your test case, you must understand what you want to test.
For example, if one relaychain node takes `Alice` as node, you can use `alice` for one of paracahin nodes, the `Alice` will test relaychain node, but `alice` is for parachain only.
```
alice: parachain 2084 is registered within 225 seconds
Alice: reports block height is at least 5 within 250 seconds
```
The first line will check parachain's block production, the second line will check relaychain's.
Because relaychain and parachain use the same node name, the zombienet's test framework won't know who is `Alice`.
10 changes: 10 additions & 0 deletions zombienet/examples/check-block-production.zndsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Description: Block Production Test
Network: ./small-network.toml
Creds: config

# metrics
Alice: reports node_roles is 4

# logs
alice: parachain 2084 is registered within 225 seconds
Alice: reports block height is at least 5 within 250 seconds
7 changes: 7 additions & 0 deletions zombienet/examples/custom-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const assert = require("assert");

async function run(nodeName, networkInfo, args) {
return 2084;
}

module.exports = { run }
48 changes: 48 additions & 0 deletions zombienet/examples/custom-script.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[settings]
timeout = 300

[relaychain]
chain = "rococo-local"
default_command = "polkadot-binary"

[[relaychain.nodes]]
name = "alice"
validator = true
ws_port = 9944

[[relaychain.nodes]]
name = "bob"
validator = true
ws_port = 9911

[[parachains]]
chain = "calamari-local"
cumulus_based = true
id = 2084

[[parachains.collators]]
command = "manta-binary"
name = "Alice"
rcp_port = 9967
validator = true
ws_port = 9921

[[parachains.collators]]
command = "manta-binary"
name = "Bob"
validator = true

[[parachains.collators]]
command = "manta-binary"
name = "Charlie"
validator = true

[[parachains.collators]]
command = "manta-binary"
name = "Dave"
validator = true

[[parachains.collators]]
command = "manta-binary"
name = "Eve"
validator = true
8 changes: 8 additions & 0 deletions zombienet/examples/custom-script.zndsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Description: Runtime Upgrade Test
Network: ./custom-script.toml
Creds: config

alice: parachain 2084 is registered within 225 seconds
Bob: reports block height is at least 5 within 250 seconds
Dave: reports block height is at least 5 within 250 seconds
Dave: js-script ./custom-script.js return is equal to 2084 within 300 seconds
Loading

0 comments on commit 4426549

Please sign in to comment.