Mostly working unit test
This commit is contained in:
parent
a0f5ec8d03
commit
4790db493b
@ -53,7 +53,7 @@ type BeaconClient struct {
|
||||
KnownGapsProcess KnownGapsProcessing // object keeping track of knowngaps processing
|
||||
CheckDb bool // Should we check the DB to see if the slot exists before processing it?
|
||||
PerformBeaconStateProcessing bool // Should we process BeaconStates?
|
||||
ProcessBeaconBlockProcessing bool // Should we process BeaconBlocks?
|
||||
PerformBeaconBlockProcessing bool // Should we process BeaconBlocks?
|
||||
|
||||
// Used for Head Tracking
|
||||
|
||||
@ -112,8 +112,8 @@ func CreateBeaconClient(ctx context.Context, connectionProtocol string, bcAddres
|
||||
Metrics: metrics,
|
||||
UniqueNodeIdentifier: uniqueNodeIdentifier,
|
||||
CheckDb: checkDb,
|
||||
ProcessBeaconBlockProcessing: true,
|
||||
PerformBeaconStateProcessing: true,
|
||||
PerformBeaconBlockProcessing: true,
|
||||
PerformBeaconStateProcessing: false,
|
||||
//FinalizationTracking: createSseEvent[FinalizedCheckpoint](endpoint, bcFinalizedTopicEndpoint),
|
||||
}, nil
|
||||
}
|
||||
|
@ -266,8 +266,12 @@ var _ = Describe("Capturehead", Label("head"), func() {
|
||||
BeaconNodeTester.SetupBeaconNodeMock(BeaconNodeTester.TestEvents, BeaconNodeTester.TestConfig.protocol, BeaconNodeTester.TestConfig.address, BeaconNodeTester.TestConfig.port, BeaconNodeTester.TestConfig.dummyParentRoot)
|
||||
defer httpmock.DeactivateAndReset()
|
||||
BeaconNodeTester.testProcessBlock(bc, BeaconNodeTester.TestEvents["100"].HeadMessage, 3, maxRetry, 1, 0, 0)
|
||||
validateSignedBeaconBlock(bc, BeaconNodeTester.TestEvents["100"].HeadMessage, BeaconNodeTester.TestEvents["100"].CorrectParentRoot, BeaconNodeTester.TestEvents["100"].CorrectEth1BlockHash, BeaconNodeTester.TestEvents["100"].CorrectSignedBeaconBlockMhKey)
|
||||
validateBeaconState(bc, BeaconNodeTester.TestEvents["100"].HeadMessage, BeaconNodeTester.TestEvents["100"].CorrectBeaconStateMhKey)
|
||||
if bc.PerformBeaconBlockProcessing {
|
||||
validateSignedBeaconBlock(bc, BeaconNodeTester.TestEvents["100"].HeadMessage, BeaconNodeTester.TestEvents["100"].CorrectParentRoot, BeaconNodeTester.TestEvents["100"].CorrectEth1BlockHash, BeaconNodeTester.TestEvents["100"].CorrectSignedBeaconBlockMhKey)
|
||||
}
|
||||
if bc.PerformBeaconStateProcessing {
|
||||
validateBeaconState(bc, BeaconNodeTester.TestEvents["100"].HeadMessage, BeaconNodeTester.TestEvents["100"].CorrectBeaconStateMhKey)
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
@ -277,8 +281,12 @@ var _ = Describe("Capturehead", Label("head"), func() {
|
||||
BeaconNodeTester.SetupBeaconNodeMock(BeaconNodeTester.TestEvents, BeaconNodeTester.TestConfig.protocol, BeaconNodeTester.TestConfig.address, BeaconNodeTester.TestConfig.port, BeaconNodeTester.TestConfig.dummyParentRoot)
|
||||
defer httpmock.DeactivateAndReset()
|
||||
BeaconNodeTester.testProcessBlock(bc, BeaconNodeTester.TestEvents["2375703"].HeadMessage, 74240, maxRetry, 1, 0, 0)
|
||||
validateSignedBeaconBlock(bc, BeaconNodeTester.TestEvents["2375703"].HeadMessage, BeaconNodeTester.TestEvents["2375703"].CorrectParentRoot, BeaconNodeTester.TestEvents["2375703"].CorrectEth1BlockHash, BeaconNodeTester.TestEvents["2375703"].CorrectSignedBeaconBlockMhKey)
|
||||
validateBeaconState(bc, BeaconNodeTester.TestEvents["2375703"].HeadMessage, BeaconNodeTester.TestEvents["2375703"].CorrectBeaconStateMhKey)
|
||||
if bc.PerformBeaconBlockProcessing {
|
||||
validateSignedBeaconBlock(bc, BeaconNodeTester.TestEvents["2375703"].HeadMessage, BeaconNodeTester.TestEvents["2375703"].CorrectParentRoot, BeaconNodeTester.TestEvents["2375703"].CorrectEth1BlockHash, BeaconNodeTester.TestEvents["2375703"].CorrectSignedBeaconBlockMhKey)
|
||||
}
|
||||
if bc.PerformBeaconStateProcessing {
|
||||
validateBeaconState(bc, BeaconNodeTester.TestEvents["2375703"].HeadMessage, BeaconNodeTester.TestEvents["2375703"].CorrectBeaconStateMhKey)
|
||||
}
|
||||
})
|
||||
})
|
||||
Context("Correctly formatted Altair Test Blocks", func() {
|
||||
|
@ -54,8 +54,12 @@ var _ = Describe("Capturehistoric", func() {
|
||||
BeaconNodeTester.writeEventToHistoricProcess(bc, 0, 0, 10)
|
||||
BeaconNodeTester.runHistoricalProcess(bc, 2, 1, 0, 0, 0)
|
||||
validateSlot(bc, BeaconNodeTester.TestEvents["0"].HeadMessage, 0, "proposed")
|
||||
validateSignedBeaconBlock(bc, BeaconNodeTester.TestEvents["0"].HeadMessage, BeaconNodeTester.TestEvents["0"].CorrectParentRoot, BeaconNodeTester.TestEvents["0"].CorrectEth1BlockHash, BeaconNodeTester.TestEvents["0"].CorrectSignedBeaconBlockMhKey)
|
||||
validateBeaconState(bc, BeaconNodeTester.TestEvents["0"].HeadMessage, BeaconNodeTester.TestEvents["0"].CorrectBeaconStateMhKey)
|
||||
if bc.PerformBeaconBlockProcessing {
|
||||
validateSignedBeaconBlock(bc, BeaconNodeTester.TestEvents["0"].HeadMessage, BeaconNodeTester.TestEvents["0"].CorrectParentRoot, BeaconNodeTester.TestEvents["0"].CorrectEth1BlockHash, BeaconNodeTester.TestEvents["0"].CorrectSignedBeaconBlockMhKey)
|
||||
}
|
||||
if bc.PerformBeaconStateProcessing {
|
||||
validateBeaconState(bc, BeaconNodeTester.TestEvents["0"].HeadMessage, BeaconNodeTester.TestEvents["0"].CorrectBeaconStateMhKey)
|
||||
}
|
||||
})
|
||||
})
|
||||
Context("When there is a skipped slot", func() {
|
||||
@ -268,16 +272,28 @@ func validateMetrics(bc *beaconclient.BeaconClient, expectedInserts, expectedReo
|
||||
// A wrapper function to validate a few popular blocks
|
||||
func validatePopularBatchBlocks(bc *beaconclient.BeaconClient) {
|
||||
validateSlot(bc, BeaconNodeTester.TestEvents["100"].HeadMessage, 3, "proposed")
|
||||
validateSignedBeaconBlock(bc, BeaconNodeTester.TestEvents["100"].HeadMessage, BeaconNodeTester.TestEvents["100"].CorrectParentRoot, BeaconNodeTester.TestEvents["100"].CorrectEth1BlockHash, BeaconNodeTester.TestEvents["100"].CorrectSignedBeaconBlockMhKey)
|
||||
validateBeaconState(bc, BeaconNodeTester.TestEvents["100"].HeadMessage, BeaconNodeTester.TestEvents["100"].CorrectBeaconStateMhKey)
|
||||
if bc.PerformBeaconBlockProcessing {
|
||||
validateSignedBeaconBlock(bc, BeaconNodeTester.TestEvents["100"].HeadMessage, BeaconNodeTester.TestEvents["100"].CorrectParentRoot, BeaconNodeTester.TestEvents["100"].CorrectEth1BlockHash, BeaconNodeTester.TestEvents["100"].CorrectSignedBeaconBlockMhKey)
|
||||
}
|
||||
if bc.PerformBeaconStateProcessing {
|
||||
validateBeaconState(bc, BeaconNodeTester.TestEvents["100"].HeadMessage, BeaconNodeTester.TestEvents["100"].CorrectBeaconStateMhKey)
|
||||
}
|
||||
|
||||
validateSlot(bc, BeaconNodeTester.TestEvents["101"].HeadMessage, 3, "proposed")
|
||||
validateSignedBeaconBlock(bc, BeaconNodeTester.TestEvents["101"].HeadMessage, BeaconNodeTester.TestEvents["100"].HeadMessage.Block, BeaconNodeTester.TestEvents["101"].CorrectEth1BlockHash, BeaconNodeTester.TestEvents["101"].CorrectSignedBeaconBlockMhKey)
|
||||
validateBeaconState(bc, BeaconNodeTester.TestEvents["101"].HeadMessage, BeaconNodeTester.TestEvents["101"].CorrectBeaconStateMhKey)
|
||||
if bc.PerformBeaconBlockProcessing {
|
||||
validateSignedBeaconBlock(bc, BeaconNodeTester.TestEvents["101"].HeadMessage, BeaconNodeTester.TestEvents["100"].HeadMessage.Block, BeaconNodeTester.TestEvents["101"].CorrectEth1BlockHash, BeaconNodeTester.TestEvents["101"].CorrectSignedBeaconBlockMhKey)
|
||||
}
|
||||
if bc.PerformBeaconStateProcessing {
|
||||
validateBeaconState(bc, BeaconNodeTester.TestEvents["101"].HeadMessage, BeaconNodeTester.TestEvents["101"].CorrectBeaconStateMhKey)
|
||||
}
|
||||
|
||||
validateSlot(bc, BeaconNodeTester.TestEvents["2375703"].HeadMessage, 74240, "proposed")
|
||||
validateSignedBeaconBlock(bc, BeaconNodeTester.TestEvents["2375703"].HeadMessage, BeaconNodeTester.TestEvents["2375703"].CorrectParentRoot, BeaconNodeTester.TestEvents["2375703"].CorrectEth1BlockHash, BeaconNodeTester.TestEvents["2375703"].CorrectSignedBeaconBlockMhKey)
|
||||
validateBeaconState(bc, BeaconNodeTester.TestEvents["2375703"].HeadMessage, BeaconNodeTester.TestEvents["2375703"].CorrectBeaconStateMhKey)
|
||||
if bc.PerformBeaconBlockProcessing {
|
||||
validateSignedBeaconBlock(bc, BeaconNodeTester.TestEvents["2375703"].HeadMessage, BeaconNodeTester.TestEvents["2375703"].CorrectParentRoot, BeaconNodeTester.TestEvents["2375703"].CorrectEth1BlockHash, BeaconNodeTester.TestEvents["2375703"].CorrectSignedBeaconBlockMhKey)
|
||||
}
|
||||
if bc.PerformBeaconStateProcessing {
|
||||
validateBeaconState(bc, BeaconNodeTester.TestEvents["2375703"].HeadMessage, BeaconNodeTester.TestEvents["2375703"].CorrectBeaconStateMhKey)
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure all rows have checked_out as false.
|
||||
|
@ -361,23 +361,6 @@ func (s *BeaconState) IsPhase0() bool {
|
||||
return s.phase0 != nil
|
||||
}
|
||||
|
||||
func (s *BeaconState) Slot() Slot {
|
||||
if s.IsBellatrix() {
|
||||
return Slot(s.bellatrix.Slot)
|
||||
}
|
||||
|
||||
if s.IsAltair() {
|
||||
return Slot(s.altair.Slot)
|
||||
}
|
||||
|
||||
if s.IsPhase0() {
|
||||
return Slot(s.phase0.Slot)
|
||||
}
|
||||
|
||||
// TODO(telackey): Something better than 0?
|
||||
return 0
|
||||
}
|
||||
|
||||
func (s *BeaconState) HashTreeRoot() Root {
|
||||
spec := chooseSpec(s.spec)
|
||||
hashFn := tree.GetHashFn()
|
||||
|
@ -43,7 +43,7 @@ type SlotProcessingDetails struct {
|
||||
KnownGapTableIncrement int // The max number of slots within a single known_gaps table entry.
|
||||
CheckDb bool // Should we check the DB to see if the slot exists before processing it?
|
||||
PerformBeaconStateProcessing bool // Should we process BeaconStates?
|
||||
ProcessBeaconBlockProcessing bool // Should we process BeaconBlocks?
|
||||
PerformBeaconBlockProcessing bool // Should we process BeaconBlocks?
|
||||
|
||||
StartingSlot int // If we're performing head tracking. What is the first slot we processed.
|
||||
PreviousSlot int // Whats the previous slot we processed
|
||||
@ -58,7 +58,7 @@ func (bc *BeaconClient) SlotProcessingDetails() SlotProcessingDetails {
|
||||
Metrics: bc.Metrics,
|
||||
|
||||
CheckDb: bc.CheckDb,
|
||||
ProcessBeaconBlockProcessing: bc.ProcessBeaconBlockProcessing,
|
||||
PerformBeaconBlockProcessing: bc.PerformBeaconBlockProcessing,
|
||||
PerformBeaconStateProcessing: bc.PerformBeaconStateProcessing,
|
||||
|
||||
KnownGapTableIncrement: bc.KnownGapTableIncrement,
|
||||
@ -168,7 +168,7 @@ func processFullSlot(
|
||||
})
|
||||
}
|
||||
|
||||
if spd.ProcessBeaconBlockProcessing {
|
||||
if spd.PerformBeaconBlockProcessing {
|
||||
// Get the SignedBeaconBlock.
|
||||
g.Go(func() error {
|
||||
select {
|
||||
@ -355,11 +355,11 @@ func (ps *ProcessSlot) getBeaconState(serverEndpoint string) error {
|
||||
// Check to make sure that the previous block we processed is the parent of the current block.
|
||||
func (ps *ProcessSlot) checkPreviousSlot(tx sql.Tx, ctx context.Context, previousSlot int, previousBlockRoot string, knownGapsTableIncrement int) {
|
||||
if nil == ps.FullSignedBeaconBlock {
|
||||
log.Debug("Can't check previous slot, no current slot.")
|
||||
log.Debug("Can't check block root, no current block.")
|
||||
return
|
||||
}
|
||||
parentRoot := toHex(ps.FullSignedBeaconBlock.Block().ParentRoot())
|
||||
slot := int(ps.FullBeaconState.Slot())
|
||||
slot := ps.Slot
|
||||
if previousSlot == slot {
|
||||
log.WithFields(log.Fields{
|
||||
"slot": slot,
|
||||
|
Loading…
Reference in New Issue
Block a user