Skip to content

Commit 4f1d415

Browse files
committed
graph: Fix silent truncation in BlockPtr::from(BlockWrapper)
Use From<(B256, u64)> which has proper i32::try_from().unwrap() overflow checking instead of direct `as i32` cast that silently truncates.
1 parent e2a4704 commit 4f1d415

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

chain/ethereum/src/chain.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,10 +1152,7 @@ impl TriggersAdapterTrait<Chain> for TriggersAdapter {
11521152
Ok(Some(BlockFinality::NonFinal(ethereum_block)))
11531153
}
11541154
ChainClient::Rpc(adapters) => {
1155-
match self
1156-
.fetch_full_block_with_rpc(adapters, &block_ptr)
1157-
.await?
1158-
{
1155+
match self.fetch_full_block_with_rpc(adapters, &block_ptr).await? {
11591156
Some(ethereum_block) => {
11601157
Ok(Some(BlockFinality::NonFinal(EthereumBlockWithCalls {
11611158
ethereum_block,

graph/src/blockchain/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ impl slog::Value for BlockPtr {
202202

203203
impl From<BlockWrapper> for BlockPtr {
204204
fn from(b: BlockWrapper) -> BlockPtr {
205-
BlockPtr::from((b.hash(), b.number_u64() as i32))
205+
BlockPtr::from((b.hash(), b.number_u64()))
206206
}
207207
}
208208

209209
impl From<&BlockWrapper> for BlockPtr {
210210
fn from(b: &BlockWrapper) -> BlockPtr {
211-
BlockPtr::from((b.hash(), b.number_u64() as i32))
211+
BlockPtr::from((b.hash(), b.number_u64()))
212212
}
213213
}
214214

0 commit comments

Comments
 (0)