Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
overlay.set_collect_extrinsics(true); in client/call_executor.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchengxu committed Feb 8, 2022
1 parent 7f3baee commit c5198e7
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 15 deletions.
1 change: 1 addition & 0 deletions client/service/src/client/call_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ where
let runtime_code = self.check_override(runtime_code, at)?;

let mut overlay = overlay;
overlay.set_collect_extrinsics(true);
sp_state_machine::prove_execution_on_trie_backend(
&trie_backend,
&mut overlay,
Expand Down
8 changes: 8 additions & 0 deletions frame/support/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,14 @@ pub fn storage_prefix(pallet_name: &[u8], storage_name: &[u8]) -> [u8; 32] {
final_key[..16].copy_from_slice(&pallet_hash);
final_key[16..].copy_from_slice(&storage_hash);

#[cfg(feature = "std")]
println!(
"pallet_name: {}, storage_name: {}, final_key: {:?}",
String::from_utf8_lossy(pallet_name),
String::from_utf8_lossy(storage_name),
final_key
);

final_key
}

Expand Down
12 changes: 6 additions & 6 deletions primitives/state-machine/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ where
}

fn storage(&self, key: &[u8]) -> Option<StorageValue> {
#[cfg(feature = "std")]
println!("[Ext::storage] key: {:?}, {:?}", HexDisplay::from(&key), key);
// #[cfg(feature = "std")]
// println!("[Ext::storage] key: {:?}, {:?}", HexDisplay::from(&key), key);
let _guard = guard();

/*
Expand All @@ -198,10 +198,10 @@ where
* */
let result =
self.overlay.storage(key).map(|x| x.map(|x| x.to_vec())).unwrap_or_else(|| {
#[cfg(feature = "std")]
println!(
"[Ext::storage] overlay does not have this storage, retrieving from backend..."
);
// #[cfg(feature = "std")]
// println!(
// "[Ext::storage] overlay does not have this storage, retrieving from backend..."
// );
self.backend.storage(key).expect(EXT_NOT_ALLOWED_TO_FAIL)
});

Expand Down
3 changes: 3 additions & 0 deletions primitives/state-machine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,9 @@ mod execution {
always_wasm(),
None,
)?;
#[cfg(feature = "std")]
println!(
"========================= after execute_using_consensus_failure_handler: overlay: {:#?}", sm.overlay);
let proof = sm.backend.extract_proof();
Ok((result.into_encoded(), proof))
}
Expand Down
2 changes: 2 additions & 0 deletions primitives/state-machine/src/overlayed_changes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ impl OverlayedChanges {
pub fn storage(&self, key: &[u8]) -> Option<Option<&[u8]>> {
#[cfg(feature = "std")]
println!("[OverlayedChanges::storage] top: {:?}", self.top);
#[cfg(feature = "std")]
println!("[OverlayedChanges::storage] key: {:?}", sp_core::hexdisplay::HexDisplay::from(&key));
self.top.get(key).map(|x| {
let value = x.value();
let size_read = value.map(|x| x.len() as u64).unwrap_or(0);
Expand Down
18 changes: 9 additions & 9 deletions primitives/state-machine/src/proving_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl<Hash> Debug for ProofRecorder<Hash> {
impl<Hash: std::hash::Hash + Eq + Debug> ProofRecorder<Hash> {
/// Record the given `key` => `val` combination.
pub fn record(&self, key: Hash, val: Option<DBValue>) {
println!("[record] key: {:?}, val: {:?}", key, val);
// println!("[record] key: {:?}, val: {:?}", key, val);
let mut inner = self.inner.write();
let encoded_size = if let Entry::Vacant(entry) = inner.records.entry(key) {
let encoded_size = val.as_ref().map(Encode::encoded_size).unwrap_or(0);
Expand All @@ -152,7 +152,7 @@ impl<Hash: std::hash::Hash + Eq + Debug> ProofRecorder<Hash> {

/// Returns the value at the given `key`.
pub fn get(&self, key: &Hash) -> Option<Option<DBValue>> {
println!("[get] key: {:?}", key);
// println!("[get] key: {:?}", key);
self.inner.read().records.get(key).cloned()
}

Expand Down Expand Up @@ -245,17 +245,17 @@ impl<'a, S: 'a + TrieBackendStorage<H>, H: 'a + Hasher> TrieBackendStorage<H>
type Overlay = S::Overlay;

fn get(&self, key: &H::Out, prefix: Prefix) -> Result<Option<DBValue>, String> {
#[cfg(feature = "std")]
println!("[ProofRecorderBackend::get] key: {:?}", key);
// #[cfg(feature = "std")]
// println!("[ProofRecorderBackend::get] key: {:?}", key);
if let Some(v) = self.proof_recorder.get(key) {
return Ok(v);
}

#[cfg(feature = "std")]
println!(
"[ProofRecorderBackend::get] key not found in proof_recorder, retrieving from the backend: {:?}",
key
);
// #[cfg(feature = "std")]
// println!(
// "[ProofRecorderBackend::get] key not found in proof_recorder, retrieving from the backend: {:?}",
// key
// );
let backend_value = self.backend.get(key, prefix)?;
self.proof_recorder.record(key.clone(), backend_value.clone());
Ok(backend_value)
Expand Down

0 comments on commit c5198e7

Please sign in to comment.