diff --git a/api/server/structs/endpoints_debug.go b/api/server/structs/endpoints_debug.go index fbcc3a6bbb..16e5b79809 100644 --- a/api/server/structs/endpoints_debug.go +++ b/api/server/structs/endpoints_debug.go @@ -54,4 +54,5 @@ type ForkChoiceNodeExtraData struct { Balance string `json:"balance"` ExecutionOptimistic bool `json:"execution_optimistic"` TimeStamp string `json:"timestamp"` + Target string `json:"target"` } diff --git a/beacon-chain/forkchoice/doubly-linked-tree/node.go b/beacon-chain/forkchoice/doubly-linked-tree/node.go index 2c4253b43d..804a74f440 100644 --- a/beacon-chain/forkchoice/doubly-linked-tree/node.go +++ b/beacon-chain/forkchoice/doubly-linked-tree/node.go @@ -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[:], @@ -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 diff --git a/beacon-chain/rpc/eth/debug/handlers.go b/beacon-chain/rpc/eth/debug/handlers.go index f50acec641..ff4ac3b5ee 100644 --- a/beacon-chain/rpc/eth/debug/handlers.go +++ b/beacon-chain/rpc/eth/debug/handlers.go @@ -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), }, } } diff --git a/changelog/potuz_add_target_to_fc_dump.md b/changelog/potuz_add_target_to_fc_dump.md new file mode 100644 index 0000000000..a4c741b831 --- /dev/null +++ b/changelog/potuz_add_target_to_fc_dump.md @@ -0,0 +1,3 @@ +### Ignored + +- Add target root to forkchoice dump diff --git a/consensus-types/forkchoice/types.go b/consensus-types/forkchoice/types.go index 3707f80c5e..bb16c6b55a 100644 --- a/consensus-types/forkchoice/types.go +++ b/consensus-types/forkchoice/types.go @@ -51,4 +51,5 @@ type Node struct { BlockRoot []byte ParentRoot []byte ExecutionBlockHash []byte + Target []byte }