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
a7c27331
Unverified
Commit
a7c27331
authored
May 25, 2023
by
OptimismBot
Committed by
GitHub
May 25, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5786 from ethereum-optimism/bugfix/safe-finalized-tags
proxyd: Pass through finalized and safe tags
parents
85520524
b48ee8d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
rewriter.go
proxyd/rewriter.go
+8
-0
rewriter_test.go
proxyd/rewriter_test.go
+32
-0
No files found.
proxyd/rewriter.go
View file @
a7c27331
...
...
@@ -159,6 +159,13 @@ func rewriteTagMap(rctx RewriteContext, m map[string]interface{}, key string) (b
}
func
rewriteTag
(
rctx
RewriteContext
,
current
string
)
(
string
,
bool
,
error
)
{
// If a tag is the safe or finalized block number, don't rewrite it.
// We have a custom check here because the rpc.BlockNumberOrHash type
// doesn't support these custom tags yet.
if
current
==
"safe"
||
current
==
"finalized"
{
return
current
,
false
,
nil
}
jv
,
err
:=
json
.
Marshal
(
current
)
if
err
!=
nil
{
return
""
,
false
,
err
...
...
@@ -177,5 +184,6 @@ func rewriteTag(rctx RewriteContext, current string) (string, bool, error) {
return
""
,
false
,
ErrRewriteBlockOutOfRange
}
}
return
current
,
false
,
nil
}
proxyd/rewriter_test.go
View file @
a7c27331
...
...
@@ -308,6 +308,38 @@ func TestRewriteRequest(t *testing.T) {
require
.
Equal
(
t
,
hexutil
.
Uint64
(
100
)
.
String
(),
p
[
0
])
},
},
{
name
:
"eth_getBlockByNumber finalized"
,
args
:
args
{
rctx
:
RewriteContext
{
latest
:
hexutil
.
Uint64
(
100
)},
req
:
&
RPCReq
{
Method
:
"eth_getBlockByNumber"
,
Params
:
mustMarshalJSON
([]
string
{
"finalized"
})},
res
:
nil
,
},
expected
:
RewriteNone
,
check
:
func
(
t
*
testing
.
T
,
args
args
)
{
var
p
[]
string
err
:=
json
.
Unmarshal
(
args
.
req
.
Params
,
&
p
)
require
.
Nil
(
t
,
err
)
require
.
Equal
(
t
,
1
,
len
(
p
))
require
.
Equal
(
t
,
"finalized"
,
p
[
0
])
},
},
{
name
:
"eth_getBlockByNumber safe"
,
args
:
args
{
rctx
:
RewriteContext
{
latest
:
hexutil
.
Uint64
(
100
)},
req
:
&
RPCReq
{
Method
:
"eth_getBlockByNumber"
,
Params
:
mustMarshalJSON
([]
string
{
"safe"
})},
res
:
nil
,
},
expected
:
RewriteNone
,
check
:
func
(
t
*
testing
.
T
,
args
args
)
{
var
p
[]
string
err
:=
json
.
Unmarshal
(
args
.
req
.
Params
,
&
p
)
require
.
Nil
(
t
,
err
)
require
.
Equal
(
t
,
1
,
len
(
p
))
require
.
Equal
(
t
,
"safe"
,
p
[
0
])
},
},
{
name
:
"eth_getBlockByNumber within range"
,
args
:
args
{
...
...
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