mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
parent
1315a15d9d
commit
48fcb08ebc
@ -13,7 +13,6 @@ import (
|
||||
dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
mockPOW "github.com/prysmaticlabs/prysm/beacon-chain/powchain/testing"
|
||||
contracts "github.com/prysmaticlabs/prysm/contracts/deposit-contract"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
)
|
||||
@ -66,12 +65,6 @@ func TestLatestMainchainInfo_OK(t *testing.T) {
|
||||
assert.Equal(t, web3Service.latestEth1Data.BlockHeight, header.Number.Uint64())
|
||||
assert.Equal(t, hexutil.Encode(web3Service.latestEth1Data.BlockHash), header.Hash().Hex())
|
||||
assert.Equal(t, web3Service.latestEth1Data.BlockTime, header.Time)
|
||||
|
||||
headerInfoExistsInCache, info, err := web3Service.headerCache.HeaderInfoByHash(bytesutil.ToBytes32(web3Service.latestEth1Data.BlockHash))
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, true, headerInfoExistsInCache, "Expected block info to exist in cache")
|
||||
assert.Equal(t, bytesutil.ToBytes32(info.Hash[:]), bytesutil.ToBytes32(web3Service.latestEth1Data.BlockHash))
|
||||
|
||||
}
|
||||
|
||||
func TestBlockHashByHeight_ReturnsHash(t *testing.T) {
|
||||
|
@ -254,6 +254,9 @@ func (s *Service) createGenesisTime(timeStamp uint64) uint64 {
|
||||
func (s *Service) processPastLogs(ctx context.Context) error {
|
||||
currentBlockNum := s.latestEth1Data.LastRequestedBlock
|
||||
deploymentBlock := int64(params.BeaconNetworkConfig().ContractDeploymentBlock)
|
||||
// Start from the deployment block if our last requested block
|
||||
// is behind it. This is as the deposit logs can only start from the
|
||||
// block of the deployment of the deposit contract.
|
||||
if uint64(deploymentBlock) > currentBlockNum {
|
||||
currentBlockNum = uint64(deploymentBlock)
|
||||
}
|
||||
@ -290,6 +293,8 @@ func (s *Service) processPastLogs(ctx context.Context) error {
|
||||
}
|
||||
start := currentBlockNum
|
||||
end := currentBlockNum + eth1HeaderReqLimit
|
||||
// Appropriately bound the request, as we do not
|
||||
// want request blocks beyond the current follow distance.
|
||||
if end > latestFollowHeight {
|
||||
end = latestFollowHeight
|
||||
}
|
||||
@ -302,7 +307,10 @@ func (s *Service) processPastLogs(ctx context.Context) error {
|
||||
}
|
||||
remainingLogs := logCount - uint64(s.lastReceivedMerkleIndex+1)
|
||||
// only change the end block if the remaining logs are below the required log limit.
|
||||
if remainingLogs < depositlogRequestLimit && end >= latestFollowHeight {
|
||||
// reset our query and end block in this case.
|
||||
withinLimit := remainingLogs < depositlogRequestLimit
|
||||
aboveFollowHeight := end >= latestFollowHeight
|
||||
if withinLimit && aboveFollowHeight {
|
||||
query.ToBlock = big.NewInt(int64(latestFollowHeight))
|
||||
end = latestFollowHeight
|
||||
}
|
||||
@ -310,6 +318,8 @@ func (s *Service) processPastLogs(ctx context.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Only request headers before chainstart to correctly determine
|
||||
// genesis.
|
||||
if !s.chainStartData.Chainstarted {
|
||||
if err := requestHeaders(start, end); err != nil {
|
||||
return err
|
||||
|
@ -539,11 +539,6 @@ func (s *Service) processBlockHeader(header *gethTypes.Header) {
|
||||
"blockNumber": s.latestEth1Data.BlockHeight,
|
||||
"blockHash": hexutil.Encode(s.latestEth1Data.BlockHash),
|
||||
}).Debug("Latest eth1 chain event")
|
||||
|
||||
if err := s.headerCache.AddHeader(header); err != nil {
|
||||
s.runError = err
|
||||
log.Errorf("Unable to add block data to cache %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// batchRequestHeaders requests the block range specified in the arguments. Instead of requesting
|
||||
@ -619,8 +614,11 @@ func (s *Service) handleETH1FollowDistance() {
|
||||
}
|
||||
// If the last requested block has not changed,
|
||||
// we do not request batched logs as this means there are no new
|
||||
// logs for the powchain service to process.
|
||||
// logs for the powchain service to process. Also is a potential
|
||||
// failure condition as would mean we have not respected the protocol
|
||||
// threshold.
|
||||
if s.latestEth1Data.LastRequestedBlock == s.latestEth1Data.BlockHeight {
|
||||
log.Error("Beacon node is not respecting the follow distance")
|
||||
return
|
||||
}
|
||||
if err := s.requestBatchedLogs(ctx); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user