Skip to content

Commit

Permalink
address code review
Browse files Browse the repository at this point in the history
  • Loading branch information
mangas committed Dec 18, 2023
1 parent d1a3636 commit 451e1b1
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 19 deletions.
1 change: 1 addition & 0 deletions chain/near/src/trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ pub struct ReceiptWithOutcome {
pub block: Arc<codec::Block>,
}

// Will try to re-enable these as part of https://github.com/graphprotocol/graph-node/issues/5079
// #[cfg(test)]
// mod tests {
// use std::convert::TryFrom;
Expand Down
10 changes: 6 additions & 4 deletions core/src/subgraph/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ where
.template
.manifest_idx()
.ok_or_else(|| anyhow!("Expected template to have an idx"))?;
let x = self
let created_ds_template = self
.inputs
.templates
.iter()
Expand All @@ -697,9 +697,11 @@ where
// Try to instantiate a data source from the template
let data_source = {
let res = match info.template {
InstanceDSTemplate::Onchain(_) => C::DataSource::from_template_info(info, x)
.map(DataSource::Onchain)
.map_err(DataSourceCreationError::from),
InstanceDSTemplate::Onchain(_) => {
C::DataSource::from_template_info(info, created_ds_template)
.map(DataSource::Onchain)
.map_err(DataSourceCreationError::from)
}
InstanceDSTemplate::Offchain(_) => offchain::DataSource::from_template_info(
info,
self.ctx.causality_region_next_value(),
Expand Down
2 changes: 1 addition & 1 deletion graph/src/data_source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ impl<C: Blockchain> DataSourceTemplate<C> {
pub fn info(&self) -> DataSourceTemplateInfo {
match self {
DataSourceTemplate::Onchain(template) => template.info(),
DataSourceTemplate::Offchain(template) => template.into(),
DataSourceTemplate::Offchain(template) => template.clone().into(),
}
}

Expand Down
4 changes: 2 additions & 2 deletions graph/src/data_source/offchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,15 +455,15 @@ pub struct DataSourceTemplate {
pub mapping: Mapping,
}

impl Into<DataSourceTemplateInfo> for &DataSourceTemplate {
impl Into<DataSourceTemplateInfo> for DataSourceTemplate {
fn into(self) -> DataSourceTemplateInfo {
let DataSourceTemplate {
kind,
network: _,
name,
manifest_idx,
mapping,
} = self.clone();
} = self;

DataSourceTemplateInfo {
api_version: mapping.api_version.clone(),
Expand Down
1 change: 0 additions & 1 deletion graph/src/runtime/wasm/host_exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ impl HostExports {
// parameter is passed to the callback without any changes
pub(crate) fn ipfs_map(
link_resolver: &Arc<dyn LinkResolver>,
// module: &mut WasmInstanceContext<C>,
store: &mut StoreContextMut<'_, WasmInstanceContext>,
link: String,
callback: &str,
Expand Down
14 changes: 3 additions & 11 deletions graph/src/runtime/wasm/module/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,9 @@ impl WasmInstanceContext {
let entity_type: String =
asc_get(&read_store, self.as_mut().asc_heap_mut(), entity_ptr, gas)?;
let id: String = asc_get(&read_store, self.as_mut().asc_heap_mut(), id_ptr, gas)?;
let entity_option = host_exports
.store_get(
&mut self.as_mut().ctx.state,
entity_type.clone(),
id.clone(),
gas,
scope,
)?
// This is not great in a hot path but otherwise the self ref would not
// be released for the next block. Would be good to find a better pattern here.
.map(|e| e.into_owned());
let block_state = &mut self.as_mut().ctx.state;
let entity_option =
host_exports.store_get(block_state, entity_type.clone(), id.clone(), gas, scope)?;

if self.as_ref().ctx.instrument {
debug!(self.as_ref().ctx.logger, "store_get";
Expand Down
2 changes: 2 additions & 0 deletions runtime/test/src/test/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use graph::runtime::wasm::asc_abi::class::{

use super::*;

// Fix once https://github.com/graphprotocol/graph-node/issues/5079 is resolved.

// async fn test_unbounded_loop(api_version: Version) {
// // Set handler timeout to 3 seconds.
// let mut instance = test_valid_module_and_store_with_timeout(
Expand Down

0 comments on commit 451e1b1

Please sign in to comment.