Skip to content

Commit

Permalink
Merge branch 'main' into ron/sno-738
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed Nov 3, 2023
2 parents a2d7617 + 59c657f commit 9cdaf0f
Show file tree
Hide file tree
Showing 12 changed files with 173 additions and 58 deletions.
2 changes: 1 addition & 1 deletion contracts/src/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ contract Gateway is IGateway, IInitializable {

CoreStorage.Layout storage $ = CoreStorage.layout();

$.mode = OperatingMode.Normal;
$.mode = OperatingMode.RejectingOutboundMessages;
$.defaultFee = defaultFee;

// Initialize an agent & channel for BridgeHub
Expand Down
3 changes: 3 additions & 0 deletions contracts/test/Gateway.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ contract GatewayTest is Test {
);
GatewayMock(address(gateway)).setCommitmentsAreVerified(true);

Gateway.SetOperatingModeParams memory params = Gateway.SetOperatingModeParams({mode: OperatingMode.Normal});
GatewayMock(address(gateway)).setOperatingModePublic(abi.encode(params));

bridgeHubAgent = IGateway(address(gateway)).agentOf(bridgeHubAgentID);
assetHubAgent = IGateway(address(gateway)).agentOf(assetHubAgentID);

Expand Down
107 changes: 70 additions & 37 deletions parachain/Cargo.lock

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

18 changes: 5 additions & 13 deletions parachain/pallets/control/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
use crate as snowbridge_control;
use frame_support::{
parameter_types,
traits::{tokens::fungible::Mutate, ConstU128, ConstU16, ConstU64, ConstU8, Contains},
traits::{tokens::fungible::Mutate, ConstU128, ConstU16, ConstU64, ConstU8},
weights::IdentityFee,
PalletId,
};
use sp_core::H256;
use xcm_executor::traits::ConvertLocation;

use snowbridge_core::{outbound::ConstantGasMeter, sibling_sovereign_account, AgentId, ParaId};
use snowbridge_core::{
outbound::ConstantGasMeter, sibling_sovereign_account, AgentId, AllowSiblingsOnly, ParaId,
};
use sp_runtime::{
traits::{AccountIdConversion, BlakeTwo256, IdentityLookup, Keccak256},
AccountId32, BuildStorage,
Expand Down Expand Up @@ -132,6 +134,7 @@ impl pallet_balances::Config for Test {
type FreezeIdentifier = ();
type MaxFreezes = ();
type RuntimeHoldReason = ();
type RuntimeFreezeReason = ();
type MaxHolds = ();
}

Expand Down Expand Up @@ -201,17 +204,6 @@ impl BenchmarkHelper<RuntimeOrigin> for () {
}
}

pub struct AllowSiblingsOnly;
impl Contains<MultiLocation> for AllowSiblingsOnly {
fn contains(location: &MultiLocation) -> bool {
if let MultiLocation { parents: 1, interior: X1(Parachain(_)) } = location {
true
} else {
false
}
}
}

impl crate::Config for Test {
type RuntimeEvent = RuntimeEvent;
type OwnParaId = OwnParaId;
Expand Down
1 change: 1 addition & 0 deletions parachain/pallets/inbound-queue/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl pallet_balances::Config for Test {
type FreezeIdentifier = ();
type MaxFreezes = ();
type RuntimeHoldReason = ();
type RuntimeFreezeReason = ();
type MaxHolds = ();
}

Expand Down
10 changes: 10 additions & 0 deletions parachain/primitives/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ pub use polkadot_parachain_primitives::primitives::{
Id as ParaId, IsSystem, Sibling as SiblingParaId,
};
pub use ringbuffer::{RingBufferMap, RingBufferMapImpl};

use frame_support::traits::Contains;
use sp_core::H256;
use sp_runtime::traits::AccountIdConversion;
use xcm::prelude::{Junction::Parachain, Junctions::X1, MultiLocation};

/// The ID of an agent contract
pub type AgentId = H256;
Expand All @@ -28,6 +31,13 @@ where
SiblingParaId::from(para_id).into_account_truncating()
}

pub struct AllowSiblingsOnly;
impl Contains<MultiLocation> for AllowSiblingsOnly {
fn contains(location: &MultiLocation) -> bool {
matches!(location, MultiLocation { parents: 1, interior: X1(Parachain(_)) })
}
}

pub const GWEI: u128 = 1_000_000_000;
pub const METH: u128 = 1_000_000_000_000_000;
pub const ETH: u128 = 1_000_000_000_000_000_000;
14 changes: 14 additions & 0 deletions parachain/primitives/core/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#[cfg(test)]
mod tests {
use frame_support::traits::Contains;
use snowbridge_core::AllowSiblingsOnly;
use xcm::prelude::{Junction::Parachain, Junctions::X1, MultiLocation};

#[test]
fn allow_siblings_predicate_only_allows_siblings() {
let sibling = MultiLocation::new(1, X1(Parachain(1000)));
let child = MultiLocation::new(0, X1(Parachain(1000)));
assert!(AllowSiblingsOnly::contains(&sibling), "Sibling returns true.");
assert!(!AllowSiblingsOnly::contains(&child), "Child returns false.");
}
}
2 changes: 1 addition & 1 deletion polkadot-sdk
Submodule polkadot-sdk updated 517 files
Loading

0 comments on commit 9cdaf0f

Please sign in to comment.