Skip to content

Commit

Permalink
Fix bifrost-polkadot barrier
Browse files Browse the repository at this point in the history
  • Loading branch information
hqwangningbo committed Dec 4, 2023
1 parent f464ef0 commit 4816922
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion runtime/bifrost-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("bifrost_polkadot"),
impl_name: create_runtime_str!("bifrost_polkadot"),
authoring_version: 0,
spec_version: 987,
spec_version: 988,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
29 changes: 27 additions & 2 deletions runtime/bifrost-polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,32 @@ impl<T: Contains<MultiLocation>> ShouldExecute for AllowTopLevelPaidExecutionDes
}
}

pub type Barrier = (
/// Sets the message ID to `t` using a `SetTopic(t)` in the last position if present.
///
/// Requires some inner barrier to pass on the rest of the message.
pub struct TrailingSetTopicAsId<InnerBarrier>(PhantomData<InnerBarrier>);
impl<InnerBarrier: ShouldExecute> ShouldExecute for TrailingSetTopicAsId<InnerBarrier> {
fn should_execute<Call>(
origin: &MultiLocation,
instructions: &mut [Instruction<Call>],
max_weight: Weight,
weight_credit: &mut Weight,
) -> Result<(), ProcessMessageError> {
log::trace!(
target: "xcm::barriers",
"TrailingSetTopicAsId origin: {:?}, instructions: {:?}, max_weight: {:?}",
origin, instructions, max_weight,
);
let until = if let Some(SetTopic(_)) = instructions.last() {
instructions.len() - 1
} else {
instructions.len()
};
InnerBarrier::should_execute(&origin, &mut instructions[..until], max_weight, weight_credit)
}
}

pub type Barrier = TrailingSetTopicAsId<(
// Weight that is paid for may be consumed.
TakeWeightCredit,
// Expected responses are OK.
Expand All @@ -317,7 +342,7 @@ pub type Barrier = (
AllowSubscriptionsFrom<Everything>,
// Barrier allowing a top level paid message with DescendOrigin instruction
AllowTopLevelPaidExecutionDescendOriginFirst<Everything>,
);
)>;

pub type BifrostAssetTransactor = MultiCurrencyAdapter<
Currencies,
Expand Down

0 comments on commit 4816922

Please sign in to comment.