Skip to content

Commit

Permalink
fix: use websocket for bidder nodes in launch script (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
aloknerurkar authored Jul 17, 2024
1 parent f0d9326 commit e858b05
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,26 @@ server {
}
}

server {
listen 443 ssl http2;

ssl_certificate {{ certificates_dir }}/{{ env }}.{{ environments[env].domain }}.crt;
ssl_certificate_key {{ certificates_dir }}/{{ env }}.{{ environments[env].domain }}.key;

server_name chainrpc-wss.{{ environments[env].domain }};

location / {
proxy_pass http://{{ nomad_server_ip }}:8546;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

server {
listen 443 ssl http2;

Expand Down
6 changes: 3 additions & 3 deletions launchmevcommit
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ BINARY_PATH="${ROOT_PATH}/mev-commit"
# Default mev-commit configuration values.
NODE_TYPE="bidder"
DOMAIN="testnet.mev-commit.xyz"
RPC_URL="https://chainrpc.${DOMAIN}"
RPC_URL="wss://chainrpc-wss.${DOMAIN}"
FAUCET_URL="https://faucet.${DOMAIN}"
BOOTNODE="/dnsaddr/bootnode.${DOMAIN}"
CONTRACTS_URL="https://contracts.${DOMAIN}"
Expand All @@ -24,7 +24,7 @@ fi
# This is useful when running the script in dev environments.
TARGET_MACHINE_IP="__TARGET_MACHINE_IP__"
if [ "${TARGET_MACHINE_IP}" != "__TARGET_MACHINE_IP__" ]; then
RPC_URL="http://${TARGET_MACHINE_IP}:8545"
RPC_URL="ws://${TARGET_MACHINE_IP}:8546"
FAUCET_URL="http://${TARGET_MACHINE_IP}"
CONTRACTS_URL="http://${TARGET_MACHINE_IP}:1010/contracts.json"
TOPOLOGY="$(curl -skL https://${TARGET_MACHINE_IP}:13523/v1/debug/topology)"
Expand Down Expand Up @@ -224,7 +224,7 @@ main() {
chmod +x ${BINARY_PATH}
log_info "Initializing mev-commit..."
${BINARY_PATH} \
--settlement-rpc-endpoint "${RPC_URL}" \
--settlement-ws-rpc-endpoint "${RPC_URL}" \
--peer-type "${NODE_TYPE}" \
--bootnodes "${BOOTNODE}" &
local pid=$!
Expand Down
5 changes: 5 additions & 0 deletions p2p/pkg/rpc/bidder/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ func startServer(t *testing.T) bidderapiv1.BidderClient {

baseServer := grpc.NewServer()
bidderapiv1.RegisterBidderServer(baseServer, srvImpl)
srvStopped := make(chan struct{})
go func() {
defer close(srvStopped)

if err := baseServer.Serve(lis); err != nil {
// Ignore "use of closed network connection" error
if opErr, ok := err.(*net.OpError); !ok || !errors.Is(opErr.Err, net.ErrClosed) {
Expand All @@ -260,6 +263,8 @@ func startServer(t *testing.T) bidderapiv1.BidderClient {
t.Errorf("error closing listener: %v", err)
}
baseServer.Stop()

<-srvStopped
})

client := bidderapiv1.NewBidderClient(conn)
Expand Down
7 changes: 6 additions & 1 deletion p2p/pkg/rpc/provider/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,14 @@ func startServer(t *testing.T) (providerapiv1.ProviderClient, *providerapi.Servi

baseServer := grpc.NewServer()
providerapiv1.RegisterProviderServer(baseServer, srvImpl)
srvStopped := make(chan struct{})
go func() {
defer close(srvStopped)

if err := baseServer.Serve(lis); err != nil {
// Ignore "use of closed network connection" error
if opErr, ok := err.(*net.OpError); !ok || !errors.Is(opErr.Err, net.ErrClosed) {
t.Errorf("server stopped err: %v", err)
t.Logf("server stopped err: %v", err)
}
}
}()
Expand All @@ -117,6 +120,8 @@ func startServer(t *testing.T) (providerapiv1.ProviderClient, *providerapi.Servi
t.Errorf("error closing listener: %v", err)
}
baseServer.Stop()

<-srvStopped
})

client := providerapiv1.NewProviderClient(conn)
Expand Down

0 comments on commit e858b05

Please sign in to comment.