Skip to content
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

zoneconcierge API: adding total number of timestamped headers to chainInfo #263

Merged
merged 2 commits into from
Jan 9, 2023

Conversation

SebastianElvis
Copy link
Member

@SebastianElvis SebastianElvis commented Jan 9, 2023

Fixes BE-16

This PR adds an extra field TimestampedHeadersCount to ChainInfo in order to track the total number of timestamped headers for a given CZ. This allows the explorer to give statistics of CZs, as proposed in https://babylon-chain.atlassian.net/wiki/spaces/BABYLON/pages/50955614/The+Oracle#2.2-The-Timestamp-Finder-Tab.

Along the way this PR also adds some comments to document the functions.

Copy link
Member

@vitsalis vitsalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

func (k Keeper) updateLatestHeader(ctx sdk.Context, chainID string, header *types.IndexedHeader) error {
if header == nil {
return sdkerrors.Wrapf(types.ErrInvalidHeader, "header is nil")
}
chainInfo := k.GetChainInfo(ctx, chainID)
chainInfo.LatestHeader = header
chainInfo.LatestHeader = header // replace the old latest header with the given one
chainInfo.TimestampedHeadersCount++ // increment the number of timestamped headers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be worth it to add a comment that this involves only the headers that we receive and not all headers that are in between submissions. For example, given the current IBC implementation if we receive header at height N and then the next one at height N+k, this number will be 2 and not k

@SebastianElvis SebastianElvis merged commit 973a472 into dev Jan 9, 2023
@SebastianElvis SebastianElvis deleted the api-count-checkpoints branch January 9, 2023 23:13
KonradStaniec added a commit that referenced this pull request Jan 12, 2023
* zoneconcierge: API for querying the chain info of a given epoch (#260)

* zoneconcierge: API for querying headers in a given epoch (#261)

* zoneconcierge API: adding total number of timestamped headers to chainInfo (#263)

* zoneconcierge API: find the BTC-finalised chain info before specific CZ height (#264)

* zoneconcierge API: find header and fork headers at a given height (#266)

* checkpointing API: add checkpoint lifecycle in `RawCheckpointWithMeta` (#267)

* chore: refactor `FinalizedChainInfo` API (#268)

* Add integration test for zoneconcierge checkpointing (#269)

* Add integration test checking info about
opposing cz chain

* Fix: Increase gas in e2e test (#270)

Increase gas

* fix: checkpointing: Do not make the `home` flag a required one and unmarshall PubKey (#271)

* Fix build

Co-authored-by: Runchao Han <me@runchao.rocks>
Co-authored-by: Vitalis Salis <VitSalis@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants