Commit 29d85754 authored by Felipe Andrade's avatar Felipe Andrade

fix(proxyd): avoid caching tx hash based methods, since the response may change with a reorg

parent d0de085d
......@@ -130,10 +130,8 @@ func newRPCCache(cache Cache) RPCCache {
"eth_getBlockTransactionCountByHash": staticHandler,
"eth_getUncleCountByBlockHash": staticHandler,
"eth_getBlockByHash": staticHandler,
"eth_getTransactionByHash": staticHandler,
"eth_getTransactionByBlockHashAndIndex": staticHandler,
"eth_getUncleByBlockHashAndIndex": staticHandler,
"eth_getTransactionReceipt": staticHandler,
}
return &rpcCache{
cache: cache,
......
......@@ -87,34 +87,6 @@ func TestRPCCacheImmutableRPCs(t *testing.T) {
},
name: "eth_getBlockByHash",
},
{
req: &RPCReq{
JSONRPC: "2.0",
Method: "eth_getTransactionByHash",
Params: mustMarshalJSON([]string{"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"}),
ID: ID,
},
res: &RPCRes{
JSONRPC: "2.0",
Result: `{"eth_getTransactionByHash":"!"}`,
ID: ID,
},
name: "eth_getTransactionByHash",
},
{
req: &RPCReq{
JSONRPC: "2.0",
Method: "eth_getTransactionByBlockHashAndIndex",
Params: mustMarshalJSON([]string{"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", "0x55"}),
ID: ID,
},
res: &RPCRes{
JSONRPC: "2.0",
Result: `{"eth_getTransactionByBlockHashAndIndex":"!"}`,
ID: ID,
},
name: "eth_getTransactionByBlockHashAndIndex",
},
{
req: &RPCReq{
JSONRPC: "2.0",
......@@ -129,20 +101,6 @@ func TestRPCCacheImmutableRPCs(t *testing.T) {
},
name: "eth_getUncleByBlockHashAndIndex",
},
{
req: &RPCReq{
JSONRPC: "2.0",
Method: "eth_getTransactionReceipt",
Params: mustMarshalJSON([]string{"0x85d995eba9763907fdf35cd2034144dd9d53ce32cbec21349d4b12823c6860c5"}),
ID: ID,
},
res: &RPCRes{
JSONRPC: "2.0",
Result: `{"eth_getTransactionReceipt":"!"}`,
ID: ID,
},
name: "eth_getTransactionReceipt",
},
}
for _, rpc := range rpcs {
......
......@@ -77,12 +77,6 @@ func TestCaching(t *testing.T) {
"{\"jsonrpc\": \"2.0\", \"result\": \"eth_getBlockByHash\", \"id\": 999}",
1,
},
{
"eth_getTransactionByHash",
[]interface{}{"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"},
"{\"jsonrpc\": \"2.0\", \"result\": \"eth_getTransactionByHash\", \"id\": 999}",
1,
},
{
"eth_getTransactionByBlockHashAndIndex",
[]interface{}{"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", "0x55"},
......@@ -95,12 +89,6 @@ func TestCaching(t *testing.T) {
"{\"jsonrpc\": \"2.0\", \"result\": \"eth_getUncleByBlockHashAndIndex\", \"id\": 999}",
1,
},
{
"eth_getTransactionReceipt",
[]interface{}{"0x85d995eba9763907fdf35cd2034144dd9d53ce32cbec21349d4b12823c6860c5"},
"{\"jsonrpc\": \"2.0\", \"result\": \"eth_getTransactionReceipt\", \"id\": 999}",
1,
},
/* not cacheable */
{
"eth_getBlockByNumber",
......@@ -111,6 +99,18 @@ func TestCaching(t *testing.T) {
"{\"jsonrpc\": \"2.0\", \"result\": \"eth_getBlockByNumber\", \"id\": 999}",
2,
},
{
"eth_getTransactionReceipt",
[]interface{}{"0x85d995eba9763907fdf35cd2034144dd9d53ce32cbec21349d4b12823c6860c5"},
"{\"jsonrpc\": \"2.0\", \"result\": \"eth_getTransactionReceipt\", \"id\": 999}",
2,
},
{
"eth_getTransactionByHash",
[]interface{}{"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"},
"{\"jsonrpc\": \"2.0\", \"result\": \"eth_getTransactionByHash\", \"id\": 999}",
2,
},
{
"eth_call",
[]interface{}{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment