mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-24 22:32:15 +00:00
TMSP -> ABCI
This commit is contained in:
parent
3a55339114
commit
c147b41013
@ -39,7 +39,7 @@ Yay open source! Please see our [contributing guidelines](https://github.com/ten
|
||||
|
||||
### Sub-projects
|
||||
|
||||
* [TMSP](http://github.com/tendermint/tmsp)
|
||||
* [ABCI](http://github.com/tendermint/abci)
|
||||
* [Mintnet](http://github.com/tendermint/mintnet)
|
||||
* [Go-Wire](http://github.com/tendermint/go-wire)
|
||||
* [Go-P2P](http://github.com/tendermint/go-p2p)
|
||||
|
@ -19,7 +19,7 @@ func parseFlags(config cfg.Config, args []string) {
|
||||
grpcLaddr string
|
||||
logLevel string
|
||||
proxyApp string
|
||||
tmspTransport string
|
||||
abciTransport string
|
||||
)
|
||||
|
||||
// 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(&proxyApp, "proxy_app", config.GetString("proxy_app"),
|
||||
"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)
|
||||
if printHelp {
|
||||
flags.PrintDefaults()
|
||||
@ -52,5 +52,5 @@ func parseFlags(config cfg.Config, args []string) {
|
||||
config.Set("grpc_laddr", grpcLaddr)
|
||||
config.Set("log_level", logLevel)
|
||||
config.Set("proxy_app", proxyApp)
|
||||
config.Set("tmsp", tmspTransport)
|
||||
config.Set("abci", abciTransport)
|
||||
}
|
||||
|
@ -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.SetDefault("genesis_file", rootDir+"/genesis.json")
|
||||
mapConfig.SetDefault("proxy_app", "tcp://127.0.0.1:46658")
|
||||
mapConfig.SetDefault("tmsp", "socket")
|
||||
mapConfig.SetDefault("abci", "socket")
|
||||
mapConfig.SetDefault("moniker", "anonymous")
|
||||
mapConfig.SetDefault("node_laddr", "tcp://0.0.0.0:46656")
|
||||
mapConfig.SetDefault("seeds", "")
|
||||
|
@ -70,7 +70,7 @@ func ResetConfig(localPath string) cfg.Config {
|
||||
mapConfig.SetDefault("chain_id", "tendermint_test")
|
||||
mapConfig.SetDefault("genesis_file", rootDir+"/genesis.json")
|
||||
mapConfig.SetDefault("proxy_app", "dummy")
|
||||
mapConfig.SetDefault("tmsp", "socket")
|
||||
mapConfig.SetDefault("abci", "socket")
|
||||
mapConfig.SetDefault("moniker", "anonymous")
|
||||
mapConfig.SetDefault("node_laddr", "tcp://0.0.0.0:36656")
|
||||
mapConfig.SetDefault("fast_sync", false)
|
||||
|
@ -20,11 +20,11 @@ import (
|
||||
mempl "github.com/tendermint/tendermint/mempool"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
tmspcli "github.com/tendermint/tmsp/client"
|
||||
tmsp "github.com/tendermint/tmsp/types"
|
||||
abcicli "github.com/tendermint/abci/client"
|
||||
abci "github.com/tendermint/abci/types"
|
||||
|
||||
"github.com/tendermint/tmsp/example/counter"
|
||||
"github.com/tendermint/tmsp/example/dummy"
|
||||
"github.com/tendermint/abci/example/counter"
|
||||
"github.com/tendermint/abci/example/dummy"
|
||||
)
|
||||
|
||||
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
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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
|
||||
blockDB := dbm.NewMemDB()
|
||||
blockStore := bc.NewBlockStore(blockDB)
|
||||
|
||||
// one for mempool, one for consensus
|
||||
mtx := new(sync.Mutex)
|
||||
proxyAppConnMem := tmspcli.NewLocalClient(mtx, app)
|
||||
proxyAppConnCon := tmspcli.NewLocalClient(mtx, app)
|
||||
proxyAppConnMem := abcicli.NewLocalClient(mtx, app)
|
||||
proxyAppConnCon := abcicli.NewLocalClient(mtx, app)
|
||||
|
||||
// Make Mempool
|
||||
mempool := mempl.NewMempool(thisConfig, proxyAppConnMem)
|
||||
@ -312,7 +312,7 @@ func ensureNoNewStep(stepCh chan interface{}) {
|
||||
//-------------------------------------------------------------------------------
|
||||
// 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)
|
||||
css := make([]*ConsensusState, nValidators)
|
||||
for i := 0; i < nValidators; i++ {
|
||||
@ -328,7 +328,7 @@ func randConsensusNet(nValidators int, testName string, tickerFunc func() Timeou
|
||||
}
|
||||
|
||||
// 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))
|
||||
css := make([]*ConsensusState, nPeers)
|
||||
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)
|
||||
}
|
||||
|
||||
func newPersistentDummy() tmsp.Application {
|
||||
func newPersistentDummy() abci.Application {
|
||||
dir, _ := ioutil.TempDir("/tmp", "persistent-dummy")
|
||||
return dummy.NewPersistentDummyApplication(dir)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
|
||||
"github.com/tendermint/tendermint/config/tendermint_test"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
tmsp "github.com/tendermint/tmsp/types"
|
||||
abci "github.com/tendermint/abci/types"
|
||||
|
||||
. "github.com/tendermint/go-common"
|
||||
)
|
||||
@ -66,10 +66,10 @@ func TestRmBadTx(t *testing.T) {
|
||||
cbCh := make(chan struct{})
|
||||
go func() {
|
||||
// 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
|
||||
err := cs.mempool.CheckTx(txBytes, func(r *tmsp.Response) {
|
||||
if r.GetCheckTx().Code != tmsp.CodeType_BadNonce {
|
||||
err := cs.mempool.CheckTx(txBytes, func(r *abci.Response) {
|
||||
if r.GetCheckTx().Code != abci.CodeType_BadNonce {
|
||||
t.Fatalf("expected checktx to return bad nonce, got %v", r)
|
||||
}
|
||||
cbCh <- struct{}{}
|
||||
@ -122,45 +122,45 @@ func NewCounterApplication() *CounterApplication {
|
||||
return &CounterApplication{}
|
||||
}
|
||||
|
||||
func (app *CounterApplication) Info() tmsp.ResponseInfo {
|
||||
return tmsp.ResponseInfo{Data: Fmt("txs:%v", app.txCount)}
|
||||
func (app *CounterApplication) Info() abci.ResponseInfo {
|
||||
return abci.ResponseInfo{Data: Fmt("txs:%v", app.txCount)}
|
||||
}
|
||||
|
||||
func (app *CounterApplication) SetOption(key string, value string) (log string) {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (app *CounterApplication) AppendTx(tx []byte) tmsp.Result {
|
||||
func (app *CounterApplication) AppendTx(tx []byte) abci.Result {
|
||||
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)
|
||||
}
|
||||
|
||||
func runTx(tx []byte, countPtr *int) tmsp.Result {
|
||||
func runTx(tx []byte, countPtr *int) abci.Result {
|
||||
count := *countPtr
|
||||
tx8 := make([]byte, 8)
|
||||
copy(tx8[len(tx8)-len(tx):], tx)
|
||||
txValue := binary.BigEndian.Uint64(tx8)
|
||||
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
|
||||
return tmsp.OK
|
||||
return abci.OK
|
||||
}
|
||||
|
||||
func (app *CounterApplication) Commit() tmsp.Result {
|
||||
func (app *CounterApplication) Commit() abci.Result {
|
||||
app.mempoolTxCount = app.txCount
|
||||
if app.txCount == 0 {
|
||||
return tmsp.OK
|
||||
return abci.OK
|
||||
} else {
|
||||
hash := make([]byte, 8)
|
||||
binary.BigEndian.PutUint64(hash, uint64(app.txCount))
|
||||
return tmsp.NewResultOK(hash, "")
|
||||
return abci.NewResultOK(hash, "")
|
||||
}
|
||||
}
|
||||
|
||||
func (app *CounterApplication) Query(query []byte) tmsp.Result {
|
||||
return tmsp.NewResultOK(nil, Fmt("Query is not supported"))
|
||||
func (app *CounterApplication) Query(query []byte) abci.Result {
|
||||
return abci.NewResultOK(nil, Fmt("Query is not supported"))
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"github.com/tendermint/go-events"
|
||||
"github.com/tendermint/go-p2p"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
"github.com/tendermint/tmsp/example/dummy"
|
||||
"github.com/tendermint/abci/example/dummy"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -354,7 +354,7 @@ func (cs *ConsensusState) OnStart() error {
|
||||
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,
|
||||
// so check here and write it if not found.
|
||||
// TODO: remove this and run the handhsake/replay
|
||||
|
23
glide.lock
generated
23
glide.lock
generated
@ -1,5 +1,5 @@
|
||||
hash: 8e2e970c04c55b02740daa62647bb637964504a65c45cf274ffed5b0b1930ae4
|
||||
updated: 2017-01-12T14:56:02.152843341-05:00
|
||||
hash: 25681f005f0b9b1816cd5c5f0a0fd013395a7477c656c6010bb570b5aebd2d0a
|
||||
updated: 2017-01-12T15:52:43.856786013-05:00
|
||||
imports:
|
||||
- name: github.com/btcsuite/btcd
|
||||
version: afec1bd1245a4a19e6dfe1306974b733e7cbb9b8
|
||||
@ -48,6 +48,16 @@ imports:
|
||||
- leveldb/storage
|
||||
- leveldb/table
|
||||
- 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
|
||||
version: 1f52c6f8b8a5c7908aff4497c186af344b428925
|
||||
subpackages:
|
||||
@ -93,15 +103,6 @@ imports:
|
||||
version: ae0f3d6450da9eac7074b439c8e1c3cabf0d5ce6
|
||||
subpackages:
|
||||
- term
|
||||
- name: github.com/tendermint/tmsp
|
||||
version: f8167872d8ddd3a2362452ef1414991b5afa8862
|
||||
subpackages:
|
||||
- client
|
||||
- example/counter
|
||||
- example/dummy
|
||||
- example/nil
|
||||
- server
|
||||
- types
|
||||
- name: golang.org/x/crypto
|
||||
version: ede567c8e044a5913dad1d1af3696d9da953104c
|
||||
subpackages:
|
||||
|
@ -28,8 +28,9 @@ import:
|
||||
- package: github.com/tendermint/go-wire
|
||||
version: develop
|
||||
- package: github.com/tendermint/log15
|
||||
- package: github.com/tendermint/tmsp
|
||||
version: develop
|
||||
- package: github.com/tendermint/abci
|
||||
version: rename
|
||||
repo: https://github.com/tendermint/tmsp
|
||||
- package: golang.org/x/crypto
|
||||
subpackages:
|
||||
- ripemd160
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
cfg "github.com/tendermint/go-config"
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
"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
|
||||
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.
|
||||
// It gets called from another goroutine.
|
||||
// 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()
|
||||
defer mem.proxyMtx.Unlock()
|
||||
|
||||
// CACHE
|
||||
if mem.cache.Exists(tx) {
|
||||
if cb != nil {
|
||||
cb(&tmsp.Response{
|
||||
Value: &tmsp.Response_CheckTx{
|
||||
&tmsp.ResponseCheckTx{
|
||||
Code: tmsp.CodeType_BadNonce, // TODO or duplicate tx
|
||||
cb(&abci.Response{
|
||||
Value: &abci.Response_CheckTx{
|
||||
&abci.ResponseCheckTx{
|
||||
Code: abci.CodeType_BadNonce, // TODO or duplicate tx
|
||||
Log: "Duplicate transaction (ignored)",
|
||||
},
|
||||
},
|
||||
@ -180,8 +180,8 @@ func (mem *Mempool) CheckTx(tx types.Tx, cb func(*tmsp.Response)) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TMSP callback function
|
||||
func (mem *Mempool) resCb(req *tmsp.Request, res *tmsp.Response) {
|
||||
// ABCI callback function
|
||||
func (mem *Mempool) resCb(req *abci.Request, res *abci.Response) {
|
||||
if mem.recheckCursor == nil {
|
||||
mem.resCbNormal(req, res)
|
||||
} 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) {
|
||||
case *tmsp.Response_CheckTx:
|
||||
if r.CheckTx.Code == tmsp.CodeType_OK {
|
||||
case *abci.Response_CheckTx:
|
||||
if r.CheckTx.Code == abci.CodeType_OK {
|
||||
mem.counter++
|
||||
memTx := &mempoolTx{
|
||||
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) {
|
||||
case *tmsp.Response_CheckTx:
|
||||
case *abci.Response_CheckTx:
|
||||
memTx := mem.recheckCursor.Value.(*mempoolTx)
|
||||
if !bytes.Equal(req.GetCheckTx().Tx, memTx.tx) {
|
||||
PanicSanity(Fmt("Unexpected tx response from proxy during recheck\n"+
|
||||
"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.
|
||||
} else {
|
||||
// Tx became invalidated due to newly committed block.
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"github.com/tendermint/tendermint/config/tendermint_test"
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
"github.com/tendermint/tmsp/example/counter"
|
||||
"github.com/tendermint/abci/example/counter"
|
||||
)
|
||||
|
||||
func TestSerialReap(t *testing.T) {
|
||||
@ -16,8 +16,8 @@ func TestSerialReap(t *testing.T) {
|
||||
app := counter.NewCounterApplication(true)
|
||||
app.SetOption("serial", "on")
|
||||
cc := proxy.NewLocalClientCreator(app)
|
||||
appConnMem, _ := cc.NewTMSPClient()
|
||||
appConnCon, _ := cc.NewTMSPClient()
|
||||
appConnMem, _ := cc.NewABCIClient()
|
||||
appConnCon, _ := cc.NewABCIClient()
|
||||
mempool := NewMempool(config, appConnMem)
|
||||
|
||||
appendTxsRange := func(start, end int) {
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
"github.com/tendermint/go-p2p"
|
||||
"github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
tmsp "github.com/tendermint/tmsp/types"
|
||||
abci "github.com/tendermint/abci/types"
|
||||
)
|
||||
|
||||
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
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ func NewNode(config cfg.Config, privValidator *types.PrivValidator, clientCreato
|
||||
sw.AddReactor("BLOCKCHAIN", bcReactor)
|
||||
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
|
||||
// XXX: query format subject to change
|
||||
if config.GetBool("filter_peers") {
|
||||
@ -311,7 +311,7 @@ func makeNodeInfo(config cfg.Config, sw *p2p.Switch, privKey crypto.PrivKeyEd255
|
||||
|
||||
// Users wishing to:
|
||||
// * 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
|
||||
// call NewNode with their custom priv validator and/or custom
|
||||
// proxy.ClientCreator interface
|
||||
|
@ -1,32 +1,32 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
tmspcli "github.com/tendermint/tmsp/client"
|
||||
"github.com/tendermint/tmsp/types"
|
||||
abcicli "github.com/tendermint/abci/client"
|
||||
"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 {
|
||||
SetResponseCallback(tmspcli.Callback)
|
||||
SetResponseCallback(abcicli.Callback)
|
||||
Error() error
|
||||
|
||||
InitChainSync(validators []*types.Validator) (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)
|
||||
CommitSync() (res types.Result)
|
||||
}
|
||||
|
||||
type AppConnMempool interface {
|
||||
SetResponseCallback(tmspcli.Callback)
|
||||
SetResponseCallback(abcicli.Callback)
|
||||
Error() error
|
||||
|
||||
CheckTxAsync(tx []byte) *tmspcli.ReqRes
|
||||
CheckTxAsync(tx []byte) *abcicli.ReqRes
|
||||
|
||||
FlushAsync() *tmspcli.ReqRes
|
||||
FlushAsync() *abcicli.ReqRes
|
||||
FlushSync() error
|
||||
}
|
||||
|
||||
@ -41,19 +41,19 @@ type AppConnQuery interface {
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// Implements AppConnConsensus (subset of tmspcli.Client)
|
||||
// Implements AppConnConsensus (subset of abcicli.Client)
|
||||
|
||||
type appConnConsensus struct {
|
||||
appConn tmspcli.Client
|
||||
appConn abcicli.Client
|
||||
}
|
||||
|
||||
func NewAppConnConsensus(appConn tmspcli.Client) *appConnConsensus {
|
||||
func NewAppConnConsensus(appConn abcicli.Client) *appConnConsensus {
|
||||
return &appConnConsensus{
|
||||
appConn: appConn,
|
||||
}
|
||||
}
|
||||
|
||||
func (app *appConnConsensus) SetResponseCallback(cb tmspcli.Callback) {
|
||||
func (app *appConnConsensus) SetResponseCallback(cb abcicli.Callback) {
|
||||
app.appConn.SetResponseCallback(cb)
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ func (app *appConnConsensus) BeginBlockSync(hash []byte, header *types.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)
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
appConn tmspcli.Client
|
||||
appConn abcicli.Client
|
||||
}
|
||||
|
||||
func NewAppConnMempool(appConn tmspcli.Client) *appConnMempool {
|
||||
func NewAppConnMempool(appConn abcicli.Client) *appConnMempool {
|
||||
return &appConnMempool{
|
||||
appConn: appConn,
|
||||
}
|
||||
}
|
||||
|
||||
func (app *appConnMempool) SetResponseCallback(cb tmspcli.Callback) {
|
||||
func (app *appConnMempool) SetResponseCallback(cb abcicli.Callback) {
|
||||
app.appConn.SetResponseCallback(cb)
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ func (app *appConnMempool) Error() error {
|
||||
return app.appConn.Error()
|
||||
}
|
||||
|
||||
func (app *appConnMempool) FlushAsync() *tmspcli.ReqRes {
|
||||
func (app *appConnMempool) FlushAsync() *abcicli.ReqRes {
|
||||
return app.appConn.FlushAsync()
|
||||
}
|
||||
|
||||
@ -110,18 +110,18 @@ func (app *appConnMempool) FlushSync() error {
|
||||
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)
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
// Implements AppConnQuery (subset of tmspcli.Client)
|
||||
// Implements AppConnQuery (subset of abcicli.Client)
|
||||
|
||||
type appConnQuery struct {
|
||||
appConn tmspcli.Client
|
||||
appConn abcicli.Client
|
||||
}
|
||||
|
||||
func NewAppConnQuery(appConn tmspcli.Client) *appConnQuery {
|
||||
func NewAppConnQuery(appConn abcicli.Client) *appConnQuery {
|
||||
return &appConnQuery{
|
||||
appConn: appConn,
|
||||
}
|
||||
|
@ -5,29 +5,29 @@ import (
|
||||
"testing"
|
||||
|
||||
. "github.com/tendermint/go-common"
|
||||
tmspcli "github.com/tendermint/tmsp/client"
|
||||
"github.com/tendermint/tmsp/example/dummy"
|
||||
"github.com/tendermint/tmsp/server"
|
||||
"github.com/tendermint/tmsp/types"
|
||||
abcicli "github.com/tendermint/abci/client"
|
||||
"github.com/tendermint/abci/example/dummy"
|
||||
"github.com/tendermint/abci/server"
|
||||
"github.com/tendermint/abci/types"
|
||||
)
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
type AppConnTest interface {
|
||||
EchoAsync(string) *tmspcli.ReqRes
|
||||
EchoAsync(string) *abcicli.ReqRes
|
||||
FlushSync() error
|
||||
InfoSync() (types.ResponseInfo, error)
|
||||
}
|
||||
|
||||
type appConnTest struct {
|
||||
appConn tmspcli.Client
|
||||
appConn abcicli.Client
|
||||
}
|
||||
|
||||
func NewAppConnTest(appConn tmspcli.Client) AppConnTest {
|
||||
func NewAppConnTest(appConn abcicli.Client) AppConnTest {
|
||||
return &appConnTest{appConn}
|
||||
}
|
||||
|
||||
func (app *appConnTest) EchoAsync(msg string) *tmspcli.ReqRes {
|
||||
func (app *appConnTest) EchoAsync(msg string) *abcicli.ReqRes {
|
||||
return app.appConn.EchoAsync(msg)
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ func TestEcho(t *testing.T) {
|
||||
}
|
||||
defer s.Stop()
|
||||
// Start client
|
||||
cli, err := clientCreator.NewTMSPClient()
|
||||
cli, err := clientCreator.NewABCIClient()
|
||||
if err != nil {
|
||||
Exit(err.Error())
|
||||
}
|
||||
@ -78,7 +78,7 @@ func BenchmarkEcho(b *testing.B) {
|
||||
}
|
||||
defer s.Stop()
|
||||
// Start client
|
||||
cli, err := clientCreator.NewTMSPClient()
|
||||
cli, err := clientCreator.NewABCIClient()
|
||||
if err != nil {
|
||||
Exit(err.Error())
|
||||
}
|
||||
@ -107,7 +107,7 @@ func TestInfo(t *testing.T) {
|
||||
}
|
||||
defer s.Stop()
|
||||
// Start client
|
||||
cli, err := clientCreator.NewTMSPClient()
|
||||
cli, err := clientCreator.NewABCIClient()
|
||||
if err != nil {
|
||||
Exit(err.Error())
|
||||
}
|
||||
|
@ -5,15 +5,15 @@ import (
|
||||
"sync"
|
||||
|
||||
cfg "github.com/tendermint/go-config"
|
||||
tmspcli "github.com/tendermint/tmsp/client"
|
||||
"github.com/tendermint/tmsp/example/dummy"
|
||||
nilapp "github.com/tendermint/tmsp/example/nil"
|
||||
"github.com/tendermint/tmsp/types"
|
||||
abcicli "github.com/tendermint/abci/client"
|
||||
"github.com/tendermint/abci/example/dummy"
|
||||
nilapp "github.com/tendermint/abci/example/nil"
|
||||
"github.com/tendermint/abci/types"
|
||||
)
|
||||
|
||||
// NewTMSPClient returns newly connected client
|
||||
// NewABCIClient returns newly connected client
|
||||
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) {
|
||||
return tmspcli.NewLocalClient(l.mtx, l.app), nil
|
||||
func (l *localClientCreator) NewABCIClient() (abcicli.Client, error) {
|
||||
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
|
||||
remoteApp, err := tmspcli.NewClient(r.addr, r.transport, r.mustConnect)
|
||||
remoteApp, err := abcicli.NewClient(r.addr, r.transport, r.mustConnect)
|
||||
if err != nil {
|
||||
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 {
|
||||
addr := config.GetString("proxy_app")
|
||||
transport := config.GetString("tmsp")
|
||||
transport := config.GetString("abci")
|
||||
|
||||
switch addr {
|
||||
case "dummy":
|
||||
|
@ -28,7 +28,7 @@ type Handshaker interface {
|
||||
}
|
||||
|
||||
// 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.
|
||||
// TODO: on app restart, clients must reboot together
|
||||
type multiAppConn struct {
|
||||
@ -45,7 +45,7 @@ type multiAppConn struct {
|
||||
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 {
|
||||
multiAppConn := &multiAppConn{
|
||||
config: config,
|
||||
@ -75,21 +75,21 @@ func (app *multiAppConn) OnStart() error {
|
||||
app.BaseService.OnStart()
|
||||
|
||||
// query connection
|
||||
querycli, err := app.clientCreator.NewTMSPClient()
|
||||
querycli, err := app.clientCreator.NewABCIClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
app.queryConn = NewAppConnQuery(querycli)
|
||||
|
||||
// mempool connection
|
||||
memcli, err := app.clientCreator.NewTMSPClient()
|
||||
memcli, err := app.clientCreator.NewABCIClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
app.mempoolConn = NewAppConnMempool(memcli)
|
||||
|
||||
// consensus connection
|
||||
concli, err := app.clientCreator.NewTMSPClient()
|
||||
concli, err := app.clientCreator.NewABCIClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/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
|
||||
func BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
resCh := make(chan *tmsp.Response, 1)
|
||||
err := mempool.CheckTx(tx, func(res *tmsp.Response) {
|
||||
resCh := make(chan *abci.Response, 1)
|
||||
err := mempool.CheckTx(tx, func(res *abci.Response) {
|
||||
resCh <- res
|
||||
})
|
||||
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)
|
||||
// or if we timeout waiting for tx to commit.
|
||||
// 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) {
|
||||
|
||||
// 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
|
||||
checkTxResCh := make(chan *tmsp.Response, 1)
|
||||
err := mempool.CheckTx(tx, func(res *tmsp.Response) {
|
||||
checkTxResCh := make(chan *abci.Response, 1)
|
||||
err := mempool.CheckTx(tx, func(res *abci.Response) {
|
||||
checkTxResCh <- res
|
||||
})
|
||||
if err != nil {
|
||||
@ -62,7 +62,7 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
}
|
||||
checkTxRes := <-checkTxResCh
|
||||
checkTxR := checkTxRes.GetCheckTx()
|
||||
if checkTxR.Code != tmsp.CodeType_OK {
|
||||
if checkTxR.Code != abci.CodeType_OK {
|
||||
// CheckTx failed!
|
||||
return &ctypes.ResultBroadcastTxCommit{
|
||||
CheckTx: checkTxR,
|
||||
@ -77,7 +77,7 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
select {
|
||||
case appendTxRes := <-appendTxResCh:
|
||||
// The tx was included in a block.
|
||||
appendTxR := &tmsp.ResponseAppendTx{
|
||||
appendTxR := &abci.ResponseAppendTx{
|
||||
Code: appendTxRes.Code,
|
||||
Data: appendTxRes.Data,
|
||||
Log: appendTxRes.Log,
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/tendermint/tendermint/consensus"
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
"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 {
|
||||
Size() int
|
||||
CheckTx(types.Tx, func(*tmsp.Response)) error
|
||||
CheckTx(types.Tx, func(*abci.Response)) error
|
||||
Reap(int) []types.Tx
|
||||
Flush()
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ var Routes = map[string]*rpc.RPCFunc{
|
||||
"unconfirmed_txs": rpc.NewRPCFunc(UnconfirmedTxsResult, ""),
|
||||
"num_unconfirmed_txs": rpc.NewRPCFunc(NumUnconfirmedTxsResult, ""),
|
||||
|
||||
"tmsp_query": rpc.NewRPCFunc(TMSPQueryResult, "query"),
|
||||
"tmsp_info": rpc.NewRPCFunc(TMSPInfoResult, ""),
|
||||
"abci_query": rpc.NewRPCFunc(ABCIQueryResult, "query"),
|
||||
"abci_info": rpc.NewRPCFunc(ABCIInfoResult, ""),
|
||||
|
||||
"unsafe_flush_mempool": rpc.NewRPCFunc(UnsafeFlushMempool, ""),
|
||||
"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) {
|
||||
if r, err := TMSPQuery(query); err != nil {
|
||||
func ABCIQueryResult(query []byte) (ctypes.TMResult, error) {
|
||||
if r, err := ABCIQuery(query); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return r, nil
|
||||
}
|
||||
}
|
||||
|
||||
func TMSPInfoResult() (ctypes.TMResult, error) {
|
||||
if r, err := TMSPInfo(); err != nil {
|
||||
func ABCIInfoResult() (ctypes.TMResult, error) {
|
||||
if r, err := ABCIInfo(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return r, nil
|
||||
|
@ -6,17 +6,17 @@ import (
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
func TMSPQuery(query []byte) (*ctypes.ResultTMSPQuery, error) {
|
||||
func ABCIQuery(query []byte) (*ctypes.ResultABCIQuery, error) {
|
||||
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()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ctypes.ResultTMSPInfo{
|
||||
return &ctypes.ResultABCIInfo{
|
||||
Data: res.Data,
|
||||
Version: res.Version,
|
||||
LastBlockHeight: res.LastBlockHeight,
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"github.com/tendermint/go-rpc/types"
|
||||
"github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
tmsp "github.com/tendermint/tmsp/types"
|
||||
abci "github.com/tendermint/abci/types"
|
||||
)
|
||||
|
||||
type ResultBlockchainInfo struct {
|
||||
@ -58,14 +58,14 @@ type ResultDumpConsensusState struct {
|
||||
}
|
||||
|
||||
type ResultBroadcastTx struct {
|
||||
Code tmsp.CodeType `json:"code"`
|
||||
Code abci.CodeType `json:"code"`
|
||||
Data []byte `json:"data"`
|
||||
Log string `json:"log"`
|
||||
}
|
||||
|
||||
type ResultBroadcastTxCommit struct {
|
||||
CheckTx *tmsp.ResponseCheckTx `json:"check_tx"`
|
||||
AppendTx *tmsp.ResponseAppendTx `json:"append_tx"`
|
||||
CheckTx *abci.ResponseCheckTx `json:"check_tx"`
|
||||
AppendTx *abci.ResponseAppendTx `json:"append_tx"`
|
||||
}
|
||||
|
||||
type ResultUnconfirmedTxs struct {
|
||||
@ -73,15 +73,15 @@ type ResultUnconfirmedTxs struct {
|
||||
Txs []types.Tx `json:"txs"`
|
||||
}
|
||||
|
||||
type ResultTMSPInfo struct {
|
||||
type ResultABCIInfo struct {
|
||||
Data string `json:"data"`
|
||||
Version string `json:"version"`
|
||||
LastBlockHeight uint64 `json:"last_block_height"`
|
||||
LastBlockAppHash []byte `json:"last_block_app_hash"`
|
||||
}
|
||||
|
||||
type ResultTMSPQuery struct {
|
||||
Result tmsp.Result `json:"result"`
|
||||
type ResultABCIQuery struct {
|
||||
Result abci.Result `json:"result"`
|
||||
}
|
||||
|
||||
type ResultUnsafeFlushMempool struct{}
|
||||
@ -125,8 +125,8 @@ const (
|
||||
ResultTypeBroadcastTxCommit = byte(0x62)
|
||||
|
||||
// 0x7 bytes are for querying the application
|
||||
ResultTypeTMSPQuery = byte(0x70)
|
||||
ResultTypeTMSPInfo = byte(0x71)
|
||||
ResultTypeABCIQuery = byte(0x70)
|
||||
ResultTypeABCIInfo = byte(0x71)
|
||||
|
||||
// 0x8 bytes are for events
|
||||
ResultTypeSubscribe = byte(0x80)
|
||||
@ -167,6 +167,6 @@ var _ = wire.RegisterInterface(
|
||||
wire.ConcreteType{&ResultUnsafeProfile{}, ResultTypeUnsafeStopCPUProfiler},
|
||||
wire.ConcreteType{&ResultUnsafeProfile{}, ResultTypeUnsafeWriteHeapProfile},
|
||||
wire.ConcreteType{&ResultUnsafeFlushMempool{}, ResultTypeUnsafeFlushMempool},
|
||||
wire.ConcreteType{&ResultTMSPQuery{}, ResultTypeTMSPQuery},
|
||||
wire.ConcreteType{&ResultTMSPInfo{}, ResultTypeTMSPInfo},
|
||||
wire.ConcreteType{&ResultABCIQuery{}, ResultTypeABCIQuery},
|
||||
wire.ConcreteType{&ResultABCIInfo{}, ResultTypeABCIInfo},
|
||||
)
|
||||
|
@ -17,7 +17,7 @@ package core_grpc
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
import types "github.com/tendermint/tmsp/types"
|
||||
import types "github.com/tendermint/abci/types"
|
||||
|
||||
import (
|
||||
context "golang.org/x/net/context"
|
||||
|
@ -1,7 +1,7 @@
|
||||
syntax = "proto3";
|
||||
package core_grpc;
|
||||
|
||||
import "github.com/tendermint/tmsp/types/types.proto";
|
||||
import "github.com/tendermint/abci/types/types.proto";
|
||||
|
||||
//----------------------------------------
|
||||
// Message types
|
||||
|
@ -12,8 +12,8 @@ import (
|
||||
"github.com/tendermint/go-wire"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
"github.com/tendermint/tmsp/example/dummy"
|
||||
tmsp "github.com/tendermint/tmsp/types"
|
||||
"github.com/tendermint/abci/example/dummy"
|
||||
abci "github.com/tendermint/abci/types"
|
||||
)
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
@ -92,7 +92,7 @@ func TestJSONBroadcastTxSync(t *testing.T) {
|
||||
func testBroadcastTxSync(t *testing.T, resI interface{}, tx []byte) {
|
||||
tmRes := resI.(*ctypes.TMResult)
|
||||
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))
|
||||
}
|
||||
mem := node.MempoolReactor().Mempool
|
||||
@ -130,30 +130,30 @@ func sendTx() ([]byte, []byte) {
|
||||
return k, v
|
||||
}
|
||||
|
||||
func TestURITMSPQuery(t *testing.T) {
|
||||
func TestURIABCIQuery(t *testing.T) {
|
||||
k, v := sendTx()
|
||||
time.Sleep(time.Second)
|
||||
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 {
|
||||
panic(err)
|
||||
}
|
||||
testTMSPQuery(t, tmResult, v)
|
||||
testABCIQuery(t, tmResult, v)
|
||||
}
|
||||
|
||||
func TestJSONTMSPQuery(t *testing.T) {
|
||||
func TestJSONABCIQuery(t *testing.T) {
|
||||
k, v := sendTx()
|
||||
tmResult := new(ctypes.TMResult)
|
||||
_, err := clientJSON.Call("tmsp_query", []interface{}{k}, tmResult)
|
||||
_, err := clientJSON.Call("abci_query", []interface{}{k}, tmResult)
|
||||
if err != nil {
|
||||
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)
|
||||
query := (*tmRes).(*ctypes.ResultTMSPQuery)
|
||||
query := (*tmRes).(*ctypes.ResultABCIQuery)
|
||||
if query.Result.IsErr() {
|
||||
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)
|
||||
res := (*tmRes).(*ctypes.ResultBroadcastTxCommit)
|
||||
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))
|
||||
}
|
||||
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))
|
||||
}
|
||||
mem := node.MempoolReactor().Mempool
|
||||
@ -295,7 +295,7 @@ func TestWSTxEvent(t *testing.T) {
|
||||
if bytes.Compare([]byte(evt.Tx), tx) != 0 {
|
||||
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)
|
||||
}
|
||||
return nil
|
||||
|
@ -1,13 +1,13 @@
|
||||
#! /bin/bash
|
||||
|
||||
go get github.com/tendermint/tmsp/...
|
||||
go get github.com/tendermint/abci/...
|
||||
|
||||
# get the tmsp commit used by tendermint
|
||||
COMMIT=`bash scripts/glide/parse.sh tmsp`
|
||||
# get the abci commit used by tendermint
|
||||
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
|
||||
glide install
|
||||
go install ./cmd/...
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"github.com/tendermint/go-crypto"
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
"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.
|
||||
// Returns a list of updates to the validator set
|
||||
// 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
|
||||
|
||||
// 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) {
|
||||
case *tmsp.Response_AppendTx:
|
||||
case *abci.Response_AppendTx:
|
||||
// TODO: make use of res.Log
|
||||
// TODO: make use of this info
|
||||
// Blocks may include invalid txs.
|
||||
// reqAppendTx := req.(tmsp.RequestAppendTx)
|
||||
// reqAppendTx := req.(abci.RequestAppendTx)
|
||||
txError := ""
|
||||
apTx := r.AppendTx
|
||||
if apTx.Code == tmsp.CodeType_OK {
|
||||
if apTx.Code == abci.CodeType_OK {
|
||||
validTxs += 1
|
||||
} else {
|
||||
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)
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
for _, v := range changedValidators {
|
||||
@ -321,7 +321,7 @@ func (h *Handshaker) Handshake(proxyApp proxy.AppConns) error {
|
||||
blockHeight := int(res.LastBlockHeight) // XXX: beware overflow
|
||||
appHash := res.LastBlockAppHash
|
||||
|
||||
log.Notice("TMSP Handshake", "appHeight", blockHeight, "appHash", appHash)
|
||||
log.Notice("ABCI Handshake", "appHeight", blockHeight, "appHash", appHash)
|
||||
|
||||
// TODO: check version
|
||||
|
||||
@ -344,7 +344,7 @@ func (h *Handshaker) ReplayBlocks(appHash []byte, appBlockHeight int, appConnCon
|
||||
|
||||
storeBlockHeight := h.store.Height()
|
||||
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 {
|
||||
return nil
|
||||
@ -355,20 +355,20 @@ func (h *Handshaker) ReplayBlocks(appHash []byte, appBlockHeight int, appConnCon
|
||||
} else if storeBlockHeight == appBlockHeight {
|
||||
// We ran Commit, but if we crashed before state.Save(),
|
||||
// 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
|
||||
stateAppHash := h.state.AppHash
|
||||
lastBlockAppHash := h.store.LoadBlock(storeBlockHeight).AppHash
|
||||
|
||||
if bytes.Equal(stateAppHash, appHash) {
|
||||
// we're all synced up
|
||||
log.Debug("TMSP RelpayBlocks: Already synced")
|
||||
log.Debug("ABCI RelpayBlocks: Already synced")
|
||||
} else if bytes.Equal(stateAppHash, lastBlockAppHash) {
|
||||
// we crashed after commit and before saving state,
|
||||
// so load the intermediate state and update the hash
|
||||
h.state.LoadIntermediate()
|
||||
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 {
|
||||
PanicSanity(Fmt("Unexpected state.AppHash: state.AppHash %X; app.AppHash %X, lastBlock.AppHash %X", stateAppHash, appHash, lastBlockAppHash))
|
||||
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
dbm "github.com/tendermint/go-db"
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
"github.com/tendermint/tmsp/example/dummy"
|
||||
"github.com/tendermint/abci/example/dummy"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -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
|
||||
RESPONSE=`tmsp-cli query \"$KEY\"`
|
||||
RESPONSE=`abci-cli query \"$KEY\"`
|
||||
|
||||
set +e
|
||||
A=`echo $RESPONSE | grep '"exists":true'`
|
||||
@ -39,7 +39,7 @@ fi
|
||||
set -e
|
||||
|
||||
# we should not be able to look up the value
|
||||
RESPONSE=`tmsp-cli query \"$VALUE\"`
|
||||
RESPONSE=`abci-cli query \"$VALUE\"`
|
||||
set +e
|
||||
A=`echo $RESPONSE | grep '"exists":true'`
|
||||
if [[ $? == 0 ]]; then
|
||||
@ -50,13 +50,13 @@ fi
|
||||
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
|
||||
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`
|
||||
|
||||
set +e
|
||||
@ -69,7 +69,7 @@ fi
|
||||
set -e
|
||||
|
||||
# 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`
|
||||
set +e
|
||||
A=`echo $RESPONSE | grep '"exists":true'`
|
||||
|
@ -65,9 +65,9 @@ function counter_over_grpc() {
|
||||
rm -rf $TMROOT
|
||||
tendermint init
|
||||
echo "Starting counter_over_grpc"
|
||||
counter --serial --tmsp grpc > /dev/null &
|
||||
counter --serial --abci grpc > /dev/null &
|
||||
pid_counter=$!
|
||||
tendermint node --tmsp grpc > tendermint.log &
|
||||
tendermint node --abci grpc > tendermint.log &
|
||||
pid_tendermint=$!
|
||||
sleep 5
|
||||
|
||||
@ -81,11 +81,11 @@ function counter_over_grpc_grpc() {
|
||||
rm -rf $TMROOT
|
||||
tendermint init
|
||||
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=$!
|
||||
sleep 1
|
||||
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=$!
|
||||
sleep 5
|
||||
|
||||
|
@ -19,7 +19,7 @@ RUN make get_vendor_deps
|
||||
COPY . $REPO
|
||||
|
||||
RUN go install ./cmd/tendermint
|
||||
RUN bash scripts/install_tmsp_apps.sh
|
||||
RUN bash scripts/install_abci_apps.sh
|
||||
|
||||
# expose the volume for debugging
|
||||
VOLUME $REPO
|
||||
|
@ -1,5 +1,5 @@
|
||||
#! /bin/bash
|
||||
# This is a sample bash script for a TMSP application
|
||||
# This is a sample bash script for a ABCI application
|
||||
|
||||
cd app/
|
||||
git clone https://github.com/tendermint/nomnomcoin.git
|
||||
|
@ -8,7 +8,7 @@ BRANCH="master"
|
||||
|
||||
go get -d $TMREPO/cmd/tendermint
|
||||
### DEPENDENCIES (example)
|
||||
# cd $GOPATH/src/github.com/tendermint/tmsp
|
||||
# cd $GOPATH/src/github.com/tendermint/abci
|
||||
# git fetch origin $BRANCH
|
||||
# git checkout $BRANCH
|
||||
### DEPENDENCIES END
|
||||
|
@ -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_MAKE_TEST=(go-rpc go-wire tmsp)
|
||||
LIBS_MAKE_TEST=(go-rpc go-wire abci)
|
||||
|
||||
for lib in "${LIBS_GO_TEST[@]}"; do
|
||||
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
. "github.com/tendermint/go-common"
|
||||
"github.com/tendermint/go-events"
|
||||
"github.com/tendermint/go-wire"
|
||||
tmsp "github.com/tendermint/tmsp/types"
|
||||
abci "github.com/tendermint/abci/types"
|
||||
)
|
||||
|
||||
// Functions to generate eventId strings
|
||||
@ -76,7 +76,7 @@ type EventDataTx struct {
|
||||
Tx Tx `json:"tx"`
|
||||
Data []byte `json:"data"`
|
||||
Log string `json:"log"`
|
||||
Code tmsp.CodeType `json:"code"`
|
||||
Code abci.CodeType `json:"code"`
|
||||
Error string `json:"error"` // this is redundant information for now
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"github.com/tendermint/tmsp/types"
|
||||
"github.com/tendermint/abci/types"
|
||||
)
|
||||
|
||||
// Convert tendermint types to protobuf types
|
||||
|
@ -1,7 +1,7 @@
|
||||
package version
|
||||
|
||||
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 Version = Maj + "." + Min + "." + Fix
|
||||
|
Loading…
x
Reference in New Issue
Block a user