mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 16:51:03 +00:00
Remove keystore when doing calls and producing a proof (#4196)
* Remove keystore parameter. * Fix tests.
This commit is contained in:
committed by
Bastian Köcher
parent
d8ca2f37df
commit
309c6c70d8
@@ -262,9 +262,6 @@ where
|
|||||||
&self.executor,
|
&self.executor,
|
||||||
method,
|
method,
|
||||||
call_data,
|
call_data,
|
||||||
// Passing `None` here, since we don't really want to prove anything
|
|
||||||
// about our local keys.
|
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ impl<Block, B, Local> CallExecutor<Block, Blake2Hasher> for
|
|||||||
_manager: ExecutionManager<EM>,
|
_manager: ExecutionManager<EM>,
|
||||||
native_call: Option<NC>,
|
native_call: Option<NC>,
|
||||||
recorder: &Option<ProofRecorder<Block>>,
|
recorder: &Option<ProofRecorder<Block>>,
|
||||||
extensions: Option<Extensions>,
|
extensions: Option<Extensions>,
|
||||||
) -> ClientResult<NativeOrEncoded<R>> where ExecutionManager<EM>: Clone {
|
) -> ClientResult<NativeOrEncoded<R>> where ExecutionManager<EM>: Clone {
|
||||||
// there's no actual way/need to specify native/wasm execution strategy on light node
|
// there's no actual way/need to specify native/wasm execution strategy on light node
|
||||||
// => we can safely ignore passed values
|
// => we can safely ignore passed values
|
||||||
@@ -277,7 +277,6 @@ fn check_execution_proof_with_make_header<Header, E, H, MakeNextHeader: Fn(&Head
|
|||||||
executor,
|
executor,
|
||||||
"Core_initialize_block",
|
"Core_initialize_block",
|
||||||
&next_header.encode(),
|
&next_header.encode(),
|
||||||
None,
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// execute method
|
// execute method
|
||||||
@@ -287,7 +286,6 @@ fn check_execution_proof_with_make_header<Header, E, H, MakeNextHeader: Fn(&Head
|
|||||||
executor,
|
executor,
|
||||||
&request.method,
|
&request.method,
|
||||||
&request.call_data,
|
&request.call_data,
|
||||||
None,
|
|
||||||
).map_err(Into::into)
|
).map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -193,6 +193,5 @@ fn record_proof_works() {
|
|||||||
&executor,
|
&executor,
|
||||||
"Core_execute_block",
|
"Core_execute_block",
|
||||||
&block.encode(),
|
&block.encode(),
|
||||||
None,
|
|
||||||
).expect("Executes block while using the proof backend");
|
).expect("Executes block while using the proof backend");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ use hash_db::Hasher;
|
|||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use primitives::{
|
use primitives::{
|
||||||
storage::well_known_keys, NativeOrEncoded, NeverNativeValue,
|
storage::well_known_keys, NativeOrEncoded, NeverNativeValue,
|
||||||
traits::{KeystoreExt, CodeExecutor}, hexdisplay::HexDisplay, hash::H256,
|
traits::CodeExecutor, hexdisplay::HexDisplay, hash::H256,
|
||||||
};
|
};
|
||||||
use overlayed_changes::OverlayedChangeSet;
|
use overlayed_changes::OverlayedChangeSet;
|
||||||
use externalities::Extensions;
|
use externalities::Extensions;
|
||||||
@@ -452,7 +452,6 @@ pub fn prove_execution<B, H, Exec>(
|
|||||||
exec: &Exec,
|
exec: &Exec,
|
||||||
method: &str,
|
method: &str,
|
||||||
call_data: &[u8],
|
call_data: &[u8],
|
||||||
keystore: Option<KeystoreExt>,
|
|
||||||
) -> Result<(Vec<u8>, StorageProof), Box<dyn Error>>
|
) -> Result<(Vec<u8>, StorageProof), Box<dyn Error>>
|
||||||
where
|
where
|
||||||
B: Backend<H>,
|
B: Backend<H>,
|
||||||
@@ -461,7 +460,7 @@ where
|
|||||||
{
|
{
|
||||||
let trie_backend = backend.as_trie_backend()
|
let trie_backend = backend.as_trie_backend()
|
||||||
.ok_or_else(|| Box::new(ExecutionError::UnableToGenerateProof) as Box<dyn Error>)?;
|
.ok_or_else(|| Box::new(ExecutionError::UnableToGenerateProof) as Box<dyn Error>)?;
|
||||||
prove_execution_on_trie_backend(trie_backend, overlay, exec, method, call_data, keystore)
|
prove_execution_on_trie_backend(trie_backend, overlay, exec, method, call_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prove execution using the given trie backend, overlayed changes, and call executor.
|
/// Prove execution using the given trie backend, overlayed changes, and call executor.
|
||||||
@@ -479,7 +478,6 @@ pub fn prove_execution_on_trie_backend<S, H, Exec>(
|
|||||||
exec: &Exec,
|
exec: &Exec,
|
||||||
method: &str,
|
method: &str,
|
||||||
call_data: &[u8],
|
call_data: &[u8],
|
||||||
keystore: Option<KeystoreExt>,
|
|
||||||
) -> Result<(Vec<u8>, StorageProof), Box<dyn Error>>
|
) -> Result<(Vec<u8>, StorageProof), Box<dyn Error>>
|
||||||
where
|
where
|
||||||
S: trie_backend_essence::TrieBackendStorage<H>,
|
S: trie_backend_essence::TrieBackendStorage<H>,
|
||||||
@@ -487,12 +485,8 @@ where
|
|||||||
Exec: CodeExecutor,
|
Exec: CodeExecutor,
|
||||||
{
|
{
|
||||||
let proving_backend = proving_backend::ProvingBackend::new(trie_backend);
|
let proving_backend = proving_backend::ProvingBackend::new(trie_backend);
|
||||||
let mut extensions = Extensions::new();
|
|
||||||
if let Some(keystore) = keystore {
|
|
||||||
extensions.register(keystore);
|
|
||||||
}
|
|
||||||
let mut sm = StateMachine::<_, H, _, InMemoryChangesTrieStorage<H, u64>, Exec>::new(
|
let mut sm = StateMachine::<_, H, _, InMemoryChangesTrieStorage<H, u64>, Exec>::new(
|
||||||
&proving_backend, None, overlay, exec, method, call_data, extensions,
|
&proving_backend, None, overlay, exec, method, call_data, Extensions::default(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let (result, _, _) = sm.execute_using_consensus_failure_handler::<_, NeverNativeValue, fn() -> _>(
|
let (result, _, _) = sm.execute_using_consensus_failure_handler::<_, NeverNativeValue, fn() -> _>(
|
||||||
@@ -512,7 +506,6 @@ pub fn execution_proof_check<H, Exec>(
|
|||||||
exec: &Exec,
|
exec: &Exec,
|
||||||
method: &str,
|
method: &str,
|
||||||
call_data: &[u8],
|
call_data: &[u8],
|
||||||
keystore: Option<KeystoreExt>,
|
|
||||||
) -> Result<Vec<u8>, Box<dyn Error>>
|
) -> Result<Vec<u8>, Box<dyn Error>>
|
||||||
where
|
where
|
||||||
H: Hasher<Out=H256>,
|
H: Hasher<Out=H256>,
|
||||||
@@ -520,7 +513,7 @@ where
|
|||||||
H::Out: Ord + 'static,
|
H::Out: Ord + 'static,
|
||||||
{
|
{
|
||||||
let trie_backend = create_proof_check_backend::<H>(root.into(), proof)?;
|
let trie_backend = create_proof_check_backend::<H>(root.into(), proof)?;
|
||||||
execution_proof_check_on_trie_backend(&trie_backend, overlay, exec, method, call_data, keystore)
|
execution_proof_check_on_trie_backend(&trie_backend, overlay, exec, method, call_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check execution proof on proving backend, generated by `prove_execution` call.
|
/// Check execution proof on proving backend, generated by `prove_execution` call.
|
||||||
@@ -530,18 +523,13 @@ pub fn execution_proof_check_on_trie_backend<H, Exec>(
|
|||||||
exec: &Exec,
|
exec: &Exec,
|
||||||
method: &str,
|
method: &str,
|
||||||
call_data: &[u8],
|
call_data: &[u8],
|
||||||
keystore: Option<KeystoreExt>,
|
|
||||||
) -> Result<Vec<u8>, Box<dyn Error>>
|
) -> Result<Vec<u8>, Box<dyn Error>>
|
||||||
where
|
where
|
||||||
H: Hasher<Out=H256>,
|
H: Hasher<Out=H256>,
|
||||||
Exec: CodeExecutor,
|
Exec: CodeExecutor,
|
||||||
{
|
{
|
||||||
let mut extensions = Extensions::new();
|
|
||||||
if let Some(keystore) = keystore {
|
|
||||||
extensions.register(keystore);
|
|
||||||
}
|
|
||||||
let mut sm = StateMachine::<_, H, _, InMemoryChangesTrieStorage<H, u64>, Exec>::new(
|
let mut sm = StateMachine::<_, H, _, InMemoryChangesTrieStorage<H, u64>, Exec>::new(
|
||||||
trie_backend, None, overlay, exec, method, call_data, extensions,
|
trie_backend, None, overlay, exec, method, call_data, Extensions::default(),
|
||||||
);
|
);
|
||||||
|
|
||||||
sm.execute_using_consensus_failure_handler::<_, NeverNativeValue, fn() -> _>(
|
sm.execute_using_consensus_failure_handler::<_, NeverNativeValue, fn() -> _>(
|
||||||
@@ -914,7 +902,6 @@ mod tests {
|
|||||||
&executor,
|
&executor,
|
||||||
"test",
|
"test",
|
||||||
&[],
|
&[],
|
||||||
None,
|
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
// check proof locally
|
// check proof locally
|
||||||
@@ -925,7 +912,6 @@ mod tests {
|
|||||||
&executor,
|
&executor,
|
||||||
"test",
|
"test",
|
||||||
&[],
|
&[],
|
||||||
None,
|
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
// check that both results are correct
|
// check that both results are correct
|
||||||
|
|||||||
Reference in New Issue
Block a user