@@ -20,7 +20,6 @@ use graph::futures03::future::try_join_all;
20
20
use graph:: futures03:: {
21
21
self , compat:: Future01CompatExt , FutureExt , StreamExt , TryFutureExt , TryStreamExt ,
22
22
} ;
23
- use graph:: prelude:: alloy:: consensus:: BlockHeader ;
24
23
use graph:: prelude:: alloy:: primitives:: Address ;
25
24
use graph:: prelude:: alloy:: rpc:: types:: Transaction ;
26
25
use graph:: prelude:: {
@@ -45,8 +44,6 @@ use graph::prelude::{
45
44
use graph:: slog:: o;
46
45
use graph:: tokio:: sync:: RwLock ;
47
46
use graph:: tokio:: time:: timeout;
48
- use graph:: util:: conversions:: alloy_block_to_block;
49
- use graph:: util:: conversions:: alloy_block_to_block_arc;
50
47
use graph:: {
51
48
blockchain:: { block_stream:: BlockWithTriggers , BlockPtr , IngestorError } ,
52
49
prelude:: {
@@ -718,7 +715,7 @@ impl EthereumAdapter {
718
715
& self ,
719
716
logger : Logger ,
720
717
ids : Vec < B256 > ,
721
- ) -> impl futures03:: Stream < Item = Result < Arc < AlloyBlock > , Error > > + Send {
718
+ ) -> impl futures03:: Stream < Item = Result < Arc < LightEthereumBlock > , Error > > + Send {
722
719
let alloy = self . alloy . clone ( ) ;
723
720
724
721
futures03:: stream:: iter ( ids. into_iter ( ) . map ( move |hash| {
@@ -739,12 +736,14 @@ impl EthereumAdapter {
739
736
. await
740
737
. map_err ( Error :: from)
741
738
. and_then ( |block| {
742
- block. map ( Arc :: new) . ok_or_else ( || {
743
- anyhow:: anyhow!(
744
- "Ethereum node did not find block {:?}" ,
745
- hash
746
- )
747
- } )
739
+ block
740
+ . map ( |b| Arc :: new ( LightEthereumBlock :: new ( b) ) )
741
+ . ok_or_else ( || {
742
+ anyhow:: anyhow!(
743
+ "Ethereum node did not find block {:?}" ,
744
+ hash
745
+ )
746
+ } )
748
747
} )
749
748
}
750
749
} )
@@ -1340,7 +1339,7 @@ impl EthereumAdapterTrait for EthereumAdapter {
1340
1339
if block. transactions . is_empty ( ) {
1341
1340
trace ! ( logger, "Block {} contains no transactions" , block_hash) ;
1342
1341
return Ok ( EthereumBlock {
1343
- block : Arc :: new ( alloy_block_to_block ( block) ) ,
1342
+ block : Arc :: new ( LightEthereumBlock :: new ( block) ) ,
1344
1343
transaction_receipts : Vec :: new ( ) ,
1345
1344
} ) ;
1346
1345
}
@@ -1359,7 +1358,7 @@ impl EthereumAdapterTrait for EthereumAdapter {
1359
1358
fetch_receipts_with_retry ( alloy, hashes, block_hash, logger, supports_block_receipts)
1360
1359
. await
1361
1360
. map ( |transaction_receipts| EthereumBlock {
1362
- block : Arc :: new ( alloy_block_to_block ( block) ) ,
1361
+ block : Arc :: new ( LightEthereumBlock :: new ( block) ) ,
1363
1362
transaction_receipts : transaction_receipts
1364
1363
. into_iter ( )
1365
1364
. map ( |receipt| receipt)
@@ -1611,35 +1610,35 @@ impl EthereumAdapterTrait for EthereumAdapter {
1611
1610
logger : Logger ,
1612
1611
chain_store : Arc < dyn ChainStore > ,
1613
1612
block_hashes : HashSet < B256 > ,
1614
- ) -> Result < Vec < Arc < AlloyBlock > > , Error > {
1613
+ ) -> Result < Vec < Arc < LightEthereumBlock > > , Error > {
1615
1614
let block_hashes: Vec < _ > = block_hashes. iter ( ) . cloned ( ) . collect ( ) ;
1616
1615
// Search for the block in the store first then use json-rpc as a backup.
1617
- let mut blocks: Vec < Arc < AlloyBlock > > = chain_store
1616
+ let mut blocks: Vec < _ > = chain_store
1618
1617
. cheap_clone ( )
1619
1618
. blocks ( block_hashes. iter ( ) . map ( |& b| b. into ( ) ) . collect :: < Vec < _ > > ( ) )
1620
1619
. await
1621
1620
. map_err ( |e| error ! ( & logger, "Error accessing block cache {}" , e) )
1622
1621
. unwrap_or_default ( )
1623
1622
. into_iter ( )
1624
1623
. filter_map ( |value| json:: from_value ( value) . ok ( ) )
1625
- . map ( Arc :: new)
1624
+ . map ( |b| Arc :: new ( LightEthereumBlock :: new ( b ) ) )
1626
1625
. collect ( ) ;
1627
1626
1628
1627
let missing_blocks = Vec :: from_iter (
1629
1628
block_hashes
1630
1629
. into_iter ( )
1631
- . filter ( |hash| !blocks. iter ( ) . any ( |b| b. header . hash == * hash) ) ,
1630
+ . filter ( |hash| !blocks. iter ( ) . any ( |b| b. hash ( ) == * hash) ) ,
1632
1631
) ;
1633
1632
1634
1633
// Return a stream that lazily loads batches of blocks.
1635
1634
debug ! ( logger, "Requesting {} block(s)" , missing_blocks. len( ) ) ;
1636
- let new_blocks: Vec < Arc < AlloyBlock > > = self
1635
+ let new_blocks: Vec < _ > = self
1637
1636
. load_blocks_rpc ( logger. clone ( ) , missing_blocks)
1638
1637
. try_collect ( )
1639
1638
. await ?;
1640
1639
let upsert_blocks: Vec < _ > = new_blocks
1641
1640
. iter ( )
1642
- . map ( |block| BlockFinality :: Final ( alloy_block_to_block_arc ( block. clone ( ) ) ) )
1641
+ . map ( |block| BlockFinality :: Final ( block. clone ( ) ) )
1643
1642
. collect ( ) ;
1644
1643
let block_refs: Vec < _ > = upsert_blocks
1645
1644
. iter ( )
@@ -1649,7 +1648,7 @@ impl EthereumAdapterTrait for EthereumAdapter {
1649
1648
error ! ( logger, "Error writing to block cache {}" , e) ;
1650
1649
}
1651
1650
blocks. extend ( new_blocks) ;
1652
- blocks. sort_by_key ( |block| block. header . number ) ;
1651
+ blocks. sort_by_key ( |block| block. number ( ) ) ;
1653
1652
Ok ( blocks)
1654
1653
}
1655
1654
}
@@ -1792,15 +1791,15 @@ pub(crate) async fn blocks_with_triggers(
1792
1791
. await ?
1793
1792
. into_iter ( )
1794
1793
. map (
1795
- move |block| match triggers_by_block. remove ( & ( block. header . number ( ) as BlockNumber ) ) {
1794
+ move |block| match triggers_by_block. remove ( & ( block. number ( ) ) ) {
1796
1795
Some ( triggers) => Ok ( BlockWithTriggers :: new (
1797
- BlockFinality :: Final ( alloy_block_to_block_arc ( block) ) ,
1796
+ BlockFinality :: Final ( block) ,
1798
1797
triggers,
1799
1798
& logger2,
1800
1799
) ) ,
1801
1800
None => Err ( anyhow ! (
1802
1801
"block {} not found in `triggers_by_block`" ,
1803
- BlockPtr :: new ( block. header . hash . into ( ) , block . header . number as i32 )
1802
+ block. block_ptr ( )
1804
1803
) ) ,
1805
1804
} ,
1806
1805
)
@@ -2612,12 +2611,11 @@ mod tests {
2612
2611
EthereumBlockWithCalls ,
2613
2612
} ;
2614
2613
use graph:: blockchain:: BlockPtr ;
2615
- use graph:: components:: ethereum:: BlockWrapper ;
2616
2614
use graph:: prelude:: alloy:: primitives:: { Address , Bytes , B256 } ;
2617
2615
use graph:: prelude:: alloy:: providers:: mock:: Asserter ;
2618
2616
use graph:: prelude:: alloy:: providers:: ProviderBuilder ;
2619
2617
use graph:: prelude:: tokio:: { self } ;
2620
- use graph:: prelude:: { create_minimal_block_for_test, EthereumCall } ;
2618
+ use graph:: prelude:: { create_minimal_block_for_test, EthereumCall , LightEthereumBlock } ;
2621
2619
use jsonrpc_core:: serde_json:: { self , Value } ;
2622
2620
use std:: collections:: HashSet ;
2623
2621
use std:: iter:: FromIterator ;
@@ -2627,10 +2625,9 @@ mod tests {
2627
2625
fn parse_block_triggers_every_block ( ) {
2628
2626
let block = create_minimal_block_for_test ( 2 , hash ( 2 ) ) ;
2629
2627
2630
- #[ allow( unreachable_code) ]
2631
2628
let block = EthereumBlockWithCalls {
2632
2629
ethereum_block : EthereumBlock {
2633
- block : Arc :: new ( BlockWrapper :: new ( block) ) ,
2630
+ block : Arc :: new ( LightEthereumBlock :: new ( block) ) ,
2634
2631
..Default :: default ( )
2635
2632
} ,
2636
2633
calls : Some ( vec ! [ EthereumCall {
@@ -2772,7 +2769,7 @@ mod tests {
2772
2769
#[ allow( unreachable_code) ]
2773
2770
let block = EthereumBlockWithCalls {
2774
2771
ethereum_block : EthereumBlock {
2775
- block : Arc :: new ( BlockWrapper :: new ( block) ) ,
2772
+ block : Arc :: new ( LightEthereumBlock :: new ( block) ) ,
2776
2773
..Default :: default ( )
2777
2774
} ,
2778
2775
calls : Some ( vec ! [ EthereumCall {
@@ -2803,7 +2800,7 @@ mod tests {
2803
2800
#[ allow( unreachable_code) ]
2804
2801
let block = EthereumBlockWithCalls {
2805
2802
ethereum_block : EthereumBlock {
2806
- block : Arc :: new ( BlockWrapper :: new ( block) ) ,
2803
+ block : Arc :: new ( LightEthereumBlock :: new ( block) ) ,
2807
2804
..Default :: default ( )
2808
2805
} ,
2809
2806
calls : Some ( vec ! [ EthereumCall {
0 commit comments