Commit fd86a57e authored by OptimismBot's avatar OptimismBot Committed by GitHub

Merge pull request #5656 from ethereum-optimism/felipe/fix-cache-for-eth2-block-tags

fix(proxyd): eth2 block tags {safe, finalized} should be valid tag values and avoid cache
parents 6188ff50 571bd368
......@@ -80,6 +80,46 @@ func TestRPCCacheImmutableRPCs(t *testing.T) {
},
name: "eth_getBlockByNumber earliest",
},
{
req: &RPCReq{
JSONRPC: "2.0",
Method: "eth_getBlockByNumber",
Params: []byte(`["safe", false]`),
ID: ID,
},
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{
JSONRPC: "2.0",
......
......@@ -271,7 +271,10 @@ func (e *EthGasPriceMethodHandler) PutRPCMethod(context.Context, *RPCReq, *RPCRe
}
func isBlockDependentParam(s string) bool {
return s == "latest" || s == "pending"
return s == "latest" ||
s == "pending" ||
s == "finalized" ||
s == "safe"
}
func decodeGetBlockByNumberParams(params json.RawMessage) (string, bool, error) {
......@@ -355,7 +358,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)
......
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