Skip to content

Commit

Permalink
Remove readonly option
Browse files Browse the repository at this point in the history
  • Loading branch information
TimDaub committed Oct 1, 2019
1 parent a2b9ba8 commit 87475b7
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 58 deletions.
1 change: 0 additions & 1 deletion cmd/tendermint/commands/run_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -702,7 +700,6 @@ func DefaultConsensusConfig() *ConsensusConfig {
CreateEmptyBlocksInterval: 0 * time.Second,
PeerGossipSleepDuration: 100 * time.Millisecond,
PeerQueryMaj23SleepDuration: 2000 * time.Millisecond,
Readonly: false,
}
}

Expand Down
3 changes: 0 additions & 3 deletions config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
34 changes: 0 additions & 34 deletions consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"runtime/debug"
"sync"
"time"
"strconv"

"github.com/pkg/errors"

Expand Down Expand Up @@ -138,8 +137,6 @@ type ConsensusState struct {

// for reporting metrics
metrics *Metrics

readonly bool
}

// StateOption sets an optional parameter on the ConsensusState.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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}, ""})
Expand Down
2 changes: 0 additions & 2 deletions rpc/core/pipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ type Consensus interface {
GetLastHeight() int64
GetRoundStateJSON() ([]byte, error)
GetRoundStateSimpleJSON() ([]byte, error)
SetReadonly(readonly bool)
IsReadonly() bool
}

type transport interface {
Expand Down
2 changes: 0 additions & 2 deletions rpc/core/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
8 changes: 0 additions & 8 deletions rpc/core/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package core
import (
"bytes"
"time"
"strconv"

cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/p2p"
Expand Down Expand Up @@ -112,7 +111,6 @@ func Status(ctx *rpctypes.Context) (*ctypes.ResultStatus, error) {
Address: pubKey.Address(),
PubKey: pubKey,
VotingPower: votingPower,
IsReadonly: consensusState.IsReadonly(),
},
}

Expand Down Expand Up @@ -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
}
5 changes: 0 additions & 5 deletions rpc/core/types/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"`
Expand Down

0 comments on commit 87475b7

Please sign in to comment.