diff --git a/infrastructure/nomad/playbooks/templates/services/mev-commit.xyz.hcl.j2 b/infrastructure/nomad/playbooks/templates/services/mev-commit.xyz.hcl.j2 index 8083050b1..2cd45dad2 100644 --- a/infrastructure/nomad/playbooks/templates/services/mev-commit.xyz.hcl.j2 +++ b/infrastructure/nomad/playbooks/templates/services/mev-commit.xyz.hcl.j2 @@ -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; diff --git a/launchmevcommit b/launchmevcommit index 10b538448..6966dcbca 100755 --- a/launchmevcommit +++ b/launchmevcommit @@ -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}" @@ -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)" @@ -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=$! diff --git a/p2p/pkg/rpc/bidder/service_test.go b/p2p/pkg/rpc/bidder/service_test.go index c00165672..16a3c8f94 100644 --- a/p2p/pkg/rpc/bidder/service_test.go +++ b/p2p/pkg/rpc/bidder/service_test.go @@ -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) { @@ -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) diff --git a/p2p/pkg/rpc/provider/service_test.go b/p2p/pkg/rpc/provider/service_test.go index abe6a0764..67c92222a 100644 --- a/p2p/pkg/rpc/provider/service_test.go +++ b/p2p/pkg/rpc/provider/service_test.go @@ -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) } } }() @@ -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)