mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 16:51:03 +00:00
Make offchain indexing work (#7940)
* Make offchain indexing work This fixes some bugs with offchain indexing to make it actually working ;) * Fix tests * Fix browser build * Update client/db/src/offchain.rs Co-authored-by: cheme <emericchevalier.pro@gmail.com> * Remove seperation between prefix and key Co-authored-by: cheme <emericchevalier.pro@gmail.com>
This commit is contained in:
@@ -29,7 +29,6 @@ use sc_executor::{RuntimeVersion, RuntimeInfo, NativeVersion};
|
||||
use sp_externalities::Extensions;
|
||||
use sp_core::{
|
||||
NativeOrEncoded, NeverNativeValue, traits::{CodeExecutor, SpawnNamed, RuntimeCode},
|
||||
offchain::storage::OffchainOverlayedChanges,
|
||||
};
|
||||
use sp_api::{ProofRecorder, InitializeBlock, StorageTransactionCache};
|
||||
use sc_client_api::{backend, call_executor::CallExecutor};
|
||||
@@ -127,11 +126,6 @@ where
|
||||
extensions: Option<Extensions>,
|
||||
) -> sp_blockchain::Result<Vec<u8>> {
|
||||
let mut changes = OverlayedChanges::default();
|
||||
let mut offchain_changes = if self.client_config.offchain_indexing_api {
|
||||
OffchainOverlayedChanges::enabled()
|
||||
} else {
|
||||
OffchainOverlayedChanges::disabled()
|
||||
};
|
||||
let changes_trie = backend::changes_tries_state_at_block(
|
||||
id, self.backend.changes_trie_storage()
|
||||
)?;
|
||||
@@ -145,7 +139,6 @@ where
|
||||
&state,
|
||||
changes_trie,
|
||||
&mut changes,
|
||||
&mut offchain_changes,
|
||||
&self.executor,
|
||||
method,
|
||||
call_data,
|
||||
@@ -176,7 +169,6 @@ where
|
||||
method: &str,
|
||||
call_data: &[u8],
|
||||
changes: &RefCell<OverlayedChanges>,
|
||||
offchain_changes: &RefCell<OffchainOverlayedChanges>,
|
||||
storage_transaction_cache: Option<&RefCell<
|
||||
StorageTransactionCache<Block, B::State>
|
||||
>>,
|
||||
@@ -201,7 +193,6 @@ where
|
||||
let mut state = self.backend.state_at(*at)?;
|
||||
|
||||
let changes = &mut *changes.borrow_mut();
|
||||
let offchain_changes = &mut *offchain_changes.borrow_mut();
|
||||
|
||||
match recorder {
|
||||
Some(recorder) => {
|
||||
@@ -213,7 +204,6 @@ where
|
||||
let state_runtime_code = sp_state_machine::backend::BackendRuntimeCode::new(&trie_state);
|
||||
// It is important to extract the runtime code here before we create the proof
|
||||
// recorder.
|
||||
|
||||
let runtime_code = state_runtime_code.runtime_code()
|
||||
.map_err(sp_blockchain::Error::RuntimeCode)?;
|
||||
let runtime_code = self.check_override(runtime_code, at)?;
|
||||
@@ -227,7 +217,6 @@ where
|
||||
&backend,
|
||||
changes_trie_state,
|
||||
changes,
|
||||
offchain_changes,
|
||||
&self.executor,
|
||||
method,
|
||||
call_data,
|
||||
@@ -249,7 +238,6 @@ where
|
||||
&state,
|
||||
changes_trie_state,
|
||||
changes,
|
||||
offchain_changes,
|
||||
&self.executor,
|
||||
method,
|
||||
call_data,
|
||||
@@ -264,7 +252,6 @@ where
|
||||
|
||||
fn runtime_version(&self, id: &BlockId<Block>) -> sp_blockchain::Result<RuntimeVersion> {
|
||||
let mut overlay = OverlayedChanges::default();
|
||||
let mut offchain_overlay = OffchainOverlayedChanges::default();
|
||||
let changes_trie_state = backend::changes_tries_state_at_block(
|
||||
id,
|
||||
self.backend.changes_trie_storage(),
|
||||
@@ -273,7 +260,6 @@ where
|
||||
let mut cache = StorageTransactionCache::<Block, B::State>::default();
|
||||
let mut ext = Ext::new(
|
||||
&mut overlay,
|
||||
&mut offchain_overlay,
|
||||
&mut cache,
|
||||
&state,
|
||||
changes_trie_state,
|
||||
|
||||
@@ -1654,7 +1654,6 @@ impl<B, E, Block, RA> CallApiAt<Block> for Client<B, E, Block, RA> where
|
||||
params.function,
|
||||
¶ms.arguments,
|
||||
params.overlayed_changes,
|
||||
params.offchain_changes,
|
||||
Some(params.storage_transaction_cache),
|
||||
params.initialize_block,
|
||||
manager,
|
||||
|
||||
Reference in New Issue
Block a user