Skip to content

Commit

Permalink
update to substrate v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Leouarz committed Aug 1, 2023
1 parent e486819 commit 2b91a0d
Show file tree
Hide file tree
Showing 9 changed files with 746 additions and 192 deletions.
855 changes: 702 additions & 153 deletions Cargo.lock

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ members = [
"nomad/merkle",
]
[patch.crates-io]
# Substrate (polkadot-v0.9.43).
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-core-hashing = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-application-crypto = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-storage = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-debug-derive = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-arithmetic = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-trie = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-runtime-interface = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-weights = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-externalities = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-inherents = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-staking = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-state-machine = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-tracing = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-version = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
sp-wasm-interface = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" }
# Substrate (polkadot-v1.0.0).
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-core-hashing = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-application-crypto = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-storage = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-debug-derive = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-arithmetic = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-trie = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-runtime-interface = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-weights = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-externalities = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-inherents = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-staking = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-state-machine = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-tracing = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-version = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-wasm-interface = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }

[profile.dev.package]
nalgebra = { opt-level = 3 }
Expand Down
3 changes: 1 addition & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static_assertions = "1.1.0"
thiserror-no-std = "2.0.2"

# Substrate
binary-merkle-tree = { git = "https://github.com/paritytech/substrate.git/", branch = "polkadot-v0.9.43", default-features = false, optional = true }
binary-merkle-tree = { git = "https://github.com/paritytech/substrate.git/", branch = "polkadot-v1.0.0", default-features = false, optional = true }
codec = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
sp-arithmetic = { version = "*", default-features = false }
Expand Down Expand Up @@ -65,5 +65,4 @@ runtime = [
header-backward-compatibility-test = []
try-runtime = [
"runtime",
"sp-runtime/try-runtime",
]
2 changes: 1 addition & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![deny(clippy::integer_arithmetic)]
#![deny(clippy::arithmetic_side_effects)]

use codec::{Decode, Encode, MaxEncodedLen};
use derive_more::{Add, Constructor, Deref, Display, Into, Mul};
Expand Down
3 changes: 2 additions & 1 deletion kate/src/com.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ pub fn flatten_and_pad_block(
assert_eq!(rem, 0);
}

#[allow(clippy::integer_arithmetic)]
#[allow(clippy::arithmetic_side_effects)]
// SAFETY: `chunk_size` comes from `NonZeroU32::get(...)` so we can safetly use `/`.
let last = block_dims_size.saturating_sub(padded_block.len()) / chunk_size;
for _ in 0..last {
Expand Down Expand Up @@ -213,6 +213,7 @@ pub fn get_block_dimensions(
// we must minimize number of rows, to minimize header size
// (performance wise it doesn't matter)
let nz_max_cols = NonZeroU32::new(max_cols.0).ok_or(Error::ZeroDimension)?;
#[allow(clippy::arithmetic_side_effects)]
let (cols, rows) = if total_cells > max_cols.0 {
(max_cols, BlockLengthRows(total_cells / nz_max_cols))
} else {
Expand Down
16 changes: 9 additions & 7 deletions kate/src/gridgen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ impl EvaluationGrid {

/// Returns a list of `(index, row)` pairs for the underlying rows of an application.
/// Returns `None` if the `app_id` cannot be found, or if the provided `orig_dims` are invalid.
#[allow(clippy::type_complexity)]
pub fn app_rows(
&self,
app_id: AppId,
Expand All @@ -168,9 +169,9 @@ impl EvaluationGrid {
// SAFETY: `origin_dims.rows is NonZeroU16`
// Compiler checks that `Dimensions::rows()` returns a `NonZeroU16` using the expression
// `NonZeroU16::get(x)` instead of `x.get()`.
#[allow(clippy::integer_arithmetic)]
#[allow(clippy::arithmetic_side_effects)]
let h_mul: usize = rows / usize::from(NonZeroU16::get(orig_dims.rows()));
#[allow(clippy::integer_arithmetic)]
#[allow(clippy::arithmetic_side_effects)]
let row_from_lineal_index = |cols, lineal_index| {
let lineal_index =
usize::try_from(lineal_index).map_err(|_| AppRowError::LinealIndexOverflows)?;
Expand All @@ -189,7 +190,7 @@ impl EvaluationGrid {
// SAFETY: This won't overflow because `h_mul = rows / orig_dim.rows()` and `*_y < rows)
debug_assert!(start_y < rows);
debug_assert!(end_y < rows);
#[allow(clippy::integer_arithmetic)]
#[allow(clippy::arithmetic_side_effects)]
let (new_start_y, new_end_y) = (start_y * h_mul, end_y * h_mul);

let app_rows = (new_start_y..=new_end_y)
Expand Down Expand Up @@ -359,7 +360,7 @@ pub struct CellBlock {
/// `mp_grid_dims` is the size of the multiproof grid, which `x,y` lies in.
/// For example, a 256x256 grid could be converted to a 4x4 target size multiproof grid, by making 16 multiproofs
/// of size 64x64.
#[allow(clippy::integer_arithmetic)]
#[allow(clippy::arithmetic_side_effects)]
pub fn multiproof_block(
x: usize,
y: usize,
Expand Down Expand Up @@ -389,6 +390,7 @@ pub fn multiproof_block(

/// Dimensions of the multiproof grid. These are guarenteed to cleanly divide `grid_dims`.
/// `target_dims` must cleanly divide `grid_dims`.
#[allow(clippy::arithmetic_side_effects)]
pub fn multiproof_dims(grid: Dimensions, target: Dimensions) -> Option<Dimensions> {
let cols = min(grid.cols(), target.cols());
let rows = min(grid.rows(), target.rows());
Expand Down Expand Up @@ -440,7 +442,7 @@ pub fn domain_points(n: usize) -> Result<Vec<ArkScalar>, Error> {
}

/// SAFETY: As `multiple` is a `NonZeroU16` we can safetly make the following ops.
#[allow(clippy::integer_arithmetic)]
#[allow(clippy::arithmetic_side_effects)]
fn round_up_to_multiple(input: usize, multiple: NonZeroU16) -> usize {
let multiple: usize = multiple.get().into();
let n_multiples = input.saturating_add(multiple - 1) / multiple;
Expand All @@ -458,7 +460,7 @@ pub(crate) fn pad_to_bls_scalar(a: impl AsRef<[u8]>) -> Result<ArkScalar, Error>
ArkScalar::from_bytes(&buf).map_err(Error::MultiproofError)
}

#[allow(clippy::integer_arithmetic)]
#[allow(clippy::arithmetic_side_effects)]
pub(crate) fn random_scalar(rng: &mut ChaChaRng) -> ArkScalar {
let mut raw_scalar = [0u8; SCALAR_SIZE];

Expand All @@ -472,7 +474,7 @@ pub(crate) fn random_scalar(rng: &mut ChaChaRng) -> ArkScalar {
}

#[cfg(test)]
#[allow(clippy::integer_arithmetic)]
#[allow(clippy::arithmetic_side_effects)]
mod unit_tests {
use super::*;
use proptest::{prop_assert_eq, proptest};
Expand Down
6 changes: 3 additions & 3 deletions kate/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![deny(clippy::integer_arithmetic)]
#![deny(clippy::arithmetic_side_effects)]

use avail_core::{BlockLengthColumns, BlockLengthRows};
use core::{
Expand Down Expand Up @@ -179,7 +179,7 @@ pub mod gridgen;
/// There is a unit test to ensure this formula match with the current
/// IEC 9797 1 algorithm we implemented. See `fn pad_iec_9797_1`
#[inline]
#[allow(clippy::integer_arithmetic)]
#[allow(clippy::arithmetic_side_effects)]
fn padded_len_of_pad_iec_9797_1(len: u32) -> u32 {
let len_plus_one = len.saturating_add(1);
let offset = (DATA_CHUNK_SIZE - (len_plus_one as usize % DATA_CHUNK_SIZE)) % DATA_CHUNK_SIZE;
Expand All @@ -189,7 +189,7 @@ fn padded_len_of_pad_iec_9797_1(len: u32) -> u32 {
}

/// Calculates the padded len based of initial `len`.
#[allow(clippy::integer_arithmetic)]
#[allow(clippy::arithmetic_side_effects)]
pub fn padded_len(len: u32, chunk_size: NonZeroU32) -> u32 {
let iec_9797_1_len = padded_len_of_pad_iec_9797_1(len);

Expand Down
7 changes: 5 additions & 2 deletions nomad/signature/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ use k256::{
PublicKey as K256PublicKey,
};
use scale_info::TypeInfo;
use sp_core::{Hasher as _, H160, H256, U256};
use sp_runtime::{traits::Keccak256, RuntimeDebug};
use sp_core::{H160, H256, U256};
use sp_runtime::{
traits::{Hash, Keccak256},
RuntimeDebug,
};
use thiserror_no_std::Error;

#[cfg(feature = "std")]
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "nightly-2022-11-15"
channel = "nightly-2023-05-22"
components = ["rustfmt", "clippy", "llvm-tools-preview"]
profile = "minimal"
targets = ["wasm32-unknown-unknown"]

0 comments on commit 2b91a0d

Please sign in to comment.