pull/4455/head
frozen 1 year ago
parent a6ddc19fed
commit 82b3f0ceda
No known key found for this signature in database
GPG Key ID: 5391C63E79B03EDE
  1. 4
      consensus/consensus.go
  2. 8
      consensus/consensus_test.go
  3. 5
      consensus/consensus_v2.go
  4. 2
      consensus/validator.go
  5. 2
      consensus/view_change_msg.go

@ -268,7 +268,7 @@ func New(
consensus := Consensus{
mutex: &sync.RWMutex{},
ShardID: shard,
fBFTLog: NewFBFTLog(),
fBFTLog: NewFBFTLog(VerifyNewBlock(registry.GetWebHooks(), registry.GetBlockchain(), registry.GetBeaconchain())),
phase: FBFTAnnounce,
current: State{mode: Normal},
Decider: Decider,
@ -302,7 +302,7 @@ func New(
consensus.RndChannel = make(chan [vdfAndSeedSize]byte)
consensus.IgnoreViewIDCheck = abool.NewBool(false)
// Make Sure Verifier is not null
consensus.vc = newViewChange(consensus.FBFTLog.BlockVerify)
consensus.vc = newViewChange(consensus.fBFTLog.BlockVerify)
// init prometheus metrics
initMetrics()
consensus.AddPubkeyMetrics()

@ -22,7 +22,7 @@ func TestConsensusInitialization(t *testing.T) {
assert.NoError(t, err)
messageSender := &MessageSender{host: host, retryTimes: int(phaseDuration.Seconds()) / RetryIntervalInSec}
fbtLog := NewFBFTLog(consensus.FBFTLog.verifyNewBlock)
fbtLog := NewFBFTLog(nil)
state := State{mode: Normal}
timeouts := createTimeout()
@ -37,10 +37,10 @@ func TestConsensusInitialization(t *testing.T) {
assert.IsType(t, make(chan struct{}), consensus.BlockNumLowChan)
// FBFTLog
assert.Equal(t, fbtLog.blocks, consensus.FBFTLog.blocks)
assert.Equal(t, fbtLog.messages, consensus.FBFTLog.messages)
assert.Equal(t, fbtLog.blocks, consensus.fBFTLog.blocks)
assert.Equal(t, fbtLog.messages, consensus.fBFTLog.messages)
assert.Equal(t, len(fbtLog.verifiedBlocks), 0)
assert.Equal(t, fbtLog.verifiedBlocks, consensus.FBFTLog.verifiedBlocks)
assert.Equal(t, fbtLog.verifiedBlocks, consensus.fBFTLog.verifiedBlocks)
assert.NotNil(t, consensus.FBFTLog())
assert.Equal(t, FBFTAnnounce, consensus.phase)

@ -4,11 +4,12 @@ import (
"bytes"
"context"
"encoding/hex"
libp2p_peer "github.com/libp2p/go-libp2p/core/peer"
"math/big"
"sync/atomic"
"time"
libp2p_peer "github.com/libp2p/go-libp2p/core/peer"
"github.com/ethereum/go-ethereum/common"
bls2 "github.com/harmony-one/bls/ffi/go/bls"
"github.com/harmony-one/harmony/consensus/signature"
@ -631,7 +632,7 @@ func (consensus *Consensus) tryCatchup() error {
}
blk.SetCurrentCommitSig(msg.Payload)
if err := consensus.FBFTLog.verifyBlock(blk); err != nil {
if err := consensus.fBFTLog.verifyBlock(blk); err != nil {
consensus.getLogger().Err(err).Msg("[TryCatchup] failed block verifier")
return err
}

@ -131,7 +131,7 @@ func (consensus *Consensus) validateNewBlock(recvMsg *FBFTMessage) (*types.Block
Hex("blockHash", recvMsg.BlockHash[:]).
Msg("[validateNewBlock] Prepared message and block added")
if err := consensus.FBFTLog.verifyBlock(&blockObj); err != nil {
if err := consensus.fBFTLog.verifyBlock(&blockObj); err != nil {
consensus.getLogger().Error().Err(err).Msg("[validateNewBlock] Block verification failed")
return nil, errors.Errorf("Block verification failed: %s", err.Error())
}

@ -45,7 +45,7 @@ func (consensus *Consensus) constructViewChangeMessage(priKey *bls.PrivateKeyWra
Interface("preparedMsg", preparedMsg).
Msg("[constructViewChangeMessage] found prepared msg")
if block != nil {
if err := consensus.FBFTLog.verifyBlock(block); err == nil {
if err := consensus.fBFTLog.verifyBlock(block); err == nil {
tmpEncoded, err := rlp.EncodeToBytes(block)
if err != nil {
consensus.getLogger().Err(err).Msg("[constructViewChangeMessage] Failed encoding block")

Loading…
Cancel
Save