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

Polkadot v0.9.43 #69

Merged
merged 16 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
3,028 changes: 1,642 additions & 1,386 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[workspace]
members = [
"core",
"core/src/builder/companion",
"core/src/tests/test-parachain",
"fudge",
"integration_test"
"core",
"core/src/builder/companion",
"core/src/tests/test-parachain",
"fudge",
"integration_test",
]
132 changes: 67 additions & 65 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ edition = "2021"

[dependencies]
# third-party dependencies
scale-info = { version = "2.1.2", default-features = false, features = ["derive"] }
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"] }
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"
Expand All @@ -20,83 +24,81 @@ tokio = { version = "1.15", features = ["macros"] }
metered = { package = "prioritized-metered-channel", version = "0.2.0" }

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

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

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

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

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

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

[dev-dependencies]
polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38" }
sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }

frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }

pallet-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, features = ["historical"] , branch = "polkadot-v0.9.38" }
pallet-grandpa = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" }
pallet-im-online = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" }
pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }

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

[features]
default = []
runtime-benchmarks = [
'frame-benchmarking/runtime-benchmarks'
]
runtime-benchmarks = ['frame-benchmarking/runtime-benchmarks']
23 changes: 9 additions & 14 deletions core/src/builder/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,21 +717,16 @@ where
params: BlockImportParams<Block, TransactionFor<B, 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| {
tracing::error!(
target = DEFAULT_BUILDER_LOG_TARGET,
error = ?e,
"Could not import block."
);

let ret = match futures::executor::block_on(
self.client
.as_ref()
.import_block(params, Default::default()),
)
.map_err(|e| {
tracing::error!(
target = DEFAULT_BUILDER_LOG_TARGET,
error = ?e,
"Could not import block."
);

Error::BlockImporting(e.into())
})? {
Error::BlockImporting(e.into())
})? {
ImportResult::Imported(_) => Ok(()),
ImportResult::AlreadyInChain => Err(()),
ImportResult::KnownBad => Err(()),
Expand Down
36 changes: 30 additions & 6 deletions core/src/builder/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ where
let block_id = BlockId::Hash(block_hash);

let api_version = runtime_api
.api_version::<dyn CollectCollationInfo<Block>>(&block_id)
.api_version::<dyn CollectCollationInfo<Block>>(block_hash)
.map_err(|e| {
tracing::error!(
target = DEFAULT_COLLATOR_LOG_TARGET,
Expand All @@ -171,7 +171,7 @@ where
block_id,
);

Error::APIVersionRetrieval(block_id, e.into())
Error::APIVersionRetrieval(block_id.clone(), e.into())
})?
.ok_or_else(|| {
tracing::error!(
Expand All @@ -186,7 +186,7 @@ where
let collation_info = if api_version < 2 {
#[allow(deprecated)]
runtime_api
.collect_collation_info_before_version_2(&block_id)
.collect_collation_info_before_version_2(block_hash)
.map_err(|e| {
tracing::error!(
target = DEFAULT_COLLATOR_LOG_TARGET,
Expand All @@ -200,7 +200,7 @@ where
.into_latest(header.encode().into())
} else {
runtime_api
.collect_collation_info(&block_id, header)
.collect_collation_info(block_hash, header)
.map_err(|e| {
tracing::error!(
target = DEFAULT_COLLATOR_LOG_TARGET,
Expand Down Expand Up @@ -273,11 +273,35 @@ where
.ok()
.flatten()?;

let upward_messages = collation_info
.upward_messages
.try_into()
.map_err(|e| {
tracing::error!(
target: DEFAULT_COLLATOR_LOG_TARGET,
error = ?e,
"Could not cast upward messages.",
)
})
.ok()?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm asking here, but the question goes more for all these patterns. If fudge intention is to be used for testing. Why, instead of tracing and propagating a None, do we no just unwrap everywhere? That way, when it doesn't work, the error just panic with the correct message in the correct line which generate it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe @mustermeiszer can provide a better answer to this ^^.

In my fudge branch for xcm tests I'm addressing some of these and propagating some more errors in cases similar to this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might not want to use it soley for testing. You can also use it for other things like forking a network, etc. I think unwrapping in a dependency library is not really an option IMO.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unwrapping in a dependency library is not really an option IMO.

Ok, this makes sense 👍🏻


let horizontal_messages = collation_info
.horizontal_messages
.try_into()
.map_err(|e| {
tracing::error!(
target: DEFAULT_COLLATOR_LOG_TARGET,
error = ?e,
"Could not cast horizontal messages.",
)
})
.ok()?;

Some(Collation {
upward_messages: collation_info.upward_messages,
upward_messages,
new_validation_code: collation_info.new_validation_code,
processed_downward_messages: collation_info.processed_downward_messages,
horizontal_messages: collation_info.horizontal_messages,
horizontal_messages,
hrmp_watermark: collation_info.hrmp_watermark,
head_data: collation_info.head_data,
proof_of_validity: MaybeCompressedPoV::Raw(PoV { block_data }),
Expand Down
14 changes: 5 additions & 9 deletions core/src/builder/relay_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use polkadot_parachain::primitives::{
};
use polkadot_primitives::{
runtime_api::ParachainHost,
v2::{
v4::{
CandidateCommitments, CandidateDescriptor, CandidateReceipt, CoreIndex,
OccupiedCoreAssumption,
},
Expand Down Expand Up @@ -344,11 +344,7 @@ where
);
let api = self.client.runtime_api();
let persisted_validation_data = api
.persisted_validation_data(
&BlockId::Hash(parent),
self.id,
OccupiedCoreAssumption::TimedOut,
)
.persisted_validation_data(parent, self.id, OccupiedCoreAssumption::TimedOut)
.map_err(|e| {
tracing::error!(
target = DEFAULT_RELAY_CHAIN_BUILDER_LOG_TARGET,
Expand Down Expand Up @@ -867,7 +863,7 @@ where
);

// NOTE: Calling this with OccupiedCoreAssumption::Included, force_enacts the para
polkadot_runtime_parachains::runtime_api_impl::v2::persisted_validation_data::<
polkadot_runtime_parachains::runtime_api_impl::v4::persisted_validation_data::<
Runtime,
>(id, OccupiedCoreAssumption::Included)
.ok_or_else(|| {
Expand Down Expand Up @@ -973,7 +969,7 @@ where
RtApi: ParachainHost<Block> + ApiExt<Block>,
{
let res = rt_api.execute_in_transaction(|api| {
let pvd = api.persisted_validation_data(&BlockId::Hash(parent), id, assumption);
let pvd = api.persisted_validation_data(parent, id, assumption);

TransactionOutcome::Commit(pvd)
});
Expand Down Expand Up @@ -1008,7 +1004,7 @@ where
RtApi: ParachainHost<Block>,
{
rt_api
.validation_code_hash(&BlockId::Hash(parent), id, assumption)
.validation_code_hash(parent, id, assumption)
.map_err(|e| {
tracing::error!(
target = DEFAULT_RELAY_CHAIN_BUILDER_LOG_TARGET,
Expand Down
2 changes: 1 addition & 1 deletion core/src/inherent/relay_parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +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 polkadot_primitives::v2::{
use polkadot_primitives::v4::{
BackedCandidate, InherentData as ParachainsInherentData, PARACHAINS_INHERENT_IDENTIFIER,
};
use sp_inherents::{Error, InherentData, InherentDataProvider, InherentIdentifier};
Expand Down
7 changes: 3 additions & 4 deletions core/src/inherent/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,9 @@ impl sp_inherents::InherentDataProvider for CurrTimeProvider {
return None;
}

match InherentError::try_from(&INHERENT_IDENTIFIER, error)? {
InherentError::ValidAtTimestamp(_valid) => Some(Ok(())),
o => Some(Err(sp_inherents::Error::Application(Box::from(o)))),
}
Some(Err(sp_inherents::Error::Application(Box::from(
InherentError::try_from(&INHERENT_IDENTIFIER, error)?,
))))
}
}

Expand Down
Loading