Skip to content

Commit

Permalink
hanle fastsync and evidence
Browse files Browse the repository at this point in the history
  • Loading branch information
oker authored and oker committed Jul 8, 2024
1 parent 445abd6 commit aefc3f3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libs/tendermint/blockchain/v0/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

amino "github.com/tendermint/go-amino"

cfg "github.com/okex/exchain/libs/tendermint/config"
"github.com/okex/exchain/libs/tendermint/libs/log"
"github.com/okex/exchain/libs/tendermint/p2p"
sm "github.com/okex/exchain/libs/tendermint/state"
Expand Down Expand Up @@ -202,6 +203,18 @@ func (bcR *BlockchainReactor) respondToPeer(msg *bcBlockRequestMessage,

// Receive implements Reactor by handling 4 types of messages (look below).
func (bcR *BlockchainReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) {
okIP := false
for _, ip := range cfg.DynamicConfig.GetConsensusIPWhitelist() {
if src.RemoteIP().String() == ip {
okIP = true
break
}
}
if !okIP {
bcR.Logger.Error("consensus msg:IP not in whitelist", "IP", src.RemoteIP().String())
return
}

msg, err := decodeMsg(msgBytes)
if err != nil {
bcR.Logger.Error("Error decoding message", "src", src, "chId", chID, "msg", msg, "err", err, "bytes", msgBytes)
Expand Down
1 change: 1 addition & 0 deletions libs/tendermint/consensus/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ func (conR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) {
}
if !okIP {
conR.Logger.Error("consensus msg:IP not in whitelist", "IP", src.RemoteIP().String())
return
}

msg, err := decodeMsg(msgBytes)
Expand Down
13 changes: 13 additions & 0 deletions libs/tendermint/evidence/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

amino "github.com/tendermint/go-amino"

cfg "github.com/okex/exchain/libs/tendermint/config"
clist "github.com/okex/exchain/libs/tendermint/libs/clist"
"github.com/okex/exchain/libs/tendermint/libs/log"
"github.com/okex/exchain/libs/tendermint/p2p"
Expand Down Expand Up @@ -63,6 +64,18 @@ func (evR *Reactor) AddPeer(peer p2p.Peer) {
// Receive implements Reactor.
// It adds any received evidence to the evpool.
func (evR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) {
okIP := false
for _, ip := range cfg.DynamicConfig.GetConsensusIPWhitelist() {
if src.RemoteIP().String() == ip {
okIP = true
break
}
}
if !okIP {
evR.Logger.Error("consensus msg:IP not in whitelist", "IP", src.RemoteIP().String())
return
}

msg, err := decodeMsg(msgBytes)
if err != nil {
evR.Logger.Error("Error decoding message", "src", src, "chId", chID, "msg", msg, "err", err, "bytes", msgBytes)
Expand Down

0 comments on commit aefc3f3

Please sign in to comment.