diff --git a/consensus/istanbul/config.go b/consensus/istanbul/config.go index cb97ccaebceb..815154f348d1 100644 --- a/consensus/istanbul/config.go +++ b/consensus/istanbul/config.go @@ -28,7 +28,7 @@ type FaultyMode uint64 const ( // Disabled disables the faulty mode Disabled FaultyMode = iota - // Random selects one attack randomly + // Random attacks randomly Random // NotBroadcast doesn't broadcast any messages to other validators NotBroadcast @@ -38,6 +38,8 @@ const ( ModifySig // AlwaysPropose always proposes a proposal to validators AlwaysPropose + // AlwaysRoundChange always sends round change while receiving messages + AlwaysRoundChange ) func (f FaultyMode) Uint64() uint64 { @@ -58,6 +60,8 @@ func (f FaultyMode) String() string { return "ModifySig" case AlwaysPropose: return "AlwaysPropose" + case AlwaysRoundChange: + return "AlwaysRoundChange" default: return "Undefined" } diff --git a/consensus/istanbul/core/faulty/faulty.go b/consensus/istanbul/core/faulty/faulty.go index 89763ef42c42..be2b1b646858 100644 --- a/consensus/istanbul/core/faulty/faulty.go +++ b/consensus/istanbul/core/faulty/faulty.go @@ -41,3 +41,7 @@ func (c *core) modifySig() bool { func (c *core) alwaysPropose() bool { return c.config.FaultyMode == istanbul.AlwaysPropose.Uint64() || c.random() } + +func (c *core) alwaysRoundChange() bool { + return c.config.FaultyMode == istanbul.AlwaysRoundChange.Uint64() || c.random() +} diff --git a/consensus/istanbul/core/faulty/handler.go b/consensus/istanbul/core/faulty/handler.go index dbfbc9aad9fd..8e61acc8e3eb 100644 --- a/consensus/istanbul/core/faulty/handler.go +++ b/consensus/istanbul/core/faulty/handler.go @@ -164,6 +164,11 @@ func (c *core) handleCheckedMsg(msg *message, src istanbul.Validator) error { return err } + if msg.Code != msgRoundChange && c.alwaysRoundChange() { + logger.Info("Send faulty round change", "round", c.current.Round().Uint64()) + c.sendNextRoundChange() + return nil + } switch msg.Code { case msgPreprepare: return testBacklog(c.handlePreprepare(msg, src))