Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
jiguantong committed Nov 1, 2022

Unverified

This user has not yet uploaded their public signing key.
1 parent 47fc92e commit 51ce7ff
Showing 60 changed files with 179 additions and 226 deletions.
12 changes: 6 additions & 6 deletions runtime/common/src/helixbridge/mock.rs
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ impl pallet_balances::Config for Test {
type AccountStore = System;
type Balance = Balance;
type DustRemoval = ();
type Event = ();
type RuntimeEvent = ();
type ExistentialDeposit = ExistentialDeposit;
type MaxLocks = ();
type MaxReserves = ();
@@ -79,9 +79,9 @@ impl frame_system::Config for Test {
type BlockLength = ();
type BlockNumber = u64;
type BlockWeights = ();
type Call = Call;
type RuntimeCall = RuntimeCall;
type DbWeight = ();
type Event = ();
type RuntimeEvent = ();
type Hash = H256;
type Hashing = BlakeTwo256;
type Header = Header;
@@ -91,7 +91,7 @@ impl frame_system::Config for Test {
type OnKilledAccount = ();
type OnNewAccount = ();
type OnSetCode = ();
type Origin = Origin;
type RuntimeOrigin = RuntimeOrigin;
type PalletInfo = PalletInfo;
type SS58Prefix = ();
type SystemWeightInfo = ();
@@ -131,7 +131,7 @@ impl MessagesBridge<Origin, AccountId<Test>, Balance, ()> for MockMessagesBridge
) -> Result<SendMessageArtifacts, Self::Error> {
// send fee to fund account [2;32]
Balances::transfer(submitter, build_account(2).0, fee)?;
Ok(SendMessageArtifacts { nonce: 0, weight: 0 })
Ok(SendMessageArtifacts { nonce: 0, weight: Weight::from_ref_time(0) })
}
}

@@ -153,7 +153,7 @@ impl Config for Test {
type BridgedAccountIdConverter = AccountIdConverter;
type BridgedChainId = PangolinChainId;
type DecimalMultiplier = DecimalsDifference;
type Event = ();
type RuntimeEvent = ();
type MessageLaneId = MessageLaneId;
type MessageNoncer = MockS2sMessageSender;
type MessagesBridge = MockMessagesBridge;
10 changes: 5 additions & 5 deletions runtime/common/src/helixbridge/tests.rs
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ fn issue_from_remote_backing_not_configured() {
let (recipient, _recipient_vec) = build_account(10);
assert_err!(
S2sIssuing::issue_from_remote(
Origin::signed(build_account(1).0),
RuntimeOrigin::signed(build_account(1).0),
1u64,
recipient.clone(),
),
@@ -49,7 +49,7 @@ fn issue_from_remote_backing_remote_sender_invalid() {
));
assert_err!(
S2sIssuing::issue_from_remote(
Origin::signed(build_account(1).0),
RuntimeOrigin::signed(build_account(1).0),
1u64,
recipient.clone(),
),
@@ -71,7 +71,7 @@ fn issue_from_remote_backing_success() {
remote_backing_account
));
assert_ok!(S2sIssuing::issue_from_remote(
Origin::signed(drived_remote_backing_account),
RuntimeOrigin::signed(drived_remote_backing_account),
1024u64,
recipient.clone(),
));
@@ -84,7 +84,7 @@ fn burn_and_remote_unlock_insufficient_balance() {
new_test_ext().execute_with(|| {
assert_err!(
S2sIssuing::burn_and_remote_unlock(
Origin::signed(build_account(1).0),
RuntimeOrigin::signed(build_account(1).0),
1,
1,
100,
@@ -100,7 +100,7 @@ fn burn_and_remote_unlock_insufficient_balance() {
fn burn_and_remote_unlock_success() {
new_test_ext().execute_with(|| {
assert_ok!(S2sIssuing::burn_and_remote_unlock(
Origin::signed(build_account(1).0),
RuntimeOrigin::signed(build_account(1).0),
1,
1,
10,
1 change: 1 addition & 0 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -54,6 +54,7 @@ frame_support::parameter_types! {
/// that combined with `AdjustmentVariable`, we can recover from the minimum.
/// See `multiplier_can_grow_from_zero`.
pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000_000_u128);
pub MaximumMultiplier: Multiplier = sp_runtime::traits::Bounded::max_value();
}

/// Handles converting a weight scalar to a fee value, based on the scale and granularity of the
12 changes: 6 additions & 6 deletions runtime/common/src/remote_governance/mock.rs
Original file line number Diff line number Diff line change
@@ -56,9 +56,9 @@ impl frame_system::Config for Test {
type BlockLength = ();
type BlockNumber = BlockNumber;
type BlockWeights = ();
type Call = Call;
type RuntimeCall = RuntimeCall;
type DbWeight = ();
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type Hash = H256;
type Hashing = BlakeTwo256;
type Header = Header;
@@ -68,7 +68,7 @@ impl frame_system::Config for Test {
type OnKilledAccount = ();
type OnNewAccount = ();
type OnSetCode = ();
type Origin = Origin;
type RuntimeOrigin = RuntimeOrigin;
type PalletInfo = PalletInfo;
type SS58Prefix = ();
type SystemWeightInfo = ();
@@ -82,7 +82,7 @@ impl pallet_balances::Config for Test {
type AccountStore = System;
type Balance = Balance;
type DustRemoval = ();
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type ExistentialDeposit = NativeTokenExistentialDeposit;
type MaxLocks = ();
type MaxReserves = ();
@@ -119,10 +119,10 @@ impl Config for Test {
type BridgeAccountIdConverter = AccountIdConverter;
type BridgeFinalized = ();
type BridgedChainId = PangolinChainId;
type Call = Call;
type RuntimeCall = RuntimeCall;
type CheckInterval = CheckInterval;
type EmergencySafeguardOrigin = EnsureAlice;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
}

construct_runtime!(
10 changes: 5 additions & 5 deletions runtime/common/src/remote_governance/tests.rs
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ fn emergency_safeguard_should_work() {

assert_noop!(
RemoteGovernance::emergency_safeguard(
Origin::signed(ALICE),
RuntimeOrigin::signed(ALICE),
force_balance_transfer.clone()
),
<Error<Test>>::EmergencyOnly
@@ -52,14 +52,14 @@ fn emergency_safeguard_should_work() {

assert_noop!(
RemoteGovernance::emergency_safeguard(
Origin::signed(BOB),
RuntimeOrigin::signed(BOB),
force_balance_transfer.clone()
),
BadOrigin
);

assert_ok!(RemoteGovernance::emergency_safeguard(
Origin::signed(ALICE),
RuntimeOrigin::signed(ALICE),
force_balance_transfer
));
assert_eq!(Balances::free_balance(BOB), 11);
@@ -80,7 +80,7 @@ fn enact_remote_call_should_work() {

assert_noop!(
RemoteGovernance::enact_remote_call(
Origin::signed(ALICE),
RuntimeOrigin::signed(ALICE),
force_balance_transfer.clone()
),
<Error<Test>>::RequireSourceRoot
@@ -90,7 +90,7 @@ fn enact_remote_call_should_work() {
let source_root = RemoteGovernance::derived_source_root();

assert_ok!(RemoteGovernance::enact_remote_call(
Origin::signed(source_root),
RuntimeOrigin::signed(source_root),
force_balance_transfer
));
assert_eq!(Balances::free_balance(BOB), 11);
21 changes: 11 additions & 10 deletions runtime/crab-parachain/src/bridges_message/crab.rs
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ pub type FromCrabMessagesProof = FromBridgedChainMessagesProof<bp_crab::Hash>;
/// Message payload for CrabParachain -> Crab messages.
pub type ToCrabMessagePayload = FromThisChainMessagePayload;
/// Message payload for Crab -> CrabParachain messages.
pub type FromCrabMessagePayload = FromBridgedChainMessagePayload<Call>;
pub type FromCrabMessagePayload = FromBridgedChainMessagePayload<RuntimeCall>;

/// Message verifier for CrabParachain -> Crab messages.
pub type ToCrabMessageVerifier<R> =
@@ -34,21 +34,24 @@ pub type FromCrabMessageDispatch = FromBridgedChainMessageDispatch<
WithCrabMessageBridge,
xcm_executor::XcmExecutor<crate::polkadot_xcm::XcmConfig>,
crate::polkadot_xcm::XcmWeigher,
// 2 XCM instructions is for simple `Trap(42)` program, coming through bridge
// (it is prepended with `UniversalOrigin` instruction)
frame_support::traits::ConstU64<BASE_XCM_WEIGHT_TWICE>,
WeightCredit
>;

pub const INITIAL_CRAB_TO_CRAB_PARACHAIN_CONVERSION_RATE: FixedU128 =
FixedU128::from_inner(FixedU128::DIV);
/// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge
/// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual
/// tests, confirming that we don't break encoding somewhere between.
pub const BASE_XCM_WEIGHT_TWICE: Weight = 2 * crate::xcm_config::BASE_XCM_WEIGHT;
pub const BASE_XCM_WEIGHT_TWICE: u64 = 2 * crate::xcm_config::BASE_XCM_WEIGHT;

frame_support::parameter_types! {
/// CrabParachain to Crab conversion rate. Initially we trate both tokens as equal.
pub storage CrabToCrabParachainConversionRate: FixedU128 = INITIAL_CRAB_TO_CRAB_PARACHAIN_CONVERSION_RATE;
/// Weight credit for our test messages.
///
/// 2 XCM instructions is for simple `Trap(42)` program, coming through bridge
/// (it is prepended with `UniversalOrigin` instruction).
pub const WeightCredit: Weight = Weight::from_ref_time(BASE_XCM_WEIGHT_TWICE);
}

#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)]
@@ -89,13 +92,12 @@ impl ChainWithMessages for CrabParachain {
type Hash = bp_crab_parachain::Hash;
type Signature = bp_crab_parachain::Signature;
type Signer = bp_crab_parachain::AccountPublic;
type Weight = Weight;
}
impl ThisChainWithMessages for CrabParachain {
type Call = Call;
type Origin = Origin;
type RuntimeCall = RuntimeCall;
type RuntimeOrigin = RuntimeOrigin;

fn is_message_accepted(send_origin: &Self::Origin, lane: &LaneId) -> bool {
fn is_message_accepted(send_origin: &Self::RuntimeOrigin, lane: &LaneId) -> bool {
let here_location =
xcm::v3::MultiLocation::from(crate::xcm_config::UniversalLocation::get());
match send_origin.caller {
@@ -128,7 +130,6 @@ impl ChainWithMessages for Crab {
type Hash = bp_crab::Hash;
type Signature = bp_crab::Signature;
type Signer = bp_crab::AccountPublic;
type Weight = Weight;
}
impl BridgedChainWithMessages for Crab {
fn maximal_extrinsic_size() -> u32 {
2 changes: 1 addition & 1 deletion runtime/crab-parachain/src/pallets/balances.rs
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ impl Config for Runtime {
type AccountStore = System;
type Balance = Balance;
type DustRemoval = ();
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type ExistentialDeposit = ExistentialDeposit;
type MaxLocks = MaxLocks;
type MaxReserves = MaxReserves;
6 changes: 3 additions & 3 deletions runtime/crab-parachain/src/pallets/bridge_messages.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ use pallet_fee_market::s2s::{
FeeMarketMessageAcceptedHandler, FeeMarketMessageConfirmedHandler, FeeMarketPayment,
};

impl SenderOrigin<AccountId> for Origin {
impl SenderOrigin<AccountId> for RuntimeOrigin {
fn linked_account(&self) -> Option<AccountId> {
// XCM deals wit fees in our deployments
None
@@ -24,14 +24,14 @@ frame_support::parameter_types! {
pub const MaxUnrewardedRelayerEntriesAtInboundLane: MessageNonce =
bp_crab::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
pub const GetDeliveryConfirmationTransactionFee: Balance =
bp_crab::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT as _;
bp_crab::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT.ref_time() as _;
pub RootAccountForPayments: Option<AccountId> = None;
}

impl Config<WithCrabMessages> for Runtime {
type AccountIdConverter = bp_crab_parachain::AccountIdConverter;
type BridgedChainId = BridgedChainId;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type InboundMessageFee = bp_crab::Balance;
type InboundPayload = bm_crab::FromCrabMessagePayload;
type InboundRelayer = bp_crab::AccountId;
2 changes: 1 addition & 1 deletion runtime/crab-parachain/src/pallets/collator_selection.rs
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ pub type CollatorSelectionUpdateOrigin =

impl Config for Runtime {
type Currency = Ring;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
// should be a multiple of session or things will get inconsistent
type KickThreshold = Period;
type MaxCandidates = MaxCandidates;
2 changes: 1 addition & 1 deletion runtime/crab-parachain/src/pallets/cumulus_xcm.rs
Original file line number Diff line number Diff line change
@@ -5,6 +5,6 @@ use xcm_executor::XcmExecutor;
use crate::*;

impl Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type XcmExecutor = XcmExecutor<XcmConfig>;
}
2 changes: 1 addition & 1 deletion runtime/crab-parachain/src/pallets/dmp_queue.rs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ use xcm_executor::XcmExecutor;
use crate::*;

impl Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
type XcmExecutor = XcmExecutor<XcmConfig>;
}
2 changes: 1 addition & 1 deletion runtime/crab-parachain/src/pallets/fee_market.rs
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ impl Config<WithCrabFeeMarket> for Runtime {
type ConfirmRelayersRewardRatio = ConfirmRelayersRewardRatio;
type Currency = Ring;
type DutyRelayersRewardRatio = DutyRelayersRewardRatio;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type LockId = FeeMarketLockId;
type MessageRelayersRewardRatio = MessageRelayersRewardRatio;
type MinimumRelayFee = MinimumRelayFee;
2 changes: 1 addition & 1 deletion runtime/crab-parachain/src/pallets/helixbridge.rs
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ impl Config for Runtime {
type BridgedAccountIdConverter = bp_crab::AccountIdConverter;
type BridgedChainId = CrabChainId;
type DecimalMultiplier = DecimalMultiplier;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type MessageLaneId = BridgeCrabLaneId;
type MessageNoncer = ToCrabMessageSender;
type MessagesBridge = BridgeCrabMessages;
4 changes: 2 additions & 2 deletions runtime/crab-parachain/src/pallets/multisig.rs
Original file line number Diff line number Diff line change
@@ -12,11 +12,11 @@ frame_support::parameter_types! {
}

impl Config for Runtime {
type Call = Call;
type RuntimeCall = RuntimeCall;
type Currency = Ring;
type DepositBase = DepositBase;
type DepositFactor = DepositFactor;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type MaxSignatories = MaxSignatories;
type WeightInfo = WeightInfo<Runtime>;
}
6 changes: 3 additions & 3 deletions runtime/crab-parachain/src/pallets/parachain_system.rs
Original file line number Diff line number Diff line change
@@ -6,14 +6,14 @@ use parachain_info::Pallet as ParachainInfoPallet;
use crate::*;

frame_support::parameter_types! {
pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
}

impl Config for Runtime {
type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases;
type DmpMessageHandler = DmpQueue;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type OnSystemEvent = ();
type OutboundXcmpMessageSource = XcmpQueue;
type ReservedDmpWeight = ReservedDmpWeight;
Loading

0 comments on commit 51ce7ff

Please sign in to comment.