File tree Expand file tree Collapse file tree 2 files changed +27
-6
lines changed
test-store/tests/postgres Expand file tree Collapse file tree 2 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -2839,13 +2839,20 @@ impl EthereumCallCache for ChainStore {
2839
2839
block : BlockPtr ,
2840
2840
return_value : call:: Retval ,
2841
2841
) -> Result < ( ) , Error > {
2842
- let call:: Retval :: Value ( return_value) = return_value else {
2843
- // We do not want to cache unsuccessful calls as some RPC nodes
2844
- // have weird behavior near the chain head. The details are lost
2845
- // to time, but we had issues with some RPC clients in the past
2846
- // where calls first failed and later succeeded
2847
- return Ok ( ( ) ) ;
2842
+ let return_value = match return_value {
2843
+ call:: Retval :: Value ( return_value) if !return_value. is_empty ( ) => return_value,
2844
+ _ => {
2845
+ // We do not want to cache unsuccessful calls as some RPC nodes
2846
+ // have weird behavior near the chain head. The details are lost
2847
+ // to time, but we had issues with some RPC clients in the past
2848
+ // where calls first failed and later succeeded
2849
+ // Also in some cases RPC nodes may return empty ("0x") values
2850
+ // which in the context of graph-node most likely means an issue
2851
+ // with the RPC node rather than a successful call.
2852
+ return Ok ( ( ) ) ;
2853
+ }
2848
2854
} ;
2855
+
2849
2856
let id = contract_call_id ( & call, & block) ;
2850
2857
let conn = & mut * self . get_conn ( ) ?;
2851
2858
conn. transaction ( |conn| {
Original file line number Diff line number Diff line change @@ -475,6 +475,7 @@ fn eth_call_cache() {
475
475
. unwrap ( ) ;
476
476
assert_eq ! ( & new_return_value, ret. as_slice( ) ) ;
477
477
478
+ // Reverted calls should not be cached
478
479
store
479
480
. set_call (
480
481
& logger,
@@ -486,6 +487,19 @@ fn eth_call_cache() {
486
487
let ret = store. get_call ( & call, BLOCK_THREE . block_ptr ( ) ) . unwrap ( ) ;
487
488
assert_eq ! ( None , ret) ;
488
489
490
+ // Empty return values should not be cached
491
+ let return_value: [ u8 ; 0 ] = [ ] ;
492
+ store
493
+ . set_call (
494
+ & logger,
495
+ call. cheap_clone ( ) ,
496
+ BLOCK_FOUR . block_ptr ( ) ,
497
+ ccr ( & return_value) ,
498
+ )
499
+ . unwrap ( ) ;
500
+ let ret = store. get_call ( & call, BLOCK_FOUR . block_ptr ( ) ) . unwrap ( ) ;
501
+ assert_eq ! ( None , ret) ;
502
+
489
503
Ok ( ( ) )
490
504
} )
491
505
}
You can’t perform that action at this time.
0 commit comments