Skip to content

Commit

Permalink
test: authority rotation integration tests (#3909)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel <daniel@chainflip.io>
Co-authored-by: dandanlen <3168260+dandanlen@users.noreply.github.com>
  • Loading branch information
3 people committed Sep 18, 2023
1 parent 3d92488 commit ae894d6
Show file tree
Hide file tree
Showing 14 changed files with 531 additions and 240 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions state-chain/amm/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,13 @@ pub(super) fn sqrt_price_at_tick(tick: Tick) -> SqrtPriceQ64F96 {
/* Proof that r is never zero (therefore avoiding the divide by zero case here):
We can think of an application of the `handle_tick_bit` macro as increasing the index I of r's MSB/`r.ilog2()` (mul by constant), and then decreasing it by 128 (the right shift).
Note the increase in I caused by the constant mul will be atleast constant.ilog2().
Note the increase in I caused by the constant mul will be at least constant.ilog2().
Also note each application of `handle_tick_bit` decreases (if the if branch is entered) or else maintains r's value as all the constants are less than 2^128.
Therefore the largest decrease would be caused if all the macros application's if branches where entered.
So we assuming all if branches are entered, after all the applications `I` would be atleast I_initial + bigsum(constant.ilog2()) - 19*128.
So we assuming all if branches are entered, after all the applications `I` would be at least I_initial + bigsum(constant.ilog2()) - 19*128.
The test `r_non_zero` checks with value is >= 0, therefore imply the smallest value r could have is more than 0.
*/
Expand Down
12 changes: 6 additions & 6 deletions state-chain/amm/src/limit_orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl FloatBetweenZeroAndOne {

let (mul_div_normalised_mantissa, div_normalise_shift) = {
// As the denominator <= U256::MAX, this div will not right-shift the mantissa more than
// 256 bits, so we maintain atleast 256 accurate bits in the result.
// 256 bits, so we maintain at least 256 accurate bits in the result.
let (d, div_remainder) =
U512::div_mod(mul_normalised_mantissa, U512::from(denominator));
let d = if div_remainder.is_zero() { d } else { d + U512::one() };
Expand All @@ -96,11 +96,11 @@ impl FloatBetweenZeroAndOne {
Self { normalised_mantissa: mul_div_normalised_mantissa, negative_exponent }
} else {
// This bounding will cause swaps to get bad prices, but this case will effectively
// never happen, as atleast (U256::MAX / 256) (~10^74) swaps would have to happen to get
// into this situation. TODO: A possible solution is disabling minting for pools "close"
// to this minimum. With a small change to the swapping logic it would be possible to
// guarantee that the pool would be emptied before percent_remaining could reach this
// min bound.
// never happen, as at least (U256::MAX / 256) (~10^74) swaps would have to happen to
// get into this situation. TODO: A possible solution is disabling minting for pools
// "close" to this minimum. With a small change to the swapping logic it would be
// possible to guarantee that the pool would be emptied before percent_remaining could
// reach this min bound.
Self { normalised_mantissa: U256::one() << 255, negative_exponent: U256::MAX }
}
}
Expand Down
2 changes: 2 additions & 0 deletions state-chain/cf-integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ targets = ['x86_64-unknown-linux-gnu']

[dependencies]
state-chain-runtime = { path = '../runtime' }
log = { version = '0.4.16', default-features = false }

[dev-dependencies]
libsecp256k1 = { version = "0.7", features = ['static-context'] }
Expand Down Expand Up @@ -79,3 +80,4 @@ sp-std = { git = "https://github.com/chainflip-io/substrate.git", tag = "chainfl
sp-transaction-pool = { git = "https://github.com/chainflip-io/substrate.git", tag = "chainflip-monthly-2023-08+2" }
sp-version = { git = "https://github.com/chainflip-io/substrate.git", tag = "chainflip-monthly-2023-08+2" }
sp-consensus-grandpa = { git = "https://github.com/chainflip-io/substrate.git", tag = "chainflip-monthly-2023-08+2" }
sp-timestamp = { git = "https://github.com/chainflip-io/substrate.git", tag = "chainflip-monthly-2023-08+2" }
1 change: 1 addition & 0 deletions state-chain/cf-integration-tests/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ fn account_deletion_removes_relevant_storage_items() {
let vanity_names = VanityNames::<Runtime>::get();
assert_eq!(*vanity_names.get(&backup_node).unwrap(), elon_vanity_name.as_bytes().to_vec());

// Redeem all
network::Cli::redeem(
&backup_node,
RedemptionAmount::Max,
Expand Down
Loading

0 comments on commit ae894d6

Please sign in to comment.