Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix xt root.
  • Loading branch information
gavofyork committed Apr 9, 2018
commit a5d5d468eaabce285bf5eb1cdaa1c929f1088c2c
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions polkadot/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ authors = ["Parity Technologies <[email protected]>"]

[dependencies]
error-chain = "0.11"
log = "0.3"
polkadot-executor = { path = "../executor" }
polkadot-runtime = { path = "../runtime" }
polkadot-primitives = { path = "../primitives" }
Expand Down
5 changes: 4 additions & 1 deletion polkadot/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ extern crate substrate_state_machine as state_machine;
#[macro_use]
extern crate error_chain;

#[macro_use]
extern crate log;

#[cfg(test)]
extern crate substrate_keyring as keyring;

Expand Down Expand Up @@ -174,7 +177,7 @@ impl<B: Backend> PolkadotApi for Client<B, NativeExecutor<LocalDispatch>>
fn check_id(&self, id: BlockId) -> Result<CheckedId> {
// bail if the code is not the same as the natively linked.
if self.code_at(&id)? != LocalDispatch::native_equivalent() {
bail!(ErrorKind::UnknownRuntime);
warn!("This node is out of date. Block authoring may not work correctly.")
Copy link
Contributor

Choose a reason for hiding this comment

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

dangerous proposition. I think authorities would prefer to get slashed for being temporarily offline than risk accidentally losing their whole bond.

also means that when we update the runtime, if >2/3 of the authorities have this behavior, they will continue growing the chain with the wrong rules.

Copy link
Contributor

Choose a reason for hiding this comment

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

(I get why this change is in this PR -- the genesis.wasm is a nuisance to work around, but we should just stop checking this stuff in and have an environment variable for when we want to use a specific runtime wasm!)

Copy link
Member Author

Choose a reason for hiding this comment

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

to be honest we're going to have to introduce semantic versioning here anyway. it's impractical to ensure that a node is updated, restarted and where necessary migrated at exactly the block boundary when the runtime changes, so there will need to be changeover periods. bailing here is unreasonable.

Copy link
Contributor

@rphmeier rphmeier Apr 11, 2018

Choose a reason for hiding this comment

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

right, but there are different approaches to that, and given that the API can change between runtimes, it's likely we might do something based on linking multiple versions of the polkadot-api crate. Network, consensus, and other client-level code might change between runtimes as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

i'd rather just have semantic versioning of the API and be done with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

can we agree to classify that as beyond the scope of this PR and introduce that later?

Copy link
Member Author

Choose a reason for hiding this comment

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

sure

}

Ok(CheckedId(id))
Expand Down
10 changes: 7 additions & 3 deletions substrate/runtime/system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ use runtime_io::{twox_128, TestExternalities};

/// Compute the extrinsics root of a list of extrinsics.
pub fn extrinsics_root<H: Hashing, E: codec::Slicable>(extrinsics: &[E]) -> H::Output {
let xts = extrinsics.iter().map(codec::Slicable::encode).collect::<Vec<_>>();
extrinsics_data_root::<H>(extrinsics.iter().map(codec::Slicable::encode).collect())
}

/// Compute the extrinsics root of a list of extrinsics.
pub fn extrinsics_data_root<H: Hashing>(xts: Vec<Vec<u8>>) -> H::Output {
let xts = xts.iter().map(Vec::as_slice).collect::<Vec<_>>();
H::enumerated_trie_root(&xts)
}
Expand Down Expand Up @@ -187,8 +191,8 @@ impl<T: Trait> Module<T> {

/// Remove all extrinsics data and save the extrinsics trie root.
pub fn derive_extrinsics() {
let extrinsics = (0..Self::extrinsic_index()).map(<ExtrinsicData<T>>::take).collect::<Vec<_>>();
let xts_root = extrinsics_root::<T::Hashing, _>(&extrinsics);
let extrinsics = (0..Self::extrinsic_index()).map(<ExtrinsicData<T>>::take).collect();
let xts_root = extrinsics_data_root::<T::Hashing>(extrinsics);
<ExtrinsicsRoot<T>>::put(xts_root);
}
}
Expand Down