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
8d5ebf21
Commit
8d5ebf21
authored
Mar 15, 2022
by
Matthew Slipper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ci: Add CircleCI config
parent
a3b12065
Changes
26
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
458 additions
and
231 deletions
+458
-231
config.yml
.circleci/config.yml
+314
-26
db.go
go/indexer/db/db.go
+58
-152
metrics.go
go/indexer/metrics/metrics.go
+2
-1
addresses.go
go/indexer/services/l1/bridge/addresses.go
+1
-0
eth_bridge.go
go/indexer/services/l1/bridge/eth_bridge.go
+1
-0
query.go
go/indexer/services/l1/query.go
+1
-1
backend.go
go/proxyd/backend.go
+7
-3
caching_test.go
go/proxyd/integration_tests/caching_test.go
+4
-3
failover_test.go
go/proxyd/integration_tests/failover_test.go
+10
-7
mock_backend_test.go
go/proxyd/integration_tests/mock_backend_test.go
+3
-2
rate_limit_test.go
go/proxyd/integration_tests/rate_limit_test.go
+3
-2
util_test.go
go/proxyd/integration_tests/util_test.go
+4
-3
validation_test.go
go/proxyd/integration_tests/validation_test.go
+3
-2
proxyd.go
go/proxyd/proxyd.go
+5
-1
rate_limiter.go
go/proxyd/rate_limiter.go
+3
-2
rpc_test.go
go/proxyd/rpc_test.go
+2
-1
server.go
go/proxyd/server.go
+8
-19
main.go
go/teleportr/cmd/teleportr/main.go
+2
-2
teleportr.go
go/teleportr/teleportr.go
+1
-1
Dockerfile
ops/docker/go-builder/Dockerfile
+7
-0
Dockerfile
ops/docker/js-builder/Dockerfile
+10
-0
integration-tests.sh
ops/scripts/integration-tests.sh
+1
-1
wait-for-sequencer.sh
ops/scripts/wait-for-sequencer.sh
+2
-2
.eslintrc.js
packages/contracts/.eslintrc.js
+4
-0
package.json
packages/message-relayer/package.json
+1
-0
package.json
packages/replica-healthcheck/package.json
+1
-0
No files found.
.circleci/config.yml
View file @
8d5ebf21
This diff is collapsed.
Click to expand it.
go/indexer/db/db.go
View file @
8d5ebf21
This diff is collapsed.
Click to expand it.
go/indexer/metrics/metrics.go
View file @
8d5ebf21
...
...
@@ -2,12 +2,13 @@ package metrics
import
(
"fmt"
"net/http"
l2common
"github.com/ethereum-optimism/optimism/l2geth/common"
"github.com/ethereum/go-ethereum/common"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
"net/http"
)
const
metricsNamespace
=
"indexer"
...
...
go/indexer/services/l1/bridge/addresses.go
View file @
8d5ebf21
...
...
@@ -2,6 +2,7 @@ package bridge
import
(
"fmt"
"github.com/ethereum-optimism/optimism/go/indexer/bindings/address_manager"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
...
...
go/indexer/services/l1/bridge/eth_bridge.go
View file @
8d5ebf21
...
...
@@ -2,6 +2,7 @@ package bridge
import
(
"context"
"github.com/ethereum-optimism/optimism/go/indexer/bindings/l1bridge"
"github.com/ethereum-optimism/optimism/go/indexer/db"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
...
...
go/indexer/services/l1/query.go
View file @
8d5ebf21
...
...
@@ -2,6 +2,7 @@ package l1
import
(
"context"
"github.com/ethereum-optimism/optimism/go/indexer/bindings/l1erc20"
"github.com/ethereum/go-ethereum/ethclient"
...
...
@@ -40,7 +41,6 @@ func QueryERC20(address common.Address, client *ethclient.Client) (*db.Token, er
},
nil
}
func
QueryStateBatches
(
filterer
*
scc
.
StateCommitmentChainFilterer
,
startHeight
,
endHeight
uint64
,
ctx
context
.
Context
)
(
map
[
common
.
Hash
][]
db
.
StateBatch
,
error
)
{
batches
:=
make
(
map
[
common
.
Hash
][]
db
.
StateBatch
)
...
...
go/proxyd/backend.go
View file @
8d5ebf21
...
...
@@ -255,7 +255,7 @@ func (b *Backend) ProxyWS(clientConn *websocket.Conn, methodWhitelist *StringSet
return
nil
,
ErrBackendOverCapacity
}
backendConn
,
_
,
err
:=
b
.
dialer
.
Dial
(
b
.
wsURL
,
nil
)
backendConn
,
_
,
err
:=
b
.
dialer
.
Dial
(
b
.
wsURL
,
nil
)
// nolint:bodyclose
if
err
!=
nil
{
b
.
setOffline
()
if
err
:=
b
.
rateLimiter
.
DecBackendWSConns
(
b
.
Name
);
err
!=
nil
{
...
...
@@ -513,7 +513,9 @@ func (w *WSProxier) clientPump(ctx context.Context, errC chan error) {
msgType
,
msg
,
err
:=
w
.
clientConn
.
ReadMessage
()
if
err
!=
nil
{
errC
<-
err
outConn
.
WriteMessage
(
websocket
.
CloseMessage
,
formatWSError
(
err
))
if
err
:=
outConn
.
WriteMessage
(
websocket
.
CloseMessage
,
formatWSError
(
err
));
err
!=
nil
{
log
.
Error
(
"error writing backendConn message"
,
"err"
,
err
)
}
return
}
...
...
@@ -575,7 +577,9 @@ func (w *WSProxier) backendPump(ctx context.Context, errC chan error) {
msgType
,
msg
,
err
:=
w
.
backendConn
.
ReadMessage
()
if
err
!=
nil
{
errC
<-
err
w
.
clientConn
.
WriteMessage
(
websocket
.
CloseMessage
,
formatWSError
(
err
))
if
err
:=
w
.
clientConn
.
WriteMessage
(
websocket
.
CloseMessage
,
formatWSError
(
err
));
err
!=
nil
{
log
.
Error
(
"error writing clientConn message"
,
"err"
,
err
)
}
return
}
...
...
go/proxyd/integration_tests/caching_test.go
View file @
8d5ebf21
...
...
@@ -3,12 +3,13 @@ package integration_tests
import
(
"bytes"
"fmt"
"github.com/alicebob/miniredis"
"github.com/ethereum-optimism/optimism/go/proxyd"
"github.com/stretchr/testify/require"
"os"
"testing"
"time"
"github.com/alicebob/miniredis"
"github.com/ethereum-optimism/optimism/go/proxyd"
"github.com/stretchr/testify/require"
)
func
TestCaching
(
t
*
testing
.
T
)
{
...
...
go/proxyd/integration_tests/failover_test.go
View file @
8d5ebf21
...
...
@@ -2,13 +2,14 @@ package integration_tests
import
(
"fmt"
"github.com/ethereum-optimism/optimism/go/proxyd"
"github.com/stretchr/testify/require"
"net/http"
"os"
"sync/atomic"
"testing"
"time"
"github.com/ethereum-optimism/optimism/go/proxyd"
"github.com/stretchr/testify/require"
)
const
(
...
...
@@ -39,7 +40,7 @@ func TestFailover(t *testing.T) {
"backend responds 200 with non-JSON response"
,
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
WriteHeader
(
200
)
w
.
Write
([]
byte
(
"this data is not JSON!"
))
_
,
_
=
w
.
Write
([]
byte
(
"this data is not JSON!"
))
}),
},
{
...
...
@@ -87,7 +88,7 @@ func TestFailover(t *testing.T) {
t
.
Run
(
"backend times out and falls back to another"
,
func
(
t
*
testing
.
T
)
{
badBackend
.
SetHandler
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
time
.
Sleep
(
2
*
time
.
Second
)
w
.
Write
([]
byte
(
"{}"
))
_
,
_
=
w
.
Write
([]
byte
(
"{}"
))
}))
res
,
statusCode
,
err
:=
client
.
SendRPC
(
"eth_chainId"
,
nil
)
require
.
NoError
(
t
,
err
)
...
...
@@ -133,7 +134,7 @@ func TestRetries(t *testing.T) {
w
.
WriteHeader
(
500
)
return
}
w
.
Write
([]
byte
(
goodResponse
))
_
,
_
=
w
.
Write
([]
byte
(
goodResponse
))
}))
// test case where request eventually succeeds
...
...
@@ -169,7 +170,7 @@ func TestOutOfServiceInterval(t *testing.T) {
defer
shutdown
()
okHandler
:=
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
Write
([]
byte
(
goodResponse
))
_
,
_
=
w
.
Write
([]
byte
(
goodResponse
))
})
badBackend
.
SetHandler
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
WriteHeader
(
503
)
...
...
@@ -190,10 +191,12 @@ func TestOutOfServiceInterval(t *testing.T) {
require
.
Equal
(
t
,
2
,
len
(
badBackend
.
Requests
()))
require
.
Equal
(
t
,
2
,
len
(
goodBackend
.
Requests
()))
res
,
statusCode
,
err
=
client
.
SendBatchRPC
(
_
,
statusCode
,
err
=
client
.
SendBatchRPC
(
NewRPCReq
(
"1"
,
"eth_chainId"
,
nil
),
NewRPCReq
(
"1"
,
"eth_chainId"
,
nil
),
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
200
,
statusCode
)
require
.
Equal
(
t
,
2
,
len
(
badBackend
.
Requests
()))
require
.
Equal
(
t
,
4
,
len
(
goodBackend
.
Requests
()))
...
...
go/proxyd/integration_tests/mock_backend_test.go
View file @
8d5ebf21
...
...
@@ -4,11 +4,12 @@ import (
"bytes"
"context"
"encoding/json"
"github.com/ethereum-optimism/optimism/go/proxyd"
"io/ioutil"
"net/http"
"net/http/httptest"
"sync"
"github.com/ethereum-optimism/optimism/go/proxyd"
)
type
RecordedRequest
struct
{
...
...
@@ -27,7 +28,7 @@ type MockBackend struct {
func
SingleResponseHandler
(
code
int
,
response
string
)
http
.
HandlerFunc
{
return
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
WriteHeader
(
code
)
w
.
Write
([]
byte
(
response
))
_
,
_
=
w
.
Write
([]
byte
(
response
))
}
}
...
...
go/proxyd/integration_tests/rate_limit_test.go
View file @
8d5ebf21
package
integration_tests
import
(
"github.com/ethereum-optimism/optimism/go/proxyd"
"github.com/stretchr/testify/require"
"os"
"testing"
"github.com/ethereum-optimism/optimism/go/proxyd"
"github.com/stretchr/testify/require"
)
type
resWithCode
struct
{
...
...
go/proxyd/integration_tests/util_test.go
View file @
8d5ebf21
...
...
@@ -4,12 +4,13 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/BurntSushi/toml"
"github.com/ethereum-optimism/optimism/go/proxyd"
"github.com/stretchr/testify/require"
"io/ioutil"
"net/http"
"testing"
"github.com/BurntSushi/toml"
"github.com/ethereum-optimism/optimism/go/proxyd"
"github.com/stretchr/testify/require"
)
type
ProxydClient
struct
{
...
...
go/proxyd/integration_tests/validation_test.go
View file @
8d5ebf21
package
integration_tests
import
(
"github.com/ethereum-optimism/optimism/go/proxyd"
"github.com/stretchr/testify/require"
"os"
"strings"
"testing"
"github.com/ethereum-optimism/optimism/go/proxyd"
"github.com/stretchr/testify/require"
)
const
(
...
...
go/proxyd/proxyd.go
View file @
8d5ebf21
...
...
@@ -217,7 +217,11 @@ func Start(config *Config) (func(), error) {
if
config
.
Metrics
.
Enabled
{
addr
:=
fmt
.
Sprintf
(
"%s:%d"
,
config
.
Metrics
.
Host
,
config
.
Metrics
.
Port
)
log
.
Info
(
"starting metrics server"
,
"addr"
,
addr
)
go
http
.
ListenAndServe
(
addr
,
promhttp
.
Handler
())
go
func
()
{
if
err
:=
http
.
ListenAndServe
(
addr
,
promhttp
.
Handler
());
err
!=
nil
{
log
.
Error
(
"error starting metrics server"
,
"err"
,
err
)
}
}()
}
// To allow integration tests to cleanly come up, wait
...
...
go/proxyd/rate_limiter.go
View file @
8d5ebf21
...
...
@@ -5,10 +5,11 @@ import (
"crypto/rand"
"encoding/hex"
"fmt"
"github.com/ethereum/go-ethereum/log"
"github.com/go-redis/redis/v8"
"sync"
"time"
"github.com/ethereum/go-ethereum/log"
"github.com/go-redis/redis/v8"
)
const
MaxRPSScript
=
`
...
...
go/proxyd/rpc_test.go
View file @
8d5ebf21
...
...
@@ -2,8 +2,9 @@ package proxyd
import
(
"encoding/json"
"github.com/stretchr/testify/require"
"testing"
"github.com/stretchr/testify/require"
)
func
TestRPCResJSON
(
t
*
testing
.
T
)
{
...
...
go/proxyd/server.go
View file @
8d5ebf21
...
...
@@ -107,15 +107,15 @@ func (s *Server) WSListenAndServe(host string, port int) error {
func
(
s
*
Server
)
Shutdown
()
{
if
s
.
rpcServer
!=
nil
{
s
.
rpcServer
.
Shutdown
(
context
.
Background
())
_
=
s
.
rpcServer
.
Shutdown
(
context
.
Background
())
}
if
s
.
wsServer
!=
nil
{
s
.
wsServer
.
Shutdown
(
context
.
Background
())
_
=
s
.
wsServer
.
Shutdown
(
context
.
Background
())
}
}
func
(
s
*
Server
)
HandleHealthz
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
Write
([]
byte
(
"OK"
))
_
,
_
=
w
.
Write
([]
byte
(
"OK"
))
}
func
(
s
*
Server
)
HandleRPC
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
...
...
@@ -159,7 +159,7 @@ func (s *Server) HandleRPC(w http.ResponseWriter, r *http.Request) {
return
}
batchRes
:=
make
([]
*
RPCRes
,
len
(
reqs
)
,
len
(
reqs
)
)
batchRes
:=
make
([]
*
RPCRes
,
len
(
reqs
))
var
batchContainsCached
bool
for
i
:=
0
;
i
<
len
(
reqs
);
i
++
{
req
,
err
:=
ParseRPCReq
(
reqs
[
i
])
...
...
@@ -301,7 +301,7 @@ func (s *Server) populateContext(w http.ResponseWriter, r *http.Request) context
}
return
context
.
WithValue
(
r
.
Context
(),
ContextKeyReqID
,
ContextKeyReqID
,
// nolint:staticcheck
randStr
(
10
),
)
}
...
...
@@ -321,11 +321,11 @@ func (s *Server) populateContext(w http.ResponseWriter, r *http.Request) context
}
}
ctx
:=
context
.
WithValue
(
r
.
Context
(),
ContextKeyAuth
,
s
.
authenticatedPaths
[
authorization
])
ctx
=
context
.
WithValue
(
ctx
,
ContextKeyXForwardedFor
,
xff
)
ctx
:=
context
.
WithValue
(
r
.
Context
(),
ContextKeyAuth
,
s
.
authenticatedPaths
[
authorization
])
// nolint:staticcheck
ctx
=
context
.
WithValue
(
ctx
,
ContextKeyXForwardedFor
,
xff
)
// nolint:staticcheck
return
context
.
WithValue
(
ctx
,
ContextKeyReqID
,
ContextKeyReqID
,
// nolint:staticcheck
randStr
(
10
),
)
}
...
...
@@ -413,17 +413,6 @@ func GetXForwardedFor(ctx context.Context) string {
return
xff
}
type
recordLenReader
struct
{
io
.
Reader
Len
int
}
func
(
r
*
recordLenReader
)
Read
(
p
[]
byte
)
(
n
int
,
err
error
)
{
n
,
err
=
r
.
Reader
.
Read
(
p
)
r
.
Len
+=
n
return
}
type
recordLenWriter
struct
{
io
.
Writer
Len
int
...
...
go/teleportr/cmd/teleportr/main.go
View file @
8d5ebf21
go/teleportr/teleportr.go
View file @
8d5ebf21
ops/docker/go-builder/Dockerfile
0 → 100644
View file @
8d5ebf21
FROM
golang:1.17.8-alpine3.15
RUN
apk add
--no-cache
make gcc musl-dev linux-headers git jq curl bash
gzip
ca-certificates openssh
&&
\
go
install
gotest.tools/gotestsum@latest
&&
\
curl
-sSfL
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh
-s
--
-b
$(
go
env
GOPATH
)
/bin v1.44.2
CMD
["bash"]
ops/docker/js-builder/Dockerfile
0 → 100644
View file @
8d5ebf21
FROM
python:3.8.12-slim-buster
RUN
apt-get update
&&
\
apt-get
install
-y
curl openssh-client git build-essential ca-certificates
&&
\
curl
-sL
https://deb.nodesource.com/setup_16.x
-o
nodesource_setup.sh
&&
\
bash nodesource_setup.sh
&&
\
apt-get
install
-y
nodejs
&&
\
npm i
-g
yarn
&&
\
npm i
-g
depcheck
&&
\
pip
install
slither-analyzer
ops/scripts/integration-tests.sh
View file @
8d5ebf21
...
...
@@ -23,4 +23,4 @@ curl \
--output
/dev/null
\
$L2_URL
npx hardhat
test
--network
optimism
--no-compile
npx hardhat
test
--network
optimism
--no-compile
"
$@
"
ops/scripts/wait-for-sequencer.sh
View file @
8d5ebf21
#!/bin/bash
CONTAINER
=
l2geth
RETRIES
=
3
0
RETRIES
=
9
0
i
=
0
until
docker-compose logs l2geth |
grep
-q
"Starting Sequencer Loop"
;
do
sleep
3
sleep
1
if
[
$i
-eq
$RETRIES
]
;
then
echo
'Timed out waiting for sequencer'
break
...
...
packages/contracts/.eslintrc.js
View file @
8d5ebf21
module
.
exports
=
{
extends
:
'
../../.eslintrc.js
'
,
ignorePatterns
:
[
'
src/contract-artifacts.ts
'
,
'
src/contract-deployed-artifacts.ts
'
,
],
}
packages/message-relayer/package.json
View file @
8d5ebf21
...
...
@@ -10,6 +10,7 @@
],
"scripts"
:
{
"start"
:
"ts-node ./src/service.ts"
,
"test:coverage"
:
"echo 'No tests defined.'"
,
"build"
:
"tsc -p ./tsconfig.build.json"
,
"clean"
:
"rimraf dist/ ./tsconfig.build.tsbuildinfo"
,
"lint"
:
"yarn lint:fix && yarn lint:check"
,
...
...
packages/replica-healthcheck/package.json
View file @
8d5ebf21
...
...
@@ -10,6 +10,7 @@
],
"scripts"
:
{
"start"
:
"ts-node ./src/service"
,
"test:coverage"
:
"echo 'No tests defined.'"
,
"build"
:
"tsc -p tsconfig.build.json"
,
"clean"
:
"rimraf ./dist ./tsconfig.build.tsbuildinfo"
,
"lint"
:
"yarn run lint:fix && yarn run lint:check"
,
...
...
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