Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ members = [

[workspace.package]
version = "0.42.1"
edition = "2021"
edition = "2024"
authors = ["The Graph core developers & contributors"]
readme = "README.md"
homepage = "https://thegraph.com"
Expand Down
8 changes: 4 additions & 4 deletions chain/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use std::collections::HashMap;
use std::fmt::Debug;

use anyhow::Error;
use protobuf::descriptor::field_descriptor_proto::Label;
use protobuf::descriptor::field_descriptor_proto::Type;
use protobuf::Message;
use protobuf::UnknownValueRef;
use protobuf::descriptor::DescriptorProto;
use protobuf::descriptor::FieldDescriptorProto;
use protobuf::descriptor::OneofDescriptorProto;
use protobuf::Message;
use protobuf::UnknownValueRef;
use protobuf::descriptor::field_descriptor_proto::Label;
use protobuf::descriptor::field_descriptor_proto::Type;
use std::convert::From;
use std::path::Path;

Expand Down
4 changes: 2 additions & 2 deletions chain/common/tests/test-acme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ fn check_repeated_type_ok() {
let types = parse_proto_file(PROTO_FILE).expect("Unable to read proto file!");

let array_types = types
.iter()
.flat_map(|(_, t)| t.fields.iter())
.values()
.flat_map(|t| t.fields.iter())
.filter(|t| t.is_array)
.map(|t| t.type_name.clone())
.collect::<std::collections::HashSet<_>>();
Expand Down
2 changes: 1 addition & 1 deletion chain/ethereum/examples/firehose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use graph::{
env::env_var,
firehose::{self, FirehoseEndpoint, SubgraphLimit},
log::logger,
prelude::{prost, tokio, tonic, MetricsRegistry},
prelude::{MetricsRegistry, prost, tokio, tonic},
};
use graph_chain_ethereum::codec;
use hex::ToHex;
Expand Down
18 changes: 10 additions & 8 deletions chain/ethereum/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const COMBINED_FILTER_TYPE_URL: &str =

use crate::capabilities::NodeCapabilities;
use crate::data_source::{BlockHandlerFilter, DataSource};
use crate::{Chain, Mapping, ENV_VARS};
use crate::{Chain, ENV_VARS, Mapping};

pub type EventSignature = B256;
pub type FunctionSelector = [u8; 4];
Expand Down Expand Up @@ -1186,7 +1186,7 @@ pub trait EthereumAdapter: Send + Sync + 'static {

#[cfg(test)]
mod tests {
use crate::adapter::{FunctionSelector, COMBINED_FILTER_TYPE_URL};
use crate::adapter::{COMBINED_FILTER_TYPE_URL, FunctionSelector};

use super::{EthereumBlockFilter, LogFilterNode};
use super::{EthereumCallFilter, EthereumLogFilter, TriggerFilter};
Expand All @@ -1195,8 +1195,8 @@ mod tests {
use graph::blockchain::TriggerFilter as _;
use graph::firehose::{CallToFilter, CombinedFilter, LogFilter, MultiLogFilter};
use graph::petgraph::graphmap::GraphMap;
use graph::prelude::alloy::primitives::{Address, Bytes, B256, U256};
use graph::prelude::EthereumCall;
use graph::prelude::alloy::primitives::{Address, B256, Bytes, U256};
use hex::ToHex;
use itertools::Itertools;
use prost::Message;
Expand Down Expand Up @@ -1264,9 +1264,11 @@ mod tests {
assert_eq!(sig, actual_sig);

let filter = LogFilter {
addresses: vec![Address::from_str(hex_addr)
.expect("failed to parse address")
.to_vec()],
addresses: vec![
Address::from_str(hex_addr)
.expect("failed to parse address")
.to_vec(),
],
event_signatures: vec![fs.to_vec()],
};

Expand Down Expand Up @@ -1651,8 +1653,8 @@ mod tests {
}

#[test]
fn extending_ethereum_block_filter_every_block_in_base_and_merge_contract_addresses_and_polling_intervals(
) {
fn extending_ethereum_block_filter_every_block_in_base_and_merge_contract_addresses_and_polling_intervals()
{
let mut base = EthereumBlockFilter {
polling_intervals: HashSet::from_iter(vec![(10, 3)]),
contract_addresses: HashSet::from_iter(vec![(10, address(2))]),
Expand Down
2 changes: 1 addition & 1 deletion chain/ethereum/src/buffered_call_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use graph::{
components::store::EthereumCallCache,
data::store::ethereum::call,
prelude::{BlockPtr, CachedEthereumCall},
slog::{error, Logger},
slog::{Logger, error},
};

/// A wrapper around an Ethereum call cache that buffers call results in
Expand Down
22 changes: 11 additions & 11 deletions chain/ethereum/src/call_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use graph::{
abi,
data::store::ethereum::call,
prelude::{
Logger,
alloy::transports::{RpcError, TransportErrorKind},
serde_json, Logger,
serde_json,
},
slog::info,
};
Expand Down Expand Up @@ -93,10 +94,10 @@ pub fn interpret_eth_call_error(
Ok(call::Retval::Null)
}

if let RpcError::ErrorResp(rpc_error) = &err {
if is_rpc_revert_message(&rpc_error.message) {
return reverted(logger, &rpc_error.message);
}
if let RpcError::ErrorResp(rpc_error) = &err
&& is_rpc_revert_message(&rpc_error.message)
{
return reverted(logger, &rpc_error.message);
}

if let RpcError::ErrorResp(rpc_error) = &err {
Expand All @@ -106,12 +107,11 @@ pub fn interpret_eth_call_error(
.as_ref()
.and_then(|d| serde_json::from_str(d.get()).ok());

if code == PARITY_VM_EXECUTION_ERROR {
if let Some(data) = data {
if is_parity_revert(&data) {
return reverted(logger, &parity_revert_reason(&data));
}
}
if code == PARITY_VM_EXECUTION_ERROR
&& let Some(data) = data
&& is_parity_revert(&data)
{
return reverted(logger, &parity_revert_reason(&data));
}
}

Expand Down
33 changes: 18 additions & 15 deletions chain/ethereum/src/chain.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::{anyhow, bail, Result};
use anyhow::{Context, Error};
use anyhow::{Result, anyhow, bail};
use async_trait::async_trait;
use graph::blockchain::client::ChainClient;
use graph::blockchain::firehose_block_ingestor::{FirehoseBlockIngestor, Transforms};
Expand All @@ -13,26 +13,27 @@ use graph::data::subgraph::UnifiedMappingApiVersion;
use graph::firehose::{FirehoseEndpoint, FirehoseEndpoints, ForkStep};
use graph::futures03::TryStreamExt;
use graph::prelude::{
retry, BlockHash, ComponentLoggerConfig, ElasticComponentLoggerConfig, EthereumBlock,
BlockHash, ComponentLoggerConfig, ElasticComponentLoggerConfig, EthereumBlock,
EthereumCallCache, LightEthereumBlock, LightEthereumBlockExt, MetricsRegistry, StoreError,
retry,
};
use graph::slog::{debug, error, trace, warn};
use graph::{
blockchain::{
Block, BlockPtr, Blockchain, ChainHeadUpdateListener, IngestorError,
RuntimeAdapter as RuntimeAdapterTrait, TriggerFilter as _,
block_stream::{
BlockRefetcher, BlockStreamEvent, BlockWithTriggers, FirehoseError,
FirehoseMapper as FirehoseMapperTrait, TriggersAdapter as TriggersAdapterTrait,
},
firehose_block_stream::FirehoseBlockStream,
Block, BlockPtr, Blockchain, ChainHeadUpdateListener, IngestorError,
RuntimeAdapter as RuntimeAdapterTrait, TriggerFilter as _,
},
cheap_clone::CheapClone,
components::store::DeploymentLocator,
firehose,
prelude::{
o, serde_json as json, BlockNumber, ChainStore, EthereumBlockWithCalls, Logger,
LoggerFactory,
BlockNumber, ChainStore, EthereumBlockWithCalls, Logger, LoggerFactory, o,
serde_json as json,
},
};
use prost::Message;
Expand All @@ -49,17 +50,17 @@ use crate::ingestor::PollingBlockIngestor;
use crate::network::EthereumNetworkAdapters;
use crate::polling_block_stream::PollingBlockStream;
use crate::runtime::runtime_adapter::eth_call_gas;
use crate::{BufferedCallCache, NodeCapabilities};
use crate::{
ENV_VARS, SubgraphEthRpcMetrics, TriggerFilter,
adapter::EthereumAdapter as _,
codec,
data_source::{DataSource, UnresolvedDataSource},
ethereum_adapter::{
blocks_with_triggers, get_calls, parse_block_triggers, parse_call_triggers,
parse_log_triggers,
},
SubgraphEthRpcMetrics, TriggerFilter, ENV_VARS,
};
use crate::{BufferedCallCache, NodeCapabilities};
use crate::{EthereumAdapter, RuntimeAdapter};
use graph::blockchain::block_stream::{
BlockStream, BlockStreamBuilder, BlockStreamError, BlockStreamMapper, FirehoseCursor,
Expand Down Expand Up @@ -396,10 +397,10 @@ where
for _ in 0..offset {
match parent_getter(current_ptr.clone()).await? {
Some(parent) => {
if let Some(root_hash) = &root {
if parent.hash == *root_hash {
break;
}
if let Some(root_hash) = &root
&& parent.hash == *root_hash
{
break;
}
current_ptr = parent;
}
Expand Down Expand Up @@ -815,8 +816,8 @@ async fn fetch_unique_blocks_from_cache(

// Collect blocks and filter out ones with multiple entries
let blocks: Vec<Arc<ExtendedBlockPtr>> = blocks_map
.into_iter()
.filter_map(|(_, values)| {
.into_values()
.filter_map(|values| {
if values.len() == 1 {
Some(Arc::new(values[0].clone()))
} else {
Expand Down Expand Up @@ -1372,7 +1373,9 @@ impl FirehoseMapperTrait<Chain> for FirehoseMapper {
}

StepFinal => {
unreachable!("irreversible step is not handled and should not be requested in the Firehose request")
unreachable!(
"irreversible step is not handled and should not be requested in the Firehose request"
)
}

StepUnset => {
Expand Down
8 changes: 4 additions & 4 deletions chain/ethereum/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ use graph::{
AnyBlock, AnyHeader, AnyRpcHeader, AnyTransactionReceiptBare, AnyTxEnvelope,
},
prelude::{
BlockNumber, Error, EthereumBlock, EthereumBlockWithCalls, EthereumCall,
LightEthereumBlock,
alloy::{
self,
consensus::{ReceiptWithBloom, TxEnvelope, TxType},
network::AnyReceiptEnvelope,
primitives::{aliases::B2048, Address, Bloom, Bytes, LogData, B256, U256},
primitives::{Address, B256, Bloom, Bytes, LogData, U256, aliases::B2048},
rpc::types::{self as alloy_rpc_types, AccessList, AccessListItem, Transaction},
},
BlockNumber, Error, EthereumBlock, EthereumBlockWithCalls, EthereumCall,
LightEthereumBlock,
},
};
use std::sync::Arc;
Expand Down Expand Up @@ -650,7 +650,7 @@ fn transaction_trace_to_alloy_txn_reciept(
TransactionTraceStatus::Unknown => {
return Err(format_err!(
"Transaction trace has UNKNOWN status; datasource is broken"
))
));
}
TransactionTraceStatus::Succeeded => true,
TransactionTraceStatus::Failed | TransactionTraceStatus::Reverted => false,
Expand Down
22 changes: 11 additions & 11 deletions chain/ethereum/src/data_source.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::{anyhow, Error};
use anyhow::{ensure, Context};
use anyhow::{Context, ensure};
use anyhow::{Error, anyhow};
use async_trait::async_trait;
use graph::abi;
use graph::abi::EventExt;
Expand All @@ -18,16 +18,16 @@ use graph::data_source::common::{
};
use graph::data_source::{CausalityRegion, MappingTrigger as MappingTriggerType};
use graph::env::ENV_VARS;
use graph::futures03::TryStreamExt;
use graph::futures03::future::try_join;
use graph::futures03::stream::FuturesOrdered;
use graph::futures03::TryStreamExt;
use graph::prelude::alloy::{
consensus::{TxEnvelope, TxLegacy},
network::TransactionResponse,
primitives::{Address, B256, U256},
rpc::types::Log,
};
use graph::prelude::{alloy, Link, SubgraphManifestValidationError};
use graph::prelude::{Link, SubgraphManifestValidationError, alloy};
use graph::slog::{debug, error, o, trace};
use itertools::Itertools;
use serde::de::Error as ErrorD;
Expand All @@ -37,26 +37,26 @@ use std::num::NonZeroU32;
use std::str::FromStr;
use std::sync::Arc;
use std::time::{Duration, Instant};
use tiny_keccak::{keccak256, Keccak};
use tiny_keccak::{Keccak, keccak256};

use graph::{
blockchain::{self, Blockchain},
prelude::{
serde_json, warn, BlockNumber, CheapClone, EthereumCall, LightEthereumBlock,
LightEthereumBlockExt, LinkResolver, Logger,
BlockNumber, CheapClone, EthereumCall, LightEthereumBlock, LightEthereumBlockExt,
LinkResolver, Logger, serde_json, warn,
},
};

use graph::data::subgraph::{
calls_host_fn, DataSourceContext, Source, MIN_SPEC_VERSION, SPEC_VERSION_0_0_8,
SPEC_VERSION_1_2_0,
DataSourceContext, MIN_SPEC_VERSION, SPEC_VERSION_0_0_8, SPEC_VERSION_1_2_0, Source,
calls_host_fn,
};

use crate::NodeCapabilities;
use crate::adapter::EthereumAdapter as _;
use crate::chain::Chain;
use crate::network::EthereumNetworkAdapters;
use crate::trigger::{EthereumBlockTriggerType, EthereumTrigger, MappingTrigger};
use crate::NodeCapabilities;

// The recommended kind is `ethereum`, `ethereum/contract` is accepted for backwards compatibility.
const ETHEREUM_KINDS: &[&str] = &["ethereum/contract", "ethereum"];
Expand Down Expand Up @@ -446,7 +446,7 @@ fn create_dummy_transaction(
) -> Result<AnyTransaction, anyhow::Error> {
use graph::components::ethereum::AnyTxEnvelope;
use graph::prelude::alloy::{
consensus::transaction::Recovered, consensus::Signed, primitives::Signature,
consensus::Signed, consensus::transaction::Recovered, primitives::Signature,
rpc::types::Transaction,
};

Expand Down
2 changes: 1 addition & 1 deletion chain/ethereum/src/env.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use envconfig::Envconfig;
use graph::env::EnvVarBoolean;
use graph::prelude::{envconfig, lazy_static, BlockNumber};
use graph::prelude::{BlockNumber, envconfig, lazy_static};
use std::fmt;
use std::time::Duration;

Expand Down
Loading
Loading