Skip to content

Commit

Permalink
Merge pull request #50 from centrifuge/polkadot-v0.9.32
Browse files Browse the repository at this point in the history
Polkadot v0.9.32
  • Loading branch information
mustermeiszer authored Dec 16, 2022
2 parents 8dd20eb + c0fb59c commit 0cba94b
Show file tree
Hide file tree
Showing 14 changed files with 1,628 additions and 1,319 deletions.
2,615 changes: 1,451 additions & 1,164 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,8 @@ env.evolve()
```


### Additional Requirements
To build you'll also need `protoc` installed from protobuf.

Should be available in `asdf` if using `asdf`, or from the protobuf release page: https://github.com/protocolbuffers/protobuf/releases
(i.e: https://github.com/protocolbuffers/protobuf/releases/download/v3.20.2/protoc-3.20.2-osx-x86_64.zip)
106 changes: 54 additions & 52 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,80 +12,82 @@ futures = "0.3.19"
async-trait = "0.1.52"
parking_lot = "0.12.1"
lazy_static = "1.4.0"
tracing = "0.1.3"
tracing = "0.1.37"
thiserror = "1.0"
tokio = { version = "1.15", features = ["macros"] }
metered = { package = "prioritized-metered-channel", version = "0.2.0" }

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

# Substrate primitives dependencies
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-storage = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-database = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sp-storage = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sp-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sp-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sp-database = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }

# Substarte client dependencies
sc-client-db = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sc-service = { git = "https://github.com/paritytech/substrate", features = ["test-helpers"], branch = "polkadot-v0.9.29" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sc-offchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sc-consensus-uncles = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sc-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
node-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sc-client-db = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sc-service = { git = "https://github.com/paritytech/substrate", features = ["test-helpers"], branch = "polkadot-v0.9.32" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sc-offchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sc-consensus-uncles = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sc-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
node-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }

# Substrate frame dependencies
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29", optional = true }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32", optional = true }

# Polkadot dependencies
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.29" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.29" }
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.29" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.29" }
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.32" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.32" }
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.32" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.32" }
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.32" }
## 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", branch = "release-v0.9.29" }
polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.32" }

# Cumulus dependencies
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.29" }
cumulus-relay-chain-inprocess-interface= { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.29" }
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.32" }
cumulus-relay-chain-inprocess-interface= { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.32" }

[dev-dependencies]
polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.29" }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.32" }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
tracing-subscriber = "0.2"
pallet-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
pallet-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.32" }
fudge-test-runtime = {path = "./src/tests/test-parachain", default-features = true}

[features]
default = []
runtime-benchmarks = [
'frame-benchmarking/runtime-benchmarks'
]
]
17 changes: 11 additions & 6 deletions core/src/builder/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

use std::{collections::hash_map::DefaultHasher, marker::PhantomData, sync::Arc};

use frame_support::{pallet_prelude::TransactionSource, sp_runtime::traits::NumberFor};
Expand Down Expand Up @@ -167,12 +168,15 @@ where
at: Option<BlockId<Block>>,
exec: impl FnOnce() -> R,
) -> Result<R, String> {
let (state, at) = if let Some(req_at) = at {
(self.backend.state_at(req_at), req_at)
} else {
let at = BlockId::Hash(self.client.info().best_hash);
(self.backend.state_at(at.clone()), at)
let hash = match at {
Some(BlockId::Hash(req_at)) => req_at,
Some(BlockId::Number(req_at)) => {
self.backend.blockchain().hash(req_at).unwrap().unwrap()
}
_ => self.client.info().best_hash,
};
let state = self.backend.state_at(&hash);
let at = sp_api::BlockId::Hash(hash);

let state = state.map_err(|_| "State at INSERT_AT_HERE not available".to_string())?;

Expand Down Expand Up @@ -351,7 +355,8 @@ where
.flatten()
.expect("State is available. qed");
let proposer = futures::executor::block_on(factory.init(&header)).unwrap();
futures::executor::block_on(proposer.propose(inherents, digest, time, Some(limit))).unwrap()
futures::executor::block_on(proposer.propose(inherents, digest, time, Some(limit)))
.expect("Proposal failure")
}

/// Import a block, that has been previosuly build
Expand Down
2 changes: 1 addition & 1 deletion core/src/builder/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ where
inherents,
digest,
Duration::from_secs(60),
usize::MAX,
6_000_000,
);
self.next = Some((block, proof));

Expand Down
7 changes: 5 additions & 2 deletions core/src/builder/relay_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use polkadot_core_primitives::Block as PBlock;
use polkadot_parachain::primitives::{Id, ValidationCodeHash};
use polkadot_primitives::{runtime_api::ParachainHost, v2::OccupiedCoreAssumption};
use polkadot_runtime_parachains::{paras, ParaLifecycle};
use polkadot_service::Handle;
use sc_client_api::{
AuxStore, Backend as BackendT, BlockBackend, BlockOf, BlockchainEvents, HeaderBackend,
TransactionFor, UsageProvider,
Expand Down Expand Up @@ -184,11 +185,13 @@ where
{
pub async fn parachain_inherent(&self) -> Option<ParachainInherentData> {
let parent = self.client.info().best_hash;
let (chnl_sndr, _chnl_rcvr) = metered::channel(64);
let dummy_handler = Handle::new(chnl_sndr);
let relay_interface = RelayChainInProcessInterface::new(
self.client.clone(),
self.backend.clone(),
Arc::new(NoNetwork {}),
None,
dummy_handler,
);
let api = self.client.runtime_api();
let persisted_validation_data = api
Expand Down Expand Up @@ -426,7 +429,7 @@ where
inherents,
digest,
Duration::from_secs(60),
usize::MAX,
6_000_000,
);
self.next = Some((block.clone(), proof));

Expand Down
2 changes: 1 addition & 1 deletion core/src/builder/stand_alone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ where
inherents,
digest,
Duration::from_secs(60),
usize::MAX,
6_000_000,
);
self.next = Some((block.clone(), proof));

Expand Down
4 changes: 2 additions & 2 deletions core/src/provider/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<Block> MemDb<Block> {
/// `with_*` method of the struct.
pub fn new() -> Self {
Self {
blocks_pruning: BlocksPruning::All,
blocks_pruning: BlocksPruning::KeepAll,
trie_cache: None,
state_pruning: Some(PruningMode::ArchiveAll),
require_create_flag: true,
Expand Down Expand Up @@ -168,7 +168,7 @@ impl<Block> DiskDb<Block> {
pub fn new(path: PathBuf) -> Self {
Self {
path,
blocks_pruning: BlocksPruning::All,
blocks_pruning: BlocksPruning::KeepAll,
trie_cache: None,
state_pruning: Some(PruningMode::ArchiveAll),
database_type: DiskDatabaseType::RocksDb {
Expand Down
6 changes: 6 additions & 0 deletions core/src/provider/initiator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use sc_service::{
};
use sc_transaction_pool::{FullChainApi, FullPool, Options, RevalidationType};
use sp_api::{ApiExt, BlockT, CallApiAt, ConstructRuntimeApi, ProvideRuntimeApi};
use sp_blockchain::{Error as BlockChainError, HeaderMetadata};
use sp_core::traits::CodeExecutor;
use sp_keystore::SyncCryptoStorePtr;
use sp_runtime::{traits::BlockIdTo, BuildStorage};
Expand Down Expand Up @@ -222,6 +223,7 @@ where
CP::Backend: Backend<Block> + 'static,
CP::Client: 'static
+ ProvideRuntimeApi<Block, Api = CP::Api>
+ HeaderMetadata<Block, Error = BlockChainError>
+ BlockOf
+ BlockBackend<Block>
+ BlockIdTo<Block>
Expand Down Expand Up @@ -287,6 +289,8 @@ where
self.pool_config.revalidation,
task_manager.spawn_essential_handle(),
client.usage_info().chain.best_number,
client.usage_info().chain.best_hash,
client.usage_info().chain.finalized_hash,
));

Ok((client, backend, pool, self.exec, task_manager))
Expand Down Expand Up @@ -404,6 +408,8 @@ where
self.pool_config.revalidation,
task_manager.spawn_essential_handle(),
client.usage_info().chain.best_number,
client.usage_info().chain.best_hash,
client.usage_info().chain.finalized_hash,
));

(self.keystore_receiver)(keystore_container);
Expand Down
10 changes: 5 additions & 5 deletions core/src/tests/stand_alone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ async fn mutating_genesis_works() {
let (send_data_pre, recv_data_pre) = builder
.with_mut_state(|| {
polkadot_runtime::Balances::transfer(
polkadot_runtime::Origin::signed(AccountId32::new([0u8; 32])),
polkadot_runtime::RuntimeOrigin::signed(AccountId32::new([0u8; 32])),
MultiAddress::Id(account("test", 0, 0)),
1_000_000_000_000u128,
)
Expand Down Expand Up @@ -227,7 +227,7 @@ async fn opening_state_from_db_path_works() {
.into_iter()
.map(|record| record.event.clone())
.collect::<Vec<_>>()
.contains(&polkadot_runtime::Event::Balances(
.contains(&polkadot_runtime::RuntimeEvent::Balances(
pallet_balances::Event::<Runtime>::Transfer {
from: AccountId32::new([0u8; 32]),
to: account::<AccountId32>("test", 0, 0),
Expand All @@ -238,7 +238,7 @@ async fn opening_state_from_db_path_works() {
let (send_data_post_20, recv_data_post_20) = builder
.with_mut_state(|| {
polkadot_runtime::Balances::transfer(
polkadot_runtime::Origin::signed(AccountId32::new([0u8; 32])),
polkadot_runtime::RuntimeOrigin::signed(AccountId32::new([0u8; 32])),
MultiAddress::Id(account("test", 0, 0)),
1_000_000_000_000u128,
)
Expand Down Expand Up @@ -269,7 +269,7 @@ async fn opening_state_from_db_path_works() {
.iter()
.map(|record| record.event.clone())
.collect::<Vec<_>>()
.contains(&polkadot_runtime::Event::Balances(
.contains(&polkadot_runtime::RuntimeEvent::Balances(
pallet_balances::Event::<Runtime>::Transfer {
from: AccountId32::new([0u8; 32]),
to: account::<AccountId32>("test", 0, 0),
Expand Down Expand Up @@ -347,7 +347,7 @@ async fn build_relay_block_works_and_mut_is_build_upon() {
let (send_data_pre, recv_data_pre) = builder
.with_mut_state(|| {
polkadot_runtime::Balances::transfer(
polkadot_runtime::Origin::signed(AccountId32::new([0u8; 32])),
polkadot_runtime::RuntimeOrigin::signed(AccountId32::new([0u8; 32])),
MultiAddress::Id(account("test", 0, 0)),
1_000_000_000_000u128,
)
Expand Down
Loading

0 comments on commit 0cba94b

Please sign in to comment.