@@ -20,7 +20,6 @@ use graph::futures03::future::try_join_all;
2020use graph:: futures03:: {
2121 self , compat:: Future01CompatExt , FutureExt , StreamExt , TryFutureExt , TryStreamExt ,
2222} ;
23- use graph:: prelude:: alloy:: consensus:: BlockHeader ;
2423use graph:: prelude:: alloy:: primitives:: Address ;
2524use graph:: prelude:: alloy:: rpc:: types:: Transaction ;
2625use graph:: prelude:: {
@@ -45,8 +44,6 @@ use graph::prelude::{
4544use graph:: slog:: o;
4645use graph:: tokio:: sync:: RwLock ;
4746use graph:: tokio:: time:: timeout;
48- use graph:: util:: conversions:: alloy_block_to_block;
49- use graph:: util:: conversions:: alloy_block_to_block_arc;
5047use graph:: {
5148 blockchain:: { block_stream:: BlockWithTriggers , BlockPtr , IngestorError } ,
5249 prelude:: {
@@ -718,7 +715,7 @@ impl EthereumAdapter {
718715 & self ,
719716 logger : Logger ,
720717 ids : Vec < B256 > ,
721- ) -> impl futures03:: Stream < Item = Result < Arc < AlloyBlock > , Error > > + Send {
718+ ) -> impl futures03:: Stream < Item = Result < Arc < LightEthereumBlock > , Error > > + Send {
722719 let alloy = self . alloy . clone ( ) ;
723720
724721 futures03:: stream:: iter ( ids. into_iter ( ) . map ( move |hash| {
@@ -739,12 +736,14 @@ impl EthereumAdapter {
739736 . await
740737 . map_err ( Error :: from)
741738 . 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+ } )
748747 } )
749748 }
750749 } )
@@ -1340,7 +1339,7 @@ impl EthereumAdapterTrait for EthereumAdapter {
13401339 if block. transactions . is_empty ( ) {
13411340 trace ! ( logger, "Block {} contains no transactions" , block_hash) ;
13421341 return Ok ( EthereumBlock {
1343- block : Arc :: new ( alloy_block_to_block ( block) ) ,
1342+ block : Arc :: new ( LightEthereumBlock :: new ( block) ) ,
13441343 transaction_receipts : Vec :: new ( ) ,
13451344 } ) ;
13461345 }
@@ -1359,7 +1358,7 @@ impl EthereumAdapterTrait for EthereumAdapter {
13591358 fetch_receipts_with_retry ( alloy, hashes, block_hash, logger, supports_block_receipts)
13601359 . await
13611360 . map ( |transaction_receipts| EthereumBlock {
1362- block : Arc :: new ( alloy_block_to_block ( block) ) ,
1361+ block : Arc :: new ( LightEthereumBlock :: new ( block) ) ,
13631362 transaction_receipts : transaction_receipts
13641363 . into_iter ( )
13651364 . map ( |receipt| receipt)
@@ -1611,35 +1610,35 @@ impl EthereumAdapterTrait for EthereumAdapter {
16111610 logger : Logger ,
16121611 chain_store : Arc < dyn ChainStore > ,
16131612 block_hashes : HashSet < B256 > ,
1614- ) -> Result < Vec < Arc < AlloyBlock > > , Error > {
1613+ ) -> Result < Vec < Arc < LightEthereumBlock > > , Error > {
16151614 let block_hashes: Vec < _ > = block_hashes. iter ( ) . cloned ( ) . collect ( ) ;
16161615 // 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
16181617 . cheap_clone ( )
16191618 . blocks ( block_hashes. iter ( ) . map ( |& b| b. into ( ) ) . collect :: < Vec < _ > > ( ) )
16201619 . await
16211620 . map_err ( |e| error ! ( & logger, "Error accessing block cache {}" , e) )
16221621 . unwrap_or_default ( )
16231622 . into_iter ( )
16241623 . filter_map ( |value| json:: from_value ( value) . ok ( ) )
1625- . map ( Arc :: new)
1624+ . map ( |b| Arc :: new ( LightEthereumBlock :: new ( b ) ) )
16261625 . collect ( ) ;
16271626
16281627 let missing_blocks = Vec :: from_iter (
16291628 block_hashes
16301629 . into_iter ( )
1631- . filter ( |hash| !blocks. iter ( ) . any ( |b| b. header . hash == * hash) ) ,
1630+ . filter ( |hash| !blocks. iter ( ) . any ( |b| b. hash ( ) == * hash) ) ,
16321631 ) ;
16331632
16341633 // Return a stream that lazily loads batches of blocks.
16351634 debug ! ( logger, "Requesting {} block(s)" , missing_blocks. len( ) ) ;
1636- let new_blocks: Vec < Arc < AlloyBlock > > = self
1635+ let new_blocks: Vec < _ > = self
16371636 . load_blocks_rpc ( logger. clone ( ) , missing_blocks)
16381637 . try_collect ( )
16391638 . await ?;
16401639 let upsert_blocks: Vec < _ > = new_blocks
16411640 . iter ( )
1642- . map ( |block| BlockFinality :: Final ( alloy_block_to_block_arc ( block. clone ( ) ) ) )
1641+ . map ( |block| BlockFinality :: Final ( block. clone ( ) ) )
16431642 . collect ( ) ;
16441643 let block_refs: Vec < _ > = upsert_blocks
16451644 . iter ( )
@@ -1649,7 +1648,7 @@ impl EthereumAdapterTrait for EthereumAdapter {
16491648 error ! ( logger, "Error writing to block cache {}" , e) ;
16501649 }
16511650 blocks. extend ( new_blocks) ;
1652- blocks. sort_by_key ( |block| block. header . number ) ;
1651+ blocks. sort_by_key ( |block| block. number ( ) ) ;
16531652 Ok ( blocks)
16541653 }
16551654}
@@ -1792,15 +1791,15 @@ pub(crate) async fn blocks_with_triggers(
17921791 . await ?
17931792 . into_iter ( )
17941793 . map (
1795- move |block| match triggers_by_block. remove ( & ( block. header . number ( ) as BlockNumber ) ) {
1794+ move |block| match triggers_by_block. remove ( & ( block. number ( ) ) ) {
17961795 Some ( triggers) => Ok ( BlockWithTriggers :: new (
1797- BlockFinality :: Final ( alloy_block_to_block_arc ( block) ) ,
1796+ BlockFinality :: Final ( block) ,
17981797 triggers,
17991798 & logger2,
18001799 ) ) ,
18011800 None => Err ( anyhow ! (
18021801 "block {} not found in `triggers_by_block`" ,
1803- BlockPtr :: new ( block. header . hash . into ( ) , block . header . number as i32 )
1802+ block. block_ptr ( )
18041803 ) ) ,
18051804 } ,
18061805 )
@@ -2612,12 +2611,11 @@ mod tests {
26122611 EthereumBlockWithCalls ,
26132612 } ;
26142613 use graph:: blockchain:: BlockPtr ;
2615- use graph:: components:: ethereum:: BlockWrapper ;
26162614 use graph:: prelude:: alloy:: primitives:: { Address , Bytes , B256 } ;
26172615 use graph:: prelude:: alloy:: providers:: mock:: Asserter ;
26182616 use graph:: prelude:: alloy:: providers:: ProviderBuilder ;
26192617 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 } ;
26212619 use jsonrpc_core:: serde_json:: { self , Value } ;
26222620 use std:: collections:: HashSet ;
26232621 use std:: iter:: FromIterator ;
@@ -2627,10 +2625,9 @@ mod tests {
26272625 fn parse_block_triggers_every_block ( ) {
26282626 let block = create_minimal_block_for_test ( 2 , hash ( 2 ) ) ;
26292627
2630- #[ allow( unreachable_code) ]
26312628 let block = EthereumBlockWithCalls {
26322629 ethereum_block : EthereumBlock {
2633- block : Arc :: new ( BlockWrapper :: new ( block) ) ,
2630+ block : Arc :: new ( LightEthereumBlock :: new ( block) ) ,
26342631 ..Default :: default ( )
26352632 } ,
26362633 calls : Some ( vec ! [ EthereumCall {
@@ -2772,7 +2769,7 @@ mod tests {
27722769 #[ allow( unreachable_code) ]
27732770 let block = EthereumBlockWithCalls {
27742771 ethereum_block : EthereumBlock {
2775- block : Arc :: new ( BlockWrapper :: new ( block) ) ,
2772+ block : Arc :: new ( LightEthereumBlock :: new ( block) ) ,
27762773 ..Default :: default ( )
27772774 } ,
27782775 calls : Some ( vec ! [ EthereumCall {
@@ -2803,7 +2800,7 @@ mod tests {
28032800 #[ allow( unreachable_code) ]
28042801 let block = EthereumBlockWithCalls {
28052802 ethereum_block : EthereumBlock {
2806- block : Arc :: new ( BlockWrapper :: new ( block) ) ,
2803+ block : Arc :: new ( LightEthereumBlock :: new ( block) ) ,
28072804 ..Default :: default ( )
28082805 } ,
28092806 calls : Some ( vec ! [ EthereumCall {
0 commit comments