Skip to content

Commit ed10f44

Browse files
committed
chain/ethereum: migrate next_existing_ptr_to_number call to use alloy
1 parent 004f986 commit ed10f44

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
@@ -1497,20 +1497,24 @@ impl EthereumAdapterTrait for EthereumAdapter {
14971497
"eth_getBlockByNumber RPC call for block number {}",
14981498
next_number
14991499
);
1500-
let web3 = self.web3.clone();
1500+
let alloy = self.alloy.clone();
15011501
let logger = logger.clone();
15021502
let res = retry(retry_log_message, &logger)
15031503
.redact_log_urls(true)
15041504
.when(|res| !res.is_ok() && !detect_null_block(res))
15051505
.no_limit()
15061506
.timeout_secs(ENV_VARS.json_rpc_timeout.as_secs())
15071507
.run(move || {
1508-
let web3 = web3.cheap_clone();
1508+
let alloy = alloy.cheap_clone();
15091509
async move {
1510-
web3.eth()
1511-
.block(BlockId::Number(next_number.into()))
1510+
alloy
1511+
.get_block_by_number(alloy_rpc_types::BlockNumberOrTag::Number(
1512+
next_number as u64,
1513+
))
15121514
.await
1513-
.map(|block_opt| block_opt.and_then(|block| block.hash))
1515+
.map(|block_opt| {
1516+
block_opt.map(|block| BlockHash::from(block.header.hash.0.to_vec()))
1517+
})
15141518
.map_err(Error::from)
15151519
}
15161520
})
@@ -1528,7 +1532,7 @@ impl EthereumAdapterTrait for EthereumAdapter {
15281532
continue;
15291533
}
15301534
return match res {
1531-
Ok(Some(hash)) => Ok(BlockPtr::new(hash.into(), next_number)),
1535+
Ok(Some(hash)) => Ok(BlockPtr::new(hash, next_number)),
15321536
Ok(None) => Err(anyhow!("Block {} does not contain hash", next_number)),
15331537
Err(e) => Err(e),
15341538
};

0 commit comments

Comments
 (0)