Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
26 changes: 22 additions & 4 deletions chain/arweave/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use graph::blockchain::client::ChainClient;
use graph::blockchain::firehose_block_ingestor::FirehoseBlockIngestor;
use graph::blockchain::{
BasicBlockchainBuilder, Block, BlockIngestor, BlockchainBuilder, BlockchainKind,
EmptyNodeCapabilities, NoopDecoderHook, NoopRuntimeAdapter,
EmptyNodeCapabilities, NoopDecoderHook, NoopRuntimeAdapter, TriggerFilterWrapper,
};
use graph::cheap_clone::CheapClone;
use graph::components::network_provider::ChainName;
use graph::components::store::DeploymentCursorTracker;
use graph::components::store::{DeploymentCursorTracker, SourceableStore};
use graph::data::subgraph::UnifiedMappingApiVersion;
use graph::env::EnvVars;
use graph::firehose::FirehoseEndpoint;
Expand All @@ -27,11 +27,13 @@ use graph::{
prelude::{async_trait, o, BlockNumber, ChainStore, Error, Logger, LoggerFactory},
};
use prost::Message;
use std::collections::HashSet;
use std::sync::Arc;

use crate::adapter::TriggerFilter;
use crate::data_source::{DataSourceTemplate, UnresolvedDataSourceTemplate};
use crate::trigger::{self, ArweaveTrigger};
use crate::Block as ArweaveBlock;
use crate::{
codec,
data_source::{DataSource, UnresolvedDataSource},
Expand Down Expand Up @@ -119,7 +121,8 @@ impl Blockchain for Chain {
deployment: DeploymentLocator,
store: impl DeploymentCursorTracker,
start_blocks: Vec<BlockNumber>,
filter: Arc<Self::TriggerFilter>,
_source_subgraph_stores: Vec<Arc<dyn SourceableStore>>,
filter: Arc<TriggerFilterWrapper<Self>>,
unified_api_version: UnifiedMappingApiVersion,
) -> Result<Box<dyn BlockStream<Self>>, Error> {
let adapter = self
Expand All @@ -135,7 +138,10 @@ impl Blockchain for Chain {
.subgraph_logger(&deployment)
.new(o!("component" => "FirehoseBlockStream"));

let firehose_mapper = Arc::new(FirehoseMapper { adapter, filter });
let firehose_mapper = Arc::new(FirehoseMapper {
adapter,
filter: filter.chain_filter.clone(),
});

Ok(Box::new(FirehoseBlockStream::new(
deployment.hash,
Expand Down Expand Up @@ -199,6 +205,10 @@ impl TriggersAdapterTrait<Chain> for TriggersAdapter {
panic!("Should never be called since not used by FirehoseBlockStream")
}

async fn chain_head_ptr(&self) -> Result<Option<BlockPtr>, Error> {
unimplemented!()
}

async fn triggers_in_block(
&self,
logger: &Logger,
Expand Down Expand Up @@ -258,6 +268,14 @@ impl TriggersAdapterTrait<Chain> for TriggersAdapter {
number: block.number.saturating_sub(1),
}))
}

async fn load_block_ptrs_by_numbers(
&self,
_logger: Logger,
_block_numbers: HashSet<BlockNumber>,
) -> Result<Vec<ArweaveBlock>, Error> {
todo!()
}
}

pub struct FirehoseMapper {
Expand Down
39 changes: 30 additions & 9 deletions chain/cosmos/src/chain.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
use graph::blockchain::firehose_block_ingestor::FirehoseBlockIngestor;
use graph::blockchain::{BlockIngestor, NoopDecoderHook};
use graph::blockchain::{BlockIngestor, NoopDecoderHook, TriggerFilterWrapper};
use graph::components::network_provider::ChainName;
use graph::env::EnvVars;
use graph::prelude::MetricsRegistry;
use graph::substreams::Clock;
use std::collections::HashSet;
use std::convert::TryFrom;
use std::sync::Arc;

use graph::blockchain::block_stream::{BlockStreamError, BlockStreamMapper, FirehoseCursor};
use graph::blockchain::client::ChainClient;
use graph::blockchain::{BasicBlockchainBuilder, BlockchainBuilder, NoopRuntimeAdapter};
use graph::cheap_clone::CheapClone;
use graph::components::store::DeploymentCursorTracker;
use graph::components::store::{DeploymentCursorTracker, SourceableStore};
use graph::data::subgraph::UnifiedMappingApiVersion;
use graph::{
blockchain::{
Expand All @@ -33,7 +34,7 @@ use crate::data_source::{
DataSource, DataSourceTemplate, EventOrigin, UnresolvedDataSource, UnresolvedDataSourceTemplate,
};
use crate::trigger::CosmosTrigger;
use crate::{codec, TriggerFilter};
use crate::{codec, Block, TriggerFilter};

pub struct Chain {
logger_factory: LoggerFactory,
Expand Down Expand Up @@ -113,7 +114,8 @@ impl Blockchain for Chain {
deployment: DeploymentLocator,
store: impl DeploymentCursorTracker,
start_blocks: Vec<BlockNumber>,
filter: Arc<Self::TriggerFilter>,
_source_subgraph_stores: Vec<Arc<dyn SourceableStore>>,
filter: Arc<TriggerFilterWrapper<Self>>,
unified_api_version: UnifiedMappingApiVersion,
) -> Result<Box<dyn BlockStream<Self>>, Error> {
let adapter = self
Expand All @@ -129,7 +131,10 @@ impl Blockchain for Chain {
.subgraph_logger(&deployment)
.new(o!("component" => "FirehoseBlockStream"));

let firehose_mapper = Arc::new(FirehoseMapper { adapter, filter });
let firehose_mapper = Arc::new(FirehoseMapper {
adapter,
filter: filter.chain_filter.clone(),
});

Ok(Box::new(FirehoseBlockStream::new(
deployment.hash,
Expand Down Expand Up @@ -192,6 +197,16 @@ impl TriggersAdapterTrait<Chain> for TriggersAdapter {
) -> Result<Option<codec::Block>, Error> {
panic!("Should never be called since not used by FirehoseBlockStream")
}
async fn load_block_ptrs_by_numbers(
&self,
_logger: Logger,
_block_numbers: HashSet<BlockNumber>,
) -> Result<Vec<Block>, Error> {
todo!()
}
async fn chain_head_ptr(&self) -> Result<Option<BlockPtr>, Error> {
unimplemented!()
}

async fn scan_triggers(
&self,
Expand Down Expand Up @@ -467,9 +482,12 @@ impl FirehoseMapperTrait<Chain> for FirehoseMapper {

#[cfg(test)]
mod test {
use graph::prelude::{
slog::{o, Discard, Logger},
tokio,
use graph::{
blockchain::Trigger,
prelude::{
slog::{o, Discard, Logger},
tokio,
},
};

use super::*;
Expand Down Expand Up @@ -600,7 +618,10 @@ mod test {
// they may not be in the same order
for trigger in expected_triggers {
assert!(
triggers.trigger_data.contains(&trigger),
triggers.trigger_data.iter().any(|t| match t {
Trigger::Chain(t) => t == &trigger,
_ => false,
}),
"Expected trigger list to contain {:?}, but it only contains: {:?}",
trigger,
triggers.trigger_data
Expand Down
13 changes: 2 additions & 11 deletions chain/ethereum/src/adapter.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use anyhow::Error;
use ethabi::{Error as ABIError, Function, ParamType, Token};
use ethabi::{Error as ABIError, ParamType, Token};
use graph::blockchain::ChainIdentifier;
use graph::components::subgraph::MappingError;
use graph::data::store::ethereum::call;
use graph::data_source::common::ContractCall;
use graph::firehose::CallToFilter;
use graph::firehose::CombinedFilter;
use graph::firehose::LogFilter;
Expand Down Expand Up @@ -93,16 +94,6 @@ impl EventSignatureWithTopics {
}
}

#[derive(Clone, Debug)]
pub struct ContractCall {
pub contract_name: String,
pub address: Address,
pub block_ptr: BlockPtr,
pub function: Function,
pub args: Vec<Token>,
pub gas: Option<u32>,
}

#[derive(Error, Debug)]
pub enum EthereumRpcError {
#[error("call error: {0}")]
Expand Down
Loading