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
c63e26a4
Unverified
Commit
c63e26a4
authored
May 26, 2023
by
mergify[bot]
Committed by
GitHub
May 26, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into sc/ci-npm-version
parents
fc94f247
a6800972
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
286 additions
and
628 deletions
+286
-628
go.mod
proxyd/go.mod
+36
-33
go.sum
proxyd/go.sum
+211
-580
rewriter.go
proxyd/rewriter.go
+19
-11
rewriter_test.go
proxyd/rewriter_test.go
+15
-0
server.go
proxyd/server.go
+5
-4
No files found.
proxyd/go.mod
View file @
c63e26a4
...
@@ -3,67 +3,70 @@ module github.com/ethereum-optimism/optimism/proxyd
...
@@ -3,67 +3,70 @@ module github.com/ethereum-optimism/optimism/proxyd
go 1.18
go 1.18
require (
require (
github.com/BurntSushi/toml v
0.4.1
github.com/BurntSushi/toml v
1.2.0
github.com/alicebob/miniredis v2.5.0+incompatible
github.com/alicebob/miniredis v2.5.0+incompatible
github.com/ethereum/go-ethereum v1.10.17
github.com/emirpasic/gods v1.18.1
github.com/ethereum/go-ethereum v1.12.0
github.com/go-redis/redis/v8 v8.11.4
github.com/go-redis/redis/v8 v8.11.4
github.com/golang/snappy v0.0.
4
github.com/golang/snappy v0.0.
5-0.20220116011046-fa5810519dcb
github.com/gorilla/mux v1.8.0
github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.5.0
github.com/gorilla/websocket v1.5.0
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
github.com/pkg/errors v0.9.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.1
1.1
github.com/prometheus/client_golang v1.1
4.0
github.com/rs/cors v1.8.2
github.com/rs/cors v1.8.2
github.com/stretchr/testify v1.
7.0
github.com/stretchr/testify v1.
8.1
golang.org/x/sync v0.
0.0-20210220032951-036812b2e83c
golang.org/x/sync v0.
1.0
gopkg.in/yaml.v
2 v2.4.0
gopkg.in/yaml.v
3 v3.0.1
)
)
require (
require (
github.com/DataDog/zstd v1.5.2 // indirect
github.com/VictoriaMetrics/fastcache v1.9.0 // indirect
github.com/VictoriaMetrics/fastcache v1.9.0 // indirect
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a // indirect
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd v0.22.0-beta // indirect
github.com/btcsuite/btcd v0.22.0-beta // indirect
github.com/btcsuite/btcd/btcec/v2 v2.1.2 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.9.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 // indirect
github.com/cockroachdb/redact v1.1.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set
v1.8
.0 // indirect
github.com/deckarep/golang-set
/v2 v2.1
.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/edsrzf/mmap-go v1.1.0 // indirect
github.com/getsentry/sentry-go v0.18.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/fjl/memsize v0.0.1 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/gomodule/redigo v1.8.8 // indirect
github.com/gomodule/redigo v1.8.8 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c // indirect
github.com/hashicorp/go-bexpr v0.1.11 // indirect
github.com/klauspost/compress v1.15.15 // indirect
github.com/huin/goupnp v1.0.3 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.
1
// indirect
github.com/matttproud/golang_protobuf_extensions v1.0.
4
// indirect
github.com/
mitchellh/mapstructure v1.4.3
// indirect
github.com/
olekukonko/tablewriter v0.0.5
// indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.
2
.0 // indirect
github.com/prometheus/client_model v0.
3
.0 // indirect
github.com/prometheus/common v0.3
0
.0 // indirect
github.com/prometheus/common v0.3
9
.0 // indirect
github.com/prometheus/procfs v0.
7.3
// indirect
github.com/prometheus/procfs v0.
9.0
// indirect
github.com/
prometheus/tsdb v0.10
.0 // indirect
github.com/
rivo/uniseg v0.2
.0 // indirect
github.com/r
jeczalik/notify v0.9.2
// indirect
github.com/r
ogpeppe/go-internal v1.9.0
// indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/s
tatus-im/keycard-go v0.0.0-20211109104530-b0e0482ba91d
// indirect
github.com/s
yndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
// indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 // indirect
github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/exp v0.0.0-20230206171751-46f607a40771 // indirect
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect
golang.org/x/sys v0.7.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
golang.org/x/text v0.8.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
)
proxyd/go.sum
View file @
c63e26a4
This source diff could not be displayed because it is too large. You can
view the blob
instead.
proxyd/rewriter.go
View file @
c63e26a4
...
@@ -85,8 +85,12 @@ func rewriteParam(rctx RewriteContext, req *RPCReq, res *RPCRes, pos int) (Rewri
...
@@ -85,8 +85,12 @@ func rewriteParam(rctx RewriteContext, req *RPCReq, res *RPCRes, pos int) (Rewri
return
RewriteOverrideError
,
err
return
RewriteOverrideError
,
err
}
}
if
len
(
p
)
<=
pos
{
// we assume latest if the param is missing,
// and we don't rewrite if there is not enough params
if
len
(
p
)
==
pos
{
p
=
append
(
p
,
"latest"
)
p
=
append
(
p
,
"latest"
)
}
else
if
len
(
p
)
<
pos
{
return
RewriteNone
,
nil
}
}
val
,
rw
,
err
:=
rewriteTag
(
rctx
,
p
[
pos
]
.
(
string
))
val
,
rw
,
err
:=
rewriteTag
(
rctx
,
p
[
pos
]
.
(
string
))
...
@@ -159,13 +163,6 @@ func rewriteTagMap(rctx RewriteContext, m map[string]interface{}, key string) (b
...
@@ -159,13 +163,6 @@ func rewriteTagMap(rctx RewriteContext, m map[string]interface{}, key string) (b
}
}
func
rewriteTag
(
rctx
RewriteContext
,
current
string
)
(
string
,
bool
,
error
)
{
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
)
jv
,
err
:=
json
.
Marshal
(
current
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
false
,
err
return
""
,
false
,
err
...
@@ -177,10 +174,21 @@ func rewriteTag(rctx RewriteContext, current string) (string, bool, error) {
...
@@ -177,10 +174,21 @@ func rewriteTag(rctx RewriteContext, current string) (string, bool, error) {
return
""
,
false
,
err
return
""
,
false
,
err
}
}
if
bnh
.
BlockNumber
!=
nil
&&
*
bnh
.
BlockNumber
==
rpc
.
LatestBlockNumber
{
// this is a hash, not a block
if
bnh
.
BlockNumber
==
nil
{
return
current
,
false
,
nil
}
switch
*
bnh
.
BlockNumber
{
case
rpc
.
SafeBlockNumber
,
rpc
.
FinalizedBlockNumber
,
rpc
.
PendingBlockNumber
,
rpc
.
EarliestBlockNumber
:
return
current
,
false
,
nil
case
rpc
.
LatestBlockNumber
:
return
rctx
.
latest
.
String
(),
true
,
nil
return
rctx
.
latest
.
String
(),
true
,
nil
}
else
if
bnh
.
BlockNumber
!=
nil
{
default
:
if
hexutil
.
Uint64
(
bnh
.
BlockNumber
.
Int64
())
>
rctx
.
latest
{
if
bnh
.
BlockNumber
.
Int64
()
>
int64
(
rctx
.
latest
)
{
return
""
,
false
,
ErrRewriteBlockOutOfRange
return
""
,
false
,
ErrRewriteBlockOutOfRange
}
}
}
}
...
...
proxyd/rewriter_test.go
View file @
c63e26a4
...
@@ -166,6 +166,21 @@ func TestRewriteRequest(t *testing.T) {
...
@@ -166,6 +166,21 @@ func TestRewriteRequest(t *testing.T) {
require
.
Equal
(
t
,
hexutil
.
Uint64
(
100
)
.
String
(),
p
[
1
])
require
.
Equal
(
t
,
hexutil
.
Uint64
(
100
)
.
String
(),
p
[
1
])
},
},
},
},
{
name
:
"eth_getCode not enough params, should do nothing"
,
args
:
args
{
rctx
:
RewriteContext
{
latest
:
hexutil
.
Uint64
(
100
)},
req
:
&
RPCReq
{
Method
:
"eth_getCode"
,
Params
:
mustMarshalJSON
([]
string
{})},
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
,
0
,
len
(
p
))
},
},
{
{
name
:
"eth_getCode latest"
,
name
:
"eth_getCode latest"
,
args
:
args
{
args
:
args
{
...
...
proxyd/server.go
View file @
c63e26a4
...
@@ -16,6 +16,8 @@ import (
...
@@ -16,6 +16,8 @@ import (
"sync"
"sync"
"time"
"time"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
...
@@ -651,19 +653,18 @@ func (s *Server) rateLimitSender(ctx context.Context, req *RPCReq) error {
...
@@ -651,19 +653,18 @@ func (s *Server) rateLimitSender(ctx context.Context, req *RPCReq) error {
// Convert the transaction into a Message object so that we can get the
// Convert the transaction into a Message object so that we can get the
// sender. This method performs an ecrecover, which can be expensive.
// sender. This method performs an ecrecover, which can be expensive.
msg
,
err
:=
tx
.
AsMessage
(
types
.
LatestSignerForChainID
(
tx
.
ChainId
()),
nil
)
msg
,
err
:=
core
.
TransactionToMessage
(
tx
,
types
.
LatestSignerForChainID
(
tx
.
ChainId
()),
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Debug
(
"could not get message from transaction"
,
"err"
,
err
,
"req_id"
,
GetReqID
(
ctx
))
log
.
Debug
(
"could not get message from transaction"
,
"err"
,
err
,
"req_id"
,
GetReqID
(
ctx
))
return
ErrInvalidParams
(
err
.
Error
())
return
ErrInvalidParams
(
err
.
Error
())
}
}
ok
,
err
:=
s
.
senderLim
.
Take
(
ctx
,
fmt
.
Sprintf
(
"%s:%d"
,
msg
.
From
.
Hex
(),
tx
.
Nonce
()))
ok
,
err
:=
s
.
senderLim
.
Take
(
ctx
,
fmt
.
Sprintf
(
"%s:%d"
,
msg
.
From
()
.
Hex
(),
tx
.
Nonce
()))
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
"error taking from sender limiter"
,
"err"
,
err
,
"req_id"
,
GetReqID
(
ctx
))
log
.
Error
(
"error taking from sender limiter"
,
"err"
,
err
,
"req_id"
,
GetReqID
(
ctx
))
return
ErrInternal
return
ErrInternal
}
}
if
!
ok
{
if
!
ok
{
log
.
Debug
(
"sender rate limit exceeded"
,
"sender"
,
msg
.
From
(),
"req_id"
,
GetReqID
(
ctx
))
log
.
Debug
(
"sender rate limit exceeded"
,
"sender"
,
msg
.
From
.
Hex
(),
"req_id"
,
GetReqID
(
ctx
))
return
ErrOverSenderRateLimit
return
ErrOverSenderRateLimit
}
}
...
...
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