Skip to content

Commit

Permalink
Merge pull request #113 from DarkLord017/DarkLord017-colors-in-consensus
Browse files Browse the repository at this point in the history
beautify consensus
  • Loading branch information
star-gazer111 authored Nov 7, 2024
2 parents 3f50496 + 43e9c32 commit 79eea13
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,10 @@ func (in *Inner) sync(checkpoint [32]byte) error {
}
in.apply_optimistic_update(&optimisticUpdate)
errorChan <- nil
log.Printf("consensus client in sync with checkpoint: 0x%s", hex.EncodeToString(checkpoint[:]))
log.Printf(
"\033[1;36mconsensus client in sync with checkpoint: 0x%s\033[0m",
hex.EncodeToString(checkpoint[:]),
)
}()

if err := <-errorChan; err != nil {
Expand Down Expand Up @@ -835,6 +838,7 @@ func (in *Inner) apply_finality_update(update *consensus_core.FinalityUpdate) {
if checkpoint != nil {
in.lastCheckpoint = checkpoint
}
in.Log_finality_update(update)
}
func (in *Inner) apply_optimistic_update(update *consensus_core.OptimisticUpdate) {
genUpdate := GenericUpdate{
Expand All @@ -846,6 +850,7 @@ func (in *Inner) apply_optimistic_update(update *consensus_core.OptimisticUpdate
if checkpoint != nil {
in.lastCheckpoint = checkpoint
}
in.Log_optimistic_update(update)
}
func (in *Inner) Log_finality_update(update *consensus_core.FinalityUpdate) {
participation := float32(getBits(update.SyncAggregate.SyncCommitteeBits[:])) / 512.0 * 100.0
Expand All @@ -861,7 +866,7 @@ func (in *Inner) Log_finality_update(update *consensus_core.FinalityUpdate) {
seconds := int(age.Seconds()) % 60

log.Printf(
"finalized slot slot=%d confidence=%.*f%% age=%02d:%02d:%02d:%02d",
"\033[1;32mfinalized slot\033[0m slot=%d confidence=%.*f%% age=%02d:%02d:%02d:%02d",
in.Store.FinalizedHeader.Slot, decimals, participation, int(days), hours, minutes, seconds,
)
}
Expand All @@ -879,7 +884,7 @@ func (in *Inner) Log_optimistic_update(update *consensus_core.OptimisticUpdate)
seconds := int(age.Seconds()) % 60

log.Printf(
"updated head slot=%d confidence=%.*f%% age=%02d:%02d:%02d:%02d",
"\033[1;33mupdated head\033[0m slot=%d confidence=%.*f%% age=%02d:%02d:%02d:%02d",
in.Store.OptimisticHeader.Slot, decimals, participation, int(days), hours, minutes, seconds,
)
}
Expand Down
2 changes: 1 addition & 1 deletion utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func IsProofValid(
for _, node := range branch {
branchInMerkle = append(branchInMerkle, merkle.Value(node))
}
fmt.Print(attestedHeader.StateRoot)

err := merkle.VerifyProof(common.Hash(attestedHeader.StateRoot), uint64(index), branchInMerkle, merkle.Value(leafObject))
if err != nil {
log.Println("Error in verifying Merkle proof:", err)
Expand Down

0 comments on commit 79eea13

Please sign in to comment.