Skip to content

Commit 31a73d3

Browse files
committed
chain/ethereum: migrate next_existing_ptr_to_number call to use alloy
1 parent 7310729 commit 31a73d3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

chain/ethereum/src/ethereum_adapter.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,20 +1512,24 @@ impl EthereumAdapterTrait for EthereumAdapter {
15121512
"eth_getBlockByNumber RPC call for block number {}",
15131513
next_number
15141514
);
1515-
let web3 = self.web3.clone();
1515+
let alloy = self.alloy.clone();
15161516
let logger = logger.clone();
15171517
let res = retry(retry_log_message, &logger)
15181518
.redact_log_urls(true)
15191519
.when(|res| !res.is_ok() && !detect_null_block(res))
15201520
.no_limit()
15211521
.timeout_secs(ENV_VARS.json_rpc_timeout.as_secs())
15221522
.run(move || {
1523-
let web3 = web3.cheap_clone();
1523+
let alloy = alloy.cheap_clone();
15241524
async move {
1525-
web3.eth()
1526-
.block(BlockId::Number(next_number.into()))
1525+
alloy
1526+
.get_block_by_number(alloy_rpc_types::BlockNumberOrTag::Number(
1527+
next_number as u64,
1528+
))
15271529
.await
1528-
.map(|block_opt| block_opt.and_then(|block| block.hash))
1530+
.map(|block_opt| {
1531+
block_opt.map(|block| BlockHash::from(block.header.hash.0.to_vec()))
1532+
})
15291533
.map_err(Error::from)
15301534
}
15311535
})
@@ -1543,7 +1547,7 @@ impl EthereumAdapterTrait for EthereumAdapter {
15431547
continue;
15441548
}
15451549
return match res {
1546-
Ok(Some(hash)) => Ok(BlockPtr::new(hash.into(), next_number)),
1550+
Ok(Some(hash)) => Ok(BlockPtr::new(hash, next_number)),
15471551
Ok(None) => Err(anyhow!("Block {} does not contain hash", next_number)),
15481552
Err(e) => Err(e),
15491553
};

0 commit comments

Comments
 (0)