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

Update toolchain #1244

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
374 changes: 160 additions & 214 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ env_logger = { version = "0.10.0" }
[features]
default = ['std']
std = [
"bridge-types/std",
'bridge-types/std',
'codec/std',
"scale-info/std",
'serde',
Expand All @@ -78,3 +78,5 @@ std = [
test = ["env_logger"]

runtime-benchmarks = []

private-net = []
10 changes: 8 additions & 2 deletions common/src/alt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,13 +497,19 @@ impl<AssetId: Ord + Clone> DiscreteQuotation<AssetId, Balance> {
if let Some(precision) = self.limits.amount_precision {
let (input_precision, output_precision) = match precision {
SideAmount::Input(input_precision) => {
let Some(output_precision) = self.limits.get_precision_step(chunk, SwapVariant::WithDesiredOutput) else {
let Some(output_precision) = self
.limits
.get_precision_step(chunk, SwapVariant::WithDesiredOutput)
else {
return false;
};
(input_precision, output_precision)
}
SideAmount::Output(output_precision) => {
let Some(input_precision) = self.limits.get_precision_step(chunk, SwapVariant::WithDesiredInput) else {
let Some(input_precision) = self
.limits
.get_precision_step(chunk, SwapVariant::WithDesiredInput)
else {
return false;
};
(input_precision, output_precision)
Expand Down
10 changes: 5 additions & 5 deletions common/src/balance_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ const RATIO: u128 = 1_000_000_000_000_000_000;
/// `Ord` (+ `PartialOrd`), and `Encode` (+ `Decode`) are not consistent with each other.
///
/// - `Ord` compares numbers by mathematical values. So `{1, indivisible}` and
/// `{10^18, divisible}` will be `Ordering::Equal`.
/// `{10^18, divisible}` will be `Ordering::Equal`.
/// - `Eq` compares them field-by-field, making divisible never equal to indivisible numbers.
/// So `{1, indivisible} != {10^18, divisible}`.
/// So `{1, indivisible} != {10^18, divisible}`.
/// - `Encode` behaves the same way as `Eq`, concentrating on the fields rather than mathematical
/// value.
/// value.
///
/// It was left this way because obtaining the following properties requires some major
/// reconsiderations of implementation, possible migrations, and a lot of effort:
Expand All @@ -71,9 +71,9 @@ const RATIO: u128 = 1_000_000_000_000_000_000;
///
/// For example, this has the following implications for `a = {1, indivisible}` and `b = {10^18, divisible}`:
/// - counterintuitively, `a > b == false`, `a < b == false`, and `(a == b) == false`
/// (first two use `PartialOrd`, the last one uses `PartialEq`)
/// (first two use `PartialOrd`, the last one uses `PartialEq`)
/// - in `StorageMap` (that uses encoded values as keys) `a` and `b` are considered different
/// keys, but in `BTreeMap` (that uses `Ord`) they are unified.
/// keys, but in `BTreeMap` (that uses `Ord`) they are unified.
#[derive(
Encode, Decode, Copy, Clone, Debug, PartialEq, Eq, scale_info::TypeInfo, MaxEncodedLen,
)]
Expand Down
2 changes: 0 additions & 2 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ pub mod prelude {
pub use super::outcome_fee::*;
pub use super::permissions;
pub use super::primitives::*;
pub use super::serialization::*;
pub use super::swap_amount::*;
pub use super::traits::*;
pub use super::weights::*;
Expand All @@ -83,7 +82,6 @@ pub mod prelude {
}
use sp_core::crypto::AccountId32;

pub use macros::*;
pub use primitives::*;
pub use traits::*;
pub use utils::*;
Expand Down
2 changes: 1 addition & 1 deletion common/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ macro_rules! balance {
($value:literal) => {{
use $crate::fixnum::_priv::parse_fixed;
const VALUE_SIGNED: i128 = parse_fixed(stringify!($value), 1_000_000_000_000_000_000);
const VALUE: $crate::Balance = VALUE_SIGNED.abs() as u128;
const VALUE: $crate::Balance = VALUE_SIGNED.unsigned_abs();
VALUE
}};
($e:expr) => {{
Expand Down
21 changes: 17 additions & 4 deletions common/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,30 @@ pub const HERMES_ASSET_ID: AssetId32<PredefinedAssetId> = AssetId32::from_bytes(
pub const APOLLO_ASSET_ID: AssetId32<PredefinedAssetId> = AssetId32::from_bytes(hex!(
"00efe45135018136733be626b380a87ae663ccf6784a25fe9d9d2be64acecb9d"
));
#[cfg(not(feature = "private-net"))]

// `private-net` is not used in prod
#[allow(deprecated)]
#[cfg(any(feature = "private-net", test))]
pub const DOT: AssetId32<PredefinedAssetId> = AssetId32::from_asset_id(PredefinedAssetId::DOT);
#[cfg(not(any(feature = "private-net", test)))]
pub const DOT: AssetId32<PredefinedAssetId> = AssetId32::from_bytes(hex!(
"0003b1dbee890acfb1b3bc12d1bb3b4295f52755423f84d1751b2545cebf000b"
));
#[cfg(not(feature = "private-net"))]

// `private-net` is not used in prod
#[allow(deprecated)]
#[cfg(any(feature = "private-net", test))]
pub const KSM: AssetId32<PredefinedAssetId> = AssetId32::from_asset_id(PredefinedAssetId::KSM);
#[cfg(not(any(feature = "private-net", test)))]
pub const KSM: AssetId32<PredefinedAssetId> = AssetId32::from_bytes(hex!(
"00117b0fa73c4672e03a7d9d774e3b3f91beb893e93d9a8d0430295f44225db8"
));

#[cfg(feature = "private-net")]
pub const ROC: AssetId32<PredefinedAssetId> = AssetId32::from_bytes(hex!(
"0x00dc9b4341fde46c9ac80b623d0d43afd9ac205baabdc087cadaa06f92b309c7"
"00dc9b4341fde46c9ac80b623d0d43afd9ac205baabdc087cadaa06f92b309c7"
));

// `private-net` is not used in prod
#[allow(deprecated)]
#[cfg(any(feature = "private-net", test))]
Expand All @@ -252,6 +264,7 @@ pub const USDT: AssetId32<PredefinedAssetId> = AssetId32::from_asset_id(Predefin
pub const USDT: AssetId32<PredefinedAssetId> = AssetId32::from_bytes(hex!(
"0083a6b3fbc6edae06f115c8953ddd7cbfba0b74579d6ea190f96853073b76f4"
));

pub const SB: AssetId32<PredefinedAssetId> = AssetId32::from_bytes(hex!(
"007f66067c940aeb968b19c8dbf9768447e80c52f73aa175aa8c3936c1bb7e5b"
));
Expand Down Expand Up @@ -1243,7 +1256,7 @@ impl<N: Get<u32>> TryFrom<&str> for BoundedString<N> {

impl<N: Get<u32>> PartialOrd for BoundedString<N> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.0.partial_cmp(&other.0)
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion common/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ pub trait Config: frame_system::Config {
/// Definition of a pending atomic swap action. It contains the following three phrases:
///
/// - **Reserve**: reserve the resources needed for a swap. This is to make sure that **Claim**
/// succeeds with best efforts.
/// succeeds with best efforts.
/// - **Claim**: claim any resources reserved in the first phrase.
/// - **Cancel**: cancel any resources reserved in the first phrase.
pub trait SwapAction<SourceAccountId, TargetAccountId, AssetId, T: Config> {
Expand Down
14 changes: 6 additions & 8 deletions common/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ pub fn linspace(a: Fixed, b: Fixed, n: usize, endpoints: IntervalEndpoints) -> V
}
match endpoints {
IntervalEndpoints::None => linspace_inner(a, b, n),
IntervalEndpoints::Left => once(a)
.chain(linspace_inner(a, b, n - 1).into_iter())
.collect(),
IntervalEndpoints::Left => once(a).chain(linspace_inner(a, b, n - 1)).collect(),
IntervalEndpoints::Right => linspace_inner(a, b, n - 1)
.into_iter()
.chain(once(b))
Expand All @@ -96,7 +94,7 @@ pub fn linspace(a: Fixed, b: Fixed, n: usize, endpoints: IntervalEndpoints) -> V
once(b).collect()
} else {
once(a)
.chain(linspace_inner(a, b, n - 2).into_iter())
.chain(linspace_inner(a, b, n - 2))
.chain(once(b))
.collect()
}
Expand Down Expand Up @@ -350,6 +348,10 @@ pub const fn pow(base: u32, mut exp: u32) -> FixedInner {
n
}

pub fn parse_hex_string(s: &str) -> Option<Vec<u8>> {
s.strip_prefix("0x").and_then(|x| x.from_hex().ok())
}

#[cfg(test)]
mod tests {
use fixnum::ops::{Bounded, CheckedMul};
Expand Down Expand Up @@ -605,7 +607,3 @@ mod tests {
);
}
}

pub fn parse_hex_string(s: &str) -> Option<Vec<u8>> {
s.strip_prefix("0x").and_then(|x| x.from_hex().ok())
}
17 changes: 4 additions & 13 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,31 +78,20 @@ sp-mmr-primitives = { git = "https://github.com/sora-xor/substrate.git", branch
prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/sora-xor/substrate.git", branch = "polkadot-v0.9.38" }
beefy-gadget-rpc = { git = "https://github.com/sora-xor/substrate.git", branch = "polkadot-v0.9.38" }
mmr-rpc = { git = "https://github.com/sora-xor/substrate.git", branch = "polkadot-v0.9.38" }
mmr-gadget = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
mmr-gadget = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38" }
leaf-provider-rpc = { git = "https://github.com/sora-xor/sora2-common.git" }
sc-transaction-pool = { git = "https://github.com/sora-xor/substrate.git", branch = "polkadot-v0.9.38" }
frame-remote-externalities = { git = "https://github.com/sora-xor/substrate.git", branch = "polkadot-v0.9.38" }

# TODO remove after toolchain is updated
# newer versions of library requires newer toolchain, current is `nightly-2023-03-21`
ahash = "=0.8.5"
bumpalo = "=3.14.0"
cargo-platform = "=0.1.7"
# newer versions of library requires newer toolchain, current is `nightly-2024-06-25`
substrate-bip39 = "=0.4.5"
schnellru = "=0.2.1"
bstr = "=1.9.1"
predicates-tree = "=1.0.9"
predicates-core = "=1.0.6"
predicates = "=3.1.0"
wasm-bindgen = "=0.2.92"

[build-dependencies]
substrate-build-script-utils = "3"

[dev-dependencies]
# TODO remove after toolchain is updated
# newer versions of librirary requires newer toolchain, current is `nightly-2023-03-21`
assert_cmd = "=2.0.13"
Comment on lines -87 to -105
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Second point of change

tokio = { version = "1.10.1", features = ["macros"] }

# Substrate dependencies
Expand All @@ -116,6 +105,7 @@ include-real-files = []
main-net-coded = []

private-net = [
"common/private-net",
"framenode-chain-spec/private-net",
"framenode-runtime/private-net",
]
Expand All @@ -130,6 +120,7 @@ wip = [
stage = ["framenode-chain-spec/stage", "framenode-runtime/stage"]

runtime-benchmarks = [
"common/runtime-benchmarks",
"frame-benchmarking-cli",
"framenode-runtime/runtime-benchmarks",
"sc-client-db/runtime-benchmarks",
Expand Down
12 changes: 11 additions & 1 deletion node/chain_spec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ include-real-files = []
main-net-coded = []
test = ["common/test"]

private-net = ["faucet", "framenode-runtime/private-net"]
runtime-benchmarks = [
"common/runtime-benchmarks",
"framenode-runtime/runtime-benchmarks",
]

private-net = [
"common/private-net",
"faucet",
"framenode-runtime/private-net",
]

wip = ["framenode-runtime/wip"]
stage = ["framenode-runtime/stage"]
2 changes: 1 addition & 1 deletion node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub struct BeefyDeps {
/// Receives notifications about best block events from BEEFY.
pub beefy_best_block_stream: BeefyBestBlockStream<Block>,
/// Executor to drive the subscription manager in the BEEFY RPC handler.
pub subscription_executor: sc_rpc::SubscriptionTaskExecutor,
pub subscription_executor: SubscriptionTaskExecutor,
}

/// Full client dependencies
Expand Down
2 changes: 2 additions & 0 deletions pallets/apollo-platform/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ default = ['std']
std = [
"assets/std",
"codec/std",
"common/std",
"dex-manager/std",
"frame-support/std",
"frame-system/std",
Expand All @@ -72,6 +73,7 @@ std = [
]

runtime-benchmarks = [
"common/runtime-benchmarks",
"frame-benchmarking",
"frame-system/runtime-benchmarks",
"frame-support/runtime-benchmarks",
Expand Down
8 changes: 4 additions & 4 deletions pallets/apollo-platform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ pub mod pallet {
<UserBorrowingInfo<T>>::get(borrowing_asset, user.clone()).unwrap_or_default();

// Add borrowing amount, collateral amount and interest to user if exists, otherwise create new user
if let Some(mut user_info) = borrow_info.get_mut(&collateral_asset) {
if let Some(user_info) = borrow_info.get_mut(&collateral_asset) {
let block_number = <frame_system::Pallet<T>>::block_number();
let calculated_interest = Self::calculate_borrowing_interest_and_reward(
user_info,
Expand Down Expand Up @@ -672,7 +672,7 @@ pub mod pallet {
let block_number = <frame_system::Pallet<T>>::block_number();

let mut borrowing_rewards = 0;
for (_, mut user_info) in user_infos.iter_mut() {
for (_, user_info) in user_infos.iter_mut() {
let interest_and_reward = Self::calculate_borrowing_interest_and_reward(
user_info,
&pool_info,
Expand Down Expand Up @@ -1227,7 +1227,7 @@ pub mod pallet {
<UserBorrowingInfo<T>>::get(borrowing_asset, user.clone()).unwrap_or_default();

// Add borrowing amount, collateral amount and interest to user if exists, otherwise return error
if let Some(mut user_info) = borrow_info.get_mut(&collateral_asset) {
if let Some(user_info) = borrow_info.get_mut(&collateral_asset) {
let block_number = <frame_system::Pallet<T>>::block_number();
let calculated_interest = Self::calculate_borrowing_interest_and_reward(
user_info,
Expand Down Expand Up @@ -1598,7 +1598,7 @@ pub mod pallet {

// Update borrowing interests
for (account_id, mut user_infos) in UserBorrowingInfo::<T>::iter_prefix(pool_asset) {
for (_, mut user_info) in user_infos.iter_mut() {
for (_, user_info) in user_infos.iter_mut() {
let user_interests = Self::calculate_borrowing_interest_and_reward(
user_info,
&pool_info,
Expand Down
1 change: 1 addition & 0 deletions pallets/assets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ std = [
]

runtime-benchmarks = [
"common/runtime-benchmarks",
"frame-benchmarking",
"frame-system/runtime-benchmarks",
"frame-support/runtime-benchmarks",
Expand Down
1 change: 1 addition & 0 deletions pallets/assets/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ default = ["std"]
std = [
"serde",
"codec/std",
"common/std",
"sp-api/std",
"sp-runtime/std",
"sp-std/std",
Expand Down
2 changes: 2 additions & 0 deletions pallets/band/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ xst = { path = "../xst", default-features = false }
default = ['std']
std = [
"codec/std",
"common/std",
"scale-info/std",
'fallible-iterator/std',
"frame-support/std",
Expand All @@ -45,6 +46,7 @@ std = [
"common/std",
]
runtime-benchmarks = [
"common/runtime-benchmarks",
"frame-benchmarking",
"frame-system/runtime-benchmarks",
"frame-support/runtime-benchmarks",
Expand Down
2 changes: 2 additions & 0 deletions pallets/bridge-proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ currencies = { git = "https://github.com/open-web3-stack/open-runtime-module-lib
default = ["std"]
std = [
"codec/std",
"common/std",
"scale-info/std",
"frame-support/std",
"frame-system/std",
Expand All @@ -63,6 +64,7 @@ std = [
]

runtime-benchmarks = [
"common/runtime-benchmarks",
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
Expand Down
12 changes: 12 additions & 0 deletions pallets/bridge-proxy/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,15 @@ sp-runtime = { git = "https://github.com/sora-xor/substrate.git", branch = "polk

bridge-proxy-runtime-api = { path = "../runtime-api" }
bridge-types = { git = "https://github.com/sora-xor/sora2-common.git" }

[features]
default = ["std"]
std = [
"bridge-proxy-runtime-api/std",
"bridge-types/std",
"codec/std",
"scale-info/std",
"serde/std",
"sp-api/std",
"sp-runtime/std",
]
Loading
Loading