Skip to content
Open
Show file tree
Hide file tree
Changes from 11 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
6,309 changes: 2,917 additions & 3,392 deletions Cargo.lock

Large diffs are not rendered by default.

257 changes: 216 additions & 41 deletions Cargo.toml

Large diffs are not rendered by default.

160 changes: 77 additions & 83 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,108 +6,102 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
# third-party dependencies
scale-info = { version = "2.1.2", default-features = false, features = [
"derive",
] }
bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] }
codec = { package = "parity-scale-codec", version = "3.0.0", features = [
"derive",
] }
futures = "0.3.19"
async-trait = "0.1.52"
parking_lot = "0.12.1"
lazy_static = "1.4.0"
tracing = "0.1.37"
thiserror = "1.0.30"
tokio = { version = "1.15", features = ["macros"] }
metered = { package = "prioritized-metered-channel", version = "0.2.0" }
futures-timer = "3.0.2"
scale-info = { workspace = true }
bitvec = { workspace = true }
parity-scale-codec = { workspace = true }
futures = { workspace = true }
async-trait = { workspace = true }
parking_lot = { workspace = true }
lazy_static = { workspace = true }
tracing = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
metered = { workspace = true }
futures-timer = { workspace = true }

# Local dependencies
fudge-companion = { path = "./src/builder/companion" }
fudge-companion = { workspace = true }

# Substrate primitives dependencies
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-storage = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-state-machine = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-externalities = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-database = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-std = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true }
sp-api = { workspace = true }
sp-runtime = { workspace = true }
sp-storage = { workspace = true }
sp-inherents = { workspace = true }
sp-block-builder = { workspace = true }
sp-blockchain = { workspace = true }
sp-consensus-aura = { workspace = true }
sp-consensus-grandpa = { workspace = true }
sp-consensus = { workspace = true }
sp-state-machine = { workspace = true }
sp-externalities = { workspace = true }
sp-database = { workspace = true }
sp-transaction-pool = { workspace = true }
sp-keystore = { workspace = true }
sp-timestamp = { workspace = true }
sp-consensus-babe = { workspace = true }

# Substarte client dependencies
sc-client-db = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sc-service = { git = "https://github.com/paritytech/polkadot-sdk", features = [
"test-helpers",
], branch = "release-polkadot-v1.1.0" }
sc-executor = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sc-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sc-block-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sc-transaction-pool-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sc-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
node-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sc-client-db = { workspace = true }
sc-client-api = { workspace = true }
sc-service = { workspace = true }
sc-executor = { workspace = true }
sc-offchain = { workspace = true }
sc-consensus = { workspace = true }
sc-basic-authorship = { workspace = true }
sc-block-builder = { workspace = true }
sc-transaction-pool-api = { workspace = true }
sc-transaction-pool = { workspace = true }
sc-consensus-aura = { workspace = true }
node-primitives = { workspace = true }

# Substrate frame dependencies
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
pallet-babe = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", optional = true, branch = "release-polkadot-v1.1.0" }
frame-system = { workspace = true }
frame-support = { workspace = true }
pallet-babe = { workspace = true }
frame-benchmarking = { workspace = true }

# Polkadot dependencies
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-node-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-parachain-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-core-primitives = { workspace = true }
polkadot-node-primitives = { workspace = true }
polkadot-primitives = { workspace = true }
polkadot-parachain-primitives = { workspace = true }
polkadot-runtime-parachains = { workspace = true }
polkadot-service = { workspace = true }
polkadot-overseer = { workspace = true }
## Currently only needed to make cumulus-relay-chain-inprocess-interface compile, not sure why cumulus works though
polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-cli = { workspace = true }

# Cumulus dependencies
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
cumulus-relay-chain-interface = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
cumulus-primitives-parachain-inherent = { workspace = true }
cumulus-relay-chain-interface = { workspace = true }
cumulus-primitives-core = { workspace = true }
cumulus-client-parachain-inherent = { workspace = true }

[dev-dependencies]
parachain-info = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-test-runtime = { workspace = true }

polkadot-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sc-keystore = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
tracing-subscriber = "0.2"
pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
fudge-test-runtime = { path = "./src/tests/test-parachain", default-features = true }
pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", features = [
"historical",
], branch = "release-polkadot-v1.1.0" }
pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
pallet-im-online = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
staging-parachain-info = { workspace = true }

sp-consensus-beefy = { workspace = true }
frame-benchmarking = { workspace = true }
pallet-timestamp = { workspace = true }
pallet-balances = { workspace = true }
sc-keystore = { workspace = true }
pallet-transaction-payment = { workspace = true }
tracing-subscriber = { workspace = true }
pallet-aura = { workspace = true }
fudge-test-runtime = { workspace = true }
pallet-session = { workspace = true }
pallet-grandpa = { workspace = true }
pallet-im-online = { workspace = true }

xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-xcm-transactor = { git = "https://github.com/moonbeam-foundation/moonbeam", default-features = false, tag = "v0.34.1" }

xcm = { workspace = true }
pallet-xcm = { workspace = true }
pallet-xcm-transactor = { workspace = true }

[features]
default = []
Expand Down
68 changes: 32 additions & 36 deletions core/src/builder/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ use std::{collections::hash_map::DefaultHasher, marker::PhantomData, sync::Arc};

use frame_support::{pallet_prelude::TransactionSource, sp_runtime::traits::NumberFor};
use sc_client_api::{
blockchain::Backend as BlockchainBackend, AuxStore,
Backend as BackendT, BlockBackend, BlockImportOperation, BlockOf, HeaderBackend, NewBlockState,
UsageProvider,
blockchain::Backend as BlockchainBackend, AuxStore, Backend as BackendT, BlockBackend,
BlockImportOperation, BlockOf, HeaderBackend, NewBlockState, UsageProvider,
};
use sc_consensus::{BlockImport, BlockImportParams, ImportResult};
use sc_executor::RuntimeVersionOf;
Expand All @@ -28,15 +27,14 @@ use sp_consensus::{Environment, InherentData, Proposal, Proposer};
use sp_core::traits::CodeExecutor;
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, BlockIdTo, Hash as HashT, Header as HeaderT, One, Zero},
traits::{Block as BlockT, BlockIdTo, Hash as HashT, Header as HeaderT, Header, One, Zero},
Digest,
};
use sp_state_machine::StorageProof;
use sp_std::time::Duration;
use sp_storage::StateVersion;
use sp_transaction_pool::runtime_api::TaggedTransactionQueue;
use thiserror::Error;
use sp_runtime::traits::Header;

use crate::{provider::externalities::ExternalitiesProvider, types::StoragePair};

Expand Down Expand Up @@ -163,9 +161,7 @@ where
Block: BlockT,
RtApi: ConstructRuntimeApi<Block, C> + Send,
Exec: CodeExecutor + RuntimeVersionOf + Clone + 'static,
C::Api: BlockBuilder<Block>

+ TaggedTransactionQueue<Block>,
C::Api: BlockBuilder<Block> + TaggedTransactionQueue<Block>,
C: 'static
+ ProvideRuntimeApi<Block>
+ BlockOf
Expand All @@ -177,8 +173,7 @@ where
+ UsageProvider<Block>
+ HeaderBackend<Block>
+ BlockImport<Block>
+ CallApiAt<Block>
+ sc_block_builder::BlockBuilderProvider<B, Block, C>,
+ CallApiAt<Block>,
for<'r> &'r C: BlockImport<Block>,
A: TransactionPool<Block = Block, Hash = Block::Hash> + MaintainedTransactionPool + 'static,
{
Expand Down Expand Up @@ -417,19 +412,21 @@ where

let mut ext = ExternalitiesProvider::<HashFor<Block>, B::State>::new(&state);

let (r, changes) = ext.execute_with_mut(exec, self.state_version()?).map_err(|e| {
tracing::error!(
target = DEFAULT_BUILDER_LOG_TARGET,
error = ?e,
"Could not execute externalities at {:?}.",
at,
);

Error::ExternalitiesExecution(
Some(BlockId::<Block>::Hash(block_hash)),
e.into(),
)
})?;
let (r, changes) =
ext.execute_with_mut(exec, self.state_version()?)
.map_err(|e| {
tracing::error!(
target = DEFAULT_BUILDER_LOG_TARGET,
error = ?e,
"Could not execute externalities at {:?}.",
at,
);

Error::ExternalitiesExecution(
Some(BlockId::<Block>::Hash(block_hash)),
e.into(),
)
})?;

self.mutate_normal(&mut op, changes, BlockId::<Block>::Hash(block_hash))?;

Expand Down Expand Up @@ -463,15 +460,17 @@ where
) -> Result<R, Error<Block>> {
let mut ext = ExternalitiesProvider::<HashFor<Block>, B::State>::new(&state);

let (r, changes) = ext.execute_with_mut(exec, self.state_version()?).map_err(|e| {
tracing::error!(
target = DEFAULT_BUILDER_LOG_TARGET,
error = ?e,
"Could not execute externalities.",
);
let (r, changes) = ext
.execute_with_mut(exec, self.state_version()?)
.map_err(|e| {
tracing::error!(
target = DEFAULT_BUILDER_LOG_TARGET,
error = ?e,
"Could not execute externalities.",
);

Error::ExternalitiesExecution(Some(BlockId::Number(Zero::zero())), e.into())
})?;
Error::ExternalitiesExecution(Some(BlockId::Number(Zero::zero())), e.into())
})?;

let (main_sc, child_sc, _, tx, root, tx_index) = changes.into_inner();

Expand Down Expand Up @@ -647,7 +646,7 @@ where
/// Caches a given extrinsic in the builder. The extrinsic will be
pub fn append_extrinsic(&mut self, ext: Block::Extrinsic) -> Result<Block::Hash, Error<Block>> {
let fut = self.pool.submit_one(
&BlockId::Hash(self.client.info().best_hash),
self.client.info().best_hash,
TransactionSource::External,
ext,
);
Expand Down Expand Up @@ -715,10 +714,7 @@ where
}

/// Import a block, that has been previously built.
pub fn import_block(
&mut self,
params: BlockImportParams<Block>,
) -> Result<(), Error<Block>> {
pub fn import_block(&mut self, params: BlockImportParams<Block>) -> Result<(), Error<Block>> {
let prev_hash = self.latest_block();
let ret = match futures::executor::block_on(self.client.as_ref().import_block(params))
.map_err(|e| {
Expand Down
16 changes: 5 additions & 11 deletions core/src/builder/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@

use std::sync::Mutex;

use codec::{Decode, Encode};
use cumulus_primitives_core::{CollationInfo, CollectCollationInfo, ParachainBlockData};
use parity_scale_codec::{Decode, Encode};
use polkadot_node_primitives::{Collation, MaybeCompressedPoV, PoV};
use polkadot_parachain_primitives::primitives::{BlockData, HeadData, Id, ValidationCode};
use polkadot_primitives::PersistedValidationData;
use sc_client_api::{
AuxStore, Backend as BackendT, BlockBackend, BlockOf, HeaderBackend,
UsageProvider,
AuxStore, Backend as BackendT, BlockBackend, BlockOf, HeaderBackend, UsageProvider,
};
use sc_client_db::Backend;
use sc_consensus::{BlockImport, BlockImportParams, ForkChoiceStrategy};
Expand All @@ -42,7 +41,7 @@ use thiserror::Error;

use crate::{
builder::{
core::{Builder, InnerError, Operation},
core::{Builder, HashFor, InnerError, Operation},
relay_chain::{CollationBuilder, CollationJudgement},
PoolState,
},
Expand All @@ -51,7 +50,6 @@ use crate::{
provider::Initiator,
types::StoragePair,
};
use crate::builder::core::HashFor;

const DEFAULT_COLLATOR_LOG_TARGET: &str = "fudge-collator";
const DEFAULT_PARACHAIN_BUILDER_LOG_TARGET: &str = "fudge-parachain";
Expand Down Expand Up @@ -437,10 +435,7 @@ where
CIDP::InherentDataProviders: Send,
DP: DigestCreator<Block>,
ExtraArgs: ArgsProvider<ExtraArgs>,
C::Api: BlockBuilder<Block>

+ TaggedTransactionQueue<Block>
+ CollectCollationInfo<Block>,
C::Api: BlockBuilder<Block> + TaggedTransactionQueue<Block> + CollectCollationInfo<Block>,
C: 'static
+ ProvideRuntimeApi<Block>
+ BlockOf
Expand All @@ -452,8 +447,7 @@ where
+ UsageProvider<Block>
+ HeaderBackend<Block>
+ BlockImport<Block>
+ CallApiAt<Block>
+ sc_block_builder::BlockBuilderProvider<B, Block, C>,
+ CallApiAt<Block>,
for<'r> &'r C: BlockImport<Block>,
A: TransactionPool<Block = Block, Hash = Block::Hash> + MaintainedTransactionPool + 'static,
{
Expand Down
Loading