State machine call proof backend (#3945)

* drafting a proof extraction at the hashdb level (to include everything
for the 'call' proof case).

* use full proof by default (replace previous proof recorder).

* fix warnings.

* Cache value not found in proof recorder.

* Remove need or internal backend struct.

* fix type.

* doc
This commit is contained in:
cheme
2019-11-12 16:57:37 +01:00
committed by Gavin Wood
parent 61e43218e5
commit 05391f7e04
10 changed files with 91 additions and 73 deletions
@@ -410,7 +410,7 @@ fn generate_call_api_at_calls(decl: &ItemTrait) -> Result<TokenStream> {
initialized_block: &std::cell::RefCell<Option<#crate_::BlockId<Block>>>,
native_call: Option<NC>,
context: #crate_::ExecutionContext,
recorder: &Option<std::rc::Rc<std::cell::RefCell<#crate_::ProofRecorder<Block>>>>,
recorder: &Option<#crate_::ProofRecorder<Block>>,
) -> std::result::Result<#crate_::NativeOrEncoded<R>, T::Error> {
let version = call_runtime_at.runtime_version_at(at)?;
use #crate_::InitializeBlock;
@@ -257,7 +257,7 @@ fn generate_runtime_api_base_structures(impls: &[ItemImpl]) -> Result<TokenStrea
commit_on_success: std::cell::RefCell<bool>,
initialized_block: std::cell::RefCell<Option<#block_id>>,
changes: std::cell::RefCell<#crate_::OverlayedChanges>,
recorder: Option<std::rc::Rc<std::cell::RefCell<#crate_::ProofRecorder<#block>>>>,
recorder: Option<#crate_::ProofRecorder<#block>>,
}
// `RuntimeApi` itself is not threadsafe. However, an instance is only available in a
@@ -300,11 +300,9 @@ fn generate_runtime_api_base_structures(impls: &[ItemImpl]) -> Result<TokenStrea
self.recorder
.take()
.map(|recorder| {
let trie_nodes = recorder
.borrow_mut()
.drain()
.into_iter()
.map(|record| record.data)
let trie_nodes = recorder.read()
.iter()
.filter_map(|(_k, v)| v.as_ref().map(|v| v.to_vec()))
.collect();
#crate_::StorageProof::new(trie_nodes)
})
@@ -339,7 +337,7 @@ fn generate_runtime_api_base_structures(impls: &[ItemImpl]) -> Result<TokenStrea
&Self,
&std::cell::RefCell<#crate_::OverlayedChanges>,
&std::cell::RefCell<Option<#crate_::BlockId<#block>>>,
&Option<std::rc::Rc<std::cell::RefCell<#crate_::ProofRecorder<#block>>>>,
&Option<#crate_::ProofRecorder<#block>>,
) -> std::result::Result<#crate_::NativeOrEncoded<R>, E>,
E,
>(