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 Polkadot v0.9.26 #888

Merged
merged 20 commits into from
Aug 30, 2022
Merged

Update Polkadot v0.9.26 #888

merged 20 commits into from
Aug 30, 2022

Conversation

NunoAlexandre
Copy link
Contributor

No description provided.

@NunoAlexandre NunoAlexandre dismissed a stale review via 488c12f August 18, 2022 15:14
@NunoAlexandre NunoAlexandre force-pushed the polkadot-v0.9.26 branch 2 times, most recently from 4cde061 to 8bd1f83 Compare August 19, 2022 09:49
@mustermeiszer mustermeiszer self-assigned this Aug 26, 2022
@NunoAlexandre NunoAlexandre changed the title [wip] Update Polkadot v0.9.26 Update Polkadot v0.9.26 Aug 26, 2022
@mustermeiszer
Copy link
Collaborator

@NunoAlexandre could you update the nix hash once the last tests run through? I haven't set up this yet ^^

@@ -40,7 +40,7 @@ async fn create_init_and_price() {
let mut nft_manager = NftManager::new();
let pool_id = 0u64;
let loan_amount = 10_000 * DECIMAL_BASE_12;
let borrow_amount = Amount::from_inner(9_000 * DECIMAL_BASE_12);
let borrow_amount = Rate::from_inner(9_000 * DECIMAL_BASE_12);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be Balance::from_inner()? Since it's an amount, not a percentage/rate.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's actually not used. I removed it. But otherwise, you were right.

Comment on lines 144 to 177
fn checked_from_rational<N: FixedPointOperand, D: FixedPointOperand>(
n: N,
d: D,
) -> Option<Self> {
if d == D::zero() {
return None;
}

let n: I129 = n.into();
let d: I129 = d.into();
let negative = n.negative != d.negative;

multiply_by_rational_with_rounding(
n.value,
Self::DIV.unique_saturated_into(),
d.value,
Rounding::from_signed(SignedRounding::NearestPrefLow, negative),
)
.and_then(|value| from_i129(I129 { value, negative }))
.map(Self::from_inner)
}

/// Checked multiplication for integer type `N`. Equal to `self * n`.
///
/// Returns `None` if the result does not fit in `N`.
fn checked_mul_int<N: FixedPointOperand>(self, n: N) -> Option<N> {
let lhs: I129 = self.into_inner().into();
let rhs: I129 = n.into();
let negative = lhs.negative != rhs.negative;

use sp_runtime::traits::UniqueSaturatedInto;
multiply_by_rational_with_rounding(
lhs.value,
rhs.value,
Self::DIV.unique_saturated_into(),
Copy link
Collaborator

@mustermeiszer mustermeiszer Aug 29, 2022

Choose a reason for hiding this comment

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

@offerijns and @branan @gruberb I simply overwrote the existing trait implementation from the trait, as Parity uses a different rounding preference.

As you can see I went for Rounding::from_signed(SignedRounding::NearestPrefLow, negative everywhere which is: Round to nearest, unless distance is equal (i.e. 5), then round to zero.
Are we fine with that? We can of course choose a different rounding preference?

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably good if @branan confirms as he's spent more time on this, but I think that's a sane default. Should we still add a ticket to make rounding direction in all usages (at least in pools) explicit though? There are some cases where we'd want to round up (e.g. calculating debt for a loan).

Copy link
Collaborator

Choose a reason for hiding this comment

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

@offerijns We can not decide on a per cal level now. IF we wann do that, we must add additional methods, that do this, which is simple and easy to do, but just to note that.

These methods here are basically the defaults.

@mustermeiszer mustermeiszer marked this pull request as ready for review August 29, 2022 14:09
Copy link
Contributor Author

@NunoAlexandre NunoAlexandre left a comment

Choose a reason for hiding this comment

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

LGTM but I also worked on this so not the best person to approve 👍

Copy link
Contributor

@mikiquantum mikiquantum left a comment

Choose a reason for hiding this comment

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

LGTM! Some minor comments only

@@ -14,8 +14,7 @@
#![cfg(test)]
#![allow(unused)]

//TODO(nuno): re-enable pools once fudge is compatible with polkadot 0.9.20
// mod pools;
mod pools;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice

runtime/common/src/fixed_point.rs Show resolved Hide resolved
@@ -60,4 +60,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}

fn spend() -> Weight {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we need to recompute the runtime weights in general right? We can do that in a following PR too

@@ -328,7 +328,7 @@ pub fn run() -> Result<()> {
)?;

let state_version = Cli::native_runtime_version(&chain_spec).state_version();
let block: Block = generate_genesis_block(&chain_spec, state_version)?;
let block: Block = generate_genesis_block(&**chain_spec, state_version)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

This dereference seems weird, doesnt it work with only one &*chain_spec if we change the above chain_spec declaration to:

let chain_spec = load_spec(

@mustermeiszer mustermeiszer merged commit 76dd221 into parachain Aug 30, 2022
@NunoAlexandre NunoAlexandre deleted the polkadot-v0.9.26 branch August 30, 2022 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants