1
- import { BitArray , CompositeViewDU , toHexString } from "@chainsafe/ssz" ;
1
+ import { BitArray , CompositeViewDU } from "@chainsafe/ssz" ;
2
2
import {
3
3
altair ,
4
4
BeaconBlock ,
@@ -31,7 +31,7 @@ import {
31
31
LightClientUpdateSummary ,
32
32
upgradeLightClientHeader ,
33
33
} from "@lodestar/light-client/spec" ;
34
- import { Logger , MapDef , pruneSetToMax } from "@lodestar/utils" ;
34
+ import { Logger , MapDef , pruneSetToMax , toRootHex } from "@lodestar/utils" ;
35
35
import { routes } from "@lodestar/api" ;
36
36
import {
37
37
MIN_SYNC_COMMITTEE_PARTICIPANTS ,
@@ -292,7 +292,7 @@ export class LightClientServer {
292
292
if ( ! syncCommitteeWitness ) {
293
293
throw new LightClientServerError (
294
294
{ code : LightClientServerErrorCode . RESOURCE_UNAVAILABLE } ,
295
- `syncCommitteeWitness not available ${ toHexString ( blockRoot ) } `
295
+ `syncCommitteeWitness not available ${ toRootHex ( blockRoot ) } `
296
296
) ;
297
297
}
298
298
@@ -352,7 +352,7 @@ export class LightClientServer {
352
352
if ( ! syncCommitteeWitness ) {
353
353
throw new LightClientServerError (
354
354
{ code : LightClientServerErrorCode . RESOURCE_UNAVAILABLE } ,
355
- `syncCommitteeWitness not available ${ toHexString ( blockRoot ) } period ${ period } `
355
+ `syncCommitteeWitness not available ${ toRootHex ( blockRoot ) } period ${ period } `
356
356
) ;
357
357
}
358
358
@@ -391,7 +391,7 @@ export class LightClientServer {
391
391
const header = blockToLightClientHeader ( this . config . getForkName ( blockSlot ) , block ) ;
392
392
393
393
const blockRoot = ssz . phase0 . BeaconBlockHeader . hashTreeRoot ( header . beacon ) ;
394
- const blockRootHex = toHexString ( blockRoot ) ;
394
+ const blockRootHex = toRootHex ( blockRoot ) ;
395
395
396
396
const syncCommitteeWitness = getSyncCommitteesWitness ( postState ) ;
397
397
@@ -410,7 +410,7 @@ export class LightClientServer {
410
410
const period = computeSyncPeriodAtSlot ( blockSlot ) ;
411
411
if ( parentBlockPeriod < period ) {
412
412
// If the parentBlock is in a previous epoch it must be the dependentRoot of this epoch transition
413
- const dependentRoot = toHexString ( block . parentRoot ) ;
413
+ const dependentRoot = toRootHex ( block . parentRoot ) ;
414
414
const periodDependentRoots = this . knownSyncCommittee . getOrDefault ( period ) ;
415
415
if ( ! periodDependentRoots . has ( dependentRoot ) ) {
416
416
periodDependentRoots . add ( dependentRoot ) ;
@@ -486,7 +486,7 @@ export class LightClientServer {
486
486
) : Promise < void > {
487
487
this . metrics ?. lightclientServer . onSyncAggregate . inc ( { event : "processed" } ) ;
488
488
489
- const signedBlockRootHex = toHexString ( signedBlockRoot ) ;
489
+ const signedBlockRootHex = toRootHex ( signedBlockRoot ) ;
490
490
const attestedData = this . prevHeadData . get ( signedBlockRootHex ) ;
491
491
if ( ! attestedData ) {
492
492
// Log cacheSize since at start this.prevHeadData will be empty
@@ -574,7 +574,7 @@ export class LightClientServer {
574
574
} catch ( e ) {
575
575
this . logger . error (
576
576
"Error updating best LightClientUpdate" ,
577
- { syncPeriod, slot : attestedHeader . beacon . slot , blockRoot : toHexString ( attestedData . blockRoot ) } ,
577
+ { syncPeriod, slot : attestedHeader . beacon . slot , blockRoot : toRootHex ( attestedData . blockRoot ) } ,
578
578
e as Error
579
579
) ;
580
580
}
@@ -619,7 +619,7 @@ export class LightClientServer {
619
619
620
620
const syncCommitteeWitness = await this . db . syncCommitteeWitness . get ( attestedData . blockRoot ) ;
621
621
if ( ! syncCommitteeWitness ) {
622
- throw Error ( `syncCommitteeWitness not available at ${ toHexString ( attestedData . blockRoot ) } ` ) ;
622
+ throw Error ( `syncCommitteeWitness not available at ${ toRootHex ( attestedData . blockRoot ) } ` ) ;
623
623
}
624
624
const nextSyncCommittee = await this . db . syncCommittee . get ( syncCommitteeWitness . nextSyncCommitteeRoot ) ;
625
625
if ( ! nextSyncCommittee ) {
@@ -697,7 +697,7 @@ export class LightClientServer {
697
697
* Get finalized header from db. Keeps a small in-memory cache to speed up most of the lookups
698
698
*/
699
699
private async getFinalizedHeader ( finalizedBlockRoot : Uint8Array ) : Promise < LightClientHeader | null > {
700
- const finalizedBlockRootHex = toHexString ( finalizedBlockRoot ) ;
700
+ const finalizedBlockRootHex = toRootHex ( finalizedBlockRoot ) ;
701
701
const cachedFinalizedHeader = this . checkpointHeaders . get ( finalizedBlockRootHex ) ;
702
702
if ( cachedFinalizedHeader ) {
703
703
return cachedFinalizedHeader ;
0 commit comments