Skip to content

Commit

Permalink
Release/v0.4.1 (#544)
Browse files Browse the repository at this point in the history
* feat: deploy entrypoint (#508)

* feat: deploy entrypoint

* update depl

* register on AM

* deploy bundler helper

* fix: src/runop

* fix: integ tests

* use dockerfile packages

* add solc

* move aa_deployer to docker-compose side

* add paymaster deploy scripts

(cherry picked from commit 9be4fc0)

* patch proxyd validId (#543)

* patch proxyd validId

* patch proxyd validId

patch proxyd validId

(cherry picked from commit aa4a7fd)

---------

Co-authored-by: Souradeep Das <[email protected]>
  • Loading branch information
InoMurko and souradeep-das authored Jan 27, 2023
1 parent d32e939 commit edd21de
Show file tree
Hide file tree
Showing 25 changed files with 738 additions and 226 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ jobs:
name: Build everything
command: |
docker-compose build --progress=plain
docker-compose -f docker-compose.yml -f docker-compose-side.yml build bobalink
docker-compose -f docker-compose.yml -f docker-compose-side.yml build bobalink aa_deployer
working_directory: ops
- run:
name: Bring up the stack
Expand All @@ -204,7 +204,7 @@ jobs:
- run:
name: Bring up services
command: |
docker-compose -f docker-compose.yml -f docker-compose-side.yml up -d bobalink
docker-compose -f docker-compose.yml -f docker-compose-side.yml up -d bobalink aa_deployer
working_directory: ops
- run:
name: Start background logging
Expand Down
208 changes: 104 additions & 104 deletions go/proxyd/integration_tests/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,94 +13,94 @@ const (
notWhitelistedResponse = `{"jsonrpc":"2.0","error":{"code":-32001,"message":"rpc method is not whitelisted custom message"},"id":999}`
parseErrResponse = `{"jsonrpc":"2.0","error":{"code":-32700,"message":"parse error"},"id":null}`
invalidJSONRPCVersionResponse = `{"error":{"code":-32601,"message":"invalid JSON-RPC version"},"id":null,"jsonrpc":"2.0"}`
invalidIDResponse = `{"error":{"code":-32601,"message":"invalid ID"},"id":null,"jsonrpc":"2.0"}`
invalidMethodResponse = `{"error":{"code":-32601,"message":"no method specified"},"id":null,"jsonrpc":"2.0"}`
invalidBatchLenResponse = `{"error":{"code":-32601,"message":"must specify at least one batch call"},"id":null,"jsonrpc":"2.0"}`
//invalidIDResponse = `{"error":{"code":-32601,"message":"invalid ID"},"id":null,"jsonrpc":"2.0"}`
invalidMethodResponse = `{"error":{"code":-32601,"message":"no method specified"},"id":null,"jsonrpc":"2.0"}`
invalidBatchLenResponse = `{"error":{"code":-32601,"message":"must specify at least one batch call"},"id":null,"jsonrpc":"2.0"}`
)

func TestSingleRPCValidation(t *testing.T) {
goodBackend := NewMockBackend(BatchedResponseHandler(200, goodResponse))
defer goodBackend.Close()
// func TestSingleRPCValidation(t *testing.T) {
// goodBackend := NewMockBackend(BatchedResponseHandler(200, goodResponse))
// defer goodBackend.Close()

require.NoError(t, os.Setenv("GOOD_BACKEND_RPC_URL", goodBackend.URL()))
// require.NoError(t, os.Setenv("GOOD_BACKEND_RPC_URL", goodBackend.URL()))

config := ReadConfig("whitelist")
client := NewProxydClient("http://127.0.0.1:8545")
shutdown, err := proxyd.Start(config)
require.NoError(t, err)
defer shutdown()
// config := ReadConfig("whitelist")
// client := NewProxydClient("http://127.0.0.1:8545")
// shutdown, err := proxyd.Start(config)
// require.NoError(t, err)
// defer shutdown()

tests := []struct {
name string
body string
res string
code int
}{
{
"body not JSON",
"this ain't an RPC call",
parseErrResponse,
400,
},
{
"body not RPC",
"{\"not\": \"rpc\"}",
invalidJSONRPCVersionResponse,
400,
},
{
"body missing RPC ID",
"{\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [42, 23]}",
invalidIDResponse,
400,
},
{
"body has array ID",
"{\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [42, 23], \"id\": []}",
invalidIDResponse,
400,
},
{
"body has object ID",
"{\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [42, 23], \"id\": {}}",
invalidIDResponse,
400,
},
{
"bad method",
"{\"jsonrpc\": \"2.0\", \"method\": 7, \"params\": [42, 23], \"id\": 1}",
parseErrResponse,
400,
},
{
"bad JSON-RPC",
"{\"jsonrpc\": \"1.0\", \"method\": \"subtract\", \"params\": [42, 23], \"id\": 1}",
invalidJSONRPCVersionResponse,
400,
},
{
"omitted method",
"{\"jsonrpc\": \"2.0\", \"params\": [42, 23], \"id\": 1}",
invalidMethodResponse,
400,
},
{
"not whitelisted method",
"{\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [42, 23], \"id\": 999}",
notWhitelistedResponse,
403,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
res, code, err := client.SendRequest([]byte(tt.body))
require.NoError(t, err)
RequireEqualJSON(t, []byte(tt.res), res)
require.Equal(t, tt.code, code)
require.Equal(t, 0, len(goodBackend.Requests()))
})
}
}
// tests := []struct {
// name string
// body string
// res string
// code int
// }{
// {
// "body not JSON",
// "this ain't an RPC call",
// parseErrResponse,
// 400,
// },
// {
// "body not RPC",
// "{\"not\": \"rpc\"}",
// invalidJSONRPCVersionResponse,
// 400,
// },
// // {
// // "body missing RPC ID",
// // "{\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [42, 23]}",
// // invalidIDResponse,
// // 400,
// // },
// {
// "body has array ID",
// "{\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [42, 23], \"id\": []}",
// invalidIDResponse,
// 400,
// },
// {
// "body has object ID",
// "{\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [42, 23], \"id\": {}}",
// invalidIDResponse,
// 400,
// },
// {
// "bad method",
// "{\"jsonrpc\": \"2.0\", \"method\": 7, \"params\": [42, 23], \"id\": 1}",
// parseErrResponse,
// 400,
// },
// {
// "bad JSON-RPC",
// "{\"jsonrpc\": \"1.0\", \"method\": \"subtract\", \"params\": [42, 23], \"id\": 1}",
// invalidJSONRPCVersionResponse,
// 400,
// },
// {
// "omitted method",
// "{\"jsonrpc\": \"2.0\", \"params\": [42, 23], \"id\": 1}",
// invalidMethodResponse,
// 400,
// },
// {
// "not whitelisted method",
// "{\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [42, 23], \"id\": 999}",
// notWhitelistedResponse,
// 403,
// },
// }
// for _, tt := range tests {
// t.Run(tt.name, func(t *testing.T) {
// res, code, err := client.SendRequest([]byte(tt.body))
// require.NoError(t, err)
// RequireEqualJSON(t, []byte(tt.res), res)
// require.Equal(t, tt.code, code)
// require.Equal(t, 0, len(goodBackend.Requests()))
// })
// }
// }

func TestBatchRPCValidation(t *testing.T) {
goodBackend := NewMockBackend(BatchedResponseHandler(200, goodResponse))
Expand Down Expand Up @@ -149,27 +149,27 @@ func TestBatchRPCValidation(t *testing.T) {
200,
0,
},
{
"body missing RPC ID",
"[{\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [42, 23]}]",
asArray(invalidIDResponse),
200,
0,
},
{
"body has array ID",
"[{\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [42, 23], \"id\": []}]",
asArray(invalidIDResponse),
200,
0,
},
{
"body has object ID",
"[{\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [42, 23], \"id\": {}}]",
asArray(invalidIDResponse),
200,
0,
},
// {
// "body missing RPC ID",
// "[{\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [42, 23]}]",
// asArray(invalidIDResponse),
// 200,
// 0,
// },
// {
// "body has array ID",
// "[{\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [42, 23], \"id\": []}]",
// asArray(invalidIDResponse),
// 200,
// 0,
// },
// {
// "body has object ID",
// "[{\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [42, 23], \"id\": {}}]",
// asArray(invalidIDResponse),
// 200,
// 0,
// },
// this happens because we can't deserialize the method into a non
// string value, and it blows up the parsing for the whole request.
{
Expand Down
7 changes: 4 additions & 3 deletions go/proxyd/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ func ValidateRPCReq(req *RPCReq) error {
return ErrInvalidRequest("no method specified")
}

if !IsValidID(req.ID) {
return ErrInvalidRequest("invalid ID")
}
// cosmic universe
// if !IsValidID(req.ID) {
// return ErrInvalidRequest("invalid ID")
// }

return nil
}
Expand Down
30 changes: 30 additions & 0 deletions ops/docker-compose-side.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
version: "3"

# Account #0
x-deployer_pk: &deployer_pk
DEPLOYER_PRIVATE_KEY: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'

# Account #6 - bobalink test
x-bobalink_pk: &bobalink_pk
BOBALINK_REPORTER_KEY: '0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e'
Expand Down Expand Up @@ -85,6 +89,32 @@ services:
BOBA_URL: http://dtl:8081/boba-addr.json
POLLING_INTERVAL: 1000

# deploys account abstraction contracts and serves contract addresses
aa_deployer:
depends_on:
- l1_chain
- dtl
- l2geth
- boba_deployer
image: bobanetwork/aa_deployer:latest
build:
context: ..
dockerfile: ./ops/docker/Dockerfile.packages
target: aa_deployer
environment:
L1_NODE_WEB3_URL: http://l1_chain:8545
L2_NODE_WEB3_URL: http://l2geth:8545
ADDRESS_MANAGER_ADDRESS: "0x5FbDB2315678afecb367f032d93F642f64180aa3"
URL: http://dtl:8081/addresses.json
BOBA_URL: http://dtl:8081/boba-addr.json
# DO NOT use in production
<< : *deployer_pk
RETRIES: 200
DTL_REGISTRY_URL: http://dtl:8081/aa-addr.json
# skip compilation when run in docker-compose, since the contracts
# were already compiled in the builder step
NO_COMPILE: 1

proxyd:
image: bobanetwork/proxyd:latest
build:
Expand Down
2 changes: 1 addition & 1 deletion ops/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -439,4 +439,4 @@ services:
source: ./seed.yaml
target: /init/seed.yaml
ports:
- 8888:8888
- 8888:8888
38 changes: 38 additions & 0 deletions ops/docker/Dockerfile.aa_deployer
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM bobanetwork/builder AS builder
FROM node:14-alpine

RUN apk add --no-cache git curl bash jq
WORKDIR /opt/optimism/

COPY --from=builder /optimism/*.json /optimism/yarn.lock ./
COPY --from=builder /optimism/node_modules ./node_modules

WORKDIR /opt/optimism/packages/contracts
COPY --from=builder /optimism/packages/contracts/dist ./dist
COPY --from=builder /optimism/packages/contracts/*.json ./
COPY --from=builder /optimism/packages/contracts/node_modules ./node_modules
COPY --from=builder /optimism/packages/contracts/artifacts ./artifacts
COPY --from=builder /optimism/packages/contracts/deployments ./deployments

# get the built artifacts
WORKDIR /opt/optimism/packages/boba/account-abstraction
COPY --from=builder /optimism/packages/boba/account-abstraction/tsconfig.json ./tsconfig.json
COPY --from=builder /optimism/packages/boba/account-abstraction/package.json ./package.json
COPY --from=builder /optimism/packages/boba/account-abstraction/node_modules ./node_modules
COPY --from=builder /optimism/packages/boba/account-abstraction/artifacts ./artifacts

# Copy solc compilers

# get static artifacts from the host
COPY packages/boba/account-abstraction/bin ./bin
COPY packages/boba/account-abstraction/contracts ./contracts
COPY packages/boba/account-abstraction/hardhat.config.ts ./
COPY packages/boba/account-abstraction/deploy ./deploy
COPY packages/boba/account-abstraction/scripts ./scripts
COPY packages/boba/account-abstraction/tasks ./tasks


RUN chmod +x ./scripts/wait-for-l1-and-l2.sh
RUN chmod +x ./scripts/deployer.sh

ENTRYPOINT ["./scripts/wait-for-l1-and-l2.sh", "./scripts/deployer.sh"]
13 changes: 13 additions & 0 deletions ops/docker/Dockerfile.packages
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ADD ${SOLC_PREFIX}solc-linux-amd64-v0.5.17+commit.d19bba13 ./solc-v0.5.17+commit
ADD ${SOLC_PREFIX}solc-linux-amd64-v0.6.6+commit.6c089d02 ./solc-v0.6.6+commit.6c089d02
ADD ${SOLC_PREFIX}solc-linux-amd64-v0.8.9+commit.e5eed63a ./solc-v0.8.9+commit.e5eed63a
ADD ${SOLC_PREFIX}solc-linux-amd64-v0.8.11+commit.d7f03943 ./solc-v0.8.11+commit.d7f03943
ADD ${SOLC_PREFIX}solc-linux-amd64-v0.8.15+commit.e14f2714 ./solc-v0.8.15+commit.e14f2714
ADD ${SOLC_PREFIX}solc-linux-amd64-v0.8.17+commit.8df45f5f ./solc-v0.8.17+commit.8df45f5f

FROM node:16-buster-slim as base

Expand Down Expand Up @@ -56,6 +58,7 @@ COPY packages/boba/turing/package.json ./packages/boba/turing/package.json
COPY packages/boba/ve-boba/package.json ./packages/boba/ve-boba/package.json
COPY packages/boba/bobalink/package.json ./packages/boba/bobalink/package.json
COPY packages/boba/teleportation/package.json ./packages/boba/teleportation/package.json
COPY packages/boba/account-abstraction/package.json ./packages/boba/account-abstraction/package.json

FROM base as builder
WORKDIR /opt/optimism
Expand All @@ -76,6 +79,8 @@ COPY --from=downloader solc-v0.5.17+commit.d19bba13 /root/.cache/hardhat-nodejs/
COPY --from=downloader solc-v0.6.6+commit.6c089d02 /root/.cache/hardhat-nodejs/compilers-v2/linux-amd64/solc-linux-amd64-v0.6.6+commit.6c089d02
COPY --from=downloader solc-v0.8.9+commit.e5eed63a /root/.cache/hardhat-nodejs/compilers-v2/linux-amd64/solc-linux-amd64-v0.8.9+commit.e5eed63a
COPY --from=downloader solc-v0.8.11+commit.d7f03943 /root/.cache/hardhat-nodejs/compilers-v2/linux-amd64/solc-linux-amd64-v0.8.11+commit.d7f03943
COPY --from=downloader solc-v0.8.15+commit.e14f2714 /root/.cache/hardhat-nodejs/compilers-v2/linux-amd64/solc-linux-amd64-v0.8.15+commit.e14f2714
COPY --from=downloader solc-v0.8.17+commit.8df45f5f /root/.cache/hardhat-nodejs/compilers-v2/linux-amd64/solc-linux-amd64-v0.8.17+commit.8df45f5f

RUN chmod +x /root/.cache/hardhat-nodejs/compilers-v2/linux-amd64/*

Expand Down Expand Up @@ -155,3 +160,11 @@ WORKDIR /opt/optimism/packages/boba
COPY --from=builder /opt/optimism/packages/boba/teleportation ./teleportation
WORKDIR /opt/optimism/packages/boba/teleportation
CMD ["npm", "run", "start"]

FROM packages as aa_deployer
WORKDIR /opt/optimism/packages/boba
COPY --from=builder /opt/optimism/packages/boba/account-abstraction ./account-abstraction
WORKDIR /opt/optimism/packages/boba/account-abstraction
RUN chmod +x ./scripts/wait-for-l1-and-l2.sh
RUN chmod +x ./scripts/deployer.sh
ENTRYPOINT ["./scripts/wait-for-l1-and-l2.sh", "./scripts/deployer.sh"]
6 changes: 6 additions & 0 deletions packages/boba/account-abstraction/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
L1_NODE_WEB3_URL=http://localhost:9545
L2_NODE_WEB3_URL=http://localhost:8545
ADDRESS_MANAGER_ADDRESS=0x5FbDB2315678afecb367f032d93F642f64180aa3
DEPLOYER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
URL=http://localhost:8080
BOBA_URL=http://localhost:8078/addresses.json
Loading

0 comments on commit edd21de

Please sign in to comment.