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

Number of digest items must match that calculated #388

Closed
AurevoirXavier opened this issue Mar 24, 2020 · 7 comments · Fixed by #389
Closed

Number of digest items must match that calculated #388

AurevoirXavier opened this issue Mar 24, 2020 · 7 comments · Fixed by #389
Assignees

Comments

@AurevoirXavier
Copy link
Member

29|darwinia-canary-2  | 2020-03-24 03:48 +00:00: 2020-03-24 03:48:00 New epoch 0 launching at block 0x636732dd (block slot 264170277 >= start slot 264170277).
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00: 2020-03-24 03:48:00 Next epoch starts at slot 264170307
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00: ====================
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00: Version: 0.5.0-00da07d-x86_64-linux-gnu
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:    0: sp_panic_handler::set::{{closure}}
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:    1: std::panicking::rust_panic_with_hook
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00: src/libstd/panicking.rs:474
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:    2: rust_begin_unwind
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:              at src/libstd/panicking.rs:378
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:    3: std::panicking::begin_panic_fmt
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:              at src/libstd/panicking.rs:332
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:    4: frame_executive::Executive<System,Block,Context,UnsignedValidator,AllModules>::execute_block
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:    5: <node_runtime::Runtime as sp_api::runtime_decl_for_Core::Core<sp_runtime::generic::block::Block<sp_runtime::generic::header::Header<u32,sp_runtime::traits::BlakeTwo256>,sp_runtime::generic::unchecked_extrinsic::UncheckedExtrinsic<<pallet_indices::Module<node_runtime::Runtime> as sp_runtime::traits::StaticLookup>::Source,node_runtime::Call,sp_runtime::MultiSignature,(frame_system::CheckVersion<node_runtime::Runtime>, frame_system::CheckGenesis<node_runtime::Runtime>, frame_system::CheckEra<node_runtime::Runtime>, frame_system::CheckNonce<node_runtime::Runtime>, frame_system::CheckWeight<node_runtime::Runtime>, pallet_transaction_payment::ChargeTransactionPayment<node_runtime::Runtime>, pallet_contracts::CheckBlockGasLimit<node_runtime::Runtime>)>>>>::execute_block
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:    6: std::panicking::try::do_call
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:    7: __rust_maybe_catch_panic
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:              at src/libpanic_unwind/lib.rs:86
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:    8: std::thread::local::LocalKey<T>::with
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:    9: sc_executor::native_executor::WasmExecutor::with_instance::{{closure}}
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00: ::wasm_runtime::RuntimeCache::with_instance
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   11: <sc_executor::native_executor::NativeExecutor<D> as sp_core::traits::CodeExecutor>::call
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   12: sp_state_machine::StateMachine<B,H,N,Exec>::execute_aux
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   13: sp_state_machine::StateMachine<B,H,N,Exec>::execute_using_consensus_failure_handler
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   14: <sc_client::call_executor::LocalCallExecutor<B,E> as sc_client_api::call_executor::CallExecutor<Block>>::contextual_call
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   15: <sc_client::client::Client<B,E,Block,RA> as sp_api::CallApiAt<Block>>::call_api_at
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   16: sp_api::runtime_decl_for_Core::execute_block_call_api_at
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   17: sp_api::Core::execute_block
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   18: <&sc_client::client::Client<B,E,Block,RA> as sp_consensus::block_import::BlockImport<Block>>::import_block
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   19: <sc_finality_grandpa::import::GrandpaBlockImport<BE,Block,Client,SC> as sp_consensus::block_import::BlockImport<Block>>::import_block
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   20: <sc_consensus_babe::BabeBlockImport<Block,Client,Inner> as sp_consensus::block_import::BlockImport<Block>>::import_block
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   21: sp_consensus::import_queue::import_single_block
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:  core::future::future::Future>::poll
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   23: futures_util::future::future::chain::Chain<Fut1,Fut2,Data>::poll
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   24: <futures_util::future::poll_fn::PollFn<F> as core::future::future::Future>::poll
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   25: futures_executor::thread_pool::PoolState::work
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   26: std::sys_common::backtrace::__rust_begin_short_backtrace
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   27: std::panicking::try::do_call
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   28: __rust_maybe_catch_panic
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:              at src/libpanic_unwind/lib.rs:86
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   29: core::ops::function::FnOnce::call_once{{vtable.shim}}
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   30: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:              at /rustc/75cf41afb468152611212271bae026948cd3ba46/src/liballoc/boxed.rs:1017
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   31: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:              at /rustc/75cf41afb468152611212271bae026948cd3ba46/src/liballoc/boxed.rs:1017
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:       std::sys_common::thread::start_thread
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:              at src/libstd/sys_common/thread.rs:13
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:       std::sys::unix::thread::Thread::new::thread_start
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:              at src/libstd/sys/unix/thread.rs:80
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   32: start_thread
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   33: __clone
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00: Thread 'import-queue-worker-0' panicked at 'assertion failed: `(left == right)`
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:   left: `2`,
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:  right: `3`: Number of digest items must match that calculated.', <::std::macros::panic macros>:5
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00: This is a bug. Please report it at:
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00: 	https://github.com/darwinia-network/darwinia/issues/new
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00:
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00: 2020-03-24 03:48:00 Block prepare storage changes error:
29|darwinia-canary-2  | 2020-03-24 03:48 +00:00: Execution(RuntimePanicked("assertion failed: `(left == right)`\n  left: `2`,\n right: `3`: Number of digest items must match that calculated."))
@AurevoirXavier
Copy link
Member Author

AurevoirXavier commented Mar 24, 2020

@hackfisher relate to #358, darwinia-network/substrate#1

@AurevoirXavier
Copy link
Member Author

AurevoirXavier commented Mar 24, 2020

In executor:

fn final_checks(header: &System::Header) {
	// remove temporaries
	let new_header = <frame_system::Module<System>>::finalize();

	// check digest
	assert_eq!(
		header.digest().logs().len(),
		new_header.digest().logs().len(),
		"Number of digest items must match that calculated."
	);
	let items_zip = eader.digest().logs().iter().zip(new_header.digest().logs().iter());
	for (header_item, computed_item) in items_zip {
		header_item.check_equal(&computed_item);
		assert!(header_item == computed_item, "Digest item must match that alculated.");
	}

	// check storage root.
	let storage_root = new_header.state_root();
	header.state_root().check_equal(&storage_root);
	assert!(header.state_root() == storage_root, "Storage root must match that calculated.");
}

@hackfisher
Copy link
Contributor

hackfisher commented Mar 24, 2020

Reproducible in multi nodes model:

 ./target/release/darwinia --alice -d ./data/alice
 ./target/release/darwinia --bob -d ./data/bob

It goes normal after re-generating the genesis or running in native model:

 ./target/release/darwinia --alice --execution=Native -d ./data/alice
 ./target/release/darwinia --bob --execution=Native -d ./data/bob

Need to find the root cause why it need to regenerate genesis after changing Digest or Runtime?
Are runtime data included in genesis (other than GenesisConfig)?

@AurevoirXavier AurevoirXavier linked a pull request Mar 24, 2020 that will close this issue
@AurevoirXavier AurevoirXavier self-assigned this Mar 24, 2020
@hackfisher
Copy link
Contributor

https://wiki.parity.io/Chain-specification

This is for ethereum, not substrate.

@hackfisher
Copy link
Contributor

hackfisher commented Mar 25, 2020

It seems that block producer node are generating block using old genesis wasm version, and applying blocks using native version(or local wasm version).

Substrate didn't compare the local wasm with on-chain wasm on genesis?

@hackfisher
Copy link
Contributor

The root cause is following:

  1. The execution strategy is as following:
impl Default for ExecutionStrategies {
	fn default() -> ExecutionStrategies {
		ExecutionStrategies {
			syncing: ExecutionStrategy::NativeElseWasm,
			importing: ExecutionStrategy::NativeElseWasm,
			block_construction: ExecutionStrategy::AlwaysWasm,
			offchain_worker: ExecutionStrategy::NativeWhenPossible,
			other: ExecutionStrategy::NativeElseWasm,
		}
	}
}
  1. The genesis binary is not re-generated.

  2. The spec runtime was not updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants