TMSP -> ABCI

This commit is contained in:
Ethan Buchman 2017-01-12 15:53:32 -05:00
parent 3a55339114
commit c147b41013
38 changed files with 208 additions and 206 deletions

View File

@ -39,7 +39,7 @@ Yay open source! Please see our [contributing guidelines](https://github.com/ten
### Sub-projects ### Sub-projects
* [TMSP](http://github.com/tendermint/tmsp) * [ABCI](http://github.com/tendermint/abci)
* [Mintnet](http://github.com/tendermint/mintnet) * [Mintnet](http://github.com/tendermint/mintnet)
* [Go-Wire](http://github.com/tendermint/go-wire) * [Go-Wire](http://github.com/tendermint/go-wire)
* [Go-P2P](http://github.com/tendermint/go-p2p) * [Go-P2P](http://github.com/tendermint/go-p2p)

View File

@ -19,7 +19,7 @@ func parseFlags(config cfg.Config, args []string) {
grpcLaddr string grpcLaddr string
logLevel string logLevel string
proxyApp string proxyApp string
tmspTransport string abciTransport string
) )
// Declare flags // Declare flags
@ -35,7 +35,7 @@ func parseFlags(config cfg.Config, args []string) {
flags.StringVar(&logLevel, "log_level", config.GetString("log_level"), "Log level") flags.StringVar(&logLevel, "log_level", config.GetString("log_level"), "Log level")
flags.StringVar(&proxyApp, "proxy_app", config.GetString("proxy_app"), flags.StringVar(&proxyApp, "proxy_app", config.GetString("proxy_app"),
"Proxy app address, or 'nilapp' or 'dummy' for local testing.") "Proxy app address, or 'nilapp' or 'dummy' for local testing.")
flags.StringVar(&tmspTransport, "tmsp", config.GetString("tmsp"), "Specify tmsp transport (socket | grpc)") flags.StringVar(&abciTransport, "abci", config.GetString("abci"), "Specify abci transport (socket | grpc)")
flags.Parse(args) flags.Parse(args)
if printHelp { if printHelp {
flags.PrintDefaults() flags.PrintDefaults()
@ -52,5 +52,5 @@ func parseFlags(config cfg.Config, args []string) {
config.Set("grpc_laddr", grpcLaddr) config.Set("grpc_laddr", grpcLaddr)
config.Set("log_level", logLevel) config.Set("log_level", logLevel)
config.Set("proxy_app", proxyApp) config.Set("proxy_app", proxyApp)
config.Set("tmsp", tmspTransport) config.Set("abci", abciTransport)
} }

View File

@ -54,7 +54,7 @@ func GetConfig(rootDir string) cfg.Config {
mapConfig.SetRequired("chain_id") // blows up if you try to use it before setting. mapConfig.SetRequired("chain_id") // blows up if you try to use it before setting.
mapConfig.SetDefault("genesis_file", rootDir+"/genesis.json") mapConfig.SetDefault("genesis_file", rootDir+"/genesis.json")
mapConfig.SetDefault("proxy_app", "tcp://127.0.0.1:46658") mapConfig.SetDefault("proxy_app", "tcp://127.0.0.1:46658")
mapConfig.SetDefault("tmsp", "socket") mapConfig.SetDefault("abci", "socket")
mapConfig.SetDefault("moniker", "anonymous") mapConfig.SetDefault("moniker", "anonymous")
mapConfig.SetDefault("node_laddr", "tcp://0.0.0.0:46656") mapConfig.SetDefault("node_laddr", "tcp://0.0.0.0:46656")
mapConfig.SetDefault("seeds", "") mapConfig.SetDefault("seeds", "")

View File

@ -70,7 +70,7 @@ func ResetConfig(localPath string) cfg.Config {
mapConfig.SetDefault("chain_id", "tendermint_test") mapConfig.SetDefault("chain_id", "tendermint_test")
mapConfig.SetDefault("genesis_file", rootDir+"/genesis.json") mapConfig.SetDefault("genesis_file", rootDir+"/genesis.json")
mapConfig.SetDefault("proxy_app", "dummy") mapConfig.SetDefault("proxy_app", "dummy")
mapConfig.SetDefault("tmsp", "socket") mapConfig.SetDefault("abci", "socket")
mapConfig.SetDefault("moniker", "anonymous") mapConfig.SetDefault("moniker", "anonymous")
mapConfig.SetDefault("node_laddr", "tcp://0.0.0.0:36656") mapConfig.SetDefault("node_laddr", "tcp://0.0.0.0:36656")
mapConfig.SetDefault("fast_sync", false) mapConfig.SetDefault("fast_sync", false)

View File

@ -20,11 +20,11 @@ import (
mempl "github.com/tendermint/tendermint/mempool" mempl "github.com/tendermint/tendermint/mempool"
sm "github.com/tendermint/tendermint/state" sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
tmspcli "github.com/tendermint/tmsp/client" abcicli "github.com/tendermint/abci/client"
tmsp "github.com/tendermint/tmsp/types" abci "github.com/tendermint/abci/types"
"github.com/tendermint/tmsp/example/counter" "github.com/tendermint/abci/example/counter"
"github.com/tendermint/tmsp/example/dummy" "github.com/tendermint/abci/example/dummy"
) )
var config cfg.Config // NOTE: must be reset for each _test.go file var config cfg.Config // NOTE: must be reset for each _test.go file
@ -229,19 +229,19 @@ func readVotes(ch chan interface{}, reads int) chan struct{} {
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
// consensus states // consensus states
func newConsensusState(state *sm.State, pv *types.PrivValidator, app tmsp.Application) *ConsensusState { func newConsensusState(state *sm.State, pv *types.PrivValidator, app abci.Application) *ConsensusState {
return newConsensusStateWithConfig(config, state, pv, app) return newConsensusStateWithConfig(config, state, pv, app)
} }
func newConsensusStateWithConfig(thisConfig cfg.Config, state *sm.State, pv *types.PrivValidator, app tmsp.Application) *ConsensusState { func newConsensusStateWithConfig(thisConfig cfg.Config, state *sm.State, pv *types.PrivValidator, app abci.Application) *ConsensusState {
// Get BlockStore // Get BlockStore
blockDB := dbm.NewMemDB() blockDB := dbm.NewMemDB()
blockStore := bc.NewBlockStore(blockDB) blockStore := bc.NewBlockStore(blockDB)
// one for mempool, one for consensus // one for mempool, one for consensus
mtx := new(sync.Mutex) mtx := new(sync.Mutex)
proxyAppConnMem := tmspcli.NewLocalClient(mtx, app) proxyAppConnMem := abcicli.NewLocalClient(mtx, app)
proxyAppConnCon := tmspcli.NewLocalClient(mtx, app) proxyAppConnCon := abcicli.NewLocalClient(mtx, app)
// Make Mempool // Make Mempool
mempool := mempl.NewMempool(thisConfig, proxyAppConnMem) mempool := mempl.NewMempool(thisConfig, proxyAppConnMem)
@ -312,7 +312,7 @@ func ensureNoNewStep(stepCh chan interface{}) {
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
// consensus nets // consensus nets
func randConsensusNet(nValidators int, testName string, tickerFunc func() TimeoutTicker, appFunc func() tmsp.Application) []*ConsensusState { func randConsensusNet(nValidators int, testName string, tickerFunc func() TimeoutTicker, appFunc func() abci.Application) []*ConsensusState {
genDoc, privVals := randGenesisDoc(nValidators, false, 10) genDoc, privVals := randGenesisDoc(nValidators, false, 10)
css := make([]*ConsensusState, nValidators) css := make([]*ConsensusState, nValidators)
for i := 0; i < nValidators; i++ { for i := 0; i < nValidators; i++ {
@ -328,7 +328,7 @@ func randConsensusNet(nValidators int, testName string, tickerFunc func() Timeou
} }
// nPeers = nValidators + nNotValidator // nPeers = nValidators + nNotValidator
func randConsensusNetWithPeers(nValidators, nPeers int, testName string, tickerFunc func() TimeoutTicker, appFunc func() tmsp.Application) []*ConsensusState { func randConsensusNetWithPeers(nValidators, nPeers int, testName string, tickerFunc func() TimeoutTicker, appFunc func() abci.Application) []*ConsensusState {
genDoc, privVals := randGenesisDoc(nValidators, false, int64(testMinPower)) genDoc, privVals := randGenesisDoc(nValidators, false, int64(testMinPower))
css := make([]*ConsensusState, nPeers) css := make([]*ConsensusState, nPeers)
for i := 0; i < nPeers; i++ { for i := 0; i < nPeers; i++ {
@ -440,11 +440,11 @@ func (m *mockTicker) Chan() <-chan timeoutInfo {
//------------------------------------ //------------------------------------
func newCounter() tmsp.Application { func newCounter() abci.Application {
return counter.NewCounterApplication(true) return counter.NewCounterApplication(true)
} }
func newPersistentDummy() tmsp.Application { func newPersistentDummy() abci.Application {
dir, _ := ioutil.TempDir("/tmp", "persistent-dummy") dir, _ := ioutil.TempDir("/tmp", "persistent-dummy")
return dummy.NewPersistentDummyApplication(dir) return dummy.NewPersistentDummyApplication(dir)
} }

View File

@ -7,7 +7,7 @@ import (
"github.com/tendermint/tendermint/config/tendermint_test" "github.com/tendermint/tendermint/config/tendermint_test"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
tmsp "github.com/tendermint/tmsp/types" abci "github.com/tendermint/abci/types"
. "github.com/tendermint/go-common" . "github.com/tendermint/go-common"
) )
@ -66,10 +66,10 @@ func TestRmBadTx(t *testing.T) {
cbCh := make(chan struct{}) cbCh := make(chan struct{})
go func() { go func() {
// Try to send the tx through the mempool. // Try to send the tx through the mempool.
// CheckTx should not err, but the app should return a bad tmsp code // CheckTx should not err, but the app should return a bad abci code
// and the tx should get removed from the pool // and the tx should get removed from the pool
err := cs.mempool.CheckTx(txBytes, func(r *tmsp.Response) { err := cs.mempool.CheckTx(txBytes, func(r *abci.Response) {
if r.GetCheckTx().Code != tmsp.CodeType_BadNonce { if r.GetCheckTx().Code != abci.CodeType_BadNonce {
t.Fatalf("expected checktx to return bad nonce, got %v", r) t.Fatalf("expected checktx to return bad nonce, got %v", r)
} }
cbCh <- struct{}{} cbCh <- struct{}{}
@ -122,45 +122,45 @@ func NewCounterApplication() *CounterApplication {
return &CounterApplication{} return &CounterApplication{}
} }
func (app *CounterApplication) Info() tmsp.ResponseInfo { func (app *CounterApplication) Info() abci.ResponseInfo {
return tmsp.ResponseInfo{Data: Fmt("txs:%v", app.txCount)} return abci.ResponseInfo{Data: Fmt("txs:%v", app.txCount)}
} }
func (app *CounterApplication) SetOption(key string, value string) (log string) { func (app *CounterApplication) SetOption(key string, value string) (log string) {
return "" return ""
} }
func (app *CounterApplication) AppendTx(tx []byte) tmsp.Result { func (app *CounterApplication) AppendTx(tx []byte) abci.Result {
return runTx(tx, &app.txCount) return runTx(tx, &app.txCount)
} }
func (app *CounterApplication) CheckTx(tx []byte) tmsp.Result { func (app *CounterApplication) CheckTx(tx []byte) abci.Result {
return runTx(tx, &app.mempoolTxCount) return runTx(tx, &app.mempoolTxCount)
} }
func runTx(tx []byte, countPtr *int) tmsp.Result { func runTx(tx []byte, countPtr *int) abci.Result {
count := *countPtr count := *countPtr
tx8 := make([]byte, 8) tx8 := make([]byte, 8)
copy(tx8[len(tx8)-len(tx):], tx) copy(tx8[len(tx8)-len(tx):], tx)
txValue := binary.BigEndian.Uint64(tx8) txValue := binary.BigEndian.Uint64(tx8)
if txValue != uint64(count) { if txValue != uint64(count) {
return tmsp.ErrBadNonce.AppendLog(Fmt("Invalid nonce. Expected %v, got %v", count, txValue)) return abci.ErrBadNonce.AppendLog(Fmt("Invalid nonce. Expected %v, got %v", count, txValue))
} }
*countPtr += 1 *countPtr += 1
return tmsp.OK return abci.OK
} }
func (app *CounterApplication) Commit() tmsp.Result { func (app *CounterApplication) Commit() abci.Result {
app.mempoolTxCount = app.txCount app.mempoolTxCount = app.txCount
if app.txCount == 0 { if app.txCount == 0 {
return tmsp.OK return abci.OK
} else { } else {
hash := make([]byte, 8) hash := make([]byte, 8)
binary.BigEndian.PutUint64(hash, uint64(app.txCount)) binary.BigEndian.PutUint64(hash, uint64(app.txCount))
return tmsp.NewResultOK(hash, "") return abci.NewResultOK(hash, "")
} }
} }
func (app *CounterApplication) Query(query []byte) tmsp.Result { func (app *CounterApplication) Query(query []byte) abci.Result {
return tmsp.NewResultOK(nil, Fmt("Query is not supported")) return abci.NewResultOK(nil, Fmt("Query is not supported"))
} }

View File

@ -11,7 +11,7 @@ import (
"github.com/tendermint/go-events" "github.com/tendermint/go-events"
"github.com/tendermint/go-p2p" "github.com/tendermint/go-p2p"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
"github.com/tendermint/tmsp/example/dummy" "github.com/tendermint/abci/example/dummy"
) )
func init() { func init() {

View File

@ -354,7 +354,7 @@ func (cs *ConsensusState) OnStart() error {
return err return err
} }
// If the latest block was applied in the tmsp handshake, // If the latest block was applied in the abci handshake,
// we may not have written the current height to the wal, // we may not have written the current height to the wal,
// so check here and write it if not found. // so check here and write it if not found.
// TODO: remove this and run the handhsake/replay // TODO: remove this and run the handhsake/replay

23
glide.lock generated
View File

@ -1,5 +1,5 @@
hash: 8e2e970c04c55b02740daa62647bb637964504a65c45cf274ffed5b0b1930ae4 hash: 25681f005f0b9b1816cd5c5f0a0fd013395a7477c656c6010bb570b5aebd2d0a
updated: 2017-01-12T14:56:02.152843341-05:00 updated: 2017-01-12T15:52:43.856786013-05:00
imports: imports:
- name: github.com/btcsuite/btcd - name: github.com/btcsuite/btcd
version: afec1bd1245a4a19e6dfe1306974b733e7cbb9b8 version: afec1bd1245a4a19e6dfe1306974b733e7cbb9b8
@ -48,6 +48,16 @@ imports:
- leveldb/storage - leveldb/storage
- leveldb/table - leveldb/table
- leveldb/util - leveldb/util
- name: github.com/tendermint/abci
version: 3a5e63e987a50cf74a16fe0a5e18e74eb82b2031
repo: https://github.com/tendermint/tmsp
subpackages:
- client
- example/counter
- example/dummy
- example/nil
- server
- types
- name: github.com/tendermint/ed25519 - name: github.com/tendermint/ed25519
version: 1f52c6f8b8a5c7908aff4497c186af344b428925 version: 1f52c6f8b8a5c7908aff4497c186af344b428925
subpackages: subpackages:
@ -93,15 +103,6 @@ imports:
version: ae0f3d6450da9eac7074b439c8e1c3cabf0d5ce6 version: ae0f3d6450da9eac7074b439c8e1c3cabf0d5ce6
subpackages: subpackages:
- term - term
- name: github.com/tendermint/tmsp
version: f8167872d8ddd3a2362452ef1414991b5afa8862
subpackages:
- client
- example/counter
- example/dummy
- example/nil
- server
- types
- name: golang.org/x/crypto - name: golang.org/x/crypto
version: ede567c8e044a5913dad1d1af3696d9da953104c version: ede567c8e044a5913dad1d1af3696d9da953104c
subpackages: subpackages:

View File

@ -28,8 +28,9 @@ import:
- package: github.com/tendermint/go-wire - package: github.com/tendermint/go-wire
version: develop version: develop
- package: github.com/tendermint/log15 - package: github.com/tendermint/log15
- package: github.com/tendermint/tmsp - package: github.com/tendermint/abci
version: develop version: rename
repo: https://github.com/tendermint/tmsp
- package: golang.org/x/crypto - package: golang.org/x/crypto
subpackages: subpackages:
- ripemd160 - ripemd160

View File

@ -13,7 +13,7 @@ import (
cfg "github.com/tendermint/go-config" cfg "github.com/tendermint/go-config"
"github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/proxy"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
tmsp "github.com/tendermint/tmsp/types" abci "github.com/tendermint/abci/types"
) )
/* /*
@ -40,7 +40,7 @@ Garbage collection of old elements from mempool.txs is handlde via
the DetachPrev() call, which makes old elements not reachable by the DetachPrev() call, which makes old elements not reachable by
peer broadcastTxRoutine() automatically garbage collected. peer broadcastTxRoutine() automatically garbage collected.
TODO: Better handle tmsp client errors. (make it automatically handle connection errors) TODO: Better handle abci client errors. (make it automatically handle connection errors)
*/ */
@ -139,17 +139,17 @@ func (mem *Mempool) TxsFrontWait() *clist.CElement {
// cb: A callback from the CheckTx command. // cb: A callback from the CheckTx command.
// It gets called from another goroutine. // It gets called from another goroutine.
// CONTRACT: Either cb will get called, or err returned. // CONTRACT: Either cb will get called, or err returned.
func (mem *Mempool) CheckTx(tx types.Tx, cb func(*tmsp.Response)) (err error) { func (mem *Mempool) CheckTx(tx types.Tx, cb func(*abci.Response)) (err error) {
mem.proxyMtx.Lock() mem.proxyMtx.Lock()
defer mem.proxyMtx.Unlock() defer mem.proxyMtx.Unlock()
// CACHE // CACHE
if mem.cache.Exists(tx) { if mem.cache.Exists(tx) {
if cb != nil { if cb != nil {
cb(&tmsp.Response{ cb(&abci.Response{
Value: &tmsp.Response_CheckTx{ Value: &abci.Response_CheckTx{
&tmsp.ResponseCheckTx{ &abci.ResponseCheckTx{
Code: tmsp.CodeType_BadNonce, // TODO or duplicate tx Code: abci.CodeType_BadNonce, // TODO or duplicate tx
Log: "Duplicate transaction (ignored)", Log: "Duplicate transaction (ignored)",
}, },
}, },
@ -180,8 +180,8 @@ func (mem *Mempool) CheckTx(tx types.Tx, cb func(*tmsp.Response)) (err error) {
return nil return nil
} }
// TMSP callback function // ABCI callback function
func (mem *Mempool) resCb(req *tmsp.Request, res *tmsp.Response) { func (mem *Mempool) resCb(req *abci.Request, res *abci.Response) {
if mem.recheckCursor == nil { if mem.recheckCursor == nil {
mem.resCbNormal(req, res) mem.resCbNormal(req, res)
} else { } else {
@ -189,10 +189,10 @@ func (mem *Mempool) resCb(req *tmsp.Request, res *tmsp.Response) {
} }
} }
func (mem *Mempool) resCbNormal(req *tmsp.Request, res *tmsp.Response) { func (mem *Mempool) resCbNormal(req *abci.Request, res *abci.Response) {
switch r := res.Value.(type) { switch r := res.Value.(type) {
case *tmsp.Response_CheckTx: case *abci.Response_CheckTx:
if r.CheckTx.Code == tmsp.CodeType_OK { if r.CheckTx.Code == abci.CodeType_OK {
mem.counter++ mem.counter++
memTx := &mempoolTx{ memTx := &mempoolTx{
counter: mem.counter, counter: mem.counter,
@ -214,15 +214,15 @@ func (mem *Mempool) resCbNormal(req *tmsp.Request, res *tmsp.Response) {
} }
} }
func (mem *Mempool) resCbRecheck(req *tmsp.Request, res *tmsp.Response) { func (mem *Mempool) resCbRecheck(req *abci.Request, res *abci.Response) {
switch r := res.Value.(type) { switch r := res.Value.(type) {
case *tmsp.Response_CheckTx: case *abci.Response_CheckTx:
memTx := mem.recheckCursor.Value.(*mempoolTx) memTx := mem.recheckCursor.Value.(*mempoolTx)
if !bytes.Equal(req.GetCheckTx().Tx, memTx.tx) { if !bytes.Equal(req.GetCheckTx().Tx, memTx.tx) {
PanicSanity(Fmt("Unexpected tx response from proxy during recheck\n"+ PanicSanity(Fmt("Unexpected tx response from proxy during recheck\n"+
"Expected %X, got %X", r.CheckTx.Data, memTx.tx)) "Expected %X, got %X", r.CheckTx.Data, memTx.tx))
} }
if r.CheckTx.Code == tmsp.CodeType_OK { if r.CheckTx.Code == abci.CodeType_OK {
// Good, nothing to do. // Good, nothing to do.
} else { } else {
// Tx became invalidated due to newly committed block. // Tx became invalidated due to newly committed block.

View File

@ -7,7 +7,7 @@ import (
"github.com/tendermint/tendermint/config/tendermint_test" "github.com/tendermint/tendermint/config/tendermint_test"
"github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/proxy"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
"github.com/tendermint/tmsp/example/counter" "github.com/tendermint/abci/example/counter"
) )
func TestSerialReap(t *testing.T) { func TestSerialReap(t *testing.T) {
@ -16,8 +16,8 @@ func TestSerialReap(t *testing.T) {
app := counter.NewCounterApplication(true) app := counter.NewCounterApplication(true)
app.SetOption("serial", "on") app.SetOption("serial", "on")
cc := proxy.NewLocalClientCreator(app) cc := proxy.NewLocalClientCreator(app)
appConnMem, _ := cc.NewTMSPClient() appConnMem, _ := cc.NewABCIClient()
appConnCon, _ := cc.NewTMSPClient() appConnCon, _ := cc.NewABCIClient()
mempool := NewMempool(config, appConnMem) mempool := NewMempool(config, appConnMem)
appendTxsRange := func(start, end int) { appendTxsRange := func(start, end int) {

View File

@ -12,7 +12,7 @@ import (
"github.com/tendermint/go-p2p" "github.com/tendermint/go-p2p"
"github.com/tendermint/go-wire" "github.com/tendermint/go-wire"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
tmsp "github.com/tendermint/tmsp/types" abci "github.com/tendermint/abci/types"
) )
const ( const (
@ -85,7 +85,7 @@ func (memR *MempoolReactor) Receive(chID byte, src *p2p.Peer, msgBytes []byte) {
} }
// Just an alias for CheckTx since broadcasting happens in peer routines // Just an alias for CheckTx since broadcasting happens in peer routines
func (memR *MempoolReactor) BroadcastTx(tx types.Tx, cb func(*tmsp.Response)) error { func (memR *MempoolReactor) BroadcastTx(tx types.Tx, cb func(*abci.Response)) error {
return memR.Mempool.CheckTx(tx, cb) return memR.Mempool.CheckTx(tx, cb)
} }

View File

@ -113,7 +113,7 @@ func NewNode(config cfg.Config, privValidator *types.PrivValidator, clientCreato
sw.AddReactor("BLOCKCHAIN", bcReactor) sw.AddReactor("BLOCKCHAIN", bcReactor)
sw.AddReactor("CONSENSUS", consensusReactor) sw.AddReactor("CONSENSUS", consensusReactor)
// filter peers by addr or pubkey with a tmsp query. // filter peers by addr or pubkey with a abci query.
// if the query return code is OK, add peer // if the query return code is OK, add peer
// XXX: query format subject to change // XXX: query format subject to change
if config.GetBool("filter_peers") { if config.GetBool("filter_peers") {
@ -311,7 +311,7 @@ func makeNodeInfo(config cfg.Config, sw *p2p.Switch, privKey crypto.PrivKeyEd255
// Users wishing to: // Users wishing to:
// * use an external signer for their validators // * use an external signer for their validators
// * supply an in-proc tmsp app // * supply an in-proc abci app
// should fork tendermint/tendermint and implement RunNode to // should fork tendermint/tendermint and implement RunNode to
// call NewNode with their custom priv validator and/or custom // call NewNode with their custom priv validator and/or custom
// proxy.ClientCreator interface // proxy.ClientCreator interface

View File

@ -1,32 +1,32 @@
package proxy package proxy
import ( import (
tmspcli "github.com/tendermint/tmsp/client" abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/tmsp/types" "github.com/tendermint/abci/types"
) )
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
// Enforce which tmsp msgs can be sent on a connection at the type level // Enforce which abci msgs can be sent on a connection at the type level
type AppConnConsensus interface { type AppConnConsensus interface {
SetResponseCallback(tmspcli.Callback) SetResponseCallback(abcicli.Callback)
Error() error Error() error
InitChainSync(validators []*types.Validator) (err error) InitChainSync(validators []*types.Validator) (err error)
BeginBlockSync(hash []byte, header *types.Header) (err error) BeginBlockSync(hash []byte, header *types.Header) (err error)
AppendTxAsync(tx []byte) *tmspcli.ReqRes AppendTxAsync(tx []byte) *abcicli.ReqRes
EndBlockSync(height uint64) (types.ResponseEndBlock, error) EndBlockSync(height uint64) (types.ResponseEndBlock, error)
CommitSync() (res types.Result) CommitSync() (res types.Result)
} }
type AppConnMempool interface { type AppConnMempool interface {
SetResponseCallback(tmspcli.Callback) SetResponseCallback(abcicli.Callback)
Error() error Error() error
CheckTxAsync(tx []byte) *tmspcli.ReqRes CheckTxAsync(tx []byte) *abcicli.ReqRes
FlushAsync() *tmspcli.ReqRes FlushAsync() *abcicli.ReqRes
FlushSync() error FlushSync() error
} }
@ -41,19 +41,19 @@ type AppConnQuery interface {
} }
//----------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------
// Implements AppConnConsensus (subset of tmspcli.Client) // Implements AppConnConsensus (subset of abcicli.Client)
type appConnConsensus struct { type appConnConsensus struct {
appConn tmspcli.Client appConn abcicli.Client
} }
func NewAppConnConsensus(appConn tmspcli.Client) *appConnConsensus { func NewAppConnConsensus(appConn abcicli.Client) *appConnConsensus {
return &appConnConsensus{ return &appConnConsensus{
appConn: appConn, appConn: appConn,
} }
} }
func (app *appConnConsensus) SetResponseCallback(cb tmspcli.Callback) { func (app *appConnConsensus) SetResponseCallback(cb abcicli.Callback) {
app.appConn.SetResponseCallback(cb) app.appConn.SetResponseCallback(cb)
} }
@ -69,7 +69,7 @@ func (app *appConnConsensus) BeginBlockSync(hash []byte, header *types.Header) (
return app.appConn.BeginBlockSync(hash, header) return app.appConn.BeginBlockSync(hash, header)
} }
func (app *appConnConsensus) AppendTxAsync(tx []byte) *tmspcli.ReqRes { func (app *appConnConsensus) AppendTxAsync(tx []byte) *abcicli.ReqRes {
return app.appConn.AppendTxAsync(tx) return app.appConn.AppendTxAsync(tx)
} }
@ -82,19 +82,19 @@ func (app *appConnConsensus) CommitSync() (res types.Result) {
} }
//------------------------------------------------ //------------------------------------------------
// Implements AppConnMempool (subset of tmspcli.Client) // Implements AppConnMempool (subset of abcicli.Client)
type appConnMempool struct { type appConnMempool struct {
appConn tmspcli.Client appConn abcicli.Client
} }
func NewAppConnMempool(appConn tmspcli.Client) *appConnMempool { func NewAppConnMempool(appConn abcicli.Client) *appConnMempool {
return &appConnMempool{ return &appConnMempool{
appConn: appConn, appConn: appConn,
} }
} }
func (app *appConnMempool) SetResponseCallback(cb tmspcli.Callback) { func (app *appConnMempool) SetResponseCallback(cb abcicli.Callback) {
app.appConn.SetResponseCallback(cb) app.appConn.SetResponseCallback(cb)
} }
@ -102,7 +102,7 @@ func (app *appConnMempool) Error() error {
return app.appConn.Error() return app.appConn.Error()
} }
func (app *appConnMempool) FlushAsync() *tmspcli.ReqRes { func (app *appConnMempool) FlushAsync() *abcicli.ReqRes {
return app.appConn.FlushAsync() return app.appConn.FlushAsync()
} }
@ -110,18 +110,18 @@ func (app *appConnMempool) FlushSync() error {
return app.appConn.FlushSync() return app.appConn.FlushSync()
} }
func (app *appConnMempool) CheckTxAsync(tx []byte) *tmspcli.ReqRes { func (app *appConnMempool) CheckTxAsync(tx []byte) *abcicli.ReqRes {
return app.appConn.CheckTxAsync(tx) return app.appConn.CheckTxAsync(tx)
} }
//------------------------------------------------ //------------------------------------------------
// Implements AppConnQuery (subset of tmspcli.Client) // Implements AppConnQuery (subset of abcicli.Client)
type appConnQuery struct { type appConnQuery struct {
appConn tmspcli.Client appConn abcicli.Client
} }
func NewAppConnQuery(appConn tmspcli.Client) *appConnQuery { func NewAppConnQuery(appConn abcicli.Client) *appConnQuery {
return &appConnQuery{ return &appConnQuery{
appConn: appConn, appConn: appConn,
} }

View File

@ -5,29 +5,29 @@ import (
"testing" "testing"
. "github.com/tendermint/go-common" . "github.com/tendermint/go-common"
tmspcli "github.com/tendermint/tmsp/client" abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/tmsp/example/dummy" "github.com/tendermint/abci/example/dummy"
"github.com/tendermint/tmsp/server" "github.com/tendermint/abci/server"
"github.com/tendermint/tmsp/types" "github.com/tendermint/abci/types"
) )
//---------------------------------------- //----------------------------------------
type AppConnTest interface { type AppConnTest interface {
EchoAsync(string) *tmspcli.ReqRes EchoAsync(string) *abcicli.ReqRes
FlushSync() error FlushSync() error
InfoSync() (types.ResponseInfo, error) InfoSync() (types.ResponseInfo, error)
} }
type appConnTest struct { type appConnTest struct {
appConn tmspcli.Client appConn abcicli.Client
} }
func NewAppConnTest(appConn tmspcli.Client) AppConnTest { func NewAppConnTest(appConn abcicli.Client) AppConnTest {
return &appConnTest{appConn} return &appConnTest{appConn}
} }
func (app *appConnTest) EchoAsync(msg string) *tmspcli.ReqRes { func (app *appConnTest) EchoAsync(msg string) *abcicli.ReqRes {
return app.appConn.EchoAsync(msg) return app.appConn.EchoAsync(msg)
} }
@ -54,7 +54,7 @@ func TestEcho(t *testing.T) {
} }
defer s.Stop() defer s.Stop()
// Start client // Start client
cli, err := clientCreator.NewTMSPClient() cli, err := clientCreator.NewABCIClient()
if err != nil { if err != nil {
Exit(err.Error()) Exit(err.Error())
} }
@ -78,7 +78,7 @@ func BenchmarkEcho(b *testing.B) {
} }
defer s.Stop() defer s.Stop()
// Start client // Start client
cli, err := clientCreator.NewTMSPClient() cli, err := clientCreator.NewABCIClient()
if err != nil { if err != nil {
Exit(err.Error()) Exit(err.Error())
} }
@ -107,7 +107,7 @@ func TestInfo(t *testing.T) {
} }
defer s.Stop() defer s.Stop()
// Start client // Start client
cli, err := clientCreator.NewTMSPClient() cli, err := clientCreator.NewABCIClient()
if err != nil { if err != nil {
Exit(err.Error()) Exit(err.Error())
} }

View File

@ -5,15 +5,15 @@ import (
"sync" "sync"
cfg "github.com/tendermint/go-config" cfg "github.com/tendermint/go-config"
tmspcli "github.com/tendermint/tmsp/client" abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/tmsp/example/dummy" "github.com/tendermint/abci/example/dummy"
nilapp "github.com/tendermint/tmsp/example/nil" nilapp "github.com/tendermint/abci/example/nil"
"github.com/tendermint/tmsp/types" "github.com/tendermint/abci/types"
) )
// NewTMSPClient returns newly connected client // NewABCIClient returns newly connected client
type ClientCreator interface { type ClientCreator interface {
NewTMSPClient() (tmspcli.Client, error) NewABCIClient() (abcicli.Client, error)
} }
//---------------------------------------------------- //----------------------------------------------------
@ -31,8 +31,8 @@ func NewLocalClientCreator(app types.Application) ClientCreator {
} }
} }
func (l *localClientCreator) NewTMSPClient() (tmspcli.Client, error) { func (l *localClientCreator) NewABCIClient() (abcicli.Client, error) {
return tmspcli.NewLocalClient(l.mtx, l.app), nil return abcicli.NewLocalClient(l.mtx, l.app), nil
} }
//--------------------------------------------------------------- //---------------------------------------------------------------
@ -52,9 +52,9 @@ func NewRemoteClientCreator(addr, transport string, mustConnect bool) ClientCrea
} }
} }
func (r *remoteClientCreator) NewTMSPClient() (tmspcli.Client, error) { func (r *remoteClientCreator) NewABCIClient() (abcicli.Client, error) {
// Run forever in a loop // Run forever in a loop
remoteApp, err := tmspcli.NewClient(r.addr, r.transport, r.mustConnect) remoteApp, err := abcicli.NewClient(r.addr, r.transport, r.mustConnect)
if err != nil { if err != nil {
return nil, fmt.Errorf("Failed to connect to proxy: %v", err) return nil, fmt.Errorf("Failed to connect to proxy: %v", err)
} }
@ -66,7 +66,7 @@ func (r *remoteClientCreator) NewTMSPClient() (tmspcli.Client, error) {
func DefaultClientCreator(config cfg.Config) ClientCreator { func DefaultClientCreator(config cfg.Config) ClientCreator {
addr := config.GetString("proxy_app") addr := config.GetString("proxy_app")
transport := config.GetString("tmsp") transport := config.GetString("abci")
switch addr { switch addr {
case "dummy": case "dummy":

View File

@ -28,7 +28,7 @@ type Handshaker interface {
} }
// a multiAppConn is made of a few appConns (mempool, consensus, query) // a multiAppConn is made of a few appConns (mempool, consensus, query)
// and manages their underlying tmsp clients, including the handshake // and manages their underlying abci clients, including the handshake
// which ensures the app and tendermint are synced. // which ensures the app and tendermint are synced.
// TODO: on app restart, clients must reboot together // TODO: on app restart, clients must reboot together
type multiAppConn struct { type multiAppConn struct {
@ -45,7 +45,7 @@ type multiAppConn struct {
clientCreator ClientCreator clientCreator ClientCreator
} }
// Make all necessary tmsp connections to the application // Make all necessary abci connections to the application
func NewMultiAppConn(config cfg.Config, clientCreator ClientCreator, handshaker Handshaker) *multiAppConn { func NewMultiAppConn(config cfg.Config, clientCreator ClientCreator, handshaker Handshaker) *multiAppConn {
multiAppConn := &multiAppConn{ multiAppConn := &multiAppConn{
config: config, config: config,
@ -75,21 +75,21 @@ func (app *multiAppConn) OnStart() error {
app.BaseService.OnStart() app.BaseService.OnStart()
// query connection // query connection
querycli, err := app.clientCreator.NewTMSPClient() querycli, err := app.clientCreator.NewABCIClient()
if err != nil { if err != nil {
return err return err
} }
app.queryConn = NewAppConnQuery(querycli) app.queryConn = NewAppConnQuery(querycli)
// mempool connection // mempool connection
memcli, err := app.clientCreator.NewTMSPClient() memcli, err := app.clientCreator.NewABCIClient()
if err != nil { if err != nil {
return err return err
} }
app.mempoolConn = NewAppConnMempool(memcli) app.mempoolConn = NewAppConnMempool(memcli)
// consensus connection // consensus connection
concli, err := app.clientCreator.NewTMSPClient() concli, err := app.clientCreator.NewABCIClient()
if err != nil { if err != nil {
return err return err
} }

View File

@ -6,7 +6,7 @@ import (
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
tmsp "github.com/tendermint/tmsp/types" abci "github.com/tendermint/abci/types"
) )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -23,8 +23,8 @@ func BroadcastTxAsync(tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
// Returns with the response from CheckTx // Returns with the response from CheckTx
func BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error) { func BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
resCh := make(chan *tmsp.Response, 1) resCh := make(chan *abci.Response, 1)
err := mempool.CheckTx(tx, func(res *tmsp.Response) { err := mempool.CheckTx(tx, func(res *abci.Response) {
resCh <- res resCh <- res
}) })
if err != nil { if err != nil {
@ -42,7 +42,7 @@ func BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
// CONTRACT: only returns error if mempool.BroadcastTx errs (ie. problem with the app) // CONTRACT: only returns error if mempool.BroadcastTx errs (ie. problem with the app)
// or if we timeout waiting for tx to commit. // or if we timeout waiting for tx to commit.
// If CheckTx or AppendTx fail, no error will be returned, but the returned result // If CheckTx or AppendTx fail, no error will be returned, but the returned result
// will contain a non-OK TMSP code. // will contain a non-OK ABCI code.
func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) { func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
// subscribe to tx being committed in block // subscribe to tx being committed in block
@ -52,8 +52,8 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
}) })
// broadcast the tx and register checktx callback // broadcast the tx and register checktx callback
checkTxResCh := make(chan *tmsp.Response, 1) checkTxResCh := make(chan *abci.Response, 1)
err := mempool.CheckTx(tx, func(res *tmsp.Response) { err := mempool.CheckTx(tx, func(res *abci.Response) {
checkTxResCh <- res checkTxResCh <- res
}) })
if err != nil { if err != nil {
@ -62,7 +62,7 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
} }
checkTxRes := <-checkTxResCh checkTxRes := <-checkTxResCh
checkTxR := checkTxRes.GetCheckTx() checkTxR := checkTxRes.GetCheckTx()
if checkTxR.Code != tmsp.CodeType_OK { if checkTxR.Code != abci.CodeType_OK {
// CheckTx failed! // CheckTx failed!
return &ctypes.ResultBroadcastTxCommit{ return &ctypes.ResultBroadcastTxCommit{
CheckTx: checkTxR, CheckTx: checkTxR,
@ -77,7 +77,7 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
select { select {
case appendTxRes := <-appendTxResCh: case appendTxRes := <-appendTxResCh:
// The tx was included in a block. // The tx was included in a block.
appendTxR := &tmsp.ResponseAppendTx{ appendTxR := &abci.ResponseAppendTx{
Code: appendTxRes.Code, Code: appendTxRes.Code,
Data: appendTxRes.Data, Data: appendTxRes.Data,
Log: appendTxRes.Log, Log: appendTxRes.Log,

View File

@ -8,7 +8,7 @@ import (
"github.com/tendermint/tendermint/consensus" "github.com/tendermint/tendermint/consensus"
"github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/proxy"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
tmsp "github.com/tendermint/tmsp/types" abci "github.com/tendermint/abci/types"
) )
//----------------------------------------------------- //-----------------------------------------------------
@ -28,7 +28,7 @@ type Consensus interface {
type Mempool interface { type Mempool interface {
Size() int Size() int
CheckTx(types.Tx, func(*tmsp.Response)) error CheckTx(types.Tx, func(*abci.Response)) error
Reap(int) []types.Tx Reap(int) []types.Tx
Flush() Flush()
} }

View File

@ -25,8 +25,8 @@ var Routes = map[string]*rpc.RPCFunc{
"unconfirmed_txs": rpc.NewRPCFunc(UnconfirmedTxsResult, ""), "unconfirmed_txs": rpc.NewRPCFunc(UnconfirmedTxsResult, ""),
"num_unconfirmed_txs": rpc.NewRPCFunc(NumUnconfirmedTxsResult, ""), "num_unconfirmed_txs": rpc.NewRPCFunc(NumUnconfirmedTxsResult, ""),
"tmsp_query": rpc.NewRPCFunc(TMSPQueryResult, "query"), "abci_query": rpc.NewRPCFunc(ABCIQueryResult, "query"),
"tmsp_info": rpc.NewRPCFunc(TMSPInfoResult, ""), "abci_info": rpc.NewRPCFunc(ABCIInfoResult, ""),
"unsafe_flush_mempool": rpc.NewRPCFunc(UnsafeFlushMempool, ""), "unsafe_flush_mempool": rpc.NewRPCFunc(UnsafeFlushMempool, ""),
"unsafe_set_config": rpc.NewRPCFunc(UnsafeSetConfigResult, "type,key,value"), "unsafe_set_config": rpc.NewRPCFunc(UnsafeSetConfigResult, "type,key,value"),
@ -155,16 +155,16 @@ func BroadcastTxAsyncResult(tx []byte) (ctypes.TMResult, error) {
} }
} }
func TMSPQueryResult(query []byte) (ctypes.TMResult, error) { func ABCIQueryResult(query []byte) (ctypes.TMResult, error) {
if r, err := TMSPQuery(query); err != nil { if r, err := ABCIQuery(query); err != nil {
return nil, err return nil, err
} else { } else {
return r, nil return r, nil
} }
} }
func TMSPInfoResult() (ctypes.TMResult, error) { func ABCIInfoResult() (ctypes.TMResult, error) {
if r, err := TMSPInfo(); err != nil { if r, err := ABCIInfo(); err != nil {
return nil, err return nil, err
} else { } else {
return r, nil return r, nil

View File

@ -6,17 +6,17 @@ import (
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
func TMSPQuery(query []byte) (*ctypes.ResultTMSPQuery, error) { func ABCIQuery(query []byte) (*ctypes.ResultABCIQuery, error) {
res := proxyAppQuery.QuerySync(query) res := proxyAppQuery.QuerySync(query)
return &ctypes.ResultTMSPQuery{res}, nil return &ctypes.ResultABCIQuery{res}, nil
} }
func TMSPInfo() (*ctypes.ResultTMSPInfo, error) { func ABCIInfo() (*ctypes.ResultABCIInfo, error) {
res, err := proxyAppQuery.InfoSync() res, err := proxyAppQuery.InfoSync()
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &ctypes.ResultTMSPInfo{ return &ctypes.ResultABCIInfo{
Data: res.Data, Data: res.Data,
Version: res.Version, Version: res.Version,
LastBlockHeight: res.LastBlockHeight, LastBlockHeight: res.LastBlockHeight,

View File

@ -6,7 +6,7 @@ import (
"github.com/tendermint/go-rpc/types" "github.com/tendermint/go-rpc/types"
"github.com/tendermint/go-wire" "github.com/tendermint/go-wire"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
tmsp "github.com/tendermint/tmsp/types" abci "github.com/tendermint/abci/types"
) )
type ResultBlockchainInfo struct { type ResultBlockchainInfo struct {
@ -58,14 +58,14 @@ type ResultDumpConsensusState struct {
} }
type ResultBroadcastTx struct { type ResultBroadcastTx struct {
Code tmsp.CodeType `json:"code"` Code abci.CodeType `json:"code"`
Data []byte `json:"data"` Data []byte `json:"data"`
Log string `json:"log"` Log string `json:"log"`
} }
type ResultBroadcastTxCommit struct { type ResultBroadcastTxCommit struct {
CheckTx *tmsp.ResponseCheckTx `json:"check_tx"` CheckTx *abci.ResponseCheckTx `json:"check_tx"`
AppendTx *tmsp.ResponseAppendTx `json:"append_tx"` AppendTx *abci.ResponseAppendTx `json:"append_tx"`
} }
type ResultUnconfirmedTxs struct { type ResultUnconfirmedTxs struct {
@ -73,15 +73,15 @@ type ResultUnconfirmedTxs struct {
Txs []types.Tx `json:"txs"` Txs []types.Tx `json:"txs"`
} }
type ResultTMSPInfo struct { type ResultABCIInfo struct {
Data string `json:"data"` Data string `json:"data"`
Version string `json:"version"` Version string `json:"version"`
LastBlockHeight uint64 `json:"last_block_height"` LastBlockHeight uint64 `json:"last_block_height"`
LastBlockAppHash []byte `json:"last_block_app_hash"` LastBlockAppHash []byte `json:"last_block_app_hash"`
} }
type ResultTMSPQuery struct { type ResultABCIQuery struct {
Result tmsp.Result `json:"result"` Result abci.Result `json:"result"`
} }
type ResultUnsafeFlushMempool struct{} type ResultUnsafeFlushMempool struct{}
@ -125,8 +125,8 @@ const (
ResultTypeBroadcastTxCommit = byte(0x62) ResultTypeBroadcastTxCommit = byte(0x62)
// 0x7 bytes are for querying the application // 0x7 bytes are for querying the application
ResultTypeTMSPQuery = byte(0x70) ResultTypeABCIQuery = byte(0x70)
ResultTypeTMSPInfo = byte(0x71) ResultTypeABCIInfo = byte(0x71)
// 0x8 bytes are for events // 0x8 bytes are for events
ResultTypeSubscribe = byte(0x80) ResultTypeSubscribe = byte(0x80)
@ -167,6 +167,6 @@ var _ = wire.RegisterInterface(
wire.ConcreteType{&ResultUnsafeProfile{}, ResultTypeUnsafeStopCPUProfiler}, wire.ConcreteType{&ResultUnsafeProfile{}, ResultTypeUnsafeStopCPUProfiler},
wire.ConcreteType{&ResultUnsafeProfile{}, ResultTypeUnsafeWriteHeapProfile}, wire.ConcreteType{&ResultUnsafeProfile{}, ResultTypeUnsafeWriteHeapProfile},
wire.ConcreteType{&ResultUnsafeFlushMempool{}, ResultTypeUnsafeFlushMempool}, wire.ConcreteType{&ResultUnsafeFlushMempool{}, ResultTypeUnsafeFlushMempool},
wire.ConcreteType{&ResultTMSPQuery{}, ResultTypeTMSPQuery}, wire.ConcreteType{&ResultABCIQuery{}, ResultTypeABCIQuery},
wire.ConcreteType{&ResultTMSPInfo{}, ResultTypeTMSPInfo}, wire.ConcreteType{&ResultABCIInfo{}, ResultTypeABCIInfo},
) )

View File

@ -17,7 +17,7 @@ package core_grpc
import proto "github.com/golang/protobuf/proto" import proto "github.com/golang/protobuf/proto"
import fmt "fmt" import fmt "fmt"
import math "math" import math "math"
import types "github.com/tendermint/tmsp/types" import types "github.com/tendermint/abci/types"
import ( import (
context "golang.org/x/net/context" context "golang.org/x/net/context"

View File

@ -1,7 +1,7 @@
syntax = "proto3"; syntax = "proto3";
package core_grpc; package core_grpc;
import "github.com/tendermint/tmsp/types/types.proto"; import "github.com/tendermint/abci/types/types.proto";
//---------------------------------------- //----------------------------------------
// Message types // Message types

View File

@ -12,8 +12,8 @@ import (
"github.com/tendermint/go-wire" "github.com/tendermint/go-wire"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
"github.com/tendermint/tmsp/example/dummy" "github.com/tendermint/abci/example/dummy"
tmsp "github.com/tendermint/tmsp/types" abci "github.com/tendermint/abci/types"
) )
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
@ -92,7 +92,7 @@ func TestJSONBroadcastTxSync(t *testing.T) {
func testBroadcastTxSync(t *testing.T, resI interface{}, tx []byte) { func testBroadcastTxSync(t *testing.T, resI interface{}, tx []byte) {
tmRes := resI.(*ctypes.TMResult) tmRes := resI.(*ctypes.TMResult)
res := (*tmRes).(*ctypes.ResultBroadcastTx) res := (*tmRes).(*ctypes.ResultBroadcastTx)
if res.Code != tmsp.CodeType_OK { if res.Code != abci.CodeType_OK {
panic(Fmt("BroadcastTxSync got non-zero exit code: %v. %X; %s", res.Code, res.Data, res.Log)) panic(Fmt("BroadcastTxSync got non-zero exit code: %v. %X; %s", res.Code, res.Data, res.Log))
} }
mem := node.MempoolReactor().Mempool mem := node.MempoolReactor().Mempool
@ -130,30 +130,30 @@ func sendTx() ([]byte, []byte) {
return k, v return k, v
} }
func TestURITMSPQuery(t *testing.T) { func TestURIABCIQuery(t *testing.T) {
k, v := sendTx() k, v := sendTx()
time.Sleep(time.Second) time.Sleep(time.Second)
tmResult := new(ctypes.TMResult) tmResult := new(ctypes.TMResult)
_, err := clientURI.Call("tmsp_query", map[string]interface{}{"query": k}, tmResult) _, err := clientURI.Call("abci_query", map[string]interface{}{"query": k}, tmResult)
if err != nil { if err != nil {
panic(err) panic(err)
} }
testTMSPQuery(t, tmResult, v) testABCIQuery(t, tmResult, v)
} }
func TestJSONTMSPQuery(t *testing.T) { func TestJSONABCIQuery(t *testing.T) {
k, v := sendTx() k, v := sendTx()
tmResult := new(ctypes.TMResult) tmResult := new(ctypes.TMResult)
_, err := clientJSON.Call("tmsp_query", []interface{}{k}, tmResult) _, err := clientJSON.Call("abci_query", []interface{}{k}, tmResult)
if err != nil { if err != nil {
panic(err) panic(err)
} }
testTMSPQuery(t, tmResult, v) testABCIQuery(t, tmResult, v)
} }
func testTMSPQuery(t *testing.T, statusI interface{}, value []byte) { func testABCIQuery(t *testing.T, statusI interface{}, value []byte) {
tmRes := statusI.(*ctypes.TMResult) tmRes := statusI.(*ctypes.TMResult)
query := (*tmRes).(*ctypes.ResultTMSPQuery) query := (*tmRes).(*ctypes.ResultABCIQuery)
if query.Result.IsErr() { if query.Result.IsErr() {
panic(Fmt("Query returned an err: %v", query)) panic(Fmt("Query returned an err: %v", query))
} }
@ -195,11 +195,11 @@ func testBroadcastTxCommit(t *testing.T, resI interface{}, tx []byte) {
tmRes := resI.(*ctypes.TMResult) tmRes := resI.(*ctypes.TMResult)
res := (*tmRes).(*ctypes.ResultBroadcastTxCommit) res := (*tmRes).(*ctypes.ResultBroadcastTxCommit)
checkTx := res.CheckTx checkTx := res.CheckTx
if checkTx.Code != tmsp.CodeType_OK { if checkTx.Code != abci.CodeType_OK {
panic(Fmt("BroadcastTxCommit got non-zero exit code from CheckTx: %v. %X; %s", checkTx.Code, checkTx.Data, checkTx.Log)) panic(Fmt("BroadcastTxCommit got non-zero exit code from CheckTx: %v. %X; %s", checkTx.Code, checkTx.Data, checkTx.Log))
} }
appendTx := res.AppendTx appendTx := res.AppendTx
if appendTx.Code != tmsp.CodeType_OK { if appendTx.Code != abci.CodeType_OK {
panic(Fmt("BroadcastTxCommit got non-zero exit code from CheckTx: %v. %X; %s", appendTx.Code, appendTx.Data, appendTx.Log)) panic(Fmt("BroadcastTxCommit got non-zero exit code from CheckTx: %v. %X; %s", appendTx.Code, appendTx.Data, appendTx.Log))
} }
mem := node.MempoolReactor().Mempool mem := node.MempoolReactor().Mempool
@ -295,7 +295,7 @@ func TestWSTxEvent(t *testing.T) {
if bytes.Compare([]byte(evt.Tx), tx) != 0 { if bytes.Compare([]byte(evt.Tx), tx) != 0 {
t.Error("Event returned different tx") t.Error("Event returned different tx")
} }
if evt.Code != tmsp.CodeType_OK { if evt.Code != abci.CodeType_OK {
t.Error("Event returned tx error code", evt.Code) t.Error("Event returned tx error code", evt.Code)
} }
return nil return nil

View File

@ -1,13 +1,13 @@
#! /bin/bash #! /bin/bash
go get github.com/tendermint/tmsp/... go get github.com/tendermint/abci/...
# get the tmsp commit used by tendermint # get the abci commit used by tendermint
COMMIT=`bash scripts/glide/parse.sh tmsp` COMMIT=`bash scripts/glide/parse.sh abci`
echo "Checking out vendored commit for tmsp: $COMMIT" echo "Checking out vendored commit for abci: $COMMIT"
cd $GOPATH/src/github.com/tendermint/tmsp cd $GOPATH/src/github.com/tendermint/abci
git checkout $COMMIT git checkout $COMMIT
glide install glide install
go install ./cmd/... go install ./cmd/...

View File

@ -11,7 +11,7 @@ import (
"github.com/tendermint/go-crypto" "github.com/tendermint/go-crypto"
"github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/proxy"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
tmsp "github.com/tendermint/tmsp/types" abci "github.com/tendermint/abci/types"
) )
//-------------------------------------------------- //--------------------------------------------------
@ -66,21 +66,21 @@ func (s *State) ExecBlock(eventCache types.Fireable, proxyAppConn proxy.AppConnC
// Executes block's transactions on proxyAppConn. // Executes block's transactions on proxyAppConn.
// Returns a list of updates to the validator set // Returns a list of updates to the validator set
// TODO: Generate a bitmap or otherwise store tx validity in state. // TODO: Generate a bitmap or otherwise store tx validity in state.
func execBlockOnProxyApp(eventCache types.Fireable, proxyAppConn proxy.AppConnConsensus, block *types.Block) ([]*tmsp.Validator, error) { func execBlockOnProxyApp(eventCache types.Fireable, proxyAppConn proxy.AppConnConsensus, block *types.Block) ([]*abci.Validator, error) {
var validTxs, invalidTxs = 0, 0 var validTxs, invalidTxs = 0, 0
// Execute transactions and get hash // Execute transactions and get hash
proxyCb := func(req *tmsp.Request, res *tmsp.Response) { proxyCb := func(req *abci.Request, res *abci.Response) {
switch r := res.Value.(type) { switch r := res.Value.(type) {
case *tmsp.Response_AppendTx: case *abci.Response_AppendTx:
// TODO: make use of res.Log // TODO: make use of res.Log
// TODO: make use of this info // TODO: make use of this info
// Blocks may include invalid txs. // Blocks may include invalid txs.
// reqAppendTx := req.(tmsp.RequestAppendTx) // reqAppendTx := req.(abci.RequestAppendTx)
txError := "" txError := ""
apTx := r.AppendTx apTx := r.AppendTx
if apTx.Code == tmsp.CodeType_OK { if apTx.Code == abci.CodeType_OK {
validTxs += 1 validTxs += 1
} else { } else {
log.Debug("Invalid tx", "code", r.AppendTx.Code, "log", r.AppendTx.Log) log.Debug("Invalid tx", "code", r.AppendTx.Code, "log", r.AppendTx.Log)
@ -132,12 +132,12 @@ func execBlockOnProxyApp(eventCache types.Fireable, proxyAppConn proxy.AppConnCo
log.Info("Executed block", "height", block.Height, "valid txs", validTxs, "invalid txs", invalidTxs) log.Info("Executed block", "height", block.Height, "valid txs", validTxs, "invalid txs", invalidTxs)
if len(respEndBlock.Diffs) > 0 { if len(respEndBlock.Diffs) > 0 {
log.Info("Update to validator set", "updates", tmsp.ValidatorsString(respEndBlock.Diffs)) log.Info("Update to validator set", "updates", abci.ValidatorsString(respEndBlock.Diffs))
} }
return respEndBlock.Diffs, nil return respEndBlock.Diffs, nil
} }
func updateValidators(validators *types.ValidatorSet, changedValidators []*tmsp.Validator) error { func updateValidators(validators *types.ValidatorSet, changedValidators []*abci.Validator) error {
// TODO: prevent change of 1/3+ at once // TODO: prevent change of 1/3+ at once
for _, v := range changedValidators { for _, v := range changedValidators {
@ -321,7 +321,7 @@ func (h *Handshaker) Handshake(proxyApp proxy.AppConns) error {
blockHeight := int(res.LastBlockHeight) // XXX: beware overflow blockHeight := int(res.LastBlockHeight) // XXX: beware overflow
appHash := res.LastBlockAppHash appHash := res.LastBlockAppHash
log.Notice("TMSP Handshake", "appHeight", blockHeight, "appHash", appHash) log.Notice("ABCI Handshake", "appHeight", blockHeight, "appHash", appHash)
// TODO: check version // TODO: check version
@ -344,7 +344,7 @@ func (h *Handshaker) ReplayBlocks(appHash []byte, appBlockHeight int, appConnCon
storeBlockHeight := h.store.Height() storeBlockHeight := h.store.Height()
stateBlockHeight := h.state.LastBlockHeight stateBlockHeight := h.state.LastBlockHeight
log.Notice("TMSP Replay Blocks", "appHeight", appBlockHeight, "storeHeight", storeBlockHeight, "stateHeight", stateBlockHeight) log.Notice("ABCI Replay Blocks", "appHeight", appBlockHeight, "storeHeight", storeBlockHeight, "stateHeight", stateBlockHeight)
if storeBlockHeight == 0 { if storeBlockHeight == 0 {
return nil return nil
@ -355,20 +355,20 @@ func (h *Handshaker) ReplayBlocks(appHash []byte, appBlockHeight int, appConnCon
} else if storeBlockHeight == appBlockHeight { } else if storeBlockHeight == appBlockHeight {
// We ran Commit, but if we crashed before state.Save(), // We ran Commit, but if we crashed before state.Save(),
// load the intermediate state and update the state.AppHash. // load the intermediate state and update the state.AppHash.
// NOTE: If TMSP allowed rollbacks, we could just replay the // NOTE: If ABCI allowed rollbacks, we could just replay the
// block even though it's been committed // block even though it's been committed
stateAppHash := h.state.AppHash stateAppHash := h.state.AppHash
lastBlockAppHash := h.store.LoadBlock(storeBlockHeight).AppHash lastBlockAppHash := h.store.LoadBlock(storeBlockHeight).AppHash
if bytes.Equal(stateAppHash, appHash) { if bytes.Equal(stateAppHash, appHash) {
// we're all synced up // we're all synced up
log.Debug("TMSP RelpayBlocks: Already synced") log.Debug("ABCI RelpayBlocks: Already synced")
} else if bytes.Equal(stateAppHash, lastBlockAppHash) { } else if bytes.Equal(stateAppHash, lastBlockAppHash) {
// we crashed after commit and before saving state, // we crashed after commit and before saving state,
// so load the intermediate state and update the hash // so load the intermediate state and update the hash
h.state.LoadIntermediate() h.state.LoadIntermediate()
h.state.AppHash = appHash h.state.AppHash = appHash
log.Debug("TMSP RelpayBlocks: Loaded intermediate state and updated state.AppHash") log.Debug("ABCI RelpayBlocks: Loaded intermediate state and updated state.AppHash")
} else { } else {
PanicSanity(Fmt("Unexpected state.AppHash: state.AppHash %X; app.AppHash %X, lastBlock.AppHash %X", stateAppHash, appHash, lastBlockAppHash)) PanicSanity(Fmt("Unexpected state.AppHash: state.AppHash %X; app.AppHash %X, lastBlock.AppHash %X", stateAppHash, appHash, lastBlockAppHash))

View File

@ -13,7 +13,7 @@ import (
dbm "github.com/tendermint/go-db" dbm "github.com/tendermint/go-db"
"github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/proxy"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
"github.com/tendermint/tmsp/example/dummy" "github.com/tendermint/abci/example/dummy"
) )
var ( var (

View File

@ -21,13 +21,13 @@ echo ""
########################### ###########################
# test using the tmsp-cli # test using the abci-cli
########################### ###########################
echo "... testing query with tmsp-cli" echo "... testing query with abci-cli"
# we should be able to look up the key # we should be able to look up the key
RESPONSE=`tmsp-cli query \"$KEY\"` RESPONSE=`abci-cli query \"$KEY\"`
set +e set +e
A=`echo $RESPONSE | grep '"exists":true'` A=`echo $RESPONSE | grep '"exists":true'`
@ -39,7 +39,7 @@ fi
set -e set -e
# we should not be able to look up the value # we should not be able to look up the value
RESPONSE=`tmsp-cli query \"$VALUE\"` RESPONSE=`abci-cli query \"$VALUE\"`
set +e set +e
A=`echo $RESPONSE | grep '"exists":true'` A=`echo $RESPONSE | grep '"exists":true'`
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
@ -50,13 +50,13 @@ fi
set -e set -e
############################# #############################
# test using the /tmsp_query # test using the /abci_query
############################# #############################
echo "... testing query with /tmsp_query" echo "... testing query with /abci_query"
# we should be able to look up the key # we should be able to look up the key
RESPONSE=`curl -s 127.0.0.1:46657/tmsp_query?query=$(toHex $KEY)` RESPONSE=`curl -s 127.0.0.1:46657/abci_query?query=$(toHex $KEY)`
RESPONSE=`echo $RESPONSE | jq .result[1].result.Data | xxd -r -p` RESPONSE=`echo $RESPONSE | jq .result[1].result.Data | xxd -r -p`
set +e set +e
@ -69,7 +69,7 @@ fi
set -e set -e
# we should not be able to look up the value # we should not be able to look up the value
RESPONSE=`curl -s 127.0.0.1:46657/tmsp_query?query=\"$(toHex $VALUE)\"` RESPONSE=`curl -s 127.0.0.1:46657/abci_query?query=\"$(toHex $VALUE)\"`
RESPONSE=`echo $RESPONSE | jq .result[1].result.Data | xxd -r -p` RESPONSE=`echo $RESPONSE | jq .result[1].result.Data | xxd -r -p`
set +e set +e
A=`echo $RESPONSE | grep '"exists":true'` A=`echo $RESPONSE | grep '"exists":true'`

View File

@ -65,9 +65,9 @@ function counter_over_grpc() {
rm -rf $TMROOT rm -rf $TMROOT
tendermint init tendermint init
echo "Starting counter_over_grpc" echo "Starting counter_over_grpc"
counter --serial --tmsp grpc > /dev/null & counter --serial --abci grpc > /dev/null &
pid_counter=$! pid_counter=$!
tendermint node --tmsp grpc > tendermint.log & tendermint node --abci grpc > tendermint.log &
pid_tendermint=$! pid_tendermint=$!
sleep 5 sleep 5
@ -81,11 +81,11 @@ function counter_over_grpc_grpc() {
rm -rf $TMROOT rm -rf $TMROOT
tendermint init tendermint init
echo "Starting counter_over_grpc_grpc (ie. with grpc broadcast_tx)" echo "Starting counter_over_grpc_grpc (ie. with grpc broadcast_tx)"
counter --serial --tmsp grpc > /dev/null & counter --serial --abci grpc > /dev/null &
pid_counter=$! pid_counter=$!
sleep 1 sleep 1
GRPC_PORT=36656 GRPC_PORT=36656
tendermint node --tmsp grpc --grpc_laddr tcp://localhost:$GRPC_PORT > tendermint.log & tendermint node --abci grpc --grpc_laddr tcp://localhost:$GRPC_PORT > tendermint.log &
pid_tendermint=$! pid_tendermint=$!
sleep 5 sleep 5

View File

@ -19,7 +19,7 @@ RUN make get_vendor_deps
COPY . $REPO COPY . $REPO
RUN go install ./cmd/tendermint RUN go install ./cmd/tendermint
RUN bash scripts/install_tmsp_apps.sh RUN bash scripts/install_abci_apps.sh
# expose the volume for debugging # expose the volume for debugging
VOLUME $REPO VOLUME $REPO

View File

@ -1,5 +1,5 @@
#! /bin/bash #! /bin/bash
# This is a sample bash script for a TMSP application # This is a sample bash script for a ABCI application
cd app/ cd app/
git clone https://github.com/tendermint/nomnomcoin.git git clone https://github.com/tendermint/nomnomcoin.git

View File

@ -8,7 +8,7 @@ BRANCH="master"
go get -d $TMREPO/cmd/tendermint go get -d $TMREPO/cmd/tendermint
### DEPENDENCIES (example) ### DEPENDENCIES (example)
# cd $GOPATH/src/github.com/tendermint/tmsp # cd $GOPATH/src/github.com/tendermint/abci
# git fetch origin $BRANCH # git fetch origin $BRANCH
# git checkout $BRANCH # git checkout $BRANCH
### DEPENDENCIES END ### DEPENDENCIES END

View File

@ -12,7 +12,7 @@ fi
#################### ####################
LIBS_GO_TEST=(go-clist go-common go-config go-crypto go-db go-events go-merkle go-p2p) LIBS_GO_TEST=(go-clist go-common go-config go-crypto go-db go-events go-merkle go-p2p)
LIBS_MAKE_TEST=(go-rpc go-wire tmsp) LIBS_MAKE_TEST=(go-rpc go-wire abci)
for lib in "${LIBS_GO_TEST[@]}"; do for lib in "${LIBS_GO_TEST[@]}"; do

View File

@ -5,7 +5,7 @@ import (
. "github.com/tendermint/go-common" . "github.com/tendermint/go-common"
"github.com/tendermint/go-events" "github.com/tendermint/go-events"
"github.com/tendermint/go-wire" "github.com/tendermint/go-wire"
tmsp "github.com/tendermint/tmsp/types" abci "github.com/tendermint/abci/types"
) )
// Functions to generate eventId strings // Functions to generate eventId strings
@ -76,7 +76,7 @@ type EventDataTx struct {
Tx Tx `json:"tx"` Tx Tx `json:"tx"`
Data []byte `json:"data"` Data []byte `json:"data"`
Log string `json:"log"` Log string `json:"log"`
Code tmsp.CodeType `json:"code"` Code abci.CodeType `json:"code"`
Error string `json:"error"` // this is redundant information for now Error string `json:"error"` // this is redundant information for now
} }

View File

@ -1,7 +1,7 @@
package types package types
import ( import (
"github.com/tendermint/tmsp/types" "github.com/tendermint/abci/types"
) )
// Convert tendermint types to protobuf types // Convert tendermint types to protobuf types

View File

@ -1,7 +1,7 @@
package version package version
const Maj = "0" const Maj = "0"
const Min = "7" // tmsp useability (protobuf, unix); optimizations; broadcast_tx_commit const Min = "7" // abci useability (protobuf, unix); optimizations; broadcast_tx_commit
const Fix = "3" // fixes to event safety, mempool deadlock, hvs race, replay non-empty blocks const Fix = "3" // fixes to event safety, mempool deadlock, hvs race, replay non-empty blocks
const Version = Maj + "." + Min + "." + Fix const Version = Maj + "." + Min + "." + Fix