-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package blockchain | ||
|
||
import ( | ||
"testing" | ||
|
||
doublylinkedtree "github.com/prysmaticlabs/prysm/v5/beacon-chain/forkchoice/doubly-linked-tree" | ||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" | ||
"github.com/prysmaticlabs/prysm/v5/testing/require" | ||
) | ||
|
||
func TestServiceGetPTCVote(t *testing.T) { | ||
c := ¤tlySyncingPayload{roots: make(map[[32]byte]primitives.PTCStatus)} | ||
s := &Service{cfg: &config{ForkChoiceStore: doublylinkedtree.New()}, payloadBeingSynced: c} | ||
r := [32]byte{'r'} | ||
require.Equal(t, primitives.PAYLOAD_ABSENT, s.GetPTCVote(r)) | ||
c.roots[r] = primitives.PAYLOAD_WITHHELD | ||
require.Equal(t, primitives.PAYLOAD_WITHHELD, s.GetPTCVote(r)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,31 @@ | ||
package doublylinkedtree | ||
|
||
import ( | ||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" | ||
"github.com/prysmaticlabs/prysm/v5/time/slots" | ||
) | ||
|
||
func (n *Node) isParentFull() bool { | ||
// Finalized checkpoint is considered full | ||
if n.parent == nil || n.parent.parent == nil { | ||
return true | ||
} | ||
return n.parent.payloadHash != [32]byte{} | ||
} | ||
|
||
func (f *ForkChoice) GetPTCVote() primitives.PTCStatus { | ||
highestNode := f.store.highestReceivedNode | ||
if highestNode == nil { | ||
return primitives.PAYLOAD_ABSENT | ||
} | ||
if slots.CurrentSlot(f.store.genesisTime) > highestNode.slot { | ||
return primitives.PAYLOAD_ABSENT | ||
} | ||
if highestNode.payloadHash == [32]byte{} { | ||
return primitives.PAYLOAD_ABSENT | ||
} | ||
if highestNode.withheld { | ||
return primitives.PAYLOAD_WITHHELD | ||
} | ||
return primitives.PAYLOAD_PRESENT | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters