Restore WS compression fix, self-heal, and gossip-host fix
Browse files
app.js
CHANGED
|
@@ -4,12 +4,23 @@ const { spawn } = require("child_process");
|
|
| 4 |
|
| 5 |
const app = express();
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
// Ethereum (Anvil) - serves JSON-RPC and WebSocket on the same port
|
| 8 |
app.use("/eth", createProxyMiddleware({
|
| 9 |
target: "http://127.0.0.1:8545",
|
| 10 |
changeOrigin: true,
|
| 11 |
ws: true,
|
| 12 |
-
pathRewrite: { "^/eth": "" }
|
|
|
|
| 13 |
}));
|
| 14 |
|
| 15 |
// Rootstock (Anvil) - serves JSON-RPC and WebSocket on the same port
|
|
@@ -17,7 +28,8 @@ app.use("/rootstock", createProxyMiddleware({
|
|
| 17 |
target: "http://127.0.0.1:8546",
|
| 18 |
changeOrigin: true,
|
| 19 |
ws: true,
|
| 20 |
-
pathRewrite: { "^/rootstock": "" }
|
|
|
|
| 21 |
}));
|
| 22 |
|
| 23 |
// Solana - JSON-RPC on 8899, pubsub/WebSocket on a separate port (8900 by
|
|
@@ -31,7 +43,8 @@ app.use("/solana", createProxyMiddleware({
|
|
| 31 |
req.headers.upgrade && req.headers.upgrade.toLowerCase() === "websocket"
|
| 32 |
? "http://127.0.0.1:8900"
|
| 33 |
: "http://127.0.0.1:8899"
|
| 34 |
-
)
|
|
|
|
| 35 |
}));
|
| 36 |
|
| 37 |
// Per-chain log files written by start.sh
|
|
|
|
| 4 |
|
| 5 |
const app = express();
|
| 6 |
|
| 7 |
+
// http-proxy-middleware (via node http-proxy) doesn't correctly relay
|
| 8 |
+
// permessage-deflate compression negotiation for proxied WebSocket upgrades,
|
| 9 |
+
// which causes clients to reject compressed frames from the upstream node
|
| 10 |
+
// with "Invalid WebSocket frame: RSV1 must be clear". Stripping the
|
| 11 |
+
// extension request header prevents compression from being negotiated at
|
| 12 |
+
// all, avoiding the mismatch entirely.
|
| 13 |
+
function stripWsCompression(proxyReq) {
|
| 14 |
+
proxyReq.removeHeader("sec-websocket-extensions");
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
// Ethereum (Anvil) - serves JSON-RPC and WebSocket on the same port
|
| 18 |
app.use("/eth", createProxyMiddleware({
|
| 19 |
target: "http://127.0.0.1:8545",
|
| 20 |
changeOrigin: true,
|
| 21 |
ws: true,
|
| 22 |
+
pathRewrite: { "^/eth": "" },
|
| 23 |
+
on: { proxyReqWs: stripWsCompression }
|
| 24 |
}));
|
| 25 |
|
| 26 |
// Rootstock (Anvil) - serves JSON-RPC and WebSocket on the same port
|
|
|
|
| 28 |
target: "http://127.0.0.1:8546",
|
| 29 |
changeOrigin: true,
|
| 30 |
ws: true,
|
| 31 |
+
pathRewrite: { "^/rootstock": "" },
|
| 32 |
+
on: { proxyReqWs: stripWsCompression }
|
| 33 |
}));
|
| 34 |
|
| 35 |
// Solana - JSON-RPC on 8899, pubsub/WebSocket on a separate port (8900 by
|
|
|
|
| 43 |
req.headers.upgrade && req.headers.upgrade.toLowerCase() === "websocket"
|
| 44 |
? "http://127.0.0.1:8900"
|
| 45 |
: "http://127.0.0.1:8899"
|
| 46 |
+
),
|
| 47 |
+
on: { proxyReqWs: stripWsCompression }
|
| 48 |
}));
|
| 49 |
|
| 50 |
// Per-chain log files written by start.sh
|
start.sh
CHANGED
|
@@ -27,10 +27,28 @@ anvil --host 0.0.0.0 --port 8546 --chain-id 30 \
|
|
| 27 |
rm -f /data/solana/ledger.lock
|
| 28 |
solana-test-validator \
|
| 29 |
--ledger /data/solana \
|
|
|
|
| 30 |
--log \
|
| 31 |
> >(tee -a /data/logs/solana.log) 2>&1 &
|
| 32 |
SOLANA_PID=$!
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
# Wait a bit for chains to start
|
| 35 |
sleep 3
|
| 36 |
|
|
|
|
| 27 |
rm -f /data/solana/ledger.lock
|
| 28 |
solana-test-validator \
|
| 29 |
--ledger /data/solana \
|
| 30 |
+
--gossip-host 127.0.0.1 \
|
| 31 |
--log \
|
| 32 |
> >(tee -a /data/logs/solana.log) 2>&1 &
|
| 33 |
SOLANA_PID=$!
|
| 34 |
|
| 35 |
+
# A restart that catches the ledger mid-write can leave it corrupted, which
|
| 36 |
+
# makes the validator panic on boot every time thereafter ("Failed to
|
| 37 |
+
# process bank 0 from ledger ... InvalidBlock(Incomplete)"), permanently
|
| 38 |
+
# stuck in a crash loop. Detect an early exit and wipe the ledger to start
|
| 39 |
+
# fresh from genesis once, rather than looping on the same panic forever.
|
| 40 |
+
sleep 5
|
| 41 |
+
if ! kill -0 $SOLANA_PID 2>/dev/null; then
|
| 42 |
+
echo "WARNING: solana-test-validator crashed on boot (likely a corrupted ledger). Wiping /data/solana and retrying from genesis." >> /data/logs/solana.log
|
| 43 |
+
rm -rf /data/solana
|
| 44 |
+
mkdir -p /data/solana
|
| 45 |
+
solana-test-validator \
|
| 46 |
+
--ledger /data/solana \
|
| 47 |
+
--log \
|
| 48 |
+
> >(tee -a /data/logs/solana.log) 2>&1 &
|
| 49 |
+
SOLANA_PID=$!
|
| 50 |
+
fi
|
| 51 |
+
|
| 52 |
# Wait a bit for chains to start
|
| 53 |
sleep 3
|
| 54 |
|