Skip to content

Commit

Permalink
Add Target root to forkchoice dump (#15009)
Browse files Browse the repository at this point in the history
* Add Target root to forkchoice dump

* review
  • Loading branch information
potuz authored Mar 5, 2025
1 parent 6015493 commit a7b016c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/server/structs/endpoints_debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ type ForkChoiceNodeExtraData struct {
Balance string `json:"balance"`
ExecutionOptimistic bool `json:"execution_optimistic"`
TimeStamp string `json:"timestamp"`
Target string `json:"target"`
}
5 changes: 5 additions & 0 deletions beacon-chain/forkchoice/doubly-linked-tree/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ func (n *Node) nodeTreeDump(ctx context.Context, nodes []*forkchoice2.Node) ([]*
if n.parent != nil {
parentRoot = n.parent.root
}
target := [32]byte{}
if n.target != nil {
target = n.target.root
}
thisNode := &forkchoice2.Node{
Slot: n.slot,
BlockRoot: n.root[:],
Expand All @@ -169,6 +173,7 @@ func (n *Node) nodeTreeDump(ctx context.Context, nodes []*forkchoice2.Node) ([]*
ExecutionOptimistic: n.optimistic,
ExecutionBlockHash: n.payloadHash[:],
Timestamp: n.timestamp,
Target: target[:],
}
if n.optimistic {
thisNode.Validity = forkchoice2.Optimistic
Expand Down
1 change: 1 addition & 0 deletions beacon-chain/rpc/eth/debug/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func (s *Server) GetForkChoice(w http.ResponseWriter, r *http.Request) {
Balance: fmt.Sprintf("%d", n.Balance),
ExecutionOptimistic: n.ExecutionOptimistic,
TimeStamp: fmt.Sprintf("%d", n.Timestamp),
Target: fmt.Sprintf("%#x", n.Target),
},
}
}
Expand Down
3 changes: 3 additions & 0 deletions changelog/potuz_add_target_to_fc_dump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Ignored

- Add target root to forkchoice dump
1 change: 1 addition & 0 deletions consensus-types/forkchoice/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ type Node struct {
BlockRoot []byte
ParentRoot []byte
ExecutionBlockHash []byte
Target []byte
}

0 comments on commit a7b016c

Please sign in to comment.