From 13c2f7b72496fedea56fbd020cbf68e36f2492bd Mon Sep 17 00:00:00 2001
From: Silas Davis <silas@erisindustries.com>
Date: Fri, 16 Sep 2016 16:08:10 +0200
Subject: [PATCH] Implemented missing RPC methods/code paths

---
 consensus/tendermint/tendermint.go     | 41 +++++++++++++
 consensus/types/consensus_engine.go    | 10 +++
 consensus/types/consensus_state.go     | 30 +++++++++
 consensus/types/validator.go           | 37 +++++++++++
 core/types/types.go                    | 26 --------
 definitions/tendermint_pipe.go         |  6 ++
 manager/eris-mint/pipe.go              | 85 ++++++++++++++++++++------
 rpc/tendermint/core/routes.go          | 45 +++++++++++---
 rpc/tendermint/core/types/responses.go | 72 +++++++++++-----------
 rpc/v0/methods.go                      | 10 +--
 rpc/v0/restServer.go                   |  8 +--
 11 files changed, 270 insertions(+), 100 deletions(-)
 create mode 100644 consensus/types/consensus_state.go
 create mode 100644 consensus/types/validator.go

diff --git a/consensus/tendermint/tendermint.go b/consensus/tendermint/tendermint.go
index a18e3531..65a58d48 100644
--- a/consensus/tendermint/tendermint.go
+++ b/consensus/tendermint/tendermint.go
@@ -27,6 +27,7 @@ import (
 
 	crypto "github.com/tendermint/go-crypto"
 	p2p "github.com/tendermint/go-p2p"
+	tendermint_consensus "github.com/tendermint/tendermint/consensus"
 	node "github.com/tendermint/tendermint/node"
 	proxy "github.com/tendermint/tendermint/proxy"
 	tendermint_types "github.com/tendermint/tendermint/types"
@@ -40,6 +41,8 @@ import (
 	// files  "github.com/eris-ltd/eris-db/files"
 	blockchain_types "github.com/eris-ltd/eris-db/blockchain/types"
 	consensus_types "github.com/eris-ltd/eris-db/consensus/types"
+	"github.com/eris-ltd/eris-db/txs"
+	"github.com/tendermint/go-wire"
 )
 
 type Tendermint struct {
@@ -222,6 +225,44 @@ func (tendermint *Tendermint) BroadcastTransaction(transaction []byte,
 	return tendermint.tmintNode.MempoolReactor().BroadcastTx(transaction, callback)
 }
 
+func (tendermint *Tendermint) ListUnconfirmedTxs(
+	maxTxs int) ([]txs.Tx, error) {
+	tendermintTxs := tendermint.tmintNode.MempoolReactor().Mempool.Reap(maxTxs)
+	transactions := make([]txs.Tx, len(tendermintTxs))
+	for i, txBytes := range tendermintTxs {
+		tx, err := txs.DecodeTx(txBytes)
+		if err != nil {
+			return nil, err
+		}
+		transactions[i] = tx
+	}
+	return transactions, nil
+}
+
+func (tendermint *Tendermint) ListValidators() []consensus_types.Validator {
+	return consensus_types.FromTendermintValidators(tendermint.tmintNode.
+		ConsensusState().Validators.Validators)
+}
+
+func (tendermint *Tendermint) ConsensusState() *consensus_types.ConsensusState {
+	return consensus_types.FromRoundState(tendermint.tmintNode.ConsensusState().
+			GetRoundState())
+}
+
+func (tendermint *Tendermint) PeerConsensusStates() map[string]string {
+	peers := tendermint.tmintNode.Switch().Peers().List()
+	peerConsensusStates := make(map[string]string,
+		len(peers))
+	for _, peer := range peers {
+		peerState := peer.Data.Get(tendermint_types.PeerStateKey).(*tendermint_consensus.PeerState)
+		peerRoundState := peerState.GetRoundState()
+		// TODO: implement a proper mapping, this is a nasty way of marshalling
+		// to JSON
+		peerConsensusStates[peer.Key] = string(wire.JSONBytes(peerRoundState))
+	}
+	return peerConsensusStates
+}
+
 //------------------------------------------------------------------------------
 // Helper functions
 
diff --git a/consensus/types/consensus_engine.go b/consensus/types/consensus_engine.go
index 893ea85e..8600bb3e 100644
--- a/consensus/types/consensus_engine.go
+++ b/consensus/types/consensus_engine.go
@@ -2,6 +2,7 @@ package types
 
 import (
 	"github.com/eris-ltd/eris-db/event"
+	"github.com/eris-ltd/eris-db/txs"
 	"github.com/tendermint/go-crypto"
 	"github.com/tendermint/go-p2p"
 	tmsp_types "github.com/tendermint/tmsp/types"
@@ -24,4 +25,13 @@ type ConsensusEngine interface {
 	// Events
 	// For consensus events like NewBlock
 	Events() event.EventEmitter
+
+	// List pending transactions in the mempool, passing 0 for maxTxs gets an
+	// unbounded number of transactions
+	ListUnconfirmedTxs(maxTxs int) ([]txs.Tx, error)
+	ListValidators() []Validator
+	ConsensusState() *ConsensusState
+	// TODO: Consider creating a real type for PeerRoundState, but at the looks
+	// quite coupled to tendermint
+	PeerConsensusStates() map[string]string
 }
diff --git a/consensus/types/consensus_state.go b/consensus/types/consensus_state.go
new file mode 100644
index 00000000..80f8fc87
--- /dev/null
+++ b/consensus/types/consensus_state.go
@@ -0,0 +1,30 @@
+package types
+
+import (
+	tendermint_consensus "github.com/tendermint/tendermint/consensus"
+	tendermint_types "github.com/tendermint/tendermint/types"
+)
+
+// ConsensusState
+type ConsensusState struct {
+	Height     int                        `json:"height"`
+	Round      int                        `json:"round"`
+	Step       uint8                      `json:"step"`
+	StartTime  string                     `json:"start_time"`
+	CommitTime string                     `json:"commit_time"`
+	Validators []Validator                `json:"validators"`
+	Proposal   *tendermint_types.Proposal `json:"proposal"`
+}
+
+func FromRoundState(rs *tendermint_consensus.RoundState) *ConsensusState {
+	cs := &ConsensusState{
+		CommitTime: rs.CommitTime.String(),
+		Height:     rs.Height,
+		Proposal:   rs.Proposal,
+		Round:      rs.Round,
+		StartTime:  rs.StartTime.String(),
+		Step:       uint8(rs.Step),
+		Validators: FromTendermintValidators(rs.Validators.Validators),
+	}
+	return cs
+}
diff --git a/consensus/types/validator.go b/consensus/types/validator.go
new file mode 100644
index 00000000..f5567bbb
--- /dev/null
+++ b/consensus/types/validator.go
@@ -0,0 +1,37 @@
+package types
+
+import (
+	"github.com/tendermint/go-wire"
+	tendermint_types "github.com/tendermint/tendermint/types"
+)
+
+var _ = wire.RegisterInterface(
+	struct{ Validator }{},
+	wire.ConcreteType{&TendermintValidator{}, byte(0x01)},
+)
+
+type Validator interface {
+	AssertIsValidator()
+}
+
+// Anticipating moving to our own definition of Validator, or at least
+// augmenting Tendermint's.
+type TendermintValidator struct {
+	*tendermint_types.Validator `json:"validator"`
+}
+
+func (validator *TendermintValidator) AssertIsValidator() {
+
+}
+
+var _ Validator = (*TendermintValidator)(nil)
+
+func FromTendermintValidators(tmValidators []*tendermint_types.Validator) []Validator {
+	validators := make([]Validator, len(tmValidators))
+	for i, tmValidator := range tmValidators {
+		// This embedding could be replaced by a mapping once if we want to describe
+		// a more general notion of validator
+		validators[i] = &TendermintValidator{tmValidator}
+	}
+	return validators
+}
diff --git a/core/types/types.go b/core/types/types.go
index 738bfb2f..274900ee 100644
--- a/core/types/types.go
+++ b/core/types/types.go
@@ -21,14 +21,12 @@ package types
 
 import (
 	"github.com/tendermint/go-p2p" // NodeInfo (drop this!)
-	tendermint_consensus "github.com/tendermint/tendermint/consensus"
 	"github.com/tendermint/tendermint/types"
 
 	account "github.com/eris-ltd/eris-db/account"
 )
 
 type (
-
 	// *********************************** Address ***********************************
 
 	// Accounts
@@ -81,17 +79,6 @@ type (
 
 	// *********************************** Consensus ***********************************
 
-	// ConsensusState
-	ConsensusState struct {
-		Height     int                `json:"height"`
-		Round      int                `json:"round"`
-		Step       uint8              `json:"step"`
-		StartTime  string             `json:"start_time"`
-		CommitTime string             `json:"commit_time"`
-		Validators []*types.Validator `json:"validators"`
-		Proposal   *types.Proposal    `json:"proposal"`
-	}
-
 	// Validators
 	ValidatorList struct {
 		BlockHeight         int                `json:"block_height"`
@@ -159,19 +146,6 @@ type (
 	}
 )
 
-func FromRoundState(rs *tendermint_consensus.RoundState) *ConsensusState {
-	cs := &ConsensusState{
-		CommitTime: rs.CommitTime.String(),
-		Height:     rs.Height,
-		Proposal:   rs.Proposal,
-		Round:      rs.Round,
-		StartTime:  rs.StartTime.String(),
-		Step:       uint8(rs.Step),
-		Validators: rs.Validators.Validators,
-	}
-	return cs
-}
-
 //------------------------------------------------------------------------------
 // copied in from NameReg
 
diff --git a/definitions/tendermint_pipe.go b/definitions/tendermint_pipe.go
index bffa94ad..37973ce4 100644
--- a/definitions/tendermint_pipe.go
+++ b/definitions/tendermint_pipe.go
@@ -69,4 +69,10 @@ type TendermintPipe interface {
 
 	// Blockchain
 	BlockchainInfo(minHeight, maxHeight, maxBlockLookback int) (*rpc_tm_types.ResultBlockchainInfo, error)
+	ListUnconfirmedTxs(maxTxs int) (*rpc_tm_types.ResultListUnconfirmedTxs, error)
+	GetBlock(height int) (*rpc_tm_types.ResultGetBlock, error)
+
+	// Consensus
+	ListValidators() (*rpc_tm_types.ResultListValidators, error)
+	DumpConsensusState() (*rpc_tm_types.ResultDumpConsensusState, error)
 }
diff --git a/manager/eris-mint/pipe.go b/manager/eris-mint/pipe.go
index 2c6b5c3b..16dc0b70 100644
--- a/manager/eris-mint/pipe.go
+++ b/manager/eris-mint/pipe.go
@@ -47,8 +47,8 @@ import (
 )
 
 type erisMintPipe struct {
-	erisMintState   *state.State
-	erisMint        *ErisMint
+	erisMintState *state.State
+	erisMint      *ErisMint
 	// Pipe implementations
 	accounts        *accounts
 	blockchain      blockchain_types.Blockchain
@@ -58,8 +58,8 @@ type erisMintPipe struct {
 	network         *network
 	transactor      *transactor
 	// Genesis cache
-	genesisDoc      *state_types.GenesisDoc
-	genesisState    *state.State
+	genesisDoc   *state_types.GenesisDoc
+	genesisState *state.State
 }
 
 // NOTE [ben] Compiler check to ensure erisMintPipe successfully implements
@@ -112,11 +112,11 @@ func NewErisMintPipe(moduleConfig *config.ModuleConfig,
 		genesisDoc:   genesisDoc,
 		genesisState: nil,
 		// TODO: What network-level information do we need?
-		network:       newNetwork(),
+		network: newNetwork(),
 		// consensus and blockchain should both be loaded into the pipe by a higher
 		// authority - this is a sort of dependency injection pattern
-		consensusEngine:     nil,
-		blockchain: nil,
+		consensusEngine: nil,
+		blockchain:      nil,
 	}, nil
 }
 
@@ -510,26 +510,34 @@ func (pipe *erisMintPipe) ListNames() (*rpc_tm_types.ResultListNames, error) {
 	return &rpc_tm_types.ResultListNames{blockHeight, names}, nil
 }
 
-// Memory pool
-// NOTE: txs must be signed
-func (pipe *erisMintPipe) BroadcastTxAsync(tx txs.Tx) (
-	*rpc_tm_types.ResultBroadcastTx, error) {
-	err := pipe.consensusEngine.BroadcastTransaction(txs.EncodeTx(tx), nil)
+func (pipe *erisMintPipe) broadcastTx(tx txs.Tx,
+	callback func(res *tmsp_types.Response)) (*rpc_tm_types.ResultBroadcastTx, error) {
+
+	txBytes, err := txs.EncodeTx(tx)
 	if err != nil {
-		return nil, fmt.Errorf("Error broadcasting txs: %v", err)
+		return nil, fmt.Errorf("Error encoding transaction: %v", err)
+	}
+	err = pipe.consensusEngine.BroadcastTransaction(txBytes, callback)
+	if err != nil {
+		return nil, fmt.Errorf("Error broadcasting transaction: %v", err)
 	}
 	return &rpc_tm_types.ResultBroadcastTx{}, nil
 }
 
-func (pipe *erisMintPipe) BroadcastTxSync(tx txs.Tx) (*rpc_tm_types.ResultBroadcastTx,
-	error) {
+// Memory pool
+// NOTE: txs must be signed
+func (pipe *erisMintPipe) BroadcastTxAsync(tx txs.Tx) (*rpc_tm_types.ResultBroadcastTx, error) {
+	return pipe.broadcastTx(tx, nil)
+}
+
+func (pipe *erisMintPipe) BroadcastTxSync(tx txs.Tx) (*rpc_tm_types.ResultBroadcastTx, error) {
 	responseChannel := make(chan *tmsp_types.Response, 1)
-	err := pipe.consensusEngine.BroadcastTransaction(txs.EncodeTx(tx),
+	_, err := pipe.broadcastTx(tx,
 		func(res *tmsp_types.Response) {
 			responseChannel <- res
 		})
 	if err != nil {
-		return nil, fmt.Errorf("Error broadcasting txs: %v", err)
+		return nil, err
 	}
 	// NOTE: [ben] This Response is set in /consensus/tendermint/local_client.go
 	// a call to Application, here implemented by ErisMint, over local callback,
@@ -562,6 +570,18 @@ func (pipe *erisMintPipe) BroadcastTxSync(tx txs.Tx) (*rpc_tm_types.ResultBroadc
 	}
 }
 
+func (pipe *erisMintPipe) ListUnconfirmedTxs(maxTxs int) (*rpc_tm_types.ResultListUnconfirmedTxs, error) {
+	// Get all transactions for now
+	transactions, err := pipe.consensusEngine.ListUnconfirmedTxs(maxTxs)
+	if err != nil {
+		return nil, err
+	}
+	return &rpc_tm_types.ResultListUnconfirmedTxs{
+		N:   len(transactions),
+		Txs: transactions,
+	}, nil
+}
+
 // Returns the current blockchain height and metadata for a range of blocks
 // between minHeight and maxHeight. Only returns maxBlockLookback block metadata
 // from the top of the range of blocks.
@@ -587,5 +607,34 @@ func (pipe *erisMintPipe) BlockchainInfo(minHeight, maxHeight,
 		blockMetas = append(blockMetas, blockMeta)
 	}
 
-	return &rpc_tm_types.ResultBlockchainInfo{latestHeight, blockMetas}, nil
+	return &rpc_tm_types.ResultBlockchainInfo{
+		LastHeight: latestHeight,
+		BlockMetas: blockMetas,
+	}, nil
+}
+
+func (pipe *erisMintPipe) GetBlock(height int) (*rpc_tm_types.ResultGetBlock, error) {
+	return &rpc_tm_types.ResultGetBlock{
+		Block:     pipe.blockchain.Block(height),
+		BlockMeta: pipe.blockchain.BlockMeta(height),
+	}, nil
+}
+
+func (pipe *erisMintPipe) ListValidators() (*rpc_tm_types.ResultListValidators, error) {
+	validators := pipe.consensusEngine.ListValidators()
+	consensusState := pipe.consensusEngine.ConsensusState()
+	// TODO: when we reintroduce support for bonding and unbonding update this
+	// to reflect the mutable bonding state
+	return &rpc_tm_types.ResultListValidators{
+		BlockHeight: consensusState.Height,
+		BondedValidators: validators,
+		UnbondingValidators: nil,
+	}, nil
+}
+
+func (pipe *erisMintPipe) DumpConsensusState() (*rpc_tm_types.ResultDumpConsensusState, error) {
+	return &rpc_tm_types.ResultDumpConsensusState{
+		ConsensusState: pipe.consensusEngine.ConsensusState(),
+		PeerConsensusStates: pipe.consensusEngine.PeerConsensusStates(),
+	}, nil
 }
diff --git a/rpc/tendermint/core/routes.go b/rpc/tendermint/core/routes.go
index 714c1066..8696ba83 100644
--- a/rpc/tendermint/core/routes.go
+++ b/rpc/tendermint/core/routes.go
@@ -38,15 +38,13 @@ func (tmRoutes *TendermintRoutes) GetRoutes() map[string]*rpc.RPCFunc {
 		"get_name":                rpc.NewRPCFunc(tmRoutes.GetNameResult, "name"),
 		"list_names":              rpc.NewRPCFunc(tmRoutes.ListNamesResult, ""),
 		"broadcast_tx":            rpc.NewRPCFunc(tmRoutes.BroadcastTxResult, "tx"),
+		"blockchain":              rpc.NewRPCFunc(tmRoutes.BlockchainInfo, "minHeight,maxHeight"),
+		"get_block":               rpc.NewRPCFunc(tmRoutes.GetBlock, "height"),
+		"list_validators":         rpc.NewRPCFunc(tmRoutes.ListValidators, ""),
+		"list_unconfirmed_txs":    rpc.NewRPCFunc(tmRoutes.ListUnconfirmedTxs, ""),
+		"dump_consensus_state":    rpc.NewRPCFunc(tmRoutes.DumpConsensusState, ""),
 		"unsafe/gen_priv_account": rpc.NewRPCFunc(tmRoutes.GenPrivAccountResult, ""),
 		"unsafe/sign_tx":          rpc.NewRPCFunc(tmRoutes.SignTxResult, "tx,privAccounts"),
-
-		// TODO: hookup
-		"blockchain": rpc.NewRPCFunc(tmRoutes.BlockchainInfo, "minHeight,maxHeight"),
-		//	"get_block":               rpc.NewRPCFunc(GetBlock, "height"),
-		// "list_validators":         rpc.NewRPCFunc(ListValidators, ""),
-		// "dump_consensus_state":    rpc.NewRPCFunc(DumpConsensusState, ""),
-		// "list_unconfirmed_txs":    rpc.NewRPCFunc(ListUnconfirmedTxs, ""),
 		// TODO: [Silas] do we also carry forward "consensus_state" as in v0?
 	}
 	return routes
@@ -211,5 +209,38 @@ func (tmRoutes *TendermintRoutes) BlockchainInfo(minHeight,
 	} else {
 		return r, nil
 	}
+}
 
+func (tmRoutes *TendermintRoutes) ListUnconfirmedTxs() (ctypes.ErisDBResult, error) {
+	// Get all Txs for now
+	r, err := tmRoutes.tendermintPipe.ListUnconfirmedTxs(0)
+	if err != nil {
+		return nil, err
+	} else {
+		return r, nil
+	}
+}
+func (tmRoutes *TendermintRoutes) GetBlock(height int) (ctypes.ErisDBResult, error) {
+	r, err := tmRoutes.tendermintPipe.GetBlock(height)
+	if err != nil {
+		return nil, err
+	} else {
+		return r, nil
+	}
+}
+func (tmRoutes *TendermintRoutes) ListValidators() (ctypes.ErisDBResult, error) {
+	r, err := tmRoutes.tendermintPipe.ListValidators()
+	if err != nil {
+		return nil, err
+	} else {
+		return r, nil
+	}
+}
+func (tmRoutes *TendermintRoutes) DumpConsensusState() (ctypes.ErisDBResult, error) {
+	r, err := tmRoutes.tendermintPipe.DumpConsensusState()
+	if err != nil {
+		return nil, err
+	} else {
+		return r, nil
+	}
 }
diff --git a/rpc/tendermint/core/types/responses.go b/rpc/tendermint/core/types/responses.go
index cacb5f5f..41aee026 100644
--- a/rpc/tendermint/core/types/responses.go
+++ b/rpc/tendermint/core/types/responses.go
@@ -5,7 +5,7 @@ import (
 	core_types "github.com/eris-ltd/eris-db/core/types"
 	stypes "github.com/eris-ltd/eris-db/manager/eris-mint/state/types"
 	"github.com/eris-ltd/eris-db/txs"
-	"github.com/tendermint/tendermint/types"
+	tendermint_types "github.com/tendermint/tendermint/types"
 
 	consensus_types "github.com/eris-ltd/eris-db/consensus/types"
 	"github.com/tendermint/go-crypto"
@@ -42,13 +42,13 @@ type StorageItem struct {
 }
 
 type ResultBlockchainInfo struct {
-	LastHeight int                `json:"last_height"`
-	BlockMetas []*types.BlockMeta `json:"block_metas"`
+	LastHeight int                           `json:"last_height"`
+	BlockMetas []*tendermint_types.BlockMeta `json:"block_metas"`
 }
 
 type ResultGetBlock struct {
-	BlockMeta *types.BlockMeta `json:"block_meta"`
-	Block     *types.Block     `json:"block"`
+	BlockMeta *tendermint_types.BlockMeta `json:"block_meta"`
+	Block     *tendermint_types.Block     `json:"block"`
 }
 
 type ResultStatus struct {
@@ -76,14 +76,14 @@ type ResultNetInfo struct {
 }
 
 type ResultListValidators struct {
-	BlockHeight         int                `json:"block_height"`
-	BondedValidators    []*types.Validator `json:"bonded_validators"`
-	UnbondingValidators []*types.Validator `json:"unbonding_validators"`
+	BlockHeight         int                         `json:"block_height"`
+	BondedValidators    []consensus_types.Validator `json:"bonded_validators"`
+	UnbondingValidators []consensus_types.Validator `json:"unbonding_validators"`
 }
 
 type ResultDumpConsensusState struct {
-	RoundState      string   `json:"round_state"`
-	PeerRoundStates []string `json:"peer_round_states"`
+	ConsensusState      *consensus_types.ConsensusState `json:"consensus_state"`
+	PeerConsensusStates map[string]string              `json:"peer_consensus_states"`
 }
 
 type ResultListNames struct {
@@ -158,28 +158,30 @@ type ErisDBResult interface {
 	rpctypes.Result
 }
 
-// for wire.readReflect
-var _ = wire.RegisterInterface(
-	struct{ ErisDBResult }{},
-	wire.ConcreteType{&ResultGetStorage{}, ResultTypeGetStorage},
-	wire.ConcreteType{&ResultCall{}, ResultTypeCall},
-	wire.ConcreteType{&ResultListAccounts{}, ResultTypeListAccounts},
-	wire.ConcreteType{&ResultDumpStorage{}, ResultTypeDumpStorage},
-	wire.ConcreteType{&ResultBlockchainInfo{}, ResultTypeBlockchainInfo},
-	wire.ConcreteType{&ResultGetBlock{}, ResultTypeGetBlock},
-	wire.ConcreteType{&ResultStatus{}, ResultTypeStatus},
-	wire.ConcreteType{&ResultNetInfo{}, ResultTypeNetInfo},
-	wire.ConcreteType{&ResultListValidators{}, ResultTypeListValidators},
-	wire.ConcreteType{&ResultDumpConsensusState{}, ResultTypeDumpConsensusState},
-	wire.ConcreteType{&ResultListNames{}, ResultTypeListNames},
-	wire.ConcreteType{&ResultGenPrivAccount{}, ResultTypeGenPrivAccount},
-	wire.ConcreteType{&ResultGetAccount{}, ResultTypeGetAccount},
-	wire.ConcreteType{&ResultBroadcastTx{}, ResultTypeBroadcastTx},
-	wire.ConcreteType{&ResultListUnconfirmedTxs{}, ResultTypeListUnconfirmedTxs},
-	wire.ConcreteType{&ResultGetName{}, ResultTypeGetName},
-	wire.ConcreteType{&ResultGenesis{}, ResultTypeGenesis},
-	wire.ConcreteType{&ResultSignTx{}, ResultTypeSignTx},
-	wire.ConcreteType{&ResultEvent{}, ResultTypeEvent},
-	wire.ConcreteType{&ResultSubscribe{}, ResultTypeSubscribe},
-	wire.ConcreteType{&ResultUnsubscribe{}, ResultTypeUnsubscribe},
-)
+func ConcreteTypes() []wire.ConcreteType {
+	return []wire.ConcreteType{
+		{&ResultGetStorage{}, ResultTypeGetStorage},
+		{&ResultCall{}, ResultTypeCall},
+		{&ResultListAccounts{}, ResultTypeListAccounts},
+		{&ResultDumpStorage{}, ResultTypeDumpStorage},
+		{&ResultBlockchainInfo{}, ResultTypeBlockchainInfo},
+		{&ResultGetBlock{}, ResultTypeGetBlock},
+		{&ResultStatus{}, ResultTypeStatus},
+		{&ResultNetInfo{}, ResultTypeNetInfo},
+		{&ResultListValidators{}, ResultTypeListValidators},
+		{&ResultDumpConsensusState{}, ResultTypeDumpConsensusState},
+		{&ResultListNames{}, ResultTypeListNames},
+		{&ResultGenPrivAccount{}, ResultTypeGenPrivAccount},
+		{&ResultGetAccount{}, ResultTypeGetAccount},
+		{&ResultBroadcastTx{}, ResultTypeBroadcastTx},
+		{&ResultListUnconfirmedTxs{}, ResultTypeListUnconfirmedTxs},
+		{&ResultGetName{}, ResultTypeGetName},
+		{&ResultGenesis{}, ResultTypeGenesis},
+		{&ResultSignTx{}, ResultTypeSignTx},
+		{&ResultEvent{}, ResultTypeEvent},
+		{&ResultSubscribe{}, ResultTypeSubscribe},
+		{&ResultUnsubscribe{}, ResultTypeUnsubscribe},
+	}
+}
+
+var _ = wire.RegisterInterface(struct{ ErisDBResult }{}, ConcreteTypes()...)
diff --git a/rpc/v0/methods.go b/rpc/v0/methods.go
index b3aac0e9..8e888e6b 100644
--- a/rpc/v0/methods.go
+++ b/rpc/v0/methods.go
@@ -256,17 +256,11 @@ func (erisDbMethods *ErisDbMethods) Block(request *rpc.RPCRequest, requester int
 // *************************************** Consensus ************************************
 
 func (erisDbMethods *ErisDbMethods) ConsensusState(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) {
-	// TODO: [Silas] erisDbMethods has not implemented this since the refactor
-	// core_types.FromRoundState() will do it, but only if we have access to
-	// Tendermint's RonudState..
-	state := &core_types.ConsensusState{}
-	return state, 0, nil
+	return erisDbMethods.pipe.Consensus().ConsensusState(), 0, nil
 }
 
 func (erisDbMethods *ErisDbMethods) Validators(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) {
-	// TODO: [Silas] erisDbMethods has not implemented this since the refactor
-	validators := &core_types.ValidatorList{}
-	return validators, 0, nil
+	return erisDbMethods.pipe.Consensus().ListValidators(), 0, nil
 }
 
 // *************************************** Net ************************************
diff --git a/rpc/v0/restServer.go b/rpc/v0/restServer.go
index d6ad13bd..42c925a3 100644
--- a/rpc/v0/restServer.go
+++ b/rpc/v0/restServer.go
@@ -221,17 +221,13 @@ func (restServer *RestServer) handleBlock(c *gin.Context) {
 
 // ********************************* Consensus *********************************
 func (restServer *RestServer) handleConsensusState(c *gin.Context) {
-	// TODO: [Silas] erisDbMethods has not implemented this since the refactor
-	// core_types.FromRoundState() will do it, but only if we have access to
-	// Tendermint's RonudState..
-	cs := &core_types.ConsensusState{}
+	cs := restServer.pipe.Consensus().ConsensusState()
 	c.Writer.WriteHeader(200)
 	restServer.codec.Encode(cs, c.Writer)
 }
 
 func (restServer *RestServer) handleValidatorList(c *gin.Context) {
-	// TODO: [Silas] erisDbMethods has not implemented this since the refactor
-	vl := &core_types.ValidatorList{}
+	vl := restServer.pipe.Consensus().ListValidators()
 	c.Writer.WriteHeader(200)
 	restServer.codec.Encode(vl, c.Writer)
 }
-- 
GitLab