pub fn prove_execution<Block, S, E>(
	state: S,
	header: Block::Header,
	executor: &E,
	method: &str,
	call_data: &[u8],
) -> ClientResult<(Vec<u8>, Vec<Vec<u8>>)>
	where
		Block: BlockT<Hash=H256>,
		S: StateBackend<Blake2Hasher>,
		E: CallExecutor<Block, Blake2Hasher>,
{
	let trie_state = state.try_into_trie_backend()
		.ok_or_else(|| Box::new(state_machine::ExecutionError::UnableToGenerateProof) as Box<state_machine::Error>)?;

	// prepare execution environment + record preparation proof
	let mut changes = Default::default();
	let (_, init_proof) = executor.prove_at_trie_state(
		&trie_state,
		&mut changes,
		"Core_initialize_block",
		&header.encode(),
	)?;

	// execute method + record execution proof
	let (result, exec_proof) = executor.prove_at_trie_state(&trie_state, &mut changes, method, call_data)?;
	let total_proof = init_proof.into_iter()
		.chain(exec_proof.into_iter())
		.collect::<HashSet<_>>()
		.into_iter()
		.collect();

	Ok((result, total_proof))
}
/// Prove contextual execution using given block header in environment.
///
/// Method is executed using passed header as environment' current block.
/// Proof includes both environment preparation proof and method execution proof.
Prove contextual execution using given block header in environment.
Method is executed using passed header as environment' current block.
Proof includes both environment preparation proof and method execution proof.
Prove contextual execution using given block header in environment . Method is executed using passed header as environment ' current block . Proof includes both environment preparation proof and method execution proof .
pub fn prove_execution<Block, S, E>(
	state: S,
	header: Block::Header,
	executor: &E,
	method: &str,
	call_data: &[u8],
) -> ClientResult<(Vec<u8>, Vec<Vec<u8>>)>
	where
		Block: BlockT<Hash=H256>,
		S: StateBackend<Blake2Hasher>,
		E: CallExecutor<Block, Blake2Hasher>,
{
	let trie_state = state.try_into_trie_backend()
		.ok_or_else(|| Box::new(state_machine::ExecutionError::UnableToGenerateProof) as Box<state_machine::Error>)?;
	// prepare execution environment + record preparation proof
	let mut changes = Default::default();
	let (_, init_proof) = executor.prove_at_trie_state(
		&trie_state,
		&mut changes,
		"Core_initialize_block",
		&header.encode(),
	)?;
	// execute method + record execution proof
	let (result, exec_proof) = executor.prove_at_trie_state(&trie_state, &mut changes, method, call_data)?;
	let total_proof = init_proof.into_iter()
		.chain(exec_proof.into_iter())
		.collect::<HashSet<_>>()
		.into_iter()
		.collect();
	Ok((result, total_proof))
}
pub fn prove_execution < Block , S , E > ( state : S , header : Block :: Header , executor : & E , method : & str , call_data : & [ u8 ] , ) -> ClientResult < ( Vec < u8 > , Vec < Vec < u8 > > ) > where Block : BlockT < Hash = H256 > , S : StateBackend < Blake2Hasher > , E : CallExecutor < Block , Blake2Hasher > , { let trie_state = state . try_into_trie_backend ( ) . ok_or_else ( | | Box :: new ( state_machine :: ExecutionError :: UnableToGenerateProof ) as Box < state_machine :: Error > ) ? ; // prepare execution environment + record preparation proof let mut changes = Default :: default ( ) ; let ( _ , init_proof ) = executor . prove_at_trie_state ( & trie_state , & mut changes , " " , & header . encode ( ) , ) ? ; // execute method + record execution proof let ( result , exec_proof ) = executor . prove_at_trie_state ( & trie_state , & mut changes , method , call_data ) ? ; let total_proof = init_proof . into_iter ( ) . chain ( exec_proof . into_iter ( ) ) . collect :: < HashSet < _ > > ( ) . into_iter ( ) . collect ( ) ; Ok ( ( result , total_proof ) ) }
Prove contextual execution using given block header in environment.
Prove contextual execution using given block header in environment .
state
S
header
Block::Header
executor
&E
method
&str
call_data
&[u8]
state
S
header
Block::Header
executor
&E
method
&str
call_data
&[u8]