mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 04:39:24 +00:00
Merge branch 'develop' into next
This commit is contained in:
@@ -13,7 +13,7 @@ all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[package.metadata.cargo-machete]
|
||||
ignored = ["scale", "scale-info"]
|
||||
ignored = ["scale"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
@@ -22,16 +22,15 @@ workspace = true
|
||||
bitvec = { version = "1", default-features = false, features = ["alloc"] }
|
||||
|
||||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "max-encoded-len"] }
|
||||
scale-info = { version = "2", default-features = false, features = ["derive"] }
|
||||
|
||||
sp-std = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
sp-application-crypto = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
sp-io = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
sp-core = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "da19e1f8ca7a9e2cbf39fbfa493918eeeb45e10b", default-features = false }
|
||||
sp-application-crypto = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "da19e1f8ca7a9e2cbf39fbfa493918eeeb45e10b", default-features = false }
|
||||
sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "da19e1f8ca7a9e2cbf39fbfa493918eeeb45e10b", default-features = false }
|
||||
sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "da19e1f8ca7a9e2cbf39fbfa493918eeeb45e10b", default-features = false }
|
||||
sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "da19e1f8ca7a9e2cbf39fbfa493918eeeb45e10b", default-features = false }
|
||||
|
||||
frame-system = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
frame-support = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "da19e1f8ca7a9e2cbf39fbfa493918eeeb45e10b", default-features = false }
|
||||
frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "da19e1f8ca7a9e2cbf39fbfa493918eeeb45e10b", default-features = false }
|
||||
|
||||
serai-primitives = { path = "../../primitives", default-features = false }
|
||||
in-instructions-primitives = { package = "serai-in-instructions-primitives", path = "../primitives", default-features = false }
|
||||
@@ -43,16 +42,16 @@ genesis-liquidity-pallet = { package = "serai-genesis-liquidity-pallet", path =
|
||||
emissions-pallet = { package = "serai-emissions-pallet", path = "../../emissions/pallet", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
pallet-babe = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
pallet-grandpa = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
pallet-timestamp = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
pallet-session = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "da19e1f8ca7a9e2cbf39fbfa493918eeeb45e10b", default-features = false }
|
||||
pallet-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "da19e1f8ca7a9e2cbf39fbfa493918eeeb45e10b", default-features = false }
|
||||
pallet-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "da19e1f8ca7a9e2cbf39fbfa493918eeeb45e10b", default-features = false }
|
||||
pallet-timestamp = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "da19e1f8ca7a9e2cbf39fbfa493918eeeb45e10b", default-features = false }
|
||||
|
||||
economic-security-pallet = { package = "serai-economic-security-pallet", path = "../../economic-security/pallet", default-features = false }
|
||||
|
||||
[features]
|
||||
std = [
|
||||
"scale/std",
|
||||
"scale-info/std",
|
||||
|
||||
"sp-std/std",
|
||||
"sp-application-crypto/std",
|
||||
|
||||
@@ -58,7 +58,6 @@ pub mod pallet {
|
||||
+ GenesisLiqConfig
|
||||
+ EmissionsConfig
|
||||
{
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
|
||||
}
|
||||
|
||||
#[pallet::event]
|
||||
|
||||
@@ -5,7 +5,7 @@ use super::*;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use frame_support::{
|
||||
construct_runtime,
|
||||
derive_impl, construct_runtime,
|
||||
traits::{ConstU16, ConstU32, ConstU64},
|
||||
};
|
||||
|
||||
@@ -52,10 +52,9 @@ construct_runtime!(
|
||||
}
|
||||
);
|
||||
|
||||
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
|
||||
impl frame_system::Config for Test {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Nonce = u64;
|
||||
@@ -66,16 +65,6 @@ impl frame_system::Config for Test {
|
||||
type Block = Block;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = ConstU64<250>;
|
||||
type DbWeight = ();
|
||||
type Version = ();
|
||||
type PalletInfo = PalletInfo;
|
||||
type AccountData = ();
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
type OnSetCode = ();
|
||||
type MaxConsumers = ConstU32<16>;
|
||||
}
|
||||
|
||||
impl timestamp::Config for Test {
|
||||
@@ -85,6 +74,16 @@ impl timestamp::Config for Test {
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
pub struct GetSession;
|
||||
impl pallet_session::GetCurrentSessionForSubstrate for GetSession {
|
||||
fn get() -> u32 {
|
||||
0
|
||||
}
|
||||
}
|
||||
impl pallet_session::Config for Test {
|
||||
type Session = GetSession;
|
||||
}
|
||||
|
||||
impl babe::Config for Test {
|
||||
type EpochDuration = ConstU64<{ FAST_EPOCH_DURATION }>;
|
||||
|
||||
@@ -94,6 +93,7 @@ impl babe::Config for Test {
|
||||
|
||||
type WeightInfo = ();
|
||||
type MaxAuthorities = MaxAuthorities;
|
||||
type MaxNominators = MaxAuthorities;
|
||||
|
||||
type KeyOwnerProof = MembershipProof<Self>;
|
||||
type EquivocationReportSystem = ();
|
||||
@@ -104,6 +104,7 @@ impl grandpa::Config for Test {
|
||||
|
||||
type WeightInfo = ();
|
||||
type MaxAuthorities = MaxAuthorities;
|
||||
type MaxNominators = MaxAuthorities;
|
||||
|
||||
type MaxSetIdSessionEntries = ConstU64<0>;
|
||||
type KeyOwnerProof = MembershipProof<Self>;
|
||||
@@ -111,18 +112,14 @@ impl grandpa::Config for Test {
|
||||
}
|
||||
|
||||
impl coins::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type AllowMint = ValidatorSets;
|
||||
}
|
||||
|
||||
impl coins::Config<coins::Instance1> for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type AllowMint = ();
|
||||
}
|
||||
|
||||
impl dex::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
|
||||
type LPFee = ConstU32<3>; // 0.3%
|
||||
type MintMinLiquidity = ConstU64<10000>;
|
||||
|
||||
@@ -134,25 +131,16 @@ impl dex::Config for Test {
|
||||
}
|
||||
|
||||
impl validator_sets::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type ShouldEndSession = Babe;
|
||||
}
|
||||
|
||||
impl genesis_liquidity::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
}
|
||||
impl genesis_liquidity::Config for Test {}
|
||||
|
||||
impl emissions::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
}
|
||||
impl emissions::Config for Test {}
|
||||
|
||||
impl economic_security::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
}
|
||||
impl economic_security::Config for Test {}
|
||||
|
||||
impl Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
}
|
||||
impl Config for Test {}
|
||||
|
||||
// Amounts for single key share per network
|
||||
pub fn key_shares() -> HashMap<NetworkId, Amount> {
|
||||
|
||||
@@ -22,7 +22,7 @@ fn set_keys_for_session(key: Public) {
|
||||
n,
|
||||
KeyPair(key, vec![].try_into().unwrap()),
|
||||
vec![].try_into().unwrap(),
|
||||
Signature([0u8; 64]),
|
||||
Signature::from([0u8; 64]),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
@@ -80,7 +80,7 @@ fn validate_batch() {
|
||||
}
|
||||
|
||||
let call = pallet::Call::<Test>::execute_batch {
|
||||
batch: SignedBatch { batch: batch.clone(), signature: Signature([0u8; 64]) },
|
||||
batch: SignedBatch { batch: batch.clone(), signature: Signature::from([0u8; 64]) },
|
||||
};
|
||||
assert_eq!(
|
||||
InInstructions::validate_unsigned(TransactionSource::External, &call),
|
||||
@@ -95,7 +95,7 @@ fn validate_batch() {
|
||||
|
||||
// 0 signature should be invalid
|
||||
let call = pallet::Call::<Test>::execute_batch {
|
||||
batch: SignedBatch { batch: batch.clone(), signature: Signature([0u8; 64]) },
|
||||
batch: SignedBatch { batch: batch.clone(), signature: Signature::from([0u8; 64]) },
|
||||
};
|
||||
assert_eq!(
|
||||
InInstructions::validate_unsigned(TransactionSource::External, &call),
|
||||
@@ -121,7 +121,7 @@ fn validate_batch() {
|
||||
|
||||
// can't submit in the first block(Block 0)
|
||||
let call = pallet::Call::<Test>::execute_batch {
|
||||
batch: SignedBatch { batch: batch.clone(), signature: signature.clone() },
|
||||
batch: SignedBatch { batch: batch.clone(), signature },
|
||||
};
|
||||
assert_eq!(
|
||||
InInstructions::validate_unsigned(TransactionSource::External, &call),
|
||||
@@ -133,7 +133,7 @@ fn validate_batch() {
|
||||
|
||||
// first batch id should be 0
|
||||
let call = pallet::Call::<Test>::execute_batch {
|
||||
batch: SignedBatch { batch: batch.clone(), signature: signature.clone() },
|
||||
batch: SignedBatch { batch: batch.clone(), signature },
|
||||
};
|
||||
assert_eq!(
|
||||
InInstructions::validate_unsigned(TransactionSource::External, &call),
|
||||
@@ -146,7 +146,7 @@ fn validate_batch() {
|
||||
|
||||
// can't have more than 1 batch per block
|
||||
let call = pallet::Call::<Test>::execute_batch {
|
||||
batch: SignedBatch { batch: batch.clone(), signature: signature.clone() },
|
||||
batch: SignedBatch { batch: batch.clone(), signature },
|
||||
};
|
||||
assert_eq!(
|
||||
InInstructions::validate_unsigned(TransactionSource::External, &call),
|
||||
@@ -224,7 +224,7 @@ fn transfer_instruction() {
|
||||
balance: ExternalBalance { coin, amount },
|
||||
}],
|
||||
},
|
||||
signature: Signature([0u8; 64]),
|
||||
signature: Signature::from([0u8; 64]),
|
||||
};
|
||||
InInstructions::execute_batch(RawOrigin::None.into(), batch).unwrap();
|
||||
|
||||
@@ -250,7 +250,7 @@ fn dex_instruction_add_liquidity() {
|
||||
balance: ExternalBalance { coin, amount },
|
||||
}],
|
||||
},
|
||||
signature: Signature([0u8; 64]),
|
||||
signature: Signature::from([0u8; 64]),
|
||||
};
|
||||
|
||||
// we should have a liquid pool before we can swap
|
||||
@@ -328,7 +328,7 @@ fn dex_instruction_swap() {
|
||||
balance: ExternalBalance { coin, amount },
|
||||
}],
|
||||
},
|
||||
signature: Signature([0u8; 64]),
|
||||
signature: Signature::from([0u8; 64]),
|
||||
};
|
||||
|
||||
// we can't send SRI to external address
|
||||
@@ -418,7 +418,7 @@ fn genesis_liquidity_instruction() {
|
||||
balance: ExternalBalance { coin, amount },
|
||||
}],
|
||||
},
|
||||
signature: Signature([0u8; 64]),
|
||||
signature: Signature::from([0u8; 64]),
|
||||
};
|
||||
|
||||
InInstructions::execute_batch(RawOrigin::None.into(), batch.clone()).unwrap();
|
||||
@@ -456,7 +456,7 @@ fn swap_to_staked_sri_instruction() {
|
||||
coin.network(),
|
||||
KeyPair(insecure_pair_from_name("random-key").public(), Vec::new().try_into().unwrap()),
|
||||
Vec::new().try_into().unwrap(),
|
||||
Signature([0u8; 64]),
|
||||
Signature::from([0u8; 64]),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@@ -479,7 +479,7 @@ fn swap_to_staked_sri_instruction() {
|
||||
balance: ExternalBalance { coin, amount },
|
||||
}],
|
||||
},
|
||||
signature: Signature([0u8; 64]),
|
||||
signature: Signature::from([0u8; 64]),
|
||||
};
|
||||
|
||||
InInstructions::execute_batch(RawOrigin::None.into(), batch.clone()).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user