Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into agustin-map-slashes
Browse files Browse the repository at this point in the history
  • Loading branch information
girazoki committed Jan 8, 2025
2 parents e647800 + 9530640 commit fce65dd
Show file tree
Hide file tree
Showing 304 changed files with 1,043 additions and 177 deletions.
44 changes: 23 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
[workspace]
members = [
"chains/container-chains/nodes/*",
"chains/container-chains/runtime-templates/*",
"chains/orchestrator-paras/node",
"chains/orchestrator-paras/runtime/*",
"chains/orchestrator-relays/client/*",
"chains/orchestrator-relays/node/*",
"chains/orchestrator-relays/runtime/dancelight",
"chains/orchestrator-relays/runtime/dancelight/constants",
"client/*",
"container-chains/nodes/*",
"container-chains/runtime-templates/*",
"node",
"pallets/*",
"pallets/collator-assignment/runtime-api",
"pallets/registrar/runtime-api",
"primitives/*",
"runtime/dancebox",
"runtime/flashbox",
"runtime/relay-encoder",
"solo-chains/client/*",
"solo-chains/node/*",
"solo-chains/runtime/dancelight",
"solo-chains/runtime/dancelight/constants",
]
resolver = "2"

Expand Down Expand Up @@ -78,27 +76,30 @@ pallet-stream-payment-runtime-api = { path = "pallets/stream-payment/runtime-api
pallet-xcm-core-buyer = { path = "pallets/xcm-core-buyer", default-features = false }
pallet-xcm-core-buyer-runtime-api = { path = "pallets/xcm-core-buyer/runtime-api", default-features = false }

container-chain-template-frontier-runtime = { path = "container-chains/runtime-templates/frontier", default-features = false }
container-chain-template-simple-runtime = { path = "container-chains/runtime-templates/simple", default-features = false }
container-chain-template-frontier-runtime = { path = "chains/container-chains/runtime-templates/frontier", default-features = false }
container-chain-template-simple-runtime = { path = "chains/container-chains/runtime-templates/simple", default-features = false }

dancebox-runtime = { path = "runtime/dancebox", default-features = false }
flashbox-runtime = { path = "runtime/flashbox", default-features = false }
dancebox-runtime = { path = "chains/orchestrator-paras/runtime/dancebox", default-features = false }
flashbox-runtime = { path = "chains/orchestrator-paras/runtime/flashbox", default-features = false }

tanssi-relay-encoder = { path = "chains/orchestrator-paras/runtime/relay-encoder", default-features = false }
tanssi-runtime-common = { path = "chains/orchestrator-paras/runtime/common", default-features = false }

dancelight-runtime = { path = "chains/orchestrator-relays/runtime/dancelight", default-features = false }
dancelight-runtime-constants = { path = "chains/orchestrator-relays/runtime/dancelight/constants", default-features = false }

tanssi-relay-cli = { path = "chains/orchestrator-relays/client/cli" }
tanssi-relay-service = { path = "chains/orchestrator-relays/node/tanssi-relay-service" }

dancelight-runtime = { path = "solo-chains/runtime/dancelight", default-features = false }
dancelight-runtime-constants = { path = "solo-chains/runtime/dancelight/constants", default-features = false }
ethabi = { package = "ethabi-decode", version = "1.0.0", default-features = false }
manual-randomness-rpc = { path = "client/manual-randomness" }
manual-xcm-rpc = { path = "client/manual-xcm" }
node-common = { path = "client/node-common" }
services-payment-rpc = { path = "client/services-payment" }
stream-payment-rpc = { path = "client/stream-payment" }
tanssi-relay-cli = { path = "solo-chains/client/cli" }
tanssi-relay-encoder = { path = "runtime/relay-encoder", default-features = false }
tanssi-relay-service = { path = "solo-chains/node/tanssi-relay-service" }
tanssi-runtime-common = { path = "runtime/common", default-features = false }
tc-consensus = { path = "client/consensus" }
tc-orchestrator-chain-rpc-interface = { path = "client/orchestrator-chain-rpc-interface" }
tc-service-container-chain = { path = "client/service-container-chain" }

tp-author-noting-inherent = { path = "primitives/author-noting-inherent", default-features = false }
tp-bridge = { path = "primitives/bridge", default-features = false }
tp-maths = { path = "primitives/maths", default-features = false }
Expand Down Expand Up @@ -341,6 +342,7 @@ fc-storage = { git = "https://github.com/moondance-labs/frontier", branch = "tan

# General (wasm)
bounded-collections = { version = "0.1.8", default-features = false }
ethabi = { package = "ethabi-decode", version = "1.0.0", default-features = false }
finality-grandpa = { version = "0.16.2", default-features = false }
hex-literal = { version = "0.3.4" }
impl-trait-for-tuples = "0.2.2"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn load_spec(
))
}
"dancebox" => Box::new(RawChainSpec::from_json_bytes(
&include_bytes!("../../specs/dancebox/dancebox-raw-specs.json")[..],
&include_bytes!("../../../../specs/dancebox/dancebox-raw-specs.json")[..],
)?),
"flashbox-dev" | "flashbox_dev" => Box::new(chain_spec::flashbox::development_config(
para_id,
Expand Down Expand Up @@ -169,7 +169,7 @@ impl SubstrateCli for RelayChainCli {
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
match id {
"westend_moonbase_relay_testnet" => Ok(Box::new(WestendChainSpec::from_json_bytes(
&include_bytes!("../../specs/dancebox/alphanet-relay-raw-specs.json")[..],
&include_bytes!("../../../../specs/dancebox/alphanet-relay-raw-specs.json")[..],
)?)),
// If we are not using a moonbeam-centric pre-baked relay spec, then fall back to the
// Polkadot service to interpret the id.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,6 @@ pub fn start_dev_node(
if parachain_config.role.is_authority() {
let client = node_builder.client.clone();
let (downward_xcm_sender, downward_xcm_receiver) = flume::bounded::<Vec<u8>>(100);

let (hrmp_xcm_sender, hrmp_xcm_receiver) = flume::bounded::<(ParaId, Vec<u8>)>(100);
// Create channels for mocked parachain candidates.
let (mock_randomness_sender, mock_randomness_receiver) =
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use jsonrpsee::{
ErrorObjectOwned,
},
};
use xcm::latest::prelude::*;

/// This RPC interface is used to provide methods in dev mode only
#[rpc(server)]
Expand All @@ -38,10 +39,15 @@ pub trait DevApi {
/// Indicate the mock parachain candidate insertion to be disabled
#[method(name = "mock_disableParaInherentCandidate")]
async fn disable_para_inherent_candidate(&self) -> RpcResult<()>;

#[method(name = "xcm_injectUpwardMessage")]
async fn inject_upward_message(&self, message: Vec<u8>) -> RpcResult<()>;
}

#[derive(Clone)]
pub struct DevRpc {
pub mock_para_inherent_channel: flume::Sender<Vec<u8>>,
pub upward_message_channel: flume::Sender<Vec<u8>>,
}

#[jsonrpsee::core::async_trait]
Expand Down Expand Up @@ -69,6 +75,43 @@ impl DevApiServer for DevRpc {

Ok(())
}

async fn inject_upward_message(&self, msg: Vec<u8>) -> RpcResult<()> {
let upward_message_channel = self.upward_message_channel.clone();
// If no message is supplied, inject a default one.
let msg = if msg.is_empty() {
// Note: Sovereign account of the origin parachain must be funded before injecting the message.
xcm::VersionedXcm::<()>::V4(Xcm(vec![
WithdrawAsset((Here, 10000000000000u128).into()),
BuyExecution {
fees: (Here, 10000000000000u128).into(),
weight_limit: Unlimited,
},
DepositAsset {
assets: AllCounted(1).into(),
beneficiary: Location::new(
0,
[AccountKey20 {
network: None,
key: hex_literal::hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"),
}],
),
},
]))
.encode()
} else {
msg
};

// Push the message to the shared channel where it will be queued up
// to be injected in to an upcoming block.
upward_message_channel
.send_async(msg)
.await
.map_err(|err| internal_err(err.to_string()))?;

Ok(())
}
}

// This bit cribbed from frontier.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use {
polkadot_core_primitives::{AccountId, Balance, Block, Hash, Nonce},
polkadot_node_core_parachains_inherent::Error as InherentError,
polkadot_overseer::Handle,
polkadot_parachain_primitives::primitives::UpwardMessages,
polkadot_primitives::{
runtime_api::ParachainHost, BackedCandidate, CandidateCommitments, CandidateDescriptor,
CollatorPair, CommittedCandidateReceipt, CompactStatement, EncodeAs,
Expand Down Expand Up @@ -107,16 +108,16 @@ struct DevDeps<C, P> {
pub pool: Arc<P>,
/// Manual seal command sink
pub command_sink: Option<futures::channel::mpsc::Sender<EngineCommand<Hash>>>,
/// Channels for dev rpcs
pub dev_rpc_data: Option<flume::Sender<Vec<u8>>>,
/// Dev rpcs
pub dev_rpc: Option<DevRpc>,
}

fn create_dev_rpc_extension<C, P>(
DevDeps {
client,
pool,
command_sink: maybe_command_sink,
dev_rpc_data: maybe_dev_rpc_data,
dev_rpc: maybe_dev_rpc,
}: DevDeps<C, P>,
) -> Result<RpcExtension, Box<dyn std::error::Error + Send + Sync>>
where
Expand Down Expand Up @@ -145,13 +146,8 @@ where
io.merge(ManualSeal::new(command_sink).into_rpc())?;
}

if let Some(mock_para_inherent_channel) = maybe_dev_rpc_data {
io.merge(
DevRpc {
mock_para_inherent_channel,
}
.into_rpc(),
)?;
if let Some(dev_rpc_data) = maybe_dev_rpc {
io.merge(dev_rpc_data.into_rpc())?;
}

Ok(io)
Expand Down Expand Up @@ -226,24 +222,33 @@ struct MockParachainsInherentDataProvider<C: HeaderBackend<Block> + ProvideRunti
pub client: Arc<C>,
pub parent: Hash,
pub keystore: KeystorePtr,
pub upward_messages_receiver: flume::Receiver<Vec<u8>>,
}

impl<C: HeaderBackend<Block> + ProvideRuntimeApi<Block>> MockParachainsInherentDataProvider<C>
where
C::Api: ParachainHost<Block>,
C: AuxStore,
{
pub fn new(client: Arc<C>, parent: Hash, keystore: KeystorePtr) -> Self {
pub fn new(
client: Arc<C>,
parent: Hash,
keystore: KeystorePtr,
upward_messages_receiver: flume::Receiver<Vec<u8>>,
) -> Self {
MockParachainsInherentDataProvider {
client,
parent,
keystore,
upward_messages_receiver,
}
}

pub async fn create(
client: Arc<C>,
parent: Hash,
keystore: KeystorePtr,
upward_messages_receiver: flume::Receiver<Vec<u8>>,
) -> Result<ParachainsInherentData, InherentError> {
let parent_header = match client.header(parent) {
Ok(Some(h)) => h,
Expand Down Expand Up @@ -388,6 +393,12 @@ where
&validation_code_hash,
);
let collator_signature = collator_pair.sign(&payload);

let upward_messages = UpwardMessages::try_from(
upward_messages_receiver.drain().collect::<Vec<_>>(),
)
.expect("create upward messages from raw messages");

// generate a candidate with most of the values mocked
let candidate = CommittedCandidateReceipt::<H256> {
descriptor: CandidateDescriptor::<H256> {
Expand All @@ -402,7 +413,7 @@ where
validation_code_hash,
},
commitments: CandidateCommitments::<u32> {
upward_messages: Default::default(),
upward_messages,
horizontal_messages: Default::default(),
new_validation_code: None,
head_data: parachain_mocked_header.clone().encode().into(),
Expand Down Expand Up @@ -481,6 +492,7 @@ where
self.client.clone(),
self.parent,
self.keystore.clone(),
self.upward_messages_receiver.clone(),
)
.await
.map_err(|e| sp_inherents::Error::Application(Box::new(e)))?
Expand Down Expand Up @@ -594,6 +606,8 @@ fn new_full<
let (downward_mock_para_inherent_sender, downward_mock_para_inherent_receiver) =
flume::bounded::<Vec<u8>>(100);

let (upward_mock_sender, upward_mock_receiver) = flume::bounded::<Vec<u8>>(100);

let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) =
service::build_network(service::BuildNetworkParams {
config: &config,
Expand Down Expand Up @@ -705,12 +719,15 @@ fn new_full<
let client_clone = client_clone.clone();
let keystore = keystore_clone.clone();
let downward_mock_para_inherent_receiver = downward_mock_para_inherent_receiver.clone();
let upward_mock_receiver = upward_mock_receiver.clone();
async move {

let downward_mock_para_inherent_receiver = downward_mock_para_inherent_receiver.clone();
// here we only take the last one
let para_inherent_decider_messages: Vec<Vec<u8>> = downward_mock_para_inherent_receiver.drain().collect();

let upward_messages_receiver = upward_mock_receiver.clone();

// If there is a value to be updated, we update it
if let Some(value) = para_inherent_decider_messages.last() {
client_clone
Expand All @@ -719,13 +736,13 @@ fn new_full<
&[],
)
.expect("Should be able to write to aux storage; qed");

}

let parachain = MockParachainsInherentDataProvider::new(
client_clone.clone(),
parent,
keystore
keystore,
upward_messages_receiver,
);

let timestamp = get_next_timestamp(client_clone, slot_duration);
Expand All @@ -744,9 +761,11 @@ fn new_full<
);
}

// We dont need the flume receiver if we are not a validator
let dev_rpc_data = if role.clone().is_authority() {
Some(downward_mock_para_inherent_sender)
let dev_rpc = if role.clone().is_authority() {
Some(DevRpc {
mock_para_inherent_channel: downward_mock_para_inherent_sender,
upward_message_channel: upward_mock_sender,
})
} else {
None
};
Expand All @@ -761,7 +780,7 @@ fn new_full<
client: client.clone(),
pool: transaction_pool.clone(),
command_sink: command_sink.clone(),
dev_rpc_data: dev_rpc_data.clone(),
dev_rpc: dev_rpc.clone(),
};

create_dev_rpc_extension(deps).map_err(Into::into)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit fce65dd

Please sign in to comment.