Skip to content

Commit

Permalink
fix: add workaround to fix compatibility with go-eth2-client (#6953)
Browse files Browse the repository at this point in the history
* fix: add workaround to fix compatibility with go-eth2-client

* Skip more endpoints

* Move comments around

* Fix assertion
  • Loading branch information
nflaig authored Jul 15, 2024
1 parent c3d7f2f commit 7489135
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/beacon-node/src/api/rest/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ export class RestApiServer {
const operationId = getOperationId(req);
this.logger.debug(`Req ${req.id} ${req.ip} ${operationId}`);
metrics?.requests.inc({operationId});

// Workaround to fix compatibility with go-eth2-client
// See https://github.com/attestantio/go-eth2-client/issues/144
if (
// go-eth2-client supports handling SSZ data in response for these endpoints
!["produceBlindedBlock", "produceBlockV3", "getBlockV2", "getStateV2"].includes(operationId) &&
// Only Vouch seems to override default header
["Go-http-client", "Vouch"].includes(req.headers["user-agent"]?.split("/")[0] ?? "")
) {
// Override Accept header to force server to return JSON
req.headers.accept = "application/json";
}
});

server.addHook("preHandler", async (req, _res) => {
Expand Down

0 comments on commit 7489135

Please sign in to comment.