Skip to content

Commit a25ea77

Browse files
authored
chore: remove outdated reasoning of the API definitions comment (#7475)
**Motivation** Forgot to update this as part of #6749, but adding new endpoints is much simpler / cleaner now and everything is inferred from `Endpoint` type definition when adding a new route, it's not possible to forget updating something as typescript will complain (and also spec tests). So instead of updating this I figured it's best to just remove it, looking at the code is much easier to figure out what do to than having to read some text I would put there, eg. see example #7472. **Description** Remove outdated reasoning of the API definitions comment
1 parent eaa83aa commit a25ea77

15 files changed

+0
-68
lines changed

packages/api/src/beacon/routes/beacon/block.ts

-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import {
2727
} from "../../../utils/metadata.js";
2828
import {WireFormat} from "../../../utils/wireFormat.js";
2929

30-
// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes
31-
3230
export const BlockHeaderResponseType = new ContainerType({
3331
root: ssz.Root,
3432
canonical: ssz.Boolean,

packages/api/src/beacon/routes/beacon/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import * as pool from "./pool.js";
77
import * as rewards from "./rewards.js";
88
import * as state from "./state.js";
99

10-
// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes
11-
1210
// NOTE: We choose to split the block, pool, state and rewards namespaces so the files are not too big.
1311
// However, for a consumer all these methods are within the same service "beacon"
1412
export {block, pool, state, rewards};

packages/api/src/beacon/routes/beacon/pool.ts

-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import {fromHeaders} from "../../../utils/headers.js";
2727
import {Endpoint, RouteDefinitions, Schema} from "../../../utils/index.js";
2828
import {MetaHeader, VersionCodec, VersionMeta} from "../../../utils/metadata.js";
2929

30-
// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes
31-
3230
const SingleAttestationListTypePhase0 = ArrayOf(ssz.phase0.Attestation);
3331
const SingleAttestationListTypeElectra = ArrayOf(ssz.electra.SingleAttestation);
3432
const AttestationListTypePhase0 = ArrayOf(ssz.phase0.Attestation);

packages/api/src/beacon/routes/beacon/rewards.ts

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import {fromValidatorIdsStr, toValidatorIdsStr} from "../../../utils/serdes.js";
99
import {BlockArgs} from "./block.js";
1010
import {ValidatorId} from "./state.js";
1111

12-
// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes
13-
1412
const BlockRewardsType = new ContainerType(
1513
{
1614
/** Proposer of the block, the proposer index who receives these rewards */

packages/api/src/beacon/routes/beacon/state.ts

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import {fromValidatorIdsStr, toValidatorIdsStr} from "../../../utils/serdes.js";
1414
import {WireFormat} from "../../../utils/wireFormat.js";
1515
import {RootResponse, RootResponseType} from "./block.js";
1616

17-
// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes
18-
1917
export type StateId = RootHex | Slot | "head" | "genesis" | "finalized" | "justified";
2018

2119
export type StateArgs = {

packages/api/src/beacon/routes/config.ts

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import {
1212
} from "../../utils/codecs.js";
1313
import {Endpoint, RouteDefinitions} from "../../utils/index.js";
1414

15-
// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes
16-
1715
export const DepositContractType = new ContainerType(
1816
{
1917
chainId: ssz.UintNum64,

packages/api/src/beacon/routes/debug.ts

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import {Endpoint, RouteDefinitions} from "../../utils/types.js";
1919
import {WireFormat} from "../../utils/wireFormat.js";
2020
import {StateArgs} from "./beacon/state.js";
2121

22-
// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes
23-
2422
const stringType = new StringType();
2523
const ProtoNodeType = new ContainerType(
2624
{

packages/api/src/beacon/routes/events.ts

-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import {getPostAltairForkTypes, getPostBellatrixForkTypes} from "../../utils/for
2525
import {Endpoint, RouteDefinitions, Schema} from "../../utils/index.js";
2626
import {VersionType} from "../../utils/metadata.js";
2727

28-
// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes
29-
3028
const stringType = new StringType();
3129
export const blobSidecarSSE = new ContainerType(
3230
{

packages/api/src/beacon/routes/index.ts

-40
Original file line numberDiff line numberDiff line change
@@ -30,43 +30,3 @@ export type Endpoints = {
3030
proof: ProofEndpoints;
3131
validator: ValidatorEndpoints;
3232
};
33-
34-
// TODO: update to reflect new design
35-
// Reasoning of the API definitions
36-
// ================================
37-
//
38-
// An HTTP request to the Lodestar BeaconNode API involves these steps regarding serialization:
39-
// 1. Serialize request: api args => req params
40-
// --- wire
41-
// 2. Deserialize request: req params => api args
42-
// --- exec api
43-
// 3. Serialize api return => res body
44-
// --- wire
45-
// 4. Deserialize res body => api return
46-
//
47-
// In our case we define the client in the exact same interface as the API executor layer.
48-
// Therefore we only need to define how to translate args <-> request, and return <-> response.
49-
//
50-
// All files in the /routes directory provide succinct definitions to do those transformations plus:
51-
// - URL + method, for each route ID
52-
// - Runtime schema, for each route ID
53-
//
54-
// Almost all routes receive JSON and return JSON. So both the client and the server can be
55-
// auto-generated from the definitions. Also, the design allows for customizability for the few
56-
// routes that need non-JSON serialization (like debug.getState and lightclient.getProof)
57-
//
58-
// With this approach Typescript help us ensure that the client and server are compatible at build
59-
// time, ensure there are tests for all routes and makes it very cheap to maintain and add new routes.
60-
//
61-
//
62-
// How to add new routes
63-
// =====================
64-
//
65-
// 1. Add the route function signature to the `Api` type. The function name MUST match the routeId from the spec.
66-
// The arguments should use spec types if appropriate. Non-spec types MUST be defined in before the Api type
67-
// so they are scoped by routes namespace. The all arguments MUST use camelCase casing.
68-
// 2. Add URL + METHOD in `routesData` matching the spec.
69-
// 3. Declare request serializers in `getReqSerializers()`. You MAY use `RouteReqTypeGenerator` to declare the
70-
// ReqTypes and request serializers in the same place.
71-
// 4. Add the return type of the route to `getReturnTypes()` if it has any. The return type doesn't have to be
72-
// a full SSZ type, but just a TypeJson with allows to convert from struct -> json -> struct.

packages/api/src/beacon/routes/lightclient.ts

-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import {getPostAltairForkTypes, toForkName} from "../../utils/fork.js";
2323
import {Endpoint, RouteDefinitions, Schema} from "../../utils/index.js";
2424
import {MetaHeader, VersionCodec, VersionMeta} from "../../utils/metadata.js";
2525

26-
// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes
27-
2826
export const HashListType = new ListCompositeType(ssz.Root, 10000);
2927
export type HashList = ValueOf<typeof HashListType>;
3028

packages/api/src/beacon/routes/lodestar.ts

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import {Endpoint, RouteDefinitions, Schema} from "../../utils/index.js";
1616
import {StateArgs} from "./beacon/state.js";
1717
import {FilterGetPeers, NodePeer, PeerDirection, PeerState} from "./node.js";
1818

19-
// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes
20-
2119
export type SyncChainDebugState = {
2220
targetRoot: string | null;
2321
targetSlot: number | null;

packages/api/src/beacon/routes/node.ts

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import {HttpStatusCode} from "../../utils/httpStatusCode.js";
1616
import {Endpoint, RouteDefinitions, Schema} from "../../utils/index.js";
1717
import {WireFormat} from "../../utils/wireFormat.js";
1818

19-
// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes
20-
2119
export const NetworkIdentityType = new ContainerType(
2220
{
2321
/** Cryptographic hash of a peer’s public key. [Read more](https://docs.libp2p.io/concepts/peer-id/) */

packages/api/src/beacon/routes/proof.ts

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ export const CompactMultiProofType = new ContainerType({
1212
descriptor: new ByteListType(2048),
1313
});
1414

15-
// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes
16-
1715
export type Endpoints = {
1816
/**
1917
* Returns a multiproof of `descriptor` at the requested `stateId`.

packages/api/src/beacon/routes/validator.ts

-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ import {
4545
} from "../../utils/metadata.js";
4646
import {fromGraffitiHex, toBoolean, toGraffitiHex} from "../../utils/serdes.js";
4747

48-
// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes
49-
5048
export enum BuilderSelection {
5149
Default = "default",
5250
BuilderAlways = "builderalways",

packages/api/src/builder/routes.ts

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ import {fromHeaders} from "../utils/headers.js";
3030
import {Endpoint, RouteDefinitions, Schema} from "../utils/index.js";
3131
import {MetaHeader, VersionCodec, VersionMeta} from "../utils/metadata.js";
3232

33-
// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes
34-
3533
// Mev-boost might not return any data if there are no bids from builders or min-bid threshold was not reached.
3634
// In this case, we receive a success response (204) which is not handled as an error. The generic response
3735
// handler already checks the status code and will not attempt to parse the body, but it will return no value.

0 commit comments

Comments
 (0)