Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize extrinsics decoding and storage indexing #462

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions substrate-archive-backend/src/read_only_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,13 @@ where
if key.len() == 4 && fun(num) {
let head: Option<Block::Header> = readable_db
.get(super::util::columns::HEADER, &value)
.map(|bytes| Decode::decode(&mut &bytes[..]).ok())
.flatten();
.and_then(|bytes| Decode::decode(&mut &bytes[..]).ok());
let body: Option<Vec<Block::Extrinsic>> = readable_db
.get(super::util::columns::BODY, &value)
.map(|bytes| Decode::decode(&mut &bytes[..]).ok())
.flatten();
.and_then(|bytes| Decode::decode(&mut &bytes[..]).ok());
let justif: Option<Justifications> = readable_db
.get(super::util::columns::JUSTIFICATION, &value)
.map(|bytes| Decode::decode(&mut &bytes[..]).ok())
.flatten();
.and_then(|bytes| Decode::decode(&mut &bytes[..]).ok());
construct_block(head, body, justif)
} else {
None
Expand Down
11 changes: 6 additions & 5 deletions substrate-archive-backend/src/runtime_version_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use arc_swap::ArcSwap;
use codec::Decode;
use hashbrown::HashMap;

use sc_executor::{WasmExecutionMethod, WasmExecutor};
use sc_executor::WasmExecutor;
use sp_core::traits::ReadRuntimeVersion;
use sp_runtime::{
generic::SignedBlock,
Expand All @@ -39,6 +39,7 @@ use sp_version::RuntimeVersion;
use crate::{
database::ReadOnlyDb,
error::{BackendError, Result},
frontend::RuntimeConfig,
read_only_backend::ReadOnlyBackend,
};

Expand All @@ -50,12 +51,12 @@ pub struct RuntimeVersionCache<Block, Db> {
}

impl<Block: BlockT, Db: ReadOnlyDb + 'static> RuntimeVersionCache<Block, Db> {
pub fn new(backend: Arc<ReadOnlyBackend<Block, Db>>) -> Self {
pub fn new(backend: Arc<ReadOnlyBackend<Block, Db>>, config: RuntimeConfig) -> Self {
// TODO: https://github.com/paritytech/substrate-archive/issues/247
let exec = WasmExecutor::<sp_io::SubstrateHostFunctions>::new(
WasmExecutionMethod::Interpreted,
Some(128),
1,
config.exec_method.into(),
config.wasm_pages,
config.block_workers,
None,
128,
);
Expand Down
Loading