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

bump rust version #4985

Merged
merged 9 commits into from
Feb 21, 2024
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
876 changes: 548 additions & 328 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"core",
"chain/*",
Expand Down Expand Up @@ -26,6 +27,8 @@ prost = "0.11.9"
prost-types = "0.11.9"
tonic = { version = "0.8.3", features = ["tls-roots", "gzip"] }
tonic-build = { version = "0.8.4", features = ["prost"] }
wasmtime = "15.0.1"
wasmparser = "0.118.1"

# Incremental compilation on Rust 1.58 causes an ICE on build. As soon as graph node builds again, these can be removed.
[profile.test]
Expand Down
11 changes: 6 additions & 5 deletions chain/arweave/src/data_source.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
use graph::anyhow::Context;
use graph::blockchain::{Block, TriggerWithHandler};
use graph::components::store::StoredDynamicDataSource;
use graph::components::subgraph::InstanceDSTemplateInfo;
use graph::data::subgraph::DataSourceContext;
use graph::prelude::SubgraphManifestValidationError;
use graph::{
anyhow::{anyhow, Error},
blockchain::{self, Blockchain},
prelude::{
async_trait, BlockNumber, CheapClone, DataSourceTemplateInfo, Deserialize, Link,
LinkResolver, Logger,
},
prelude::{async_trait, BlockNumber, CheapClone, Deserialize, Link, LinkResolver, Logger},
semver,
};
use std::collections::HashSet;
Expand All @@ -34,7 +32,10 @@ pub struct DataSource {
}

impl blockchain::DataSource<Chain> for DataSource {
fn from_template_info(_info: DataSourceTemplateInfo<Chain>) -> Result<Self, Error> {
fn from_template_info(
_info: InstanceDSTemplateInfo,
_template: &graph::data_source::DataSourceTemplate<Chain>,
) -> Result<Self, Error> {
Err(anyhow!("Arweave subgraphs do not support templates"))
}

Expand Down
9 changes: 6 additions & 3 deletions chain/cosmos/src/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use std::sync::Arc;

use anyhow::{Context, Error, Result};

use graph::components::subgraph::InstanceDSTemplateInfo;
use graph::{
blockchain::{self, Block, Blockchain, TriggerWithHandler},
components::store::StoredDynamicDataSource,
data::subgraph::DataSourceContext,
prelude::{
anyhow, async_trait, BlockNumber, CheapClone, DataSourceTemplateInfo, Deserialize, Link,
LinkResolver, Logger,
anyhow, async_trait, BlockNumber, CheapClone, Deserialize, Link, LinkResolver, Logger,
},
};

Expand Down Expand Up @@ -41,7 +41,10 @@ pub struct DataSource {
}

impl blockchain::DataSource<Chain> for DataSource {
fn from_template_info(_template_info: DataSourceTemplateInfo<Chain>) -> Result<Self, Error> {
fn from_template_info(
_info: InstanceDSTemplateInfo,
_template: &graph::data_source::DataSourceTemplate<Chain>,
) -> Result<Self, Error> {
Err(anyhow!(TEMPLATE_ERROR))
}

Expand Down
2 changes: 1 addition & 1 deletion chain/cosmos/src/protobuf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#[path = "sf.cosmos.r#type.v1.rs"]
pub mod pbcodec;

pub use graph_runtime_wasm::asc_abi::class::{Array, AscEnum, AscString, Uint8Array};
pub use graph_runtime_wasm::asc_abi::class::{Array, Uint8Array};

pub use crate::runtime::abi::*;
pub use pbcodec::*;
27 changes: 17 additions & 10 deletions chain/ethereum/src/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use anyhow::{anyhow, Error};
use anyhow::{ensure, Context};
use graph::blockchain::TriggerWithHandler;
use graph::components::store::StoredDynamicDataSource;
use graph::components::subgraph::InstanceDSTemplateInfo;
use graph::data_source::CausalityRegion;
use graph::prelude::ethabi::ethereum_types::H160;
use graph::prelude::ethabi::StateMutability;
Expand All @@ -22,8 +23,8 @@ use graph::{
ethabi::{Address, Contract, Event, Function, LogParam, ParamType, RawLog},
serde_json, warn,
web3::types::{Log, Transaction, H256},
BlockNumber, CheapClone, DataSourceTemplateInfo, Deserialize, EthereumCall,
LightEthereumBlock, LightEthereumBlockExt, LinkResolver, Logger, TryStreamExt,
BlockNumber, CheapClone, Deserialize, EthereumCall, LightEthereumBlock,
LightEthereumBlockExt, LinkResolver, Logger, TryStreamExt,
},
};

Expand Down Expand Up @@ -59,14 +60,20 @@ pub struct DataSource {
}

impl blockchain::DataSource<Chain> for DataSource {
fn from_template_info(info: DataSourceTemplateInfo<Chain>) -> Result<Self, Error> {
let DataSourceTemplateInfo {
template,
fn from_template_info(
info: InstanceDSTemplateInfo,
ds_template: &graph::data_source::DataSourceTemplate<Chain>,
) -> Result<Self, Error> {
// Note: There clearly is duplication between the data in `ds_template and the `template`
// field here. Both represent a template definition, would be good to unify them.
let InstanceDSTemplateInfo {
template: _,
params,
context,
creation_block,
} = info;
let template = template.into_onchain().ok_or(anyhow!(

let template = ds_template.as_onchain().ok_or(anyhow!(
"Cannot create onchain data source from offchain template"
))?;

Expand Down Expand Up @@ -94,14 +101,14 @@ impl blockchain::DataSource<Chain> for DataSource {
.with_context(|| format!("template `{}`", template.name))?;

Ok(DataSource {
kind: template.kind,
network: template.network,
name: template.name,
kind: template.kind.clone(),
network: template.network.clone(),
name: template.name.clone(),
manifest_idx: template.manifest_idx,
address: Some(address),
start_block: creation_block,
end_block: None,
mapping: template.mapping,
mapping: template.mapping.clone(),
context: Arc::new(context),
creation_block: Some(creation_block),
contract_abi,
Expand Down
2 changes: 1 addition & 1 deletion chain/ethereum/src/runtime/runtime_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl blockchain::RuntimeAdapter<Chain> for RuntimeAdapter {
fn ethereum_call(
eth_adapter: &EthereumAdapter,
call_cache: Arc<dyn EthereumCallCache>,
ctx: HostFnCtx<'_>,
ctx: HostFnCtx,
wasm_ptr: u32,
abis: &[Arc<MappingABI>],
eth_call_gas: Option<u32>,
Expand Down
1 change: 0 additions & 1 deletion chain/ethereum/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ impl web3::Transport for Transport {
conn_type: graph::endpoint::ConnectionType::Rpc,
};
let out = async move {
let labels = labels;
let out = client.send(id, request).await;
match out {
Ok(_) => metrics.success(&labels),
Expand Down
11 changes: 6 additions & 5 deletions chain/near/src/data_source.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
use graph::anyhow::Context;
use graph::blockchain::{Block, TriggerWithHandler};
use graph::components::store::StoredDynamicDataSource;
use graph::components::subgraph::InstanceDSTemplateInfo;
use graph::data::subgraph::DataSourceContext;
use graph::prelude::SubgraphManifestValidationError;
use graph::{
anyhow::{anyhow, Error},
blockchain::{self, Blockchain},
prelude::{
async_trait, BlockNumber, CheapClone, DataSourceTemplateInfo, Deserialize, Link,
LinkResolver, Logger,
},
prelude::{async_trait, BlockNumber, CheapClone, Deserialize, Link, LinkResolver, Logger},
semver,
};
use std::collections::HashSet;
Expand All @@ -35,7 +33,10 @@ pub struct DataSource {
}

impl blockchain::DataSource<Chain> for DataSource {
fn from_template_info(_template_info: DataSourceTemplateInfo<Chain>) -> Result<Self, Error> {
fn from_template_info(
_info: InstanceDSTemplateInfo,
_template: &graph::data_source::DataSourceTemplate<Chain>,
) -> Result<Self, Error> {
Err(anyhow!("Near subgraphs do not support templates"))

// How this might be implemented if/when Near gets support for templates:
Expand Down
12 changes: 9 additions & 3 deletions chain/starknet/src/data_source.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use graph::{
anyhow::{anyhow, Error},
blockchain::{self, Block as BlockchainBlock, TriggerWithHandler},
components::{link_resolver::LinkResolver, store::StoredDynamicDataSource},
components::{
link_resolver::LinkResolver, store::StoredDynamicDataSource,
subgraph::InstanceDSTemplateInfo,
},
data::subgraph::{DataSourceContext, SubgraphManifestValidationError},
prelude::{async_trait, BlockNumber, DataSourceTemplateInfo, Deserialize, Link, Logger},
prelude::{async_trait, BlockNumber, Deserialize, Link, Logger},
semver,
};
use sha3::{Digest, Keccak256};
Expand Down Expand Up @@ -88,7 +91,10 @@ pub struct DataSourceTemplate;
pub struct UnresolvedDataSourceTemplate;

impl blockchain::DataSource<Chain> for DataSource {
fn from_template_info(_template_info: DataSourceTemplateInfo<Chain>) -> Result<Self, Error> {
fn from_template_info(
_info: InstanceDSTemplateInfo,
_template: &graph::data_source::DataSourceTemplate<Chain>,
) -> Result<Self, Error> {
Err(anyhow!("StarkNet subgraphs do not support templates"))
}

Expand Down
9 changes: 0 additions & 9 deletions chain/substreams/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,16 @@ edition.workspace = true
tonic-build = { workspace = true }

[dependencies]
async-stream = "0.3"
envconfig = "0.10.0"
futures = "0.1.21"
http = "0.2.4"
jsonrpc-core = "18.0.0"
graph = { path = "../../graph" }
graph-runtime-wasm = { path = "../../runtime/wasm" }
lazy_static = "1.2.0"
serde = "1.0"
prost = { workspace = true }
prost-types = { workspace = true }
dirs-next = "2.0"
anyhow = "1.0"
tiny-keccak = "1.5.0"
hex = "0.4.3"
semver = "1.0.21"
base64 = "0.20.0"

itertools = "0.12.0"

[dev-dependencies]
tokio = { version = "1", features = ["full"] }
9 changes: 6 additions & 3 deletions chain/substreams/src/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use anyhow::{anyhow, Context, Error};
use graph::{
blockchain,
cheap_clone::CheapClone,
components::link_resolver::LinkResolver,
prelude::{async_trait, BlockNumber, DataSourceTemplateInfo, Link},
components::{link_resolver::LinkResolver, subgraph::InstanceDSTemplateInfo},
prelude::{async_trait, BlockNumber, Link},
slog::Logger,
};

Expand Down Expand Up @@ -35,7 +35,10 @@ pub struct DataSource {
}

impl blockchain::DataSource<Chain> for DataSource {
fn from_template_info(_template_info: DataSourceTemplateInfo<Chain>) -> Result<Self, Error> {
fn from_template_info(
_info: InstanceDSTemplateInfo,
_template: &graph::data_source::DataSourceTemplate<Chain>,
) -> Result<Self, Error> {
Err(anyhow!("Substreams does not support templates"))
}

Expand Down
10 changes: 5 additions & 5 deletions chain/substreams/src/trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,19 @@ impl<T> graph::prelude::TriggerProcessor<Chain, T> for TriggerProcessor
where
T: RuntimeHostBuilder<Chain>,
{
async fn process_trigger(
&self,
async fn process_trigger<'a>(
&'a self,
logger: &Logger,
_: Box<dyn Iterator<Item = &T::Host> + Send + '_>,
_: Box<dyn Iterator<Item = &T::Host> + Send + 'a>,
block: &Arc<Block>,
_trigger: &data_source::TriggerData<Chain>,
mut state: BlockState<Chain>,
mut state: BlockState,
proof_of_indexing: &SharedProofOfIndexing,
causality_region: &str,
_debug_fork: &Option<Arc<dyn SubgraphFork>>,
_subgraph_metrics: &Arc<graph::prelude::SubgraphInstanceMetrics>,
_instrument: bool,
) -> Result<BlockState<Chain>, MappingError> {
) -> Result<BlockState, MappingError> {
for parsed_change in block.parsed_changes.clone().into_iter() {
match parsed_change {
ParsedChanges::Unset => {
Expand Down
8 changes: 1 addition & 7 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ edition.workspace = true
[dependencies]
async-trait = "0.1.50"
atomic_refcell = "0.1.13"
async-stream = "0.3"
bytes = "1.0"
futures01 = { package = "futures", version = "0.1.31" }
futures = { version = "0.3.4", features = ["compat"] }
Expand All @@ -19,15 +18,10 @@ graph-chain-near = { path = "../chain/near" }
graph-chain-cosmos = { path = "../chain/cosmos" }
graph-chain-substreams = { path = "../chain/substreams" }
graph-chain-starknet = { path = "../chain/starknet" }
lazy_static = "1.2.0"
lru_time_cache = "0.11"
semver = "1.0.21"
serde = "1.0"
serde_json = "1.0"
graph-runtime-wasm = { path = "../runtime/wasm" }
serde_yaml = "0.9.21"
# Switch to crates.io once tower 0.5 is released
tower = { git = "https://github.com/tower-rs/tower.git", features = ["full"] }
graph-runtime-wasm = { path = "../runtime/wasm" }
cid = "0.11.0"
anyhow = "1.0"

Expand Down
2 changes: 0 additions & 2 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
pub mod polling_monitor;

mod link_resolver;
mod subgraph;

pub use crate::link_resolver::LinkResolver;
pub use crate::subgraph::{
SubgraphAssignmentProvider, SubgraphInstanceManager, SubgraphRegistrar, SubgraphRunner,
SubgraphTriggerProcessor,
Expand Down
4 changes: 3 additions & 1 deletion core/src/subgraph/context/instance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ where
}

let is_onchain = data_source.is_onchain();
let Some(host) = self.new_host(logger.clone(), data_source)? else { return Ok(None) };
let Some(host) = self.new_host(logger.clone(), data_source)? else {
return Ok(None);
};

// Check for duplicates and add the host.
if is_onchain {
Expand Down
12 changes: 6 additions & 6 deletions core/src/subgraph/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ impl<C: Blockchain, T: RuntimeHostBuilder<C>> IndexingContext<C, T> {
logger: &Logger,
block: &Arc<C::Block>,
trigger: &TriggerData<C>,
state: BlockState<C>,
state: BlockState,
proof_of_indexing: &SharedProofOfIndexing,
causality_region: &str,
debug_fork: &Option<Arc<dyn SubgraphFork>>,
subgraph_metrics: &Arc<SubgraphInstanceMetrics>,
instrument: bool,
) -> Result<BlockState<C>, MappingError> {
) -> Result<BlockState, MappingError> {
self.process_trigger_in_hosts(
logger,
self.instance.hosts_for_trigger(trigger),
Expand All @@ -136,13 +136,13 @@ impl<C: Blockchain, T: RuntimeHostBuilder<C>> IndexingContext<C, T> {
block_time: BlockTime,
block_data: Box<[u8]>,
handler: String,
mut state: BlockState<C>,
mut state: BlockState,
proof_of_indexing: &SharedProofOfIndexing,
causality_region: &str,
debug_fork: &Option<Arc<dyn SubgraphFork>>,
subgraph_metrics: &Arc<SubgraphInstanceMetrics>,
instrument: bool,
) -> Result<BlockState<C>, MappingError> {
) -> Result<BlockState, MappingError> {
let error_count = state.deterministic_errors.len();

if let Some(proof_of_indexing) = proof_of_indexing {
Expand Down Expand Up @@ -195,13 +195,13 @@ impl<C: Blockchain, T: RuntimeHostBuilder<C>> IndexingContext<C, T> {
hosts: Box<dyn Iterator<Item = &T::Host> + Send + '_>,
block: &Arc<C::Block>,
trigger: &TriggerData<C>,
state: BlockState<C>,
state: BlockState,
proof_of_indexing: &SharedProofOfIndexing,
causality_region: &str,
debug_fork: &Option<Arc<dyn SubgraphFork>>,
subgraph_metrics: &Arc<SubgraphInstanceMetrics>,
instrument: bool,
) -> Result<BlockState<C>, MappingError> {
) -> Result<BlockState, MappingError> {
self.trigger_processor
.process_trigger(
logger,
Expand Down
Loading
Loading