Skip to content

Commit bbf1bc3

Browse files
committed
cleanup typos, commented out code and minor refactoring
1 parent d211801 commit bbf1bc3

File tree

7 files changed

+20
-44
lines changed

7 files changed

+20
-44
lines changed

graph/src/components/transaction_receipt.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
66
use alloy::network::ReceiptResponse;
77
use alloy::primitives::B256;
8-
use alloy::rpc::types::TransactionReceipt;
98

109
#[derive(Debug, PartialEq, Eq)]
1110
pub struct LightTransactionReceipt {
@@ -17,19 +16,6 @@ pub struct LightTransactionReceipt {
1716
pub status: bool,
1817
}
1918

20-
impl From<TransactionReceipt> for LightTransactionReceipt {
21-
fn from(receipt: alloy::rpc::types::TransactionReceipt) -> Self {
22-
LightTransactionReceipt {
23-
transaction_hash: receipt.transaction_hash,
24-
transaction_index: receipt.transaction_index.unwrap(),
25-
block_hash: receipt.block_hash,
26-
block_number: receipt.block_number,
27-
gas_used: receipt.gas_used,
28-
status: receipt.status(),
29-
}
30-
}
31-
}
32-
3319
impl From<alloy::network::AnyTransactionReceipt> for LightTransactionReceipt {
3420
fn from(receipt: alloy::network::AnyTransactionReceipt) -> Self {
3521
LightTransactionReceipt {

graph/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ pub mod abi;
4141

4242
/// Wrapper for spawning tasks that abort on panic, which is our default.
4343
mod task_spawn;
44-
4544
pub use task_spawn::{
4645
block_on, spawn, spawn_allow_panic, spawn_blocking, spawn_blocking_allow_panic, spawn_thread,
4746
};

node/src/manager/commands/chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ pub async fn ingest(
280280
let number = block.header.number;
281281
// For inserting the block, it doesn't matter whether the block is final or not.
282282
let block = Arc::new(BlockFinality::Final(Arc::new(LightEthereumBlock::new(
283-
block.into(),
283+
block,
284284
))));
285285
chain_store.upsert_block(block).await?;
286286

store/postgres/src/chain_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ mod data {
169169
hash: Vec<u8>,
170170
}
171171

172-
// Like H256::from_slice, but returns an error instead of panicking
172+
// Like B256::from_slice, but returns an error instead of panicking
173173
// when `bytes` does not have the right length
174174
fn b256_from_bytes(bytes: &[u8]) -> Result<B256, StoreError> {
175175
if bytes.len() == B256::len_bytes() {

store/postgres/src/deployment.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ use graph::{
2222
slog::{debug, Logger},
2323
};
2424
use graph::{components::store::StoreResult, semver::Version};
25-
use graph::{
26-
data::store::scalar::ToPrimitive,
27-
prelude::{anyhow, hex, BlockNumber, BlockPtr, DeploymentHash, DeploymentState, StoreError},
28-
schema::InputSchema,
29-
};
3025
use graph::{
3126
data::subgraph::schema::{DeploymentCreate, SubgraphManifestEntity},
3227
util::backoff::ExponentialBackoff,
3328
};
29+
use graph::{
30+
prelude::{anyhow, hex, BlockNumber, BlockPtr, DeploymentHash, DeploymentState, StoreError},
31+
schema::InputSchema,
32+
};
3433
use stable_hash_legacy::crypto::SetHasher;
3534
use std::sync::Arc;
3635
use std::{convert::TryFrom, ops::Bound, time::Duration};
@@ -261,14 +260,13 @@ fn graft(
261260
//
262261
// workaround for arweave
263262
let hash = B256::from_slice(&hash.as_slice()[..32]);
264-
let block = block.to_u64().expect("block numbers fit into a u64");
265263
let subgraph = DeploymentHash::new(subgraph.clone()).map_err(|_| {
266264
StoreError::Unknown(anyhow!(
267265
"the base subgraph for a graft must be a valid subgraph id but is `{}`",
268266
subgraph
269267
))
270268
})?;
271-
Ok(Some((subgraph, BlockPtr::from((hash, block as i32)))))
269+
Ok(Some((subgraph, BlockPtr::from((hash, block)))))
272270
}
273271
_ => unreachable!(
274272
"graftBlockHash and graftBlockNumber are either both set or neither is set"

tests/src/fixture/ethereum.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,10 @@ pub async fn chain(
7979
}
8080

8181
pub fn genesis() -> BlockWithTriggers<graph_chain_ethereum::Chain> {
82-
#[allow(unused_variables)]
8382
let ptr = test_ptr(0);
8483

8584
let block = create_minimal_block_for_test(ptr.number as u64, ptr.hash.as_b256());
8685

87-
#[allow(unreachable_code)]
8886
BlockWithTriggers::<graph_chain_ethereum::Chain> {
8987
block: BlockFinality::Final(Arc::new(LightEthereumBlock::new(block.into()))),
9088
trigger_data: vec![Trigger::Chain(EthereumTrigger::Block(

tests/tests/integration_tests.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ use std::time::{self, Duration, Instant};
1616
use anyhow::{anyhow, bail, Context, Result};
1717
use graph::futures03::StreamExt;
1818
use graph::itertools::Itertools;
19-
use graph::prelude::alloy::primitives::U256;
2019
use graph::prelude::serde_json::{json, Value};
2120
use graph_tests::contract::Contract;
2221
use graph_tests::subgraph::Subgraph;
2322
use graph_tests::{error, status, CONFIG};
2423
use tokio::process::Child;
2524
use tokio::task::JoinError;
2625
use tokio::time::sleep;
27-
use web3;
26+
use web3::types::U256;
2827

2928
const SUBGRAPH_LAST_GRAFTING_BLOCK: i32 = 3;
3029

@@ -635,10 +634,6 @@ pub async fn subgraph_data_sources(ctx: TestContext) -> anyhow::Result<()> {
635634
Ok(())
636635
}
637636

638-
fn alloy_u256_to_web3_u256(u: U256) -> web3::types::U256 {
639-
web3::types::U256::from_little_endian(u.as_le_slice())
640-
}
641-
642637
async fn test_topic_filters(ctx: TestContext) -> anyhow::Result<()> {
643638
let subgraph = ctx.subgraph;
644639
assert!(subgraph.healthy);
@@ -653,9 +648,9 @@ async fn test_topic_filters(ctx: TestContext) -> anyhow::Result<()> {
653648
.call(
654649
"emitAnotherTrigger",
655650
(
656-
alloy_u256_to_web3_u256(U256::from(1)),
657-
alloy_u256_to_web3_u256(U256::from(2)),
658-
alloy_u256_to_web3_u256(U256::from(3)),
651+
U256::from(1),
652+
U256::from(2),
653+
U256::from(3),
659654
"abc".to_string(),
660655
),
661656
)
@@ -666,9 +661,9 @@ async fn test_topic_filters(ctx: TestContext) -> anyhow::Result<()> {
666661
.call(
667662
"emitAnotherTrigger",
668663
(
669-
alloy_u256_to_web3_u256(U256::from(1)),
670-
alloy_u256_to_web3_u256(U256::from(1)),
671-
alloy_u256_to_web3_u256(U256::from(1)),
664+
U256::from(1),
665+
U256::from(1),
666+
U256::from(1),
672667
"abc".to_string(),
673668
),
674669
)
@@ -679,9 +674,9 @@ async fn test_topic_filters(ctx: TestContext) -> anyhow::Result<()> {
679674
.call(
680675
"emitAnotherTrigger",
681676
(
682-
alloy_u256_to_web3_u256(U256::from(4)),
683-
alloy_u256_to_web3_u256(U256::from(2)),
684-
alloy_u256_to_web3_u256(U256::from(3)),
677+
U256::from(4),
678+
U256::from(2),
679+
U256::from(3),
685680
"abc".to_string(),
686681
),
687682
)
@@ -692,9 +687,9 @@ async fn test_topic_filters(ctx: TestContext) -> anyhow::Result<()> {
692687
.call(
693688
"emitAnotherTrigger",
694689
(
695-
alloy_u256_to_web3_u256(U256::from(4)),
696-
alloy_u256_to_web3_u256(U256::from(4)),
697-
alloy_u256_to_web3_u256(U256::from(3)),
690+
U256::from(4),
691+
U256::from(4),
692+
U256::from(3),
698693
"abc".to_string(),
699694
),
700695
)

0 commit comments

Comments
 (0)