-
Notifications
You must be signed in to change notification settings - Fork 91
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
Conversation
4cde061
to
8bd1f83
Compare
fa60461
to
b45feb4
Compare
f61b0a6
to
8433a51
Compare
@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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
runtime/common/src/fixed_point.rs
Outdated
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(), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
Faulty rebase
6849b68
to
7acdbc8
Compare
There was a problem hiding this 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 👍
There was a problem hiding this 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
@@ -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 { |
There was a problem hiding this comment.
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)?; |
There was a problem hiding this comment.
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(
No description provided.