From a0ee96da6d05824083b2d08bf6a35dc36460b170 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Thu, 23 Nov 2023 01:02:15 -0400 Subject: [PATCH] change from and to block just to sanitize the block numbers --- web3_proxy/src/block_number.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/web3_proxy/src/block_number.rs b/web3_proxy/src/block_number.rs index d277c6a4..aab05125 100644 --- a/web3_proxy/src/block_number.rs +++ b/web3_proxy/src/block_number.rs @@ -394,11 +394,9 @@ impl CacheMode { BlockNumber_to_U64(block_num, head_block.number()); // TODO: double check this. it scares me - // if change { - // // TODO: include the hash instead of the number? - // trace!("changing fromBlock in eth_getLogs. {} -> {}", x, block_num); - // *x = json!(block_num); - // } + // we always change because some clients send U64 with padding and erigon doesn't like that + trace!("changing fromBlock in eth_getLogs. {} -> {}", x, block_num); + *x = json!(block_num); BlockNumOrHash::Num(block_num) } else { @@ -418,10 +416,8 @@ impl CacheMode { let (block_num, change) = BlockNumber_to_U64(block_num, latest_block); // TODO: double check this. it scares me but i think we need it - // if change { - // trace!("changing toBlock in eth_getLogs. {} -> {}", x, block_num); - // *x = json!(block_num); - // } + trace!("changing toBlock in eth_getLogs. {} -> {}", x, block_num); + *x = json!(block_num); if let Some(app) = app { // TODO: make a jsonrpc query here? cache rates will be better but it adds a network request @@ -574,7 +570,7 @@ mod test { jsonrpc::{LooseId, SingleRequest}, rpcs::blockchain::BlockHeader, }; - use ethers::types::{Block, H256}; + use ethers::types::{Block, H256, U64}; use serde_json::json; use std::sync::Arc; @@ -688,5 +684,10 @@ mod test { matches!(x, CacheMode::Never); } + #[test] + fn test_serializing_padded_ints() { + let x: U64 = "0x001234".parse().unwrap(); + } + // TODO: tests for eth_getLogs }