Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into chore-improve-whilt…
Browse files Browse the repository at this point in the history
…elist-test
  • Loading branch information
parity-processbot committed May 17, 2023
2 parents f4c6d7e + 6507a79 commit 7030ea0
Show file tree
Hide file tree
Showing 84 changed files with 1,059 additions and 579 deletions.
16 changes: 14 additions & 2 deletions .github/pr-custom-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,24 @@ rules:
check_type: changed_files
condition:
include: .*
# excluding files from 'CI team' rules
exclude: ^\.gitlab-ci\.yml|^scripts/ci/.*|^\.github/.*|^\.config/nextest.toml
# excluding files from 'CI team' and 'FRAME coders' rules
exclude: ^\.gitlab-ci\.yml|^scripts/ci/.*|^\.github/.*|^\.config/nextest.toml|^frame/(?!.*(nfts/.*|uniques/.*|babe/.*|grandpa/.*|beefy|merkle-mountain-range/.*|contracts/.*|election|nomination-pools/.*|staking/.*|aura/.*))
min_approvals: 2
teams:
- core-devs

- name: FRAME coders
check_type: changed_files
condition:
include: ^frame/(?!.*(nfts/.*|uniques/.*|babe/.*|grandpa/.*|beefy|merkle-mountain-range/.*|contracts/.*|election|nomination-pools/.*|staking/.*|aura/.*))
all:
- min_approvals: 2
teams:
- core-devs
- min_approvals: 1
teams:
- frame-coders

- name: CI team
check_type: changed_files
condition:
Expand Down
24 changes: 9 additions & 15 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ members = [
"primitives/runtime-interface/test",
"primitives/runtime-interface/test-wasm",
"primitives/runtime-interface/test-wasm-deprecated",
"primitives/serializer",
"primitives/session",
"primitives/staking",
"primitives/state-machine",
Expand Down
2 changes: 1 addition & 1 deletion bin/node/bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tempfile = "3.1.0"
fs_extra = "1"
rand = { version = "0.8.5", features = ["small_rng"] }
lazy_static = "1.4.0"
parity-db = "0.4.7"
parity-db = "0.4.8"
sc-transaction-pool = { version = "4.0.0-dev", path = "../../../client/transaction-pool" }
sc-transaction-pool-api = { version = "4.0.0-dev", path = "../../../client/transaction-pool/api" }
futures = { version = "0.3.21", features = ["thread-pool"] }
2 changes: 1 addition & 1 deletion client/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ kvdb-memorydb = "0.13.0"
kvdb-rocksdb = { version = "0.19.0", optional = true }
linked-hash-map = "0.5.4"
log = "0.4.17"
parity-db = "0.4.7"
parity-db = "0.4.8"
parking_lot = "0.12.1"
sc-client-api = { version = "4.0.0-dev", path = "../api" }
sc-state-db = { version = "0.10.0-dev", path = "../state-db" }
Expand Down
6 changes: 3 additions & 3 deletions client/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,17 @@
//! More precise usage details are still being worked on and will likely change in the future.
mod behaviour;
mod discovery;
mod peer_info;
mod protocol;
mod service;
mod transport;

pub mod config;
pub mod discovery;
pub mod error;
pub mod event;
pub mod network_state;
pub mod peer_info;
pub mod request_responses;
pub mod transport;
pub mod types;
pub mod utils;

Expand Down
3 changes: 3 additions & 0 deletions client/network/src/peer_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! [`PeerInfoBehaviour`] is implementation of `NetworkBehaviour` that holds information about peers
//! in cache.
use crate::utils::interval;
use either::Either;

Expand Down
2 changes: 2 additions & 0 deletions client/network/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! Transport that serves as a common ground for all connections.
use either::Either;
use libp2p::{
core::{
Expand Down
2 changes: 1 addition & 1 deletion client/rpc-servers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ log = "0.4.17"
serde_json = "1.0.85"
tokio = { version = "1.22.0", features = ["parking_lot"] }
prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../utils/prometheus" }
tower-http = { version = "0.3.4", features = ["cors"] }
tower-http = { version = "0.4.0", features = ["cors"] }
tower = "0.4.13"
http = "0.2.8"
4 changes: 2 additions & 2 deletions client/service/test/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ fn construct_genesis_should_work_with_native() {
vec![AccountKeyring::One.into(), AccountKeyring::Two.into()],
1000 * DOLLARS,
)
.build_storage();
.build();
let genesis_hash = insert_genesis_block(&mut storage);

let backend = InMemoryBackend::from((storage, StateVersion::default()));
Expand Down Expand Up @@ -204,7 +204,7 @@ fn construct_genesis_should_work_with_wasm() {
vec![AccountKeyring::One.into(), AccountKeyring::Two.into()],
1000 * DOLLARS,
)
.build_storage();
.build();
let genesis_hash = insert_genesis_block(&mut storage);

let backend = InMemoryBackend::from((storage, StateVersion::default()));
Expand Down
2 changes: 1 addition & 1 deletion client/statement-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ futures = "0.3.21"
futures-timer = "3.0.2"
log = "0.4.17"
parking_lot = "0.12.1"
parity-db = "0.4.7"
parity-db = "0.4.8"
tokio = { version = "1.22.0", features = ["time"] }
sp-statement-store = { version = "4.0.0-dev", path = "../../primitives/statement-store" }
prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../utils/prometheus" }
Expand Down
36 changes: 19 additions & 17 deletions client/storage-monitor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ use std::{

const LOG_TARGET: &str = "storage-monitor";

/// Result type used in this crate.
pub type Result<T> = std::result::Result<T, Error>;

/// Error type used in this crate.
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("IO Error")]
IOError(#[from] io::Error),
#[error("Out of storage space: available {0}MB, required {1}MB")]
#[error("Out of storage space: available {0}MiB, required {1}MiB")]
StorageOutOfSpace(u64, u64),
}

Expand All @@ -42,22 +45,22 @@ pub struct StorageMonitorParams {
/// Required available space on database storage. If available space for DB storage drops below
/// the given threshold, node will be gracefully terminated. If `0` is given monitoring will be
/// disabled.
#[arg(long = "db-storage-threshold", value_name = "MB", default_value_t = 1000)]
#[arg(long = "db-storage-threshold", value_name = "MiB", default_value_t = 1024)]
pub threshold: u64,

/// How often available space is polled.
#[arg(long = "db-storage-polling-period", value_name = "SECONDS", default_value_t = 5, value_parser = clap::value_parser!(u32).range(1..))]
pub polling_period: u32,
}

/// Storage monitor service: checks the available space for the filesystem for fiven path.
/// Storage monitor service: checks the available space for the filesystem for given path.
pub struct StorageMonitorService {
/// watched path
path: PathBuf,
/// number of megabytes that shall be free on the filesystem for watched path
threshold: u64,
/// storage space polling period (seconds)
polling_period: u32,
/// storage space polling period
polling_period: Duration,
}

impl StorageMonitorService {
Expand All @@ -66,7 +69,7 @@ impl StorageMonitorService {
parameters: StorageMonitorParams,
database: DatabaseSource,
spawner: &impl SpawnEssentialNamed,
) -> Result<(), Error> {
) -> Result<()> {
Ok(match (parameters.threshold, database.path()) {
(0, _) => {
log::info!(
Expand All @@ -83,16 +86,15 @@ impl StorageMonitorService {
(threshold, Some(path)) => {
log::debug!(
target: LOG_TARGET,
"Initializing StorageMonitorService for db path: {:?}",
path,
"Initializing StorageMonitorService for db path: {path:?}",
);

Self::check_free_space(&path, threshold)?;

let storage_monitor_service = StorageMonitorService {
path: path.to_path_buf(),
threshold,
polling_period: parameters.polling_period,
polling_period: Duration::from_secs(parameters.polling_period.into()),
};

spawner.spawn_essential(
Expand All @@ -108,22 +110,22 @@ impl StorageMonitorService {
/// below threshold.
async fn run(self) {
loop {
tokio::time::sleep(Duration::from_secs(self.polling_period.into())).await;
tokio::time::sleep(self.polling_period).await;
if Self::check_free_space(&self.path, self.threshold).is_err() {
break
};
}
}

/// Returns free space in MB, or error if statvfs failed.
fn free_space(path: &Path) -> Result<u64, Error> {
Ok(fs4::available_space(path).map(|s| s / 1_000_000)?)
/// Returns free space in MiB, or error if statvfs failed.
fn free_space(path: &Path) -> Result<u64> {
Ok(fs4::available_space(path).map(|s| s / 1024 / 1024)?)
}

/// Checks if the amount of free space for given `path` is above given `threshold`.
/// Checks if the amount of free space for given `path` is above given `threshold` in MiB.
/// If it dropped below, error is returned.
/// System errors are silently ignored.
fn check_free_space(path: &Path, threshold: u64) -> Result<(), Error> {
fn check_free_space(path: &Path, threshold: u64) -> Result<()> {
match StorageMonitorService::free_space(path) {
Ok(available_space) => {
log::trace!(
Expand All @@ -132,14 +134,14 @@ impl StorageMonitorService {
);

if available_space < threshold {
log::error!(target: LOG_TARGET, "Available space {available_space}MB for path `{}` dropped below threshold: {threshold}MB , terminating...", path.display());
log::error!(target: LOG_TARGET, "Available space {available_space}MiB for path `{}` dropped below threshold: {threshold}MiB , terminating...", path.display());
Err(Error::StorageOutOfSpace(available_space, threshold))
} else {
Ok(())
}
},
Err(e) => {
log::error!(target: LOG_TARGET, "Could not read available space: {:?}.", e);
log::error!(target: LOG_TARGET, "Could not read available space: {e:?}.");
Err(e)
},
}
Expand Down
25 changes: 9 additions & 16 deletions docs/node-template-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,26 @@ by running the following command.
delete files/directories that are removed from the source. So you need to manually check and
remove them in the destination.

3. There are actually three packages in the Node Template, `node-template` (the node),
`node-template-runtime` (the runtime), and `pallet-template`, and each has its own `Cargo.toml`.
Inside these three files, dependencies are listed in expanded form and linked to a certain git
commit in Substrate remote repository, such as:
3. There is a `Cargo.toml` file in the root directory. Inside, dependencies are listed form and
linked to a certain git commit in Substrate remote repository, such as:

```toml
[dev-dependencies.sp-core]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'c1fe59d060600a10eebb4ace277af1fee20bad17'
version = '3.0.0'
sp-core = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", rev = "de80d0107336a9c7a2efdc0199015e4d67fcbdb5", default-features = false }
```

We will update each of them to the shortened form and link them to the Rust
[crate registry](https://crates.io/). After confirming the versioned package is published in
the crate, the above will become:
We will update each of them to link to the Rust [crate registry](https://crates.io/).
After confirming the versioned package is published in the crate, the above will become:

```toml
[dev-dependencies]
sp-core = { version = '3.0.0', default-features = false }
[workspace.dependencies]
sp-core = { version = "7.0.0", default-features = false }
```

P.S: This step can be automated if we update `node-template-release` package in
`scripts/ci/node-template-release`.

4. Once the three `Cargo.toml`s are updated, compile and confirm that the Node Template builds. Then
commit the changes to a new branch in [Substrate Node Template](https://github.com/substrate-developer-hub/substrate-node-template), and make a PR.
4. Once the `Cargo.toml` is updated, compile and confirm that the Node Template builds. Then commit
the changes to a new branch in [Substrate Node Template](https://github.com/substrate-developer-hub/substrate-node-template), and make a PR.

> Note that there is a chance the code in Substrate Node Template works with the linked Substrate git
commit but not with published packages due to the latest (as yet) unpublished features. In this case,
Expand Down
2 changes: 1 addition & 1 deletion frame/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,7 @@ pub mod pallet {
impl<T: Config<I>, I: 'static> AccountTouch<T::AssetId, T::AccountId> for Pallet<T, I> {
type Balance = DepositBalanceOf<T, I>;

fn deposit_required() -> Self::Balance {
fn deposit_required(_: T::AssetId) -> Self::Balance {
T::AssetAccountDeposit::get()
}

Expand Down
Loading

0 comments on commit 7030ea0

Please sign in to comment.