Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Polkadot SDK #1008

Merged
merged 7 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
467 changes: 393 additions & 74 deletions parachain/Cargo.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions parachain/pallets/outbound-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ sp-runtime = { path = "../../../polkadot-sdk/substrate/primitives/runtime", defa
sp-io = { path = "../../../polkadot-sdk/substrate/primitives/io", default-features = false }
sp-arithmetic = { path = "../../../polkadot-sdk/substrate/primitives/arithmetic", default-features = false }

cumulus-primitives-core = { path = "../../../polkadot-sdk/cumulus/primitives/core", default-features = false }

snowbridge-core = { path = "../../primitives/core", features = ["serde"], default-features = false }
snowbridge-outbound-queue-merkle-tree = { path = "merkle-tree", default-features = false }
ethabi = { git = "https://github.com/Snowfork/ethabi-decode.git", package = "ethabi-decode", branch = "master", default-features = false }
Expand Down Expand Up @@ -53,11 +55,13 @@ std = [
"snowbridge-outbound-queue-merkle-tree/std",
"ethabi/std",
"xcm/std",
"cumulus-primitives-core/std"
]
runtime-benchmarks = [
"snowbridge-core/runtime-benchmarks",
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"hex-literal",
"cumulus-primitives-core/runtime-benchmarks"
]
5 changes: 3 additions & 2 deletions parachain/pallets/outbound-queue/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
use super::*;

use codec::Encode;
use cumulus_primitives_core::AggregateMessageOrigin;
use frame_benchmarking::v2::*;
use snowbridge_core::{
outbound::{AggregateMessageOrigin, Command, Initializer},
outbound::{Command, Initializer},
ChannelId,
};
use sp_core::{H160, H256};
Expand Down Expand Up @@ -35,7 +36,7 @@ mod benchmarks {
}),
},
};
let origin = AggregateMessageOrigin::Snowbridge(ChannelId::from([1; 32]));
let origin = AggregateMessageOrigin::GeneralKey([1; 32]);
let encoded_enqueued_message = enqueued_message.encode();

#[block]
Expand Down
6 changes: 2 additions & 4 deletions parachain/pallets/outbound-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,14 @@ mod mock;
mod test;

use codec::Decode;
use cumulus_primitives_core::AggregateMessageOrigin;
use frame_support::{
storage::StorageStreamIter,
traits::{tokens::Balance, EnqueueMessage, Get, ProcessMessageError},
weights::{Weight, WeightToFee},
};
use snowbridge_core::{
outbound::{
AggregateMessageOrigin, Command, Fee, GasMeter, QueuedMessage, VersionedQueuedMessage,
ETHER_DECIMALS,
},
outbound::{Command, Fee, GasMeter, QueuedMessage, VersionedQueuedMessage, ETHER_DECIMALS},
BasicOperatingMode, ChannelId, GWEI, METH,
};
use snowbridge_outbound_queue_merkle_tree::merkle_root;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use frame_support::{
traits::{ProcessMessage, ProcessMessageError},
weights::WeightMeter,
};
use snowbridge_core::outbound::AggregateMessageOrigin;

impl<T: Config> ProcessMessage for Pallet<T> {
type Origin = AggregateMessageOrigin;
Expand Down
7 changes: 4 additions & 3 deletions parachain/pallets/outbound-queue/src/send_message_impl.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Implementation for [`snowbridge_core::outbound::SendMessage`]
use super::*;
use codec::Encode;
use cumulus_primitives_core::AggregateMessageOrigin;
use frame_support::{
ensure,
traits::{EnqueueMessage, Get},
Expand All @@ -9,8 +10,8 @@ use frame_support::{
use frame_system::unique;
use snowbridge_core::{
outbound::{
AggregateMessageOrigin, Fee, Message, QueuedMessage, SendError, SendMessage,
SendMessageFeeProvider, VersionedQueuedMessage,
Fee, Message, QueuedMessage, SendError, SendMessage, SendMessageFeeProvider,
VersionedQueuedMessage,
},
ChannelId, PRIMARY_GOVERNANCE_CHANNEL,
};
Expand Down Expand Up @@ -70,7 +71,7 @@ where
}

fn deliver(ticket: Self::Ticket) -> Result<H256, SendError> {
let origin = AggregateMessageOrigin::Snowbridge(ticket.channel_id);
let origin = AggregateMessageOrigin::GeneralKey(ticket.channel_id.into());

if ticket.channel_id != PRIMARY_GOVERNANCE_CHANNEL {
ensure!(!Self::operating_mode().is_halted(), SendError::Halted);
Expand Down
32 changes: 16 additions & 16 deletions parachain/pallets/outbound-queue/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ fn process_message_yields_on_max_messages_per_block() {
MessageLeaves::<Test>::append(H256::zero())
}

let channel_id = ParaId::from(1000).into();
let origin = AggregateMessageOrigin::Snowbridge(channel_id);
let channel_id: ChannelId = ParaId::from(1000).into();
let origin = AggregateMessageOrigin::GeneralKey(channel_id.into());
let message = QueuedMessage {
id: Default::default(),
channel_id,
Expand All @@ -113,8 +113,8 @@ fn process_message_yields_on_max_messages_per_block() {
fn process_message_fails_on_overweight_message() {
new_tester().execute_with(|| {
let sibling_id = 1000;
let channel_id = ParaId::from(sibling_id).into();
let origin = AggregateMessageOrigin::Snowbridge(channel_id);
let channel_id: ChannelId = ParaId::from(sibling_id).into();
let origin = AggregateMessageOrigin::GeneralKey(channel_id.into());
let message = mock_message(sibling_id).encode();
let mut meter = WeightMeter::with_limit(Weight::from_parts(1, 1));
assert_noop!(
Expand Down Expand Up @@ -200,8 +200,8 @@ fn governance_message_does_not_get_the_chance_to_processed_in_same_block_when_co
let (ticket, _) = OutboundQueue::validate(&message).unwrap();
OutboundQueue::deliver(ticket).unwrap();
}
let footprint = MessageQueue::footprint(Snowbridge(sibling_channel_id));
assert_eq!(footprint.count, (max_messages) as u64);
let footprint = MessageQueue::footprint(GeneralKey(sibling_channel_id.into()));
assert_eq!(footprint.storage.count, (max_messages) as u64);

let message = mock_governance_message::<Test>();
let (ticket, _) = OutboundQueue::validate(&message).unwrap();
Expand All @@ -212,29 +212,29 @@ fn governance_message_does_not_get_the_chance_to_processed_in_same_block_when_co
run_to_end_of_next_block();

// first process 20 messages from sibling channel
let footprint = MessageQueue::footprint(Snowbridge(sibling_channel_id));
assert_eq!(footprint.count, 40 - 20);
let footprint = MessageQueue::footprint(GeneralKey(sibling_channel_id.into()));
assert_eq!(footprint.storage.count, 40 - 20);

// and governance message does not have the chance to execute in same block
let footprint = MessageQueue::footprint(Snowbridge(PRIMARY_GOVERNANCE_CHANNEL));
assert_eq!(footprint.count, 1);
let footprint = MessageQueue::footprint(GeneralKey(PRIMARY_GOVERNANCE_CHANNEL.into()));
assert_eq!(footprint.storage.count, 1);

// move to next block
ServiceWeight::set(Some(Weight::MAX));
run_to_end_of_next_block();

// now governance message get executed in this block
let footprint = MessageQueue::footprint(Snowbridge(PRIMARY_GOVERNANCE_CHANNEL));
assert_eq!(footprint.count, 0);
let footprint = MessageQueue::footprint(GeneralKey(PRIMARY_GOVERNANCE_CHANNEL.into()));
assert_eq!(footprint.storage.count, 0);

// and this time process 19 messages from sibling channel so we have 1 message left
let footprint = MessageQueue::footprint(Snowbridge(sibling_channel_id));
assert_eq!(footprint.count, 1);
let footprint = MessageQueue::footprint(GeneralKey(sibling_channel_id.into()));
assert_eq!(footprint.storage.count, 1);

// move to the next block, the last 1 message from sibling channel get executed
ServiceWeight::set(Some(Weight::MAX));
run_to_end_of_next_block();
let footprint = MessageQueue::footprint(Snowbridge(sibling_channel_id));
assert_eq!(footprint.count, 0);
let footprint = MessageQueue::footprint(GeneralKey(sibling_channel_id.into()));
assert_eq!(footprint.storage.count, 0);
});
}
6 changes: 6 additions & 0 deletions parachain/primitives/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ impl From<[u8; 32]> for ChannelId {
}
}

impl From<ChannelId> for [u8; 32] {
fn from(value: ChannelId) -> Self {
value.0
}
}

impl<'a> From<&'a [u8; 32]> for ChannelId {
fn from(value: &'a [u8; 32]) -> Self {
ChannelId(*value)
Expand Down
15 changes: 1 addition & 14 deletions parachain/primitives/core/src/outbound.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::{ChannelId, ParaId};
use codec::{Decode, Encode, MaxEncodedLen};
use codec::{Decode, Encode};
use frame_support::PalletError;
use scale_info::TypeInfo;
use sp_arithmetic::traits::{BaseArithmetic, Unsigned};
Expand Down Expand Up @@ -383,16 +382,4 @@ impl GasMeter for () {
}
}

impl From<u32> for AggregateMessageOrigin {
fn from(value: u32) -> Self {
AggregateMessageOrigin::Snowbridge(ParaId::from(value).into())
}
}

/// Aggregate message origin for the `MessageQueue` pallet.
#[derive(Encode, Decode, Clone, Copy, MaxEncodedLen, Eq, PartialEq, RuntimeDebug, TypeInfo)]
pub enum AggregateMessageOrigin {
Snowbridge(ChannelId),
}

pub const ETHER_DECIMALS: u8 = 18;
2 changes: 1 addition & 1 deletion polkadot-sdk
Submodule polkadot-sdk updated 967 files
2 changes: 1 addition & 1 deletion relayer/cmd/generate_beacon_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func generateBeaconCheckpoint(cmd *cobra.Command, _ []string) error {
}
checkPointBytes, _ := types.EncodeToBytes(checkPointScale)
// Call index for EthereumBeaconClient.force_checkpoint
checkPointCallIndex := "0x3200"
checkPointCallIndex := "0x3E00"
checkPointUpdateCall := checkPointCallIndex + hex.EncodeToString(checkPointBytes)
fmt.Println(checkPointUpdateCall)
return nil
Expand Down
Loading