diff --git a/cmd/tendermint/commands/run_node.go b/cmd/tendermint/commands/run_node.go index 163e4a6fad1..fa63b4944e8 100644 --- a/cmd/tendermint/commands/run_node.go +++ b/cmd/tendermint/commands/run_node.go @@ -41,7 +41,6 @@ func AddNodeFlags(cmd *cobra.Command) { // consensus flags cmd.Flags().Bool("consensus.create_empty_blocks", config.Consensus.CreateEmptyBlocks, "Set this to false to only produce blocks when there are txs or when the AppHash changes") - cmd.Flags().Bool("consensus.readonly", config.Consensus.Readonly, "Set this to true to make validator skip producing blocks") } // NewRunNodeCmd returns the command that allows the CLI to start a node. diff --git a/config/config.go b/config/config.go index 6233c3c83b8..6c4654fedcf 100644 --- a/config/config.go +++ b/config/config.go @@ -682,8 +682,6 @@ type ConsensusConfig struct { // Reactor sleep duration parameters PeerGossipSleepDuration time.Duration `mapstructure:"peer_gossip_sleep_duration"` PeerQueryMaj23SleepDuration time.Duration `mapstructure:"peer_query_maj23_sleep_duration"` - - Readonly bool `mapstructure:"readonly"` } // DefaultConsensusConfig returns a default configuration for the consensus service @@ -702,7 +700,6 @@ func DefaultConsensusConfig() *ConsensusConfig { CreateEmptyBlocksInterval: 0 * time.Second, PeerGossipSleepDuration: 100 * time.Millisecond, PeerQueryMaj23SleepDuration: 2000 * time.Millisecond, - Readonly: false, } } diff --git a/config/toml.go b/config/toml.go index a62f4ea4a0a..b1541c05ad9 100644 --- a/config/toml.go +++ b/config/toml.go @@ -310,9 +310,6 @@ create_empty_blocks_interval = "{{ .Consensus.CreateEmptyBlocksInterval }}" peer_gossip_sleep_duration = "{{ .Consensus.PeerGossipSleepDuration }}" peer_query_maj23_sleep_duration = "{{ .Consensus.PeerQueryMaj23SleepDuration }}" -# Do not produce blocks, just observe (for validator) -readonly = {{ .Consensus.Readonly }} - ##### transactions indexer configuration options ##### [tx_index] diff --git a/consensus/state.go b/consensus/state.go index 211db614665..2f9de62e583 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -7,7 +7,6 @@ import ( "runtime/debug" "sync" "time" - "strconv" "github.com/pkg/errors" @@ -138,8 +137,6 @@ type ConsensusState struct { // for reporting metrics metrics *Metrics - - readonly bool } // StateOption sets an optional parameter on the ConsensusState. @@ -172,7 +169,6 @@ func NewConsensusState( evpool: evpool, evsw: tmevents.NewEventSwitch(), metrics: NopMetrics(), - readonly: config.Readonly, } // set function defaults (may be overwritten before calling Start) cs.decideProposal = cs.defaultDecideProposal @@ -771,24 +767,6 @@ func (cs *ConsensusState) handleTxsAvailable() { cs.enterPropose(cs.Height, 0) } -func (cs *ConsensusState) SetReadonly(readonly bool) { - cs.Logger.Info("[SetReadonly]: Set to " + strconv.FormatBool(readonly) + " " + strconv.FormatBool(cs.readonly)) - cs.mtx.Lock() - cs.readonly = readonly - cs.mtx.Unlock() - - if (!cs.readonly) { - if (cs.LastCommit.HasAll()) { - // Fix consensus stalling after readOnly switch with no other validators in the network - cs.scheduleTimeout(5000, cs.Height, cs.Round, cstypes.RoundStepPrevoteWait) - } - } -} - -func (cs *ConsensusState) IsReadonly() bool { - return cs.readonly; -} - //----------------------------------------------------------------------------- // State functions // Used internally by handleTimeout and handleMsg to make state transitions @@ -911,12 +889,6 @@ func (cs *ConsensusState) enterPropose(height int64, round int) { if cs.isProposer(address) { logger.Info("enterPropose: Our turn to propose", "proposer", cs.Validators.GetProposer().Address, "privValidator", cs.privValidator) - // validator is readonly, do nothing - if (cs.readonly) { - logger.Info("enterPropose: Validator is in readonly mode. Skipping..") - return - } - if height % 32 == 0 { rsp, err := cs.proxyApp.CheckBridgeSync(abci.RequestCheckBridge{Height: int32(round)}) if err != nil { @@ -1771,12 +1743,6 @@ func (cs *ConsensusState) signAddVote(type_ types.SignedMsgType, hash []byte, he return nil } - // validator is readonly, do nothing - if (cs.readonly) { - cs.Logger.Info("signAddVote: Validator is in readonly mode") - return nil - } - vote, err := cs.signVote(type_, hash, header) if err == nil { cs.sendInternalMessage(msgInfo{&VoteMessage{vote}, ""}) diff --git a/rpc/core/pipe.go b/rpc/core/pipe.go index c19dafcc504..28a492e6fb9 100644 --- a/rpc/core/pipe.go +++ b/rpc/core/pipe.go @@ -35,8 +35,6 @@ type Consensus interface { GetLastHeight() int64 GetRoundStateJSON() ([]byte, error) GetRoundStateSimpleJSON() ([]byte, error) - SetReadonly(readonly bool) - IsReadonly() bool } type transport interface { diff --git a/rpc/core/routes.go b/rpc/core/routes.go index f4c40006c0f..736ded60787 100644 --- a/rpc/core/routes.go +++ b/rpc/core/routes.go @@ -50,6 +50,4 @@ func AddUnsafeRoutes() { Routes["unsafe_start_cpu_profiler"] = rpc.NewRPCFunc(UnsafeStartCPUProfiler, "filename") Routes["unsafe_stop_cpu_profiler"] = rpc.NewRPCFunc(UnsafeStopCPUProfiler, "") Routes["unsafe_write_heap_profile"] = rpc.NewRPCFunc(UnsafeWriteHeapProfile, "filename") - - Routes["set_readonly"] = rpc.NewRPCFunc(SetReadonly, "readonly") } diff --git a/rpc/core/status.go b/rpc/core/status.go index 2e36325c879..aab86466786 100644 --- a/rpc/core/status.go +++ b/rpc/core/status.go @@ -3,7 +3,6 @@ package core import ( "bytes" "time" - "strconv" cmn "github.com/tendermint/tendermint/libs/common" "github.com/tendermint/tendermint/p2p" @@ -112,7 +111,6 @@ func Status(ctx *rpctypes.Context) (*ctypes.ResultStatus, error) { Address: pubKey.Address(), PubKey: pubKey, VotingPower: votingPower, - IsReadonly: consensusState.IsReadonly(), }, } @@ -144,9 +142,3 @@ func validatorAtHeight(h int64) *types.Validator { return nil } - -func SetReadonly(ctx *rpctypes.Context, readonly bool) (*ctypes.ResultSetReadonly, error) { - consensusState.SetReadonly(readonly) - - return &ctypes.ResultSetReadonly{Log: "Set validator as readonly: " + strconv.FormatBool(readonly)}, nil -} diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index 151891df236..74457b38ae0 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -70,7 +70,6 @@ type ValidatorInfo struct { Address cmn.HexBytes `json:"address"` PubKey crypto.PubKey `json:"pub_key"` VotingPower int64 `json:"voting_power"` - IsReadonly bool `json:"is_readonly"` } // Node Status @@ -106,10 +105,6 @@ type ResultDialPeers struct { Log string `json:"log"` } -type ResultSetReadonly struct { - Log string `json:"log"` -} - // A peer type Peer struct { NodeInfo p2p.DefaultNodeInfo `json:"node_info"`