Skip to content

Commit

Permalink
require some gap before unstake is possible
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik committed Apr 7, 2023
1 parent 2da6789 commit c14cb68
Show file tree
Hide file tree
Showing 12 changed files with 1,012 additions and 495 deletions.
13 changes: 9 additions & 4 deletions bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ use bridge_runtime_common::{
ActualFeeRefund, RefundBridgedParachainMessages, RefundableMessagesLane,
RefundableParachain,
},
relayer_slashing::DeliveryStakeAndSlashFromBalance,
};
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
Expand Down Expand Up @@ -373,6 +372,7 @@ parameter_types! {
/// Authorities are changing every 5 minutes.
pub const Period: BlockNumber = bp_millau::SESSION_LENGTH;
pub const Offset: BlockNumber = 0;
pub const RelayerStakeReserveId: [u8; 8] = *b"brdgrlrs";
}

impl pallet_session::Config for Runtime {
Expand All @@ -393,6 +393,14 @@ impl pallet_bridge_relayers::Config for Runtime {
type Reward = Balance;
type PaymentProcedure =
bp_relayers::PayRewardFromAccount<pallet_balances::Pallet<Runtime>, AccountId>;
type StakeAndSlash = pallet_bridge_relayers::StakeAndSlashNamed<
AccountId,
BlockNumber,
Balances,
RelayerStakeReserveId,
ConstU64<1_000>,
ConstU64<8>,
>;
type WeightInfo = ();
}

Expand Down Expand Up @@ -591,15 +599,12 @@ generate_bridge_reject_obsolete_headers_and_messages! {
bp_runtime::generate_static_str_provider!(BridgeRefundRialtoPara2000Lane0Msgs);
/// Signed extension that refunds relayers that are delivering messages from the Rialto parachain.
pub type PriorityBoostPerMessage = ConstU64<921_900_294>;
pub type DeliveryStakeAndSlash =
DeliveryStakeAndSlashFromBalance<AccountId, Balances, Runtime, ConstU64<1_000>>;
pub type BridgeRefundRialtoParachainMessages = RefundBridgedParachainMessages<
Runtime,
RefundableParachain<WithRialtoParachainsInstance, RialtoParachainId>,
RefundableMessagesLane<WithRialtoParachainMessagesInstance, RialtoParachainMessagesLane>,
ActualFeeRefund<Runtime>,
PriorityBoostPerMessage,
DeliveryStakeAndSlash,
StrBridgeRefundRialtoPara2000Lane0Msgs,
>;

Expand Down
1 change: 1 addition & 0 deletions bin/rialto-parachain/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ impl pallet_bridge_relayers::Config for Runtime {
type Reward = Balance;
type PaymentProcedure =
bp_relayers::PayRewardFromAccount<pallet_balances::Pallet<Runtime>, AccountId>;
type StakeAndSlash = ();
type WeightInfo = ();
}

Expand Down
1 change: 1 addition & 0 deletions bin/rialto/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ impl pallet_bridge_relayers::Config for Runtime {
type Reward = Balance;
type PaymentProcedure =
bp_relayers::PayRewardFromAccount<pallet_balances::Pallet<Runtime>, AccountId>;
type StakeAndSlash = ();
type WeightInfo = ();
}

Expand Down
1 change: 0 additions & 1 deletion bin/runtime-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ pub mod messages_xcm_extension;
pub mod parachains_benchmarking;
pub mod priority_calculator;
pub mod refund_relayer_extension;
pub mod relayer_slashing;

mod messages_generation;
mod mock;
Expand Down
27 changes: 16 additions & 11 deletions bin/runtime-common/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@
#![cfg(test)]

use crate::{
messages::{
source::{
FromThisChainMaximalOutboundPayloadSize, FromThisChainMessagePayload,
FromThisChainMessageVerifier, TargetHeaderChainAdapter,
},
target::{FromBridgedChainMessagePayload, SourceHeaderChainAdapter},
BridgedChainWithMessages, HashOf, MessageBridge, ThisChainWithMessages,
use crate::messages::{
source::{
FromThisChainMaximalOutboundPayloadSize, FromThisChainMessagePayload,
FromThisChainMessageVerifier, TargetHeaderChainAdapter,
},
relayer_slashing::DeliveryStakeAndSlashFromBalance,
target::{FromBridgedChainMessagePayload, SourceHeaderChainAdapter},
BridgedChainWithMessages, HashOf, MessageBridge, ThisChainWithMessages,
};

use bp_header_chain::{ChainWithGrandpa, HeaderChain};
Expand Down Expand Up @@ -92,8 +89,14 @@ pub type TestPaymentProcedure = PayRewardFromAccount<Balances, ThisChainAccountI
/// Stake that we are using in tests.
pub type TestStake = ConstU64<5_000>;
/// Stake and slash mechanism to use in tests.
pub type TestDeliveryStakeAndSlash =
DeliveryStakeAndSlashFromBalance<ThisChainAccountId, Balances, TestRuntime, TestStake>;
pub type TestStakeAndSlash = pallet_bridge_relayers::StakeAndSlashNamed<
ThisChainAccountId,
ThisChainBlockNumber,
Balances,
ReserveId,
TestStake,
ConstU32<8>,
>;

/// Message lane used in tests.
pub const TEST_LANE_ID: LaneId = LaneId([0, 0, 0, 0]);
Expand Down Expand Up @@ -138,6 +141,7 @@ parameter_types! {
pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(3, 100_000);
pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000u128);
pub MaximumMultiplier: Multiplier = sp_runtime::traits::Bounded::max_value();
pub const ReserveId: [u8; 8] = *b"brdgrlrs";
}

impl frame_system::Config for TestRuntime {
Expand Down Expand Up @@ -255,6 +259,7 @@ impl pallet_bridge_relayers::Config for TestRuntime {
type RuntimeEvent = RuntimeEvent;
type Reward = ThisChainBalance;
type PaymentProcedure = TestPaymentProcedure;
type StakeAndSlash = TestStakeAndSlash;
type WeightInfo = ();
}

Expand Down
Loading

0 comments on commit c14cb68

Please sign in to comment.