diff --git a/proxyd/proxyd/cache_test.go b/proxyd/proxyd/cache_test.go index 11c277b..7f7f08c 100644 --- a/proxyd/proxyd/cache_test.go +++ b/proxyd/proxyd/cache_test.go @@ -73,12 +73,48 @@ func TestRPCCacheImmutableRPCs(t *testing.T) { Params: []byte(`["earliest", false]`), ID: ID, }, - res: &RPCRes{ + res: nil, + name: "eth_getBlockByNumber earliest", + }, + { + req: &RPCReq{ JSONRPC: "2.0", - Result: `{"difficulty": "0x1", "number": "0x1"}`, + Method: "eth_getBlockByNumber", + Params: []byte(`["safe", false]`), ID: ID, }, - name: "eth_getBlockByNumber earliest", + res: nil, + name: "eth_getBlockByNumber safe", + }, + { + req: &RPCReq{ + JSONRPC: "2.0", + Method: "eth_getBlockByNumber", + Params: []byte(`["finalized", false]`), + ID: ID, + }, + res: nil, + name: "eth_getBlockByNumber finalized", + }, + { + req: &RPCReq{ + JSONRPC: "2.0", + Method: "eth_getBlockByNumber", + Params: []byte(`["pending", false]`), + ID: ID, + }, + res: nil, + name: "eth_getBlockByNumber pending", + }, + { + req: &RPCReq{ + JSONRPC: "2.0", + Method: "eth_getBlockByNumber", + Params: []byte(`["latest", false]`), + ID: ID, + }, + res: nil, + name: "eth_getBlockByNumber latest", }, { req: &RPCReq{ @@ -101,11 +137,7 @@ func TestRPCCacheImmutableRPCs(t *testing.T) { Params: []byte(`["earliest", "0x2", false]`), ID: ID, }, - res: &RPCRes{ - JSONRPC: "2.0", - Result: `[{"number": "0x1"}, {"number": "0x2"}]`, - ID: ID, - }, + res: nil, name: "eth_getBlockRange earliest", }, } diff --git a/proxyd/proxyd/methods.go b/proxyd/proxyd/methods.go index 4b1731f..011b476 100644 --- a/proxyd/proxyd/methods.go +++ b/proxyd/proxyd/methods.go @@ -271,7 +271,11 @@ func (e *EthGasPriceMethodHandler) PutRPCMethod(context.Context, *RPCReq, *RPCRe } func isBlockDependentParam(s string) bool { - return s == "latest" || s == "pending" + return s == "earliest" || + s == "latest" || + s == "pending" || + s == "finalized" || + s == "safe" } func decodeGetBlockByNumberParams(params json.RawMessage) (string, bool, error) { @@ -355,7 +359,11 @@ func decodeEthCallParams(req *RPCReq) (*ethCallParams, string, error) { } func validBlockInput(input string) bool { - if input == "earliest" || input == "pending" || input == "latest" { + if input == "earliest" || + input == "latest" || + input == "pending" || + input == "finalized" || + input == "safe" { return true } _, err := decodeBlockInput(input)