Skip to content

Commit

Permalink
feat(beaconApi): Add getDomainSyncCommittee and getForkVersion to bea…
Browse files Browse the repository at this point in the history
…conApi class
  • Loading branch information
kkirkov committed Dec 10, 2024
1 parent 9cb7870 commit 05fd36b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions relay/abstraction/beacon-api-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ export interface IBeaconApi {
getFinalizedBlockHeader(slot: number): Promise<BeaconBlockHeader>;

getExecutionStateRoot(slot: number): Promise<string>;

getDomainSyncCommittee(): Promise<string>;

getForkVersion(): Promise<string>;
}
23 changes: 22 additions & 1 deletion relay/implementations/beacon-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export class BeaconApi implements IBeaconApi {
(await this.fetchWithFallback('/eth/v1/beacon/headers/head')).json(),
'getCurrentHeadSlot',
);
logger.info('CurrentHeadSlot: ', currentHead.data.header.message.slot);

return Number(currentHead.data.header.message.slot);
}
Expand All @@ -173,7 +174,10 @@ export class BeaconApi implements IBeaconApi {
await this.fetchWithFallback(`/eth/v1/beacon/headers/${blockHash}`)
).json();

logger.info('Got CurrentHeadSlot..');
logger.info(
'Got CurrentHeadSlot..',
await Number(headResult.data.header.message.slot),
);
return Number(headResult.data.header.message.slot);
}

Expand Down Expand Up @@ -611,6 +615,23 @@ export class BeaconApi implements IBeaconApi {
return { beaconState, stateTree };
}

async getDomainSyncCommittee(): Promise<string> {
const config = await (
await this.fetchWithFallback('/eth/v1/config/spec')
).json();

const domainSyncCommittee = config.data.DOMAIN_SYNC_COMMITTEE;
return domainSyncCommittee;
}

async getForkVersion(): Promise<string> {
const config = await (
await this.fetchWithFallback('/eth/v1/config/spec')
).json();

const forkVersion = config.data.DENEB_FORK_VERSION;
return forkVersion;
}
private nextApi(): void {
this.currentApiIndex =
(this.currentApiIndex + 1) % this.beaconRestApis.length;
Expand Down

0 comments on commit 05fd36b

Please sign in to comment.