Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
a1b85fba
Commit
a1b85fba
authored
May 08, 2023
by
Felipe Andrade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proxyd/fix: eth2 block tags {safe, finalized} should be valid tag values and avoid cache
parent
1e31e66a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
10 deletions
+50
-10
cache_test.go
proxyd/cache_test.go
+40
-8
methods.go
proxyd/methods.go
+10
-2
No files found.
proxyd/cache_test.go
View file @
a1b85fba
...
...
@@ -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"
,
},
}
...
...
proxyd/methods.go
View file @
a1b85fba
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment