-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add getLedgers endpoint #111
Comments
@janewang can you give some context on what use cases we expect this endpoint to be supporting? Asking because RPC does not currently save the ledger header info (just meta associated with a ledger), so this will be more data we'll need to start storing. Given that, and taking a critical look at all the info here, I'm not sure why a lot of it would be necessary. I think sequence/closed_at and possibly the tx counts have real uses, but not sure about all the other stuff. I also only just realized that the info Horizon's API exposes is not exhaustive of all the fields in the ledger header (see here). So it'd be good to have your perspective on what fields we should include here. |
Yes, we typically use That said, information such as block-level fees, ledger close (finality), and the state of the chain at a point in time comes from block-level data. Theoretically, any state transition applied to that block level should be reproducible. In other L1s, most RPCs ask developers to query Regarding the header, do we store the |
Btw, I think ledger headers should be stored. I have seen RPC on other L1s storing the headers as well as downloading headers first before downloading blocks. |
RPC does not currently save the ledger header xdr, no. So then, are all the fields in the Response format example in the description necessary? And/or do we want to include any additional fields from the ledger header?
It sounds to me like you're saying here that we don't have to include the transaction hashes in this API, but correct me if I'm misunderstanding that. |
They are not all necessary but we could simply unpack the XDR and show them. I listed the ones I think we should include for sure.
|
On the Horizon API, we provide a href to the transactions of this ledger:
We could do the above. If not, we should return a list of transaction hashes, and the user could iterate via |
@janewang we're about ready to start work on this but I wanted to kick off the schema discussion again so that we're all on the same page. Since we have xdr2json support now via // request: getLedgers(startLedger, pagination?: { limit; cursor });
// response:
interface GetLedgersResponse {
ledgers: LedgerResponse[];
latestLedger: number;
latestLedgerCloseTime: number;
oldestLedger: number;
oldestLedgerCloseTime: number;
cursor: string;
}
interface LedgerResponse {
hash: string;
sequence: number;
closeTime: number;
closeMeta: string; // xdr.LedgerCloseMeta
header: string; // xdr.LedgerHeader
}; Users interested in the details of each field in this response can just use JSON expansion, while anyone programmatically interested can derive all data from the header or its parent meta. If a user is interested in doing transaction pagination, we can also return a single |
This makes sense to me, unpacking |
@Shaptic +1 on the response schema. However, I dont understand the |
@aditya1702 oh yeah, good point! Since transactions are more granular than ledgers, the cursor would always point to the beginning. I was just thinking of a way to address @janewang's concern about ledger -> transaction pagination but you're right that it's just One thing I would like to highly recommend we do, for this and all other endpoints, is to elaborate in detail how to inspect commonly-necessary fields using the SDKs. We can add this to the documentation for every endpoint accordingly. For example, if a user wants the transaction hashes, transaction envelopes, operation counts, etc. we should outline how to extract them out of the metadata. Also, just to clarify: the curl ... { ..., "xdrFormat": "json", ... } | jq '.ledgers[] | .ledgerHeader' We can just keep it deep in the meta as well if folks would like. |
@Shaptic Yes definitely. This will be very helpful for the partners and anyone trying to get info from XDRs. Yeah I agree, we should add it in the response even if it is present in meta |
Users need to be able to page through all ledgers available in RPC's retention window. The
getLedgers
endpoint should be able to support pagination and should provide all ledger header fields, similar to Horizon'sledgers
endpointScope for this will be limited to simple pagination with no filters, and we will work/propose additional filters on this as separate issues.
Request format
Response format
The above example represents all fields that are currently in Horizon's response. However, we should assess whether all of these are necessary for RPC.
The text was updated successfully, but these errors were encountered: