diff --git a/LICENSE b/LICENSE index 3934a10fe..57951bb8a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Tendermint TMSP +Tendermint ABCI Copyright (C) 2015 Tendermint diff --git a/Makefile b/Makefile index b00c5a672..22fa6fdd1 100644 --- a/Makefile +++ b/Makefile @@ -2,13 +2,13 @@ all: protoc test install -NOVENDOR = go list github.com/tendermint/tmsp/... | grep -v /vendor/ +NOVENDOR = go list github.com/tendermint/abci/... | grep -v /vendor/ protoc: protoc --go_out=plugins=grpc:. types/*.proto install: - go install github.com/tendermint/tmsp/cmd/... + go install github.com/tendermint/abci/cmd/... test: go test `${NOVENDOR}` diff --git a/README.md b/README.md index e50e3292b..ea09fa7c2 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,37 @@ -# Tendermint Socket Protocol (TMSP) +# Tendermint Socket Protocol (ABCI) -[![CircleCI](https://circleci.com/gh/tendermint/tmsp.svg?style=svg)](https://circleci.com/gh/tendermint/tmsp) +[![CircleCI](https://circleci.com/gh/tendermint/abci.svg?style=svg)](https://circleci.com/gh/tendermint/abci) Blockchains are a system for creating shared multi-master application state. -**TMSP** is a socket protocol enabling a blockchain consensus engine, running in one process, +**ABCI** is a socket protocol enabling a blockchain consensus engine, running in one process, to manage a blockchain application state, running in another. -For more information on TMSP, motivations, and tutorials, please visit [our blog post](https://tendermint.com/blog/tmsp-the-tendermint-socket-protocol). +For more information on ABCI, motivations, and tutorials, please visit [our blog post](https://tendermint.com/blog/abci-the-tendermint-socket-protocol). Other implementations: -* [cpp-tmsp](https://github.com/mdyring/cpp-tmsp) by Martin Dyring-Andersen -* [js-tmsp](https://github.com/tendermint/js-tmsp) -* [jTMSP](https://github.com/jTMSP/) for Java +* [cpp-abci](https://github.com/mdyring/cpp-abci) by Martin Dyring-Andersen +* [js-abci](https://github.com/tendermint/js-abci) +* [jABCI](https://github.com/jABCI/) for Java ## Contents This repository holds a number of important pieces: - `types/types.proto` - - the protobuf file defining TMSP message types, and the optional grpc interface. + - the protobuf file defining ABCI message types, and the optional grpc interface. - to build, run `make protoc` - see `protoc --help` and [the grpc docs](https://www.grpc.io/docs) for examples and details of other languages -- golang implementation of TMSP client and server +- golang implementation of ABCI client and server - two implementations: - asynchronous, ordered message passing over unix or tcp; - messages are serialized using protobuf and length prefixed - grpc - TendermintCore runs a client, and the application runs a server -- `cmd/tmsp-cli` - - command line tool wrapping the client for probing/testing a TMSP application - - use `tmsp-cli --version` to get the TMSP version +- `cmd/abci-cli` + - command line tool wrapping the client for probing/testing a ABCI application + - use `abci-cli --version` to get the ABCI version - examples: - the `cmd/counter` application, which illustrates nonce checking in txs @@ -42,15 +42,15 @@ This repository holds a number of important pieces: Since this is a streaming protocol, all messages are encoded with a length-prefix followed by the message encoded in Protobuf3. Protobuf3 doesn't have an official length-prefix standard, so we use our own. The first byte represents the length of the big-endian encoded length. -For example, if the Protobuf3 encoded TMSP message is `0xDEADBEEF` (4 bytes), the length-prefixed message is `0x0104DEADBEEF`. If the Protobuf3 encoded TMSP message is 65535 bytes long, the length-prefixed message would be like `0x02FFFF...`. +For example, if the Protobuf3 encoded ABCI message is `0xDEADBEEF` (4 bytes), the length-prefixed message is `0x0104DEADBEEF`. If the Protobuf3 encoded ABCI message is 65535 bytes long, the length-prefixed message would be like `0x02FFFF...`. Note this prefixing does not apply for grpc. ## Message types -TMSP requests/responses are simple Protobuf messages. Check out the [schema file](https://github.com/tendermint/tmsp/blob/master/types/types.proto). +ABCI requests/responses are simple Protobuf messages. Check out the [schema file](https://github.com/tendermint/abci/blob/master/types/types.proto). -#### AppendTx +#### DeliverTx * __Arguments__: * `Data ([]byte)`: The request transaction bytes * __Returns__: @@ -68,7 +68,11 @@ TMSP requests/responses are simple Protobuf messages. Check out the [schema fil * `Data ([]byte)`: Result bytes, if any * `Log (string)`: Debug or error message * __Usage__:
- Validate a transaction. This message should not mutate the state. + Validate a mempool transaction, prior to broadcasting or proposing. This message should not mutate the main state, but application + developers may want to keep a separate CheckTx state that gets reset upon Commit. + + CheckTx can happen interspersed with DeliverTx, but they happen on different connections - CheckTx from the mempool connection, and DeliverTx from the consensus connection. During Commit, the mempool is locked, so you can reset the mempool state to the latest state after running all those delivertxs, and then the mempool will re run whatever txs it has against that latest mempool stte + Transactions are first run through CheckTx before broadcast to peers in the mempool layer. You can make CheckTx semi-stateful and clear the state upon `Commit` or `BeginBlock`, to allow for dependent sequences of transactions in the same block. @@ -118,7 +122,7 @@ TMSP requests/responses are simple Protobuf messages. Check out the [schema fil * __Arguments__: * `Height (uint64)`: The block height that is starting * __Usage__:
- Signals the beginning of a new block. Called prior to any AppendTxs. + Signals the beginning of a new block. Called prior to any DeliverTxs. #### EndBlock * __Arguments__: @@ -144,8 +148,8 @@ TMSP requests/responses are simple Protobuf messages. Check out the [schema fil ##### Jan 23th, 2016 -* Added CheckTx/Query TMSP message types -* Added Result/Log fields to AppendTx/CheckTx/SetOption +* Added CheckTx/Query ABCI message types +* Added Result/Log fields to DeliverTx/CheckTx/SetOption * Removed Listener messages * Removed Code from ResponseSetOption and ResponseGetHash * Made examples BigEndian @@ -156,4 +160,4 @@ TMSP requests/responses are simple Protobuf messages. Check out the [schema fil ##### Jan 8th, 2016 -* Tendermint/TMSP now comes to consensus on the order first before AppendTx. +* Tendermint/ABCI now comes to consensus on the order first before DeliverTx. diff --git a/client/client.go b/client/client.go index 291c4863a..8ea295937 100644 --- a/client/client.go +++ b/client/client.go @@ -1,11 +1,11 @@ -package tmspcli +package abcicli import ( "fmt" "sync" . "github.com/tendermint/go-common" - "github.com/tendermint/tmsp/types" + "github.com/tendermint/abci/types" ) type Client interface { @@ -18,27 +18,27 @@ type Client interface { EchoAsync(msg string) *ReqRes InfoAsync() *ReqRes SetOptionAsync(key string, value string) *ReqRes - AppendTxAsync(tx []byte) *ReqRes + DeliverTxAsync(tx []byte) *ReqRes CheckTxAsync(tx []byte) *ReqRes QueryAsync(tx []byte) *ReqRes CommitAsync() *ReqRes FlushSync() error EchoSync(msg string) (res types.Result) - InfoSync() (res types.Result) + InfoSync() (resInfo types.ResponseInfo, err error) SetOptionSync(key string, value string) (res types.Result) - AppendTxSync(tx []byte) (res types.Result) + DeliverTxSync(tx []byte) (res types.Result) CheckTxSync(tx []byte) (res types.Result) QuerySync(tx []byte) (res types.Result) CommitSync() (res types.Result) InitChainAsync(validators []*types.Validator) *ReqRes - BeginBlockAsync(height uint64) *ReqRes + BeginBlockAsync(hash []byte, header *types.Header) *ReqRes EndBlockAsync(height uint64) *ReqRes InitChainSync(validators []*types.Validator) (err error) - BeginBlockSync(height uint64) (err error) - EndBlockSync(height uint64) (changedValidators []*types.Validator, err error) + BeginBlockSync(hash []byte, header *types.Header) (err error) + EndBlockSync(height uint64) (resEndBlock types.ResponseEndBlock, err error) } //---------------------------------------- @@ -50,7 +50,7 @@ func NewClient(addr, transport string, mustConnect bool) (client Client, err err case "grpc": client, err = NewGRPCClient(addr, mustConnect) default: - err = fmt.Errorf("Unknown tmsp transport %s", transport) + err = fmt.Errorf("Unknown abci transport %s", transport) } return diff --git a/client/grpc_client.go b/client/grpc_client.go index 771302c19..566ee183e 100644 --- a/client/grpc_client.go +++ b/client/grpc_client.go @@ -1,4 +1,4 @@ -package tmspcli +package abcicli import ( "net" @@ -9,16 +9,16 @@ import ( grpc "google.golang.org/grpc" . "github.com/tendermint/go-common" - "github.com/tendermint/tmsp/types" + "github.com/tendermint/abci/types" ) // A stripped copy of the remoteClient that makes // synchronous calls using grpc type grpcClient struct { - QuitService + BaseService mustConnect bool - client types.TMSPApplicationClient + client types.ABCIApplicationClient mtx sync.Mutex addr string @@ -31,7 +31,7 @@ func NewGRPCClient(addr string, mustConnect bool) (*grpcClient, error) { addr: addr, mustConnect: mustConnect, } - cli.QuitService = *NewQuitService(nil, "grpcClient", cli) + cli.BaseService = *NewBaseService(nil, "grpcClient", cli) _, err := cli.Start() // Just start it, it's confusing for callers to remember to start. return cli, err } @@ -41,7 +41,7 @@ func dialerFunc(addr string, timeout time.Duration) (net.Conn, error) { } func (cli *grpcClient) OnStart() error { - cli.QuitService.OnStart() + cli.BaseService.OnStart() RETRY_LOOP: for { @@ -50,13 +50,13 @@ RETRY_LOOP: if cli.mustConnect { return err } else { - log.Warn(Fmt("tmsp.grpcClient failed to connect to %v. Retrying...\n", cli.addr)) + log.Warn(Fmt("abci.grpcClient failed to connect to %v. Retrying...\n", cli.addr)) time.Sleep(time.Second * 3) continue RETRY_LOOP } } - client := types.NewTMSPApplicationClient(conn) + client := types.NewABCIApplicationClient(conn) ENSURE_CONNECTED: for { @@ -73,7 +73,7 @@ RETRY_LOOP: } func (cli *grpcClient) OnStop() { - cli.QuitService.OnStop() + cli.BaseService.OnStop() cli.mtx.Lock() defer cli.mtx.Unlock() // TODO: how to close conn? its not a net.Conn and grpc doesn't expose a Close() @@ -93,7 +93,7 @@ func (cli *grpcClient) StopForError(err error) { } cli.mtx.Unlock() - log.Warn(Fmt("Stopping tmsp.grpcClient for error: %v", err.Error())) + log.Warn(Fmt("Stopping abci.grpcClient for error: %v", err.Error())) cli.Stop() } @@ -155,13 +155,13 @@ func (cli *grpcClient) SetOptionAsync(key string, value string) *ReqRes { return cli.finishAsyncCall(req, &types.Response{&types.Response_SetOption{res}}) } -func (cli *grpcClient) AppendTxAsync(tx []byte) *ReqRes { - req := types.ToRequestAppendTx(tx) - res, err := cli.client.AppendTx(context.Background(), req.GetAppendTx(), grpc.FailFast(true)) +func (cli *grpcClient) DeliverTxAsync(tx []byte) *ReqRes { + req := types.ToRequestDeliverTx(tx) + res, err := cli.client.DeliverTx(context.Background(), req.GetDeliverTx(), grpc.FailFast(true)) if err != nil { cli.StopForError(err) } - return cli.finishAsyncCall(req, &types.Response{&types.Response_AppendTx{res}}) + return cli.finishAsyncCall(req, &types.Response{&types.Response_DeliverTx{res}}) } func (cli *grpcClient) CheckTxAsync(tx []byte) *ReqRes { @@ -200,8 +200,8 @@ func (cli *grpcClient) InitChainAsync(validators []*types.Validator) *ReqRes { return cli.finishAsyncCall(req, &types.Response{&types.Response_InitChain{res}}) } -func (cli *grpcClient) BeginBlockAsync(height uint64) *ReqRes { - req := types.ToRequestBeginBlock(height) +func (cli *grpcClient) BeginBlockAsync(hash []byte, header *types.Header) *ReqRes { + req := types.ToRequestBeginBlock(hash, header) res, err := cli.client.BeginBlock(context.Background(), req.GetBeginBlock(), grpc.FailFast(true)) if err != nil { cli.StopForError(err) @@ -262,13 +262,16 @@ func (cli *grpcClient) FlushSync() error { return nil } -func (cli *grpcClient) InfoSync() (res types.Result) { +func (cli *grpcClient) InfoSync() (resInfo types.ResponseInfo, err error) { reqres := cli.InfoAsync() - if res := cli.checkErrGetResult(); res.IsErr() { - return res + if err = cli.Error(); err != nil { + return resInfo, err + } + if resInfo_ := reqres.Response.GetInfo(); resInfo_ != nil { + return *resInfo_, nil + } else { + return resInfo, nil } - resp := reqres.Response.GetInfo() - return types.NewResultOK([]byte(resp.Info), LOG) } func (cli *grpcClient) SetOptionSync(key string, value string) (res types.Result) { @@ -280,12 +283,12 @@ func (cli *grpcClient) SetOptionSync(key string, value string) (res types.Result return types.Result{Code: OK, Data: nil, Log: resp.Log} } -func (cli *grpcClient) AppendTxSync(tx []byte) (res types.Result) { - reqres := cli.AppendTxAsync(tx) +func (cli *grpcClient) DeliverTxSync(tx []byte) (res types.Result) { + reqres := cli.DeliverTxAsync(tx) if res := cli.checkErrGetResult(); res.IsErr() { return res } - resp := reqres.Response.GetAppendTx() + resp := reqres.Response.GetDeliverTx() return types.Result{Code: resp.Code, Data: resp.Data, Log: resp.Log} } @@ -321,15 +324,19 @@ func (cli *grpcClient) InitChainSync(validators []*types.Validator) (err error) return cli.Error() } -func (cli *grpcClient) BeginBlockSync(height uint64) (err error) { - cli.BeginBlockAsync(height) +func (cli *grpcClient) BeginBlockSync(hash []byte, header *types.Header) (err error) { + cli.BeginBlockAsync(hash, header) return cli.Error() } -func (cli *grpcClient) EndBlockSync(height uint64) (validators []*types.Validator, err error) { +func (cli *grpcClient) EndBlockSync(height uint64) (resEndBlock types.ResponseEndBlock, err error) { reqres := cli.EndBlockAsync(height) if err := cli.Error(); err != nil { - return nil, err + return resEndBlock, err + } + if resEndBlock_ := reqres.Response.GetEndBlock(); resEndBlock_ != nil { + return *resEndBlock_, nil + } else { + return resEndBlock, nil } - return reqres.Response.GetEndBlock().Diffs, nil } diff --git a/client/local_client.go b/client/local_client.go index ce17f6c07..b787eb365 100644 --- a/client/local_client.go +++ b/client/local_client.go @@ -1,10 +1,10 @@ -package tmspcli +package abcicli import ( "sync" . "github.com/tendermint/go-common" - types "github.com/tendermint/tmsp/types" + types "github.com/tendermint/abci/types" ) type localClient struct { @@ -51,11 +51,11 @@ func (app *localClient) EchoAsync(msg string) *ReqRes { func (app *localClient) InfoAsync() *ReqRes { app.mtx.Lock() - info := app.Application.Info() + resInfo := app.Application.Info() app.mtx.Unlock() return app.callback( types.ToRequestInfo(), - types.ToResponseInfo(info), + types.ToResponseInfo(resInfo), ) } @@ -69,13 +69,13 @@ func (app *localClient) SetOptionAsync(key string, value string) *ReqRes { ) } -func (app *localClient) AppendTxAsync(tx []byte) *ReqRes { +func (app *localClient) DeliverTxAsync(tx []byte) *ReqRes { app.mtx.Lock() - res := app.Application.AppendTx(tx) + res := app.Application.DeliverTx(tx) app.mtx.Unlock() return app.callback( - types.ToRequestAppendTx(tx), - types.ToResponseAppendTx(res.Code, res.Data, res.Log), + types.ToRequestDeliverTx(tx), + types.ToResponseDeliverTx(res.Code, res.Data, res.Log), ) } @@ -122,28 +122,28 @@ func (app *localClient) InitChainAsync(validators []*types.Validator) *ReqRes { return reqRes } -func (app *localClient) BeginBlockAsync(height uint64) *ReqRes { +func (app *localClient) BeginBlockAsync(hash []byte, header *types.Header) *ReqRes { app.mtx.Lock() if bcApp, ok := app.Application.(types.BlockchainAware); ok { - bcApp.BeginBlock(height) + bcApp.BeginBlock(hash, header) } app.mtx.Unlock() return app.callback( - types.ToRequestBeginBlock(height), + types.ToRequestBeginBlock(hash, header), types.ToResponseBeginBlock(), ) } func (app *localClient) EndBlockAsync(height uint64) *ReqRes { app.mtx.Lock() - var validators []*types.Validator + var resEndBlock types.ResponseEndBlock if bcApp, ok := app.Application.(types.BlockchainAware); ok { - validators = bcApp.EndBlock(height) + resEndBlock = bcApp.EndBlock(height) } app.mtx.Unlock() return app.callback( types.ToRequestEndBlock(height), - types.ToResponseEndBlock(validators), + types.ToResponseEndBlock(resEndBlock), ) } @@ -157,11 +157,11 @@ func (app *localClient) EchoSync(msg string) (res types.Result) { return types.OK.SetData([]byte(msg)) } -func (app *localClient) InfoSync() (res types.Result) { +func (app *localClient) InfoSync() (resInfo types.ResponseInfo, err error) { app.mtx.Lock() - info := app.Application.Info() - app.mtx.Unlock() - return types.OK.SetData([]byte(info)) + defer app.mtx.Unlock() + resInfo = app.Application.Info() + return resInfo, nil } func (app *localClient) SetOptionSync(key string, value string) (res types.Result) { @@ -171,9 +171,9 @@ func (app *localClient) SetOptionSync(key string, value string) (res types.Resul return types.OK.SetLog(log) } -func (app *localClient) AppendTxSync(tx []byte) (res types.Result) { +func (app *localClient) DeliverTxSync(tx []byte) (res types.Result) { app.mtx.Lock() - res = app.Application.AppendTx(tx) + res = app.Application.DeliverTx(tx) app.mtx.Unlock() return res } @@ -208,22 +208,22 @@ func (app *localClient) InitChainSync(validators []*types.Validator) (err error) return nil } -func (app *localClient) BeginBlockSync(height uint64) (err error) { +func (app *localClient) BeginBlockSync(hash []byte, header *types.Header) (err error) { app.mtx.Lock() if bcApp, ok := app.Application.(types.BlockchainAware); ok { - bcApp.BeginBlock(height) + bcApp.BeginBlock(hash, header) } app.mtx.Unlock() return nil } -func (app *localClient) EndBlockSync(height uint64) (changedValidators []*types.Validator, err error) { +func (app *localClient) EndBlockSync(height uint64) (resEndBlock types.ResponseEndBlock, err error) { app.mtx.Lock() if bcApp, ok := app.Application.(types.BlockchainAware); ok { - changedValidators = bcApp.EndBlock(height) + resEndBlock = bcApp.EndBlock(height) } app.mtx.Unlock() - return changedValidators, nil + return resEndBlock, nil } //------------------------------------------------------- diff --git a/client/log.go b/client/log.go index deadf6c34..944b05ba0 100644 --- a/client/log.go +++ b/client/log.go @@ -1,7 +1,7 @@ -package tmspcli +package abcicli import ( "github.com/tendermint/go-logger" ) -var log = logger.New("module", "tmspcli") +var log = logger.New("module", "abcicli") diff --git a/client/socket_client.go b/client/socket_client.go index 27e74787c..9b4f9aed4 100644 --- a/client/socket_client.go +++ b/client/socket_client.go @@ -1,4 +1,4 @@ -package tmspcli +package abcicli import ( "bufio" @@ -11,7 +11,7 @@ import ( "time" . "github.com/tendermint/go-common" - "github.com/tendermint/tmsp/types" + "github.com/tendermint/abci/types" ) const ( @@ -27,7 +27,7 @@ const flushThrottleMS = 20 // Don't wait longer than... // the application in general is not meant to be interfaced // with concurrent callers. type socketClient struct { - QuitService + BaseService reqQueue chan *ReqRes flushTimer *ThrottleTimer @@ -52,14 +52,14 @@ func NewSocketClient(addr string, mustConnect bool) (*socketClient, error) { reqSent: list.New(), resCb: nil, } - cli.QuitService = *NewQuitService(nil, "socketClient", cli) + cli.BaseService = *NewBaseService(nil, "socketClient", cli) _, err := cli.Start() // Just start it, it's confusing for callers to remember to start. return cli, err } func (cli *socketClient) OnStart() error { - cli.QuitService.OnStart() + cli.BaseService.OnStart() var err error var conn net.Conn @@ -70,7 +70,7 @@ RETRY_LOOP: if cli.mustConnect { return err } else { - log.Warn(Fmt("tmsp.socketClient failed to connect to %v. Retrying...", cli.addr)) + log.Warn(Fmt("abci.socketClient failed to connect to %v. Retrying...", cli.addr)) time.Sleep(time.Second * 3) continue RETRY_LOOP } @@ -86,7 +86,7 @@ RETRY_LOOP: } func (cli *socketClient) OnStop() { - cli.QuitService.OnStop() + cli.BaseService.OnStop() cli.mtx.Lock() defer cli.mtx.Unlock() @@ -109,7 +109,7 @@ func (cli *socketClient) StopForError(err error) { } cli.mtx.Unlock() - log.Warn(Fmt("Stopping tmsp.socketClient for error: %v", err.Error())) + log.Warn(Fmt("Stopping abci.socketClient for error: %v", err.Error())) cli.Stop() } @@ -140,7 +140,7 @@ func (cli *socketClient) sendRequestsRoutine(conn net.Conn) { default: // Probably will fill the buffer, or retry later. } - case <-cli.QuitService.Quit: + case <-cli.BaseService.Quit: return case reqres := <-cli.reqQueue: cli.willSendReq(reqres) @@ -243,8 +243,8 @@ func (cli *socketClient) SetOptionAsync(key string, value string) *ReqRes { return cli.queueRequest(types.ToRequestSetOption(key, value)) } -func (cli *socketClient) AppendTxAsync(tx []byte) *ReqRes { - return cli.queueRequest(types.ToRequestAppendTx(tx)) +func (cli *socketClient) DeliverTxAsync(tx []byte) *ReqRes { + return cli.queueRequest(types.ToRequestDeliverTx(tx)) } func (cli *socketClient) CheckTxAsync(tx []byte) *ReqRes { @@ -263,8 +263,8 @@ func (cli *socketClient) InitChainAsync(validators []*types.Validator) *ReqRes { return cli.queueRequest(types.ToRequestInitChain(validators)) } -func (cli *socketClient) BeginBlockAsync(height uint64) *ReqRes { - return cli.queueRequest(types.ToRequestBeginBlock(height)) +func (cli *socketClient) BeginBlockAsync(hash []byte, header *types.Header) *ReqRes { + return cli.queueRequest(types.ToRequestBeginBlock(hash, header)) } func (cli *socketClient) EndBlockAsync(height uint64) *ReqRes { @@ -292,14 +292,17 @@ func (cli *socketClient) FlushSync() error { return cli.Error() } -func (cli *socketClient) InfoSync() (res types.Result) { +func (cli *socketClient) InfoSync() (resInfo types.ResponseInfo, err error) { reqres := cli.queueRequest(types.ToRequestInfo()) cli.FlushSync() if err := cli.Error(); err != nil { - return types.ErrInternalError.SetLog(err.Error()) + return resInfo, err + } + if resInfo_ := reqres.Response.GetInfo(); resInfo_ != nil { + return *resInfo_, nil + } else { + return resInfo, nil } - resp := reqres.Response.GetInfo() - return types.Result{Code: OK, Data: []byte(resp.Info), Log: LOG} } func (cli *socketClient) SetOptionSync(key string, value string) (res types.Result) { @@ -312,13 +315,13 @@ func (cli *socketClient) SetOptionSync(key string, value string) (res types.Resu return types.Result{Code: OK, Data: nil, Log: resp.Log} } -func (cli *socketClient) AppendTxSync(tx []byte) (res types.Result) { - reqres := cli.queueRequest(types.ToRequestAppendTx(tx)) +func (cli *socketClient) DeliverTxSync(tx []byte) (res types.Result) { + reqres := cli.queueRequest(types.ToRequestDeliverTx(tx)) cli.FlushSync() if err := cli.Error(); err != nil { return types.ErrInternalError.SetLog(err.Error()) } - resp := reqres.Response.GetAppendTx() + resp := reqres.Response.GetDeliverTx() return types.Result{Code: resp.Code, Data: resp.Data, Log: resp.Log} } @@ -361,8 +364,8 @@ func (cli *socketClient) InitChainSync(validators []*types.Validator) (err error return nil } -func (cli *socketClient) BeginBlockSync(height uint64) (err error) { - cli.queueRequest(types.ToRequestBeginBlock(height)) +func (cli *socketClient) BeginBlockSync(hash []byte, header *types.Header) (err error) { + cli.queueRequest(types.ToRequestBeginBlock(hash, header)) cli.FlushSync() if err := cli.Error(); err != nil { return err @@ -370,13 +373,17 @@ func (cli *socketClient) BeginBlockSync(height uint64) (err error) { return nil } -func (cli *socketClient) EndBlockSync(height uint64) (validators []*types.Validator, err error) { +func (cli *socketClient) EndBlockSync(height uint64) (resEndBlock types.ResponseEndBlock, err error) { reqres := cli.queueRequest(types.ToRequestEndBlock(height)) cli.FlushSync() if err := cli.Error(); err != nil { - return nil, err + return resEndBlock, err + } + if resEndBlock_ := reqres.Response.GetEndBlock(); resEndBlock_ != nil { + return *resEndBlock_, nil + } else { + return resEndBlock, nil } - return reqres.Response.GetEndBlock().Diffs, nil } //---------------------------------------- @@ -422,8 +429,8 @@ func resMatchesReq(req *types.Request, res *types.Response) (ok bool) { _, ok = res.Value.(*types.Response_Info) case *types.Request_SetOption: _, ok = res.Value.(*types.Response_SetOption) - case *types.Request_AppendTx: - _, ok = res.Value.(*types.Response_AppendTx) + case *types.Request_DeliverTx: + _, ok = res.Value.(*types.Response_DeliverTx) case *types.Request_CheckTx: _, ok = res.Value.(*types.Response_CheckTx) case *types.Request_Commit: @@ -432,6 +439,8 @@ func resMatchesReq(req *types.Request, res *types.Response) (ok bool) { _, ok = res.Value.(*types.Response_Query) case *types.Request_InitChain: _, ok = res.Value.(*types.Response_InitChain) + case *types.Request_BeginBlock: + _, ok = res.Value.(*types.Response_BeginBlock) case *types.Request_EndBlock: _, ok = res.Value.(*types.Response_EndBlock) } diff --git a/cmd/tmsp-cli/tmsp-cli.go b/cmd/abci-cli/tmsp-cli.go similarity index 57% rename from cmd/tmsp-cli/tmsp-cli.go rename to cmd/abci-cli/tmsp-cli.go index 084241290..39dace9f9 100644 --- a/cmd/tmsp-cli/tmsp-cli.go +++ b/cmd/abci-cli/tmsp-cli.go @@ -9,20 +9,48 @@ import ( "os" "strings" + "github.com/tendermint/abci/client" + "github.com/tendermint/abci/types" . "github.com/tendermint/go-common" - "github.com/tendermint/tmsp/client" - "github.com/tendermint/tmsp/types" "github.com/urfave/cli" ) +//structure for data passed to print response +// variables must be exposed for JSON to read +type response struct { + Res types.Result + Data string + PrintCode bool + Code string +} + +func newResponse(res types.Result, data string, printCode bool) *response { + rsp := &response{ + Res: res, + Data: data, + PrintCode: printCode, + Code: "", + } + + if printCode { + rsp.Code = res.Code.String() + } + + return rsp +} + // client is a global variable so it can be reused by the console -var client tmspcli.Client +var client abcicli.Client func main() { + + //workaround for the cli library (https://github.com/urfave/cli/issues/565) + cli.OsExiter = func(_ int) {} + app := cli.NewApp() - app.Name = "tmsp-cli" - app.Usage = "tmsp-cli [command] [args...]" - app.Version = "0.2.1" // better error handling in console + app.Name = "abci-cli" + app.Usage = "abci-cli [command] [args...]" + app.Version = "0.3.0" // hex handling app.Flags = []cli.Flag{ cli.StringFlag{ Name: "address", @@ -30,7 +58,7 @@ func main() { Usage: "address of application socket", }, cli.StringFlag{ - Name: "tmsp", + Name: "abci", Value: "socket", Usage: "socket or grpc", }, @@ -42,14 +70,14 @@ func main() { app.Commands = []cli.Command{ { Name: "batch", - Usage: "Run a batch of tmsp commands against an application", + Usage: "Run a batch of abci commands against an application", Action: func(c *cli.Context) error { return cmdBatch(app, c) }, }, { Name: "console", - Usage: "Start an interactive tmsp console for multiple commands", + Usage: "Start an interactive abci console for multiple commands", Action: func(c *cli.Context) error { return cmdConsole(app, c) }, @@ -76,10 +104,10 @@ func main() { }, }, { - Name: "append_tx", - Usage: "Append a new tx to application", + Name: "deliver_tx", + Usage: "Deliver a new tx to application", Action: func(c *cli.Context) error { - return cmdAppendTx(c) + return cmdDeliverTx(c) }, }, { @@ -115,7 +143,7 @@ func main() { func before(c *cli.Context) error { if client == nil { var err error - client, err = tmspcli.NewClient(c.GlobalString("address"), c.GlobalString("tmsp"), false) + client, err = abcicli.NewClient(c.GlobalString("address"), c.GlobalString("abci"), false) if err != nil { Exit(err.Error()) } @@ -131,6 +159,20 @@ func badCmd(c *cli.Context, cmd string) { cli.DefaultAppComplete(c) } +//Generates new Args array based off of previous call args to maintain flag persistence +func persistentArgs(line []byte) []string { + + //generate the arguments to run from orginal os.Args + // to maintain flag arguments + args := os.Args + args = args[:len(args)-1] // remove the previous command argument + + if len(line) > 0 { //prevents introduction of extra space leading to argument parse errors + args = append(args, strings.Split(string(line), " ")...) + } + return args +} + //-------------------------------------------------------------------------------- func cmdBatch(app *cli.App, c *cli.Context) error { @@ -146,12 +188,9 @@ func cmdBatch(app *cli.App, c *cli.Context) error { } else if err != nil { return err } - args := []string{"tmsp-cli"} - if c.GlobalBool("verbose") { - args = append(args, "--verbose") - } - args = append(args, strings.Split(string(line), " ")...) - app.Run(args) + + args := persistentArgs(line) + app.Run(args) //cli prints error within its func call } return nil } @@ -159,6 +198,7 @@ func cmdBatch(app *cli.App, c *cli.Context) error { func cmdConsole(app *cli.App, c *cli.Context) error { // don't hard exit on mistyped commands (eg. check vs check_tx) app.CommandNotFound = badCmd + for { fmt.Printf("\n> ") bufReader := bufio.NewReader(os.Stdin) @@ -169,12 +209,8 @@ func cmdConsole(app *cli.App, c *cli.Context) error { return err } - args := []string{"tmsp-cli"} - args = append(args, strings.Split(string(line), " ")...) - if err := app.Run(args); err != nil { - // if the command doesn't succeed, inform the user without exiting - fmt.Println("Error:", err.Error()) - } + args := persistentArgs(line) + app.Run(args) //cli prints error within its func call } } @@ -185,14 +221,19 @@ func cmdEcho(c *cli.Context) error { return errors.New("Command echo takes 1 argument") } res := client.EchoSync(args[0]) - printResponse(c, res, string(res.Data), false) + rsp := newResponse(res, string(res.Data), false) + printResponse(c, rsp) return nil } // Get some info from the application func cmdInfo(c *cli.Context) error { - res := client.InfoSync() - printResponse(c, res, string(res.Data), false) + resInfo, err := client.InfoSync() + if err != nil { + return err + } + rsp := newResponse(types.Result{}, string(resInfo.Data), false) + printResponse(c, rsp) return nil } @@ -203,19 +244,24 @@ func cmdSetOption(c *cli.Context) error { return errors.New("Command set_option takes 2 arguments (key, value)") } res := client.SetOptionSync(args[0], args[1]) - printResponse(c, res, Fmt("%s=%s", args[0], args[1]), false) + rsp := newResponse(res, Fmt("%s=%s", args[0], args[1]), false) + printResponse(c, rsp) return nil } // Append a new tx to application -func cmdAppendTx(c *cli.Context) error { +func cmdDeliverTx(c *cli.Context) error { args := c.Args() if len(args) != 1 { - return errors.New("Command append_tx takes 1 argument") + return errors.New("Command deliver_tx takes 1 argument") } - txBytes := stringOrHexToBytes(c.Args()[0]) - res := client.AppendTxSync(txBytes) - printResponse(c, res, string(res.Data), true) + txBytes, err := stringOrHexToBytes(c.Args()[0]) + if err != nil { + return err + } + res := client.DeliverTxSync(txBytes) + rsp := newResponse(res, string(res.Data), true) + printResponse(c, rsp) return nil } @@ -225,16 +271,21 @@ func cmdCheckTx(c *cli.Context) error { if len(args) != 1 { return errors.New("Command check_tx takes 1 argument") } - txBytes := stringOrHexToBytes(c.Args()[0]) + txBytes, err := stringOrHexToBytes(c.Args()[0]) + if err != nil { + return err + } res := client.CheckTxSync(txBytes) - printResponse(c, res, string(res.Data), true) + rsp := newResponse(res, string(res.Data), true) + printResponse(c, rsp) return nil } // Get application Merkle root hash func cmdCommit(c *cli.Context) error { res := client.CommitSync() - printResponse(c, res, Fmt("%X", res.Data), false) + rsp := newResponse(res, Fmt("0x%X", res.Data), false) + printResponse(c, rsp) return nil } @@ -244,46 +295,62 @@ func cmdQuery(c *cli.Context) error { if len(args) != 1 { return errors.New("Command query takes 1 argument") } - queryBytes := stringOrHexToBytes(c.Args()[0]) + queryBytes, err := stringOrHexToBytes(c.Args()[0]) + if err != nil { + return err + } res := client.QuerySync(queryBytes) - printResponse(c, res, string(res.Data), true) + rsp := newResponse(res, string(res.Data), true) + printResponse(c, rsp) return nil } //-------------------------------------------------------------------------------- -func printResponse(c *cli.Context, res types.Result, s string, printCode bool) { - if c.GlobalBool("verbose") { +func printResponse(c *cli.Context, rsp *response) { + + verbose := c.GlobalBool("verbose") + + if verbose { fmt.Println(">", c.Command.Name, strings.Join(c.Args(), " ")) } - if printCode { - fmt.Printf("-> code: %s\n", res.Code.String()) + if rsp.PrintCode { + fmt.Printf("-> code: %s\n", rsp.Code) } - /*if res.Error != "" { - fmt.Printf("-> error: %s\n", res.Error) - }*/ - if s != "" { - fmt.Printf("-> data: {%s}\n", s) + + //if pr.res.Error != "" { + // fmt.Printf("-> error: %s\n", pr.res.Error) + //} + + if rsp.Data != "" { + fmt.Printf("-> data: %s\n", rsp.Data) } - if res.Log != "" { - fmt.Printf("-> log: %s\n", res.Log) + if rsp.Res.Log != "" { + fmt.Printf("-> log: %s\n", rsp.Res.Log) } - if c.GlobalBool("verbose") { + if verbose { fmt.Println("") } } // NOTE: s is interpreted as a string unless prefixed with 0x -func stringOrHexToBytes(s string) []byte { - if len(s) > 2 && s[:2] == "0x" { +func stringOrHexToBytes(s string) ([]byte, error) { + if len(s) > 2 && strings.ToLower(s[:2]) == "0x" { b, err := hex.DecodeString(s[2:]) if err != nil { - fmt.Println("Error decoding hex argument:", err.Error()) + err = fmt.Errorf("Error decoding hex argument: %s", err.Error()) + return nil, err } - return b + return b, nil + } + + if !strings.HasPrefix(s, "\"") || !strings.HasSuffix(s, "\"") { + err := fmt.Errorf("Invalid string arg: \"%s\". Must be quoted or a \"0x\"-prefixed hex string", s) + return nil, err } - return []byte(s) + + return []byte(s[1 : len(s)-1]), nil } diff --git a/cmd/counter/main.go b/cmd/counter/main.go index c04a40e0f..218224a0a 100644 --- a/cmd/counter/main.go +++ b/cmd/counter/main.go @@ -4,20 +4,20 @@ import ( "flag" . "github.com/tendermint/go-common" - "github.com/tendermint/tmsp/example/counter" - "github.com/tendermint/tmsp/server" + "github.com/tendermint/abci/example/counter" + "github.com/tendermint/abci/server" ) func main() { addrPtr := flag.String("addr", "tcp://0.0.0.0:46658", "Listen address") - tmspPtr := flag.String("tmsp", "socket", "TMSP server: socket | grpc") + abciPtr := flag.String("abci", "socket", "ABCI server: socket | grpc") serialPtr := flag.Bool("serial", false, "Enforce incrementing (serial) txs") flag.Parse() app := counter.NewCounterApplication(*serialPtr) // Start the listener - _, err := server.NewServer(*addrPtr, *tmspPtr, app) + srv, err := server.NewServer(*addrPtr, *abciPtr, app) if err != nil { Exit(err.Error()) } @@ -25,6 +25,7 @@ func main() { // Wait forever TrapSignal(func() { // Cleanup + srv.Stop() }) } diff --git a/cmd/dummy/main.go b/cmd/dummy/main.go index 8efa69e6b..aecb1138f 100644 --- a/cmd/dummy/main.go +++ b/cmd/dummy/main.go @@ -4,18 +4,28 @@ import ( "flag" . "github.com/tendermint/go-common" - "github.com/tendermint/tmsp/example/dummy" - "github.com/tendermint/tmsp/server" + "github.com/tendermint/abci/example/dummy" + "github.com/tendermint/abci/server" + "github.com/tendermint/abci/types" ) func main() { addrPtr := flag.String("addr", "tcp://0.0.0.0:46658", "Listen address") - tmspPtr := flag.String("tmsp", "socket", "socket | grpc") + abciPtr := flag.String("abci", "socket", "socket | grpc") + persistencePtr := flag.String("persist", "", "directory to use for a database") flag.Parse() + // Create the application - in memory or persisted to disk + var app types.Application + if *persistencePtr == "" { + app = dummy.NewDummyApplication() + } else { + app = dummy.NewPersistentDummyApplication(*persistencePtr) + } + // Start the listener - _, err := server.NewServer(*addrPtr, *tmspPtr, dummy.NewDummyApplication()) + srv, err := server.NewServer(*addrPtr, *abciPtr, app) if err != nil { Exit(err.Error()) } @@ -23,6 +33,7 @@ func main() { // Wait forever TrapSignal(func() { // Cleanup + srv.Stop() }) } diff --git a/example/chain_aware/chain_aware_app.go b/example/chain_aware/chain_aware_app.go new file mode 100644 index 000000000..e3543f13c --- /dev/null +++ b/example/chain_aware/chain_aware_app.go @@ -0,0 +1,76 @@ +package main + +import ( + "flag" + + . "github.com/tendermint/go-common" + "github.com/tendermint/abci/server" + "github.com/tendermint/abci/types" +) + +func main() { + + addrPtr := flag.String("addr", "tcp://0.0.0.0:46658", "Listen address") + abciPtr := flag.String("abci", "socket", "socket | grpc") + flag.Parse() + + // Start the listener + srv, err := server.NewServer(*addrPtr, *abciPtr, NewChainAwareApplication()) + if err != nil { + Exit(err.Error()) + } + + // Wait forever + TrapSignal(func() { + // Cleanup + srv.Stop() + }) + +} + +type ChainAwareApplication struct { + beginCount int + endCount int +} + +func NewChainAwareApplication() *ChainAwareApplication { + return &ChainAwareApplication{} +} + +func (app *ChainAwareApplication) Info() types.ResponseInfo { + return types.ResponseInfo{} +} + +func (app *ChainAwareApplication) SetOption(key string, value string) (log string) { + return "" +} + +func (app *ChainAwareApplication) DeliverTx(tx []byte) types.Result { + return types.NewResultOK(nil, "") +} + +func (app *ChainAwareApplication) CheckTx(tx []byte) types.Result { + return types.NewResultOK(nil, "") +} + +func (app *ChainAwareApplication) Commit() types.Result { + return types.NewResultOK([]byte("nil"), "") +} + +func (app *ChainAwareApplication) Query(query []byte) types.Result { + return types.NewResultOK([]byte(Fmt("%d,%d", app.beginCount, app.endCount)), "") +} + +func (app *ChainAwareApplication) BeginBlock(hash []byte, header *types.Header) { + app.beginCount += 1 + return +} + +func (app *ChainAwareApplication) EndBlock(height uint64) (resEndBlock types.ResponseEndBlock) { + app.endCount += 1 + return +} + +func (app *ChainAwareApplication) InitChain(vals []*types.Validator) { + return +} diff --git a/example/chain_aware/chain_aware_test.go b/example/chain_aware/chain_aware_test.go new file mode 100644 index 000000000..f5283a386 --- /dev/null +++ b/example/chain_aware/chain_aware_test.go @@ -0,0 +1,54 @@ +package main + +import ( + "strconv" + "strings" + "testing" + + . "github.com/tendermint/go-common" + "github.com/tendermint/abci/client" + "github.com/tendermint/abci/server" + "github.com/tendermint/abci/types" +) + +func TestChainAware(t *testing.T) { + + app := NewChainAwareApplication() + + // Start the listener + srv, err := server.NewServer("unix://test.sock", "socket", app) + if err != nil { + t.Fatal(err) + } + defer srv.Stop() + + // Connect to the socket + client, err := abcicli.NewSocketClient("unix://test.sock", false) + if err != nil { + Exit(Fmt("Error starting socket client: %v", err.Error())) + } + client.Start() + defer client.Stop() + + n := uint64(5) + hash := []byte("fake block hash") + header := &types.Header{} + for i := uint64(0); i < n; i++ { + client.BeginBlockSync(hash, header) + client.EndBlockSync(i) + client.CommitSync() + } + + r := app.Query(nil) + spl := strings.Split(string(r.Data), ",") + if len(spl) != 2 { + t.Fatal("expected %d,%d ; got %s", n, n, string(r.Data)) + } + beginCount, _ := strconv.Atoi(spl[0]) + endCount, _ := strconv.Atoi(spl[1]) + if uint64(beginCount) != n { + t.Fatalf("expected beginCount of %d, got %d", n, beginCount) + } else if uint64(endCount) != n { + t.Fatalf("expected endCount of %d, got %d", n, endCount) + } +} diff --git a/example/counter/counter.go b/example/counter/counter.go index 711ddc3f4..90be6d92b 100644 --- a/example/counter/counter.go +++ b/example/counter/counter.go @@ -2,10 +2,9 @@ package counter import ( "encoding/binary" - "fmt" . "github.com/tendermint/go-common" - "github.com/tendermint/tmsp/types" + "github.com/tendermint/abci/types" ) type CounterApplication struct { @@ -18,8 +17,8 @@ func NewCounterApplication(serial bool) *CounterApplication { return &CounterApplication{serial: serial} } -func (app *CounterApplication) Info() string { - return Fmt("hashes:%v, txs:%v", app.hashCount, app.txCount) +func (app *CounterApplication) Info() types.ResponseInfo { + return types.ResponseInfo{Data: Fmt("{\"hashes\":%v,\"txs\":%v}", app.hashCount, app.txCount)} } func (app *CounterApplication) SetOption(key string, value string) (log string) { @@ -29,17 +28,16 @@ func (app *CounterApplication) SetOption(key string, value string) (log string) return "" } -func (app *CounterApplication) AppendTx(tx []byte) types.Result { +func (app *CounterApplication) DeliverTx(tx []byte) types.Result { if app.serial { + if len(tx) > 8 { + return types.ErrEncodingError.SetLog(Fmt("Max tx size is 8 bytes, got %d", len(tx))) + } tx8 := make([]byte, 8) copy(tx8[len(tx8)-len(tx):], tx) txValue := binary.BigEndian.Uint64(tx8) if txValue != uint64(app.txCount) { - return types.Result{ - Code: types.CodeType_BadNonce, - Data: nil, - Log: fmt.Sprintf("Invalid nonce. Expected %v, got %v", app.txCount, txValue), - } + return types.ErrBadNonce.SetLog(Fmt("Invalid nonce. Expected %v, got %v", app.txCount, txValue)) } } app.txCount += 1 @@ -48,15 +46,14 @@ func (app *CounterApplication) AppendTx(tx []byte) types.Result { func (app *CounterApplication) CheckTx(tx []byte) types.Result { if app.serial { + if len(tx) > 8 { + return types.ErrEncodingError.SetLog(Fmt("Max tx size is 8 bytes, got %d", len(tx))) + } tx8 := make([]byte, 8) copy(tx8[len(tx8)-len(tx):], tx) txValue := binary.BigEndian.Uint64(tx8) if txValue < uint64(app.txCount) { - return types.Result{ - Code: types.CodeType_BadNonce, - Data: nil, - Log: fmt.Sprintf("Invalid nonce. Expected >= %v, got %v", app.txCount, txValue), - } + return types.ErrBadNonce.SetLog(Fmt("Invalid nonce. Expected >= %v, got %v", app.txCount, txValue)) } } return types.OK @@ -75,5 +72,14 @@ func (app *CounterApplication) Commit() types.Result { } func (app *CounterApplication) Query(query []byte) types.Result { - return types.NewResultOK(nil, fmt.Sprintf("Query is not supported")) + queryStr := string(query) + + switch queryStr { + case "hash": + return types.NewResultOK(nil, Fmt("%v", app.hashCount)) + case "tx": + return types.NewResultOK(nil, Fmt("%v", app.txCount)) + } + + return types.ErrUnknownRequest.SetLog(Fmt("Invalid nonce. Expected hash or tx, got %v", queryStr)) } diff --git a/example/dummy/README.md b/example/dummy/README.md new file mode 100644 index 000000000..8c1f0f042 --- /dev/null +++ b/example/dummy/README.md @@ -0,0 +1,31 @@ +# Dummy + +There are two app's here: the DummyApplication and the PersistentDummyApplication. + +## DummyApplication + +The DummyApplication is a simple merkle key-value store. +Transactions of the form `key=value` are stored as key-value pairs in the tree. +Transactions without an `=` sign set the value to the key. +The app has no replay protection (other than what the mempool provides). + +## PersistentDummyApplication + +The PersistentDummyApplication wraps the DummyApplication +and provides two additional features: + +1) persistence of state across app restarts (using Tendermint's ABCI-Handshake mechanism) +2) validator set changes + +The state is persisted in leveldb along with the last block committed, +and the Handshake allows any necessary blocks to be replayed. +Validator set changes are effected using the following transaction format: + +``` +val:pubkey1/power1,addr2/power2,addr3/power3" +``` + +where `power1` is the new voting power for the validator with `pubkey1` (possibly a new one). +There is no sybil protection against new validators joining. +Validators can be removed by setting their power to `0`. + diff --git a/example/dummy/dummy.go b/example/dummy/dummy.go index ca3a8c03a..648ef07e3 100644 --- a/example/dummy/dummy.go +++ b/example/dummy/dummy.go @@ -1,11 +1,13 @@ package dummy import ( + "encoding/hex" "strings" . "github.com/tendermint/go-common" "github.com/tendermint/go-merkle" - "github.com/tendermint/tmsp/types" + "github.com/tendermint/go-wire" + "github.com/tendermint/abci/types" ) type DummyApplication struct { @@ -13,15 +15,12 @@ type DummyApplication struct { } func NewDummyApplication() *DummyApplication { - state := merkle.NewIAVLTree( - 0, - nil, - ) + state := merkle.NewIAVLTree(0, nil) return &DummyApplication{state: state} } -func (app *DummyApplication) Info() string { - return Fmt("size:%v", app.state.Size()) +func (app *DummyApplication) Info() (resInfo types.ResponseInfo) { + return types.ResponseInfo{Data: Fmt("{\"size\":%v}", app.state.Size())} } func (app *DummyApplication) SetOption(key string, value string) (log string) { @@ -29,7 +28,7 @@ func (app *DummyApplication) SetOption(key string, value string) (log string) { } // tx is either "key=value" or just arbitrary bytes -func (app *DummyApplication) AppendTx(tx []byte) types.Result { +func (app *DummyApplication) DeliverTx(tx []byte) types.Result { parts := strings.Split(string(tx), "=") if len(parts) == 2 { app.state.Set([]byte(parts[0]), []byte(parts[1])) @@ -50,6 +49,13 @@ func (app *DummyApplication) Commit() types.Result { func (app *DummyApplication) Query(query []byte) types.Result { index, value, exists := app.state.Get(query) - resStr := Fmt("Index=%v value=%v exists=%v", index, string(value), exists) - return types.NewResultOK([]byte(resStr), "") + queryResult := QueryResult{index, string(value), hex.EncodeToString(value), exists} + return types.NewResultOK(wire.JSONBytes(queryResult), "") +} + +type QueryResult struct { + Index int `json:"index"` + Value string `json:"value"` + ValueHex string `json:"valueHex"` + Exists bool `json:"exists"` } diff --git a/example/dummy/dummy_test.go b/example/dummy/dummy_test.go new file mode 100644 index 000000000..d22943472 --- /dev/null +++ b/example/dummy/dummy_test.go @@ -0,0 +1,203 @@ +package dummy + +import ( + "bytes" + "io/ioutil" + "sort" + "testing" + + . "github.com/tendermint/go-common" + "github.com/tendermint/go-crypto" + "github.com/tendermint/go-wire" + "github.com/tendermint/abci/types" +) + +func testDummy(t *testing.T, dummy types.Application, tx []byte, key, value string) { + if r := dummy.DeliverTx(tx); r.IsErr() { + t.Fatal(r) + } + if r := dummy.DeliverTx(tx); r.IsErr() { + t.Fatal(r) + } + + r := dummy.Query([]byte(key)) + if r.IsErr() { + t.Fatal(r) + } + + q := new(QueryResult) + if err := wire.ReadJSONBytes(r.Data, q); err != nil { + t.Fatal(err) + } + + if q.Value != value { + t.Fatalf("Got %s, expected %s", q.Value, value) + } + +} + +func TestDummyKV(t *testing.T) { + dummy := NewDummyApplication() + key := "abc" + value := key + tx := []byte(key) + testDummy(t, dummy, tx, key, value) + + value = "def" + tx = []byte(key + "=" + value) + testDummy(t, dummy, tx, key, value) +} + +func TestPersistentDummyKV(t *testing.T) { + dir, err := ioutil.TempDir("/tmp", "abci-dummy-test") // TODO + if err != nil { + t.Fatal(err) + } + dummy := NewPersistentDummyApplication(dir) + key := "abc" + value := key + tx := []byte(key) + testDummy(t, dummy, tx, key, value) + + value = "def" + tx = []byte(key + "=" + value) + testDummy(t, dummy, tx, key, value) +} + +func TestPersistentDummyInfo(t *testing.T) { + dir, err := ioutil.TempDir("/tmp", "abci-dummy-test") // TODO + if err != nil { + t.Fatal(err) + } + dummy := NewPersistentDummyApplication(dir) + height := uint64(0) + + resInfo := dummy.Info() + if resInfo.LastBlockHeight != height { + t.Fatalf("expected height of %d, got %d", height, resInfo.LastBlockHeight) + } + + // make and apply block + height = uint64(1) + hash := []byte("foo") + header := &types.Header{ + Height: uint64(height), + } + dummy.BeginBlock(hash, header) + dummy.EndBlock(height) + dummy.Commit() + + resInfo = dummy.Info() + if resInfo.LastBlockHeight != height { + t.Fatalf("expected height of %d, got %d", height, resInfo.LastBlockHeight) + } + +} + +// add a validator, remove a validator, update a validator +func TestValSetChanges(t *testing.T) { + dir, err := ioutil.TempDir("/tmp", "abci-dummy-test") // TODO + if err != nil { + t.Fatal(err) + } + dummy := NewPersistentDummyApplication(dir) + + // init with some validators + total := 10 + nInit := 5 + vals := make([]*types.Validator, total) + for i := 0; i < total; i++ { + pubkey := crypto.GenPrivKeyEd25519FromSecret([]byte(Fmt("test%d", i))).PubKey().Bytes() + power := RandInt() + vals[i] = &types.Validator{pubkey, uint64(power)} + } + // iniitalize with the first nInit + dummy.InitChain(vals[:nInit]) + + vals1, vals2 := vals[:nInit], dummy.Validators() + valsEqual(t, vals1, vals2) + + var v1, v2, v3 *types.Validator + + // add some validators + v1, v2 = vals[nInit], vals[nInit+1] + diff := []*types.Validator{v1, v2} + tx1 := MakeValSetChangeTx(v1.PubKey, v1.Power) + tx2 := MakeValSetChangeTx(v2.PubKey, v2.Power) + + makeApplyBlock(t, dummy, 1, diff, tx1, tx2) + + vals1, vals2 = vals[:nInit+2], dummy.Validators() + valsEqual(t, vals1, vals2) + + // remove some validators + v1, v2, v3 = vals[nInit-2], vals[nInit-1], vals[nInit] + v1.Power = 0 + v2.Power = 0 + v3.Power = 0 + diff = []*types.Validator{v1, v2, v3} + tx1 = MakeValSetChangeTx(v1.PubKey, v1.Power) + tx2 = MakeValSetChangeTx(v2.PubKey, v2.Power) + tx3 := MakeValSetChangeTx(v3.PubKey, v3.Power) + + makeApplyBlock(t, dummy, 2, diff, tx1, tx2, tx3) + + vals1 = append(vals[:nInit-2], vals[nInit+1]) + vals2 = dummy.Validators() + valsEqual(t, vals1, vals2) + + // update some validators + v1 = vals[0] + if v1.Power == 5 { + v1.Power = 6 + } else { + v1.Power = 5 + } + diff = []*types.Validator{v1} + tx1 = MakeValSetChangeTx(v1.PubKey, v1.Power) + + makeApplyBlock(t, dummy, 3, diff, tx1) + + vals1 = append([]*types.Validator{v1}, vals1[1:len(vals1)]...) + vals2 = dummy.Validators() + valsEqual(t, vals1, vals2) + +} + +func makeApplyBlock(t *testing.T, dummy types.Application, heightInt int, diff []*types.Validator, txs ...[]byte) { + // make and apply block + height := uint64(heightInt) + hash := []byte("foo") + header := &types.Header{ + Height: height, + } + + dummyChain := dummy.(types.BlockchainAware) // hmm... + dummyChain.BeginBlock(hash, header) + for _, tx := range txs { + if r := dummy.DeliverTx(tx); r.IsErr() { + t.Fatal(r) + } + } + resEndBlock := dummyChain.EndBlock(height) + dummy.Commit() + + valsEqual(t, diff, resEndBlock.Diffs) + +} + +// order doesn't matter +func valsEqual(t *testing.T, vals1, vals2 []*types.Validator) { + if len(vals1) != len(vals2) { + t.Fatalf("vals dont match in len. got %d, expected %d", len(vals2), len(vals1)) + } + sort.Sort(types.Validators(vals1)) + sort.Sort(types.Validators(vals2)) + for i, v1 := range vals1 { + v2 := vals2[i] + if !bytes.Equal(v1.PubKey, v2.PubKey) || + v1.Power != v2.Power { + t.Fatalf("vals dont match at index %d. got %X/%d , expected %X/%d", i, v2.PubKey, v2.Power, v1.PubKey, v1.Power) + } + } +} diff --git a/example/dummy/log.go b/example/dummy/log.go new file mode 100644 index 000000000..8571fa01e --- /dev/null +++ b/example/dummy/log.go @@ -0,0 +1,7 @@ +package dummy + +import ( + "github.com/tendermint/go-logger" +) + +var log = logger.New("module", "dummy") diff --git a/example/dummy/persistent_dummy.go b/example/dummy/persistent_dummy.go new file mode 100644 index 000000000..fa730bcb5 --- /dev/null +++ b/example/dummy/persistent_dummy.go @@ -0,0 +1,229 @@ +package dummy + +import ( + "bytes" + "encoding/hex" + "strconv" + "strings" + + . "github.com/tendermint/go-common" + dbm "github.com/tendermint/go-db" + "github.com/tendermint/go-merkle" + "github.com/tendermint/go-wire" + "github.com/tendermint/abci/types" +) + +const ( + ValidatorSetChangePrefix string = "val:" +) + +//----------------------------------------- + +type PersistentDummyApplication struct { + app *DummyApplication + db dbm.DB + + // latest received + // TODO: move to merkle tree? + blockHeader *types.Header + + // validator set + changes []*types.Validator +} + +func NewPersistentDummyApplication(dbDir string) *PersistentDummyApplication { + db := dbm.NewDB("dummy", "leveldb", dbDir) + lastBlock := LoadLastBlock(db) + + stateTree := merkle.NewIAVLTree(0, db) + stateTree.Load(lastBlock.AppHash) + + log.Notice("Loaded state", "block", lastBlock.Height, "root", stateTree.Hash()) + + return &PersistentDummyApplication{ + app: &DummyApplication{state: stateTree}, + db: db, + } +} + +func (app *PersistentDummyApplication) Info() (resInfo types.ResponseInfo) { + resInfo = app.app.Info() + lastBlock := LoadLastBlock(app.db) + resInfo.LastBlockHeight = lastBlock.Height + resInfo.LastBlockAppHash = lastBlock.AppHash + return resInfo +} + +func (app *PersistentDummyApplication) SetOption(key string, value string) (log string) { + return app.app.SetOption(key, value) +} + +// tx is either "key=value" or just arbitrary bytes +func (app *PersistentDummyApplication) DeliverTx(tx []byte) types.Result { + // if it starts with "val:", update the validator set + // format is "val:pubkey/power" + if isValidatorTx(tx) { + // update validators in the merkle tree + // and in app.changes + return app.execValidatorTx(tx) + } + + // otherwise, update the key-value store + return app.app.DeliverTx(tx) +} + +func (app *PersistentDummyApplication) CheckTx(tx []byte) types.Result { + return app.app.CheckTx(tx) +} + +func (app *PersistentDummyApplication) Commit() types.Result { + // Save + appHash := app.app.state.Save() + log.Info("Saved state", "root", appHash) + + lastBlock := LastBlockInfo{ + Height: app.blockHeader.Height, + AppHash: appHash, // this hash will be in the next block header + } + SaveLastBlock(app.db, lastBlock) + return types.NewResultOK(appHash, "") +} + +func (app *PersistentDummyApplication) Query(query []byte) types.Result { + return app.app.Query(query) +} + +// Save the validators in the merkle tree +func (app *PersistentDummyApplication) InitChain(validators []*types.Validator) { + for _, v := range validators { + r := app.updateValidator(v) + if r.IsErr() { + log.Error("Error updating validators", "r", r) + } + } +} + +// Track the block hash and header information +func (app *PersistentDummyApplication) BeginBlock(hash []byte, header *types.Header) { + // update latest block info + app.blockHeader = header + + // reset valset changes + app.changes = make([]*types.Validator, 0) +} + +// Update the validator set +func (app *PersistentDummyApplication) EndBlock(height uint64) (resEndBlock types.ResponseEndBlock) { + return types.ResponseEndBlock{Diffs: app.changes} +} + +//----------------------------------------- +// persist the last block info + +var lastBlockKey = []byte("lastblock") + +type LastBlockInfo struct { + Height uint64 + AppHash []byte +} + +// Get the last block from the db +func LoadLastBlock(db dbm.DB) (lastBlock LastBlockInfo) { + buf := db.Get(lastBlockKey) + if len(buf) != 0 { + r, n, err := bytes.NewReader(buf), new(int), new(error) + wire.ReadBinaryPtr(&lastBlock, r, 0, n, err) + if *err != nil { + // DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED + Exit(Fmt("Data has been corrupted or its spec has changed: %v\n", *err)) + } + // TODO: ensure that buf is completely read. + } + + return lastBlock +} + +func SaveLastBlock(db dbm.DB, lastBlock LastBlockInfo) { + log.Notice("Saving block", "height", lastBlock.Height, "root", lastBlock.AppHash) + buf, n, err := new(bytes.Buffer), new(int), new(error) + wire.WriteBinary(lastBlock, buf, n, err) + if *err != nil { + // TODO + PanicCrisis(*err) + } + db.Set(lastBlockKey, buf.Bytes()) +} + +//--------------------------------------------- +// update validators + +func (app *PersistentDummyApplication) Validators() (validators []*types.Validator) { + app.app.state.Iterate(func(key, value []byte) bool { + if isValidatorTx(key) { + validator := new(types.Validator) + err := types.ReadMessage(bytes.NewBuffer(value), validator) + if err != nil { + panic(err) + } + validators = append(validators, validator) + } + return false + }) + return +} + +func MakeValSetChangeTx(pubkey []byte, power uint64) []byte { + return []byte(Fmt("val:%X/%d", pubkey, power)) +} + +func isValidatorTx(tx []byte) bool { + if strings.HasPrefix(string(tx), ValidatorSetChangePrefix) { + return true + } + return false +} + +// format is "val:pubkey1/power1,addr2/power2,addr3/power3"tx +func (app *PersistentDummyApplication) execValidatorTx(tx []byte) types.Result { + tx = tx[len(ValidatorSetChangePrefix):] + pubKeyAndPower := strings.Split(string(tx), "/") + if len(pubKeyAndPower) != 2 { + return types.ErrEncodingError.SetLog(Fmt("Expected 'pubkey/power'. Got %v", pubKeyAndPower)) + } + pubkeyS, powerS := pubKeyAndPower[0], pubKeyAndPower[1] + pubkey, err := hex.DecodeString(pubkeyS) + if err != nil { + return types.ErrEncodingError.SetLog(Fmt("Pubkey (%s) is invalid hex", pubkeyS)) + } + power, err := strconv.Atoi(powerS) + if err != nil { + return types.ErrEncodingError.SetLog(Fmt("Power (%s) is not an int", powerS)) + } + + // update + return app.updateValidator(&types.Validator{pubkey, uint64(power)}) +} + +// add, update, or remove a validator +func (app *PersistentDummyApplication) updateValidator(v *types.Validator) types.Result { + key := []byte("val:" + string(v.PubKey)) + if v.Power == 0 { + // remove validator + if !app.app.state.Has(key) { + return types.ErrUnauthorized.SetLog(Fmt("Cannot remove non-existent validator %X", key)) + } + app.app.state.Remove(key) + } else { + // add or update validator + value := bytes.NewBuffer(make([]byte, 0)) + if err := types.WriteMessage(v, value); err != nil { + return types.ErrInternalError.SetLog(Fmt("Error encoding validator: %v", err)) + } + app.app.state.Set(key, value.Bytes()) + } + + // we only update the changes array if we succesfully updated the tree + app.changes = append(app.changes, v) + + return types.OK +} diff --git a/example/example_test.go b/example/example_test.go index 3293be555..1ddefddb5 100644 --- a/example/example_test.go +++ b/example/example_test.go @@ -11,11 +11,11 @@ import ( "google.golang.org/grpc" . "github.com/tendermint/go-common" - "github.com/tendermint/tmsp/client" - "github.com/tendermint/tmsp/example/dummy" - nilapp "github.com/tendermint/tmsp/example/nil" - "github.com/tendermint/tmsp/server" - "github.com/tendermint/tmsp/types" + "github.com/tendermint/abci/client" + "github.com/tendermint/abci/example/dummy" + nilapp "github.com/tendermint/abci/example/nil" + "github.com/tendermint/abci/server" + "github.com/tendermint/abci/types" ) func TestDummy(t *testing.T) { @@ -35,7 +35,7 @@ func TestGRPC(t *testing.T) { func testStream(t *testing.T, app types.Application) { - numAppendTxs := 200000 + numDeliverTxs := 200000 // Start the listener server, err := server.NewSocketServer("unix://test.sock", app) @@ -45,7 +45,7 @@ func testStream(t *testing.T, app types.Application) { defer server.Stop() // Connect to the socket - client, err := tmspcli.NewSocketClient("unix://test.sock", false) + client, err := abcicli.NewSocketClient("unix://test.sock", false) if err != nil { Exit(Fmt("Error starting socket client: %v", err.Error())) } @@ -57,15 +57,15 @@ func testStream(t *testing.T, app types.Application) { client.SetResponseCallback(func(req *types.Request, res *types.Response) { // Process response switch r := res.Value.(type) { - case *types.Response_AppendTx: + case *types.Response_DeliverTx: counter += 1 - if r.AppendTx.Code != types.CodeType_OK { - t.Error("AppendTx failed with ret_code", r.AppendTx.Code) + if r.DeliverTx.Code != types.CodeType_OK { + t.Error("DeliverTx failed with ret_code", r.DeliverTx.Code) } - if counter > numAppendTxs { - t.Fatalf("Too many AppendTx responses. Got %d, expected %d", counter, numAppendTxs) + if counter > numDeliverTxs { + t.Fatalf("Too many DeliverTx responses. Got %d, expected %d", counter, numDeliverTxs) } - if counter == numAppendTxs { + if counter == numDeliverTxs { go func() { time.Sleep(time.Second * 2) // Wait for a bit to allow counter overflow close(done) @@ -80,9 +80,9 @@ func testStream(t *testing.T, app types.Application) { }) // Write requests - for counter := 0; counter < numAppendTxs; counter++ { + for counter := 0; counter < numDeliverTxs; counter++ { // Send request - reqRes := client.AppendTxAsync([]byte("test")) + reqRes := client.DeliverTxAsync([]byte("test")) _ = reqRes // check err ? @@ -108,7 +108,7 @@ func dialerFunc(addr string, timeout time.Duration) (net.Conn, error) { func testGRPCSync(t *testing.T, app *types.GRPCApplication) { - numAppendTxs := 2000 + numDeliverTxs := 2000 // Start the listener server, err := server.NewGRPCServer("unix://test.sock", app) @@ -124,24 +124,24 @@ func testGRPCSync(t *testing.T, app *types.GRPCApplication) { } defer conn.Close() - client := types.NewTMSPApplicationClient(conn) + client := types.NewABCIApplicationClient(conn) // Write requests - for counter := 0; counter < numAppendTxs; counter++ { + for counter := 0; counter < numDeliverTxs; counter++ { // Send request - response, err := client.AppendTx(context.Background(), &types.RequestAppendTx{[]byte("test")}) + response, err := client.DeliverTx(context.Background(), &types.RequestDeliverTx{[]byte("test")}) if err != nil { - t.Fatalf("Error in GRPC AppendTx: %v", err.Error()) + t.Fatalf("Error in GRPC DeliverTx: %v", err.Error()) } counter += 1 if response.Code != types.CodeType_OK { - t.Error("AppendTx failed with ret_code", response.Code) + t.Error("DeliverTx failed with ret_code", response.Code) } - if counter > numAppendTxs { - t.Fatal("Too many AppendTx responses") + if counter > numDeliverTxs { + t.Fatal("Too many DeliverTx responses") } t.Log("response", counter) - if counter == numAppendTxs { + if counter == numDeliverTxs { go func() { time.Sleep(time.Second * 2) // Wait for a bit to allow counter overflow }() diff --git a/example/js/README.md b/example/js/README.md index f18755065..1bef9cbf5 100644 --- a/example/js/README.md +++ b/example/js/README.md @@ -1 +1 @@ -This example has been moved here: https://github.com/tendermint/js-tmsp/tree/master/example +This example has been moved here: https://github.com/tendermint/js-abci/tree/master/example diff --git a/example/nil/nil_app.go b/example/nil/nil_app.go index 40474a9f2..cd57f0d98 100644 --- a/example/nil/nil_app.go +++ b/example/nil/nil_app.go @@ -1,7 +1,7 @@ package nilapp import ( - "github.com/tendermint/tmsp/types" + "github.com/tendermint/abci/types" ) type NilApplication struct { @@ -11,15 +11,15 @@ func NewNilApplication() *NilApplication { return &NilApplication{} } -func (app *NilApplication) Info() string { - return "nil" +func (app *NilApplication) Info() (resInfo types.ResponseInfo) { + return } func (app *NilApplication) SetOption(key string, value string) (log string) { return "" } -func (app *NilApplication) AppendTx(tx []byte) types.Result { +func (app *NilApplication) DeliverTx(tx []byte) types.Result { return types.NewResultOK(nil, "") } diff --git a/example/python/tmsp/__init__.py b/example/python/abci/__init__.py similarity index 100% rename from example/python/tmsp/__init__.py rename to example/python/abci/__init__.py diff --git a/example/python/tmsp/msg.py b/example/python/abci/msg.py similarity index 89% rename from example/python/tmsp/msg.py rename to example/python/abci/msg.py index a03c0a073..7329f5852 100644 --- a/example/python/tmsp/msg.py +++ b/example/python/abci/msg.py @@ -6,14 +6,14 @@ message_types = { 0x02: "flush", 0x03: "info", 0x04: "set_option", - 0x21: "append_tx", + 0x21: "deliver_tx", 0x22: "check_tx", 0x23: "commit", 0x24: "add_listener", 0x25: "rm_listener", } -# return the decoded arguments of tmsp messages +# return the decoded arguments of abci messages class RequestDecoder(): @@ -32,7 +32,7 @@ class RequestDecoder(): def set_option(self): return decode_string(self.reader), decode_string(self.reader) - def append_tx(self): + def deliver_tx(self): return decode_string(self.reader) def check_tx(self): diff --git a/example/python/tmsp/reader.py b/example/python/abci/reader.py similarity index 100% rename from example/python/tmsp/reader.py rename to example/python/abci/reader.py diff --git a/example/python/tmsp/server.py b/example/python/abci/server.py similarity index 98% rename from example/python/tmsp/server.py rename to example/python/abci/server.py index 60f76e3af..40d50896c 100644 --- a/example/python/tmsp/server.py +++ b/example/python/abci/server.py @@ -26,9 +26,9 @@ class Connection(): raise IOError("dead connection") this.recBuf.write(data) -# TMSP server responds to messges by calling methods on the app +# ABCI server responds to messges by calling methods on the app -class TMSPServer(): +class ABCIServer(): def __init__(self, app, port=5410): self.app = app diff --git a/example/python/tmsp/wire.py b/example/python/abci/wire.py similarity index 100% rename from example/python/tmsp/wire.py rename to example/python/abci/wire.py diff --git a/example/python/app.py b/example/python/app.py index b8cfcca8b..a44ff3455 100644 --- a/example/python/app.py +++ b/example/python/app.py @@ -1,8 +1,8 @@ import sys -from tmsp.wire import hex2bytes, decode_big_endian, encode_big_endian -from tmsp.server import TMSPServer -from tmsp.reader import BytesBuffer +from abci.wire import hex2bytes, decode_big_endian, encode_big_endian +from abci.server import ABCIServer +from abci.reader import BytesBuffer class CounterApplication(): @@ -24,7 +24,7 @@ class CounterApplication(): self.serial = True return 0 - def append_tx(self, txBytes): + def deliver_tx(self, txBytes): if self.serial: txByteArray = bytearray(txBytes) if len(txBytes) >= 2 and txBytes[:2] == "0x": @@ -75,8 +75,8 @@ if __name__ == '__main__': print "too many arguments" quit() - print 'TMSP Demo APP (Python)' + print 'ABCI Demo APP (Python)' app = CounterApplication() - server = TMSPServer(app, port) + server = ABCIServer(app, port) server.main_loop() diff --git a/example/python3/tmsp/__init__.py b/example/python3/abci/__init__.py similarity index 100% rename from example/python3/tmsp/__init__.py rename to example/python3/abci/__init__.py diff --git a/example/python3/tmsp/msg.py b/example/python3/abci/msg.py similarity index 89% rename from example/python3/tmsp/msg.py rename to example/python3/abci/msg.py index ae30f88d9..807c4b6b0 100644 --- a/example/python3/tmsp/msg.py +++ b/example/python3/abci/msg.py @@ -6,14 +6,14 @@ message_types = { 0x02: "flush", 0x03: "info", 0x04: "set_option", - 0x21: "append_tx", + 0x21: "deliver_tx", 0x22: "check_tx", 0x23: "commit", 0x24: "add_listener", 0x25: "rm_listener", } -# return the decoded arguments of tmsp messages +# return the decoded arguments of abci messages class RequestDecoder(): @@ -32,7 +32,7 @@ class RequestDecoder(): def set_option(self): return decode_string(self.reader), decode_string(self.reader) - def append_tx(self): + def deliver_tx(self): return decode_string(self.reader) def check_tx(self): diff --git a/example/python3/tmsp/reader.py b/example/python3/abci/reader.py similarity index 100% rename from example/python3/tmsp/reader.py rename to example/python3/abci/reader.py diff --git a/example/python3/tmsp/server.py b/example/python3/abci/server.py similarity index 98% rename from example/python3/tmsp/server.py rename to example/python3/abci/server.py index 03735bb37..04063262d 100644 --- a/example/python3/tmsp/server.py +++ b/example/python3/abci/server.py @@ -29,9 +29,9 @@ class Connection(): raise IOError("dead connection") this.recBuf.write(data) -# TMSP server responds to messges by calling methods on the app +# ABCI server responds to messges by calling methods on the app -class TMSPServer(): +class ABCIServer(): def __init__(self, app, port=5410): self.app = app diff --git a/example/python3/tmsp/wire.py b/example/python3/abci/wire.py similarity index 100% rename from example/python3/tmsp/wire.py rename to example/python3/abci/wire.py diff --git a/example/python3/app.py b/example/python3/app.py index c3d11490e..b40041a43 100644 --- a/example/python3/app.py +++ b/example/python3/app.py @@ -1,8 +1,8 @@ import sys -from tmsp.wire import hex2bytes, decode_big_endian, encode_big_endian -from tmsp.server import TMSPServer -from tmsp.reader import BytesBuffer +from abci.wire import hex2bytes, decode_big_endian, encode_big_endian +from abci.server import ABCIServer +from abci.reader import BytesBuffer class CounterApplication(): @@ -24,7 +24,7 @@ class CounterApplication(): self.serial = True return 0 - def append_tx(self, txBytes): + def deliver_tx(self, txBytes): if self.serial: txByteArray = bytearray(txBytes) if len(txBytes) >= 2 and txBytes[:2] == "0x": @@ -75,8 +75,8 @@ if __name__ == '__main__': print("too many arguments") quit() - print('TMSP Demo APP (Python)') + print('ABCI Demo APP (Python)') app = CounterApplication() - server = TMSPServer(app, port) + server = ABCIServer(app, port) server.main_loop() diff --git a/glide.lock b/glide.lock index a87f5dc18..27767606d 100644 --- a/glide.lock +++ b/glide.lock @@ -1,26 +1,26 @@ -hash: 65769cd1c6d94a9733e9109e1bd7004f31b8df60c6d2cd47d9d8aecb9a94ffc2 -updated: 2016-11-15T14:05:15.057591061-05:00 +hash: c050dfd4a6af84ab490a78c1580ac74caf42ed00799de7017d2ee325b806f77e +updated: 2017-01-12T21:19:13.812049926-05:00 imports: - name: github.com/btcsuite/btcd - version: d9a674e1b7bc09d0830d6986c71cf5f535d753c3 + version: 153dca5c1e4b5d1ea1523592495e5bedfa503391 subpackages: - btcec -- name: github.com/btcsuite/fastsha256 - version: 637e656429416087660c84436a2a035d69d54e2e - name: github.com/go-stack/stack version: 100eb0c0a9c5b306ca2fb4f165df21d80ada4b82 - name: github.com/golang/protobuf - version: da116c3771bf4a398a43f44e069195ef1c9688ef + version: 8ee79997227bf9b34611aee7946ae64735e6fd93 subpackages: - proto - name: github.com/golang/snappy version: d9eb7a3d35ec988b8585d4a0068e462c27d28380 +- name: github.com/jmhodges/levigo + version: c42d9e0ca023e2198120196f842701bb4c55d7b9 - name: github.com/mattn/go-colorable version: d228849504861217f796da67fae4f6e347643f15 - name: github.com/mattn/go-isatty - version: 66b8e73f3f5cda9f96b69efd03dd3d7fc4a5cdb8 + version: 30a891c33c7cde7b02a981314b4228ec99380cca - name: github.com/syndtr/goleveldb - version: 6b4daa5362b502898ddf367c5c11deb9e7a5c727 + version: 23851d93a2292dcc56e71a18ec9e0624d84a0f65 subpackages: - leveldb - leveldb/cache @@ -40,27 +40,27 @@ imports: - edwards25519 - extra25519 - name: github.com/tendermint/go-common - version: 1c62bb6dadc6269aeecad5f9e7b153d950a54362 + version: 70e694ee76f09058ea38c9ba81b4aa621bd54df1 - name: github.com/tendermint/go-crypto version: 4b11d62bdb324027ea01554e5767b71174680ba0 - name: github.com/tendermint/go-db - version: 31fdd21c7eaeed53e0ea7ca597fb1e960e2988a5 + version: 2645626c33d8702739e52a61a55d705c2dfe4530 - name: github.com/tendermint/go-logger version: cefb3a45c0bf3c493a04e9bcd9b1540528be59f2 - name: github.com/tendermint/go-merkle - version: 05042c6ab9cad51d12e4cecf717ae68e3b1409a8 + version: 2979c7eb8aa020fa1cf203654907dbb889703888 - name: github.com/tendermint/go-process - version: ba01cfbb58d446673beff17e72883cb49c835fb9 + version: 7f507d69fa4c13b34e7a17ff5c87d1eaaa759145 - name: github.com/tendermint/go-wire - version: 287d8caeae91d21686340f5f87170560531681e6 + version: 2f3b7aafe21c80b19b6ee3210ecb3e3d07c7a471 - name: github.com/tendermint/log15 version: ae0f3d6450da9eac7074b439c8e1c3cabf0d5ce6 subpackages: - term - name: github.com/urfave/cli - version: b4f4786f378c0c1d3336b5bb798094b166edf5a9 + version: 8ef3805c9de2519805c3f060524b695bba2cd715 - name: golang.org/x/crypto - version: 9477e0b78b9ac3d0b03822fd95422e2fe07627cd + version: 7c6cc321c680f03b9ef0764448e780704f486b51 subpackages: - nacl/secretbox - openpgp/armor @@ -69,7 +69,7 @@ imports: - ripemd160 - salsa20/salsa - name: golang.org/x/net - version: cac22060de4e495155959e69adcb4b45763ccb10 + version: 60c41d1de8da134c05b7b40154a9a82bf5b7edb9 subpackages: - context - http2 @@ -79,11 +79,18 @@ imports: - lex/httplex - trace - name: golang.org/x/sys - version: b699b7032584f0953262cb2788a0ca19bb494703 + version: d75a52659825e75fff6158388dddc6a5b04f9ba5 subpackages: - unix +- name: golang.org/x/text + version: 44f4f658a783b0cee41fe0a23b8fc91d9c120558 + subpackages: + - secure/bidirule + - transform + - unicode/bidi + - unicode/norm - name: google.golang.org/grpc - version: 0d9891286aca15aeb2b0a73be9f5946c3cfefa85 + version: 50955793b0183f9de69bd78e2ec251cf20aab121 subpackages: - codes - credentials diff --git a/glide.yaml b/glide.yaml index f39ae801e..91283045d 100644 --- a/glide.yaml +++ b/glide.yaml @@ -1,13 +1,18 @@ -package: github.com/tendermint/tmsp +package: github.com/tendermint/abci import: - package: github.com/golang/protobuf subpackages: - proto - package: github.com/tendermint/go-common + version: develop - package: github.com/tendermint/go-crypto - package: github.com/tendermint/go-logger +- package: github.com/tendermint/go-db + version: develop - package: github.com/tendermint/go-merkle + version: develop - package: github.com/tendermint/go-process + version: develop - package: github.com/tendermint/go-wire - package: github.com/urfave/cli - package: golang.org/x/net diff --git a/server/grpc_server.go b/server/grpc_server.go index 02f6fa3f8..1acd45a36 100644 --- a/server/grpc_server.go +++ b/server/grpc_server.go @@ -7,23 +7,23 @@ import ( "google.golang.org/grpc" . "github.com/tendermint/go-common" - "github.com/tendermint/tmsp/types" + "github.com/tendermint/abci/types" ) // var maxNumberConnections = 2 type GRPCServer struct { - QuitService + BaseService proto string addr string listener net.Listener server *grpc.Server - app types.TMSPApplicationServer + app types.ABCIApplicationServer } -func NewGRPCServer(protoAddr string, app types.TMSPApplicationServer) (Service, error) { +func NewGRPCServer(protoAddr string, app types.ABCIApplicationServer) (Service, error) { parts := strings.SplitN(protoAddr, "://", 2) proto, addr := parts[0], parts[1] s := &GRPCServer{ @@ -32,25 +32,25 @@ func NewGRPCServer(protoAddr string, app types.TMSPApplicationServer) (Service, listener: nil, app: app, } - s.QuitService = *NewQuitService(nil, "TMSPServer", s) + s.BaseService = *NewBaseService(nil, "ABCIServer", s) _, err := s.Start() // Just start it return s, err } func (s *GRPCServer) OnStart() error { - s.QuitService.OnStart() + s.BaseService.OnStart() ln, err := net.Listen(s.proto, s.addr) if err != nil { return err } s.listener = ln s.server = grpc.NewServer() - types.RegisterTMSPApplicationServer(s.server, s.app) + types.RegisterABCIApplicationServer(s.server, s.app) go s.server.Serve(s.listener) return nil } func (s *GRPCServer) OnStop() { - s.QuitService.OnStop() + s.BaseService.OnStop() s.server.Stop() } diff --git a/server/log.go b/server/log.go index 8ac4092e7..4b313d25f 100644 --- a/server/log.go +++ b/server/log.go @@ -4,4 +4,4 @@ import ( "github.com/tendermint/go-logger" ) -var log = logger.New("module", "tmsp-server") +var log = logger.New("module", "abci-server") diff --git a/server/server.go b/server/server.go index f2b9d0af4..496767470 100644 --- a/server/server.go +++ b/server/server.go @@ -4,7 +4,7 @@ import ( "fmt" . "github.com/tendermint/go-common" - "github.com/tendermint/tmsp/types" + "github.com/tendermint/abci/types" ) func NewServer(protoAddr, transport string, app types.Application) (Service, error) { diff --git a/server/socket_server.go b/server/socket_server.go index ff01a9082..bd26a18a8 100644 --- a/server/socket_server.go +++ b/server/socket_server.go @@ -9,13 +9,13 @@ import ( "sync" . "github.com/tendermint/go-common" - "github.com/tendermint/tmsp/types" + "github.com/tendermint/abci/types" ) // var maxNumberConnections = 2 type SocketServer struct { - QuitService + BaseService proto string addr string @@ -39,13 +39,13 @@ func NewSocketServer(protoAddr string, app types.Application) (Service, error) { app: app, conns: make(map[int]net.Conn), } - s.QuitService = *NewQuitService(nil, "TMSPServer", s) + s.BaseService = *NewBaseService(nil, "ABCIServer", s) _, err := s.Start() // Just start it return s, err } func (s *SocketServer) OnStart() error { - s.QuitService.OnStart() + s.BaseService.OnStart() ln, err := net.Listen(s.proto, s.addr) if err != nil { return err @@ -56,7 +56,7 @@ func (s *SocketServer) OnStart() error { } func (s *SocketServer) OnStop() { - s.QuitService.OnStop() + s.BaseService.OnStop() s.listener.Close() s.connsMtx.Lock() @@ -168,15 +168,15 @@ func (s *SocketServer) handleRequest(req *types.Request, responses chan<- *types case *types.Request_Flush: responses <- types.ToResponseFlush() case *types.Request_Info: - data := s.app.Info() - responses <- types.ToResponseInfo(data) + resInfo := s.app.Info() + responses <- types.ToResponseInfo(resInfo) case *types.Request_SetOption: so := r.SetOption logStr := s.app.SetOption(so.Key, so.Value) responses <- types.ToResponseSetOption(logStr) - case *types.Request_AppendTx: - res := s.app.AppendTx(r.AppendTx.Tx) - responses <- types.ToResponseAppendTx(res.Code, res.Data, res.Log) + case *types.Request_DeliverTx: + res := s.app.DeliverTx(r.DeliverTx.Tx) + responses <- types.ToResponseDeliverTx(res.Code, res.Data, res.Log) case *types.Request_CheckTx: res := s.app.CheckTx(r.CheckTx.Tx) responses <- types.ToResponseCheckTx(res.Code, res.Data, res.Log) @@ -189,16 +189,19 @@ func (s *SocketServer) handleRequest(req *types.Request, responses chan<- *types case *types.Request_InitChain: if app, ok := s.app.(types.BlockchainAware); ok { app.InitChain(r.InitChain.Validators) - responses <- types.ToResponseInitChain() - } else { - responses <- types.ToResponseInitChain() } + responses <- types.ToResponseInitChain() + case *types.Request_BeginBlock: + if app, ok := s.app.(types.BlockchainAware); ok { + app.BeginBlock(r.BeginBlock.Hash, r.BeginBlock.Header) + } + responses <- types.ToResponseBeginBlock() case *types.Request_EndBlock: if app, ok := s.app.(types.BlockchainAware); ok { - validators := app.EndBlock(r.EndBlock.Height) - responses <- types.ToResponseEndBlock(validators) + resEndBlock := app.EndBlock(r.EndBlock.Height) + responses <- types.ToResponseEndBlock(resEndBlock) } else { - responses <- types.ToResponseEndBlock(nil) + responses <- types.ToResponseEndBlock(types.ResponseEndBlock{}) } default: responses <- types.ToResponseException("Unknown request") diff --git a/tests/benchmarks/parallel/parallel.go b/tests/benchmarks/parallel/parallel.go index db57e19bf..5960d529a 100644 --- a/tests/benchmarks/parallel/parallel.go +++ b/tests/benchmarks/parallel/parallel.go @@ -6,7 +6,7 @@ import ( //"encoding/hex" . "github.com/tendermint/go-common" - "github.com/tendermint/tmsp/types" + "github.com/tendermint/abci/types" ) func main() { diff --git a/tests/benchmarks/simple/simple.go b/tests/benchmarks/simple/simple.go index 585ebd2b5..fb536730c 100644 --- a/tests/benchmarks/simple/simple.go +++ b/tests/benchmarks/simple/simple.go @@ -9,7 +9,7 @@ import ( //"encoding/hex" . "github.com/tendermint/go-common" - "github.com/tendermint/tmsp/types" + "github.com/tendermint/abci/types" ) func main() { diff --git a/tests/test_app/app.go b/tests/test_app/app.go index 2a1bf15ad..59d5b0e70 100644 --- a/tests/test_app/app.go +++ b/tests/test_app/app.go @@ -7,23 +7,24 @@ import ( . "github.com/tendermint/go-common" "github.com/tendermint/go-process" - "github.com/tendermint/tmsp/client" - "github.com/tendermint/tmsp/types" + "github.com/tendermint/abci/client" + "github.com/tendermint/abci/types" ) //---------------------------------------- -func StartApp(tmspApp string) *process.Process { +func StartApp(abciApp string) *process.Process { // Start the app //outBuf := NewBufferCloser(nil) - proc, err := process.StartProcess("tmsp_app", + proc, err := process.StartProcess("abci_app", + "", "bash", - []string{"-c", tmspApp}, + []string{"-c", abciApp}, nil, os.Stdout, ) if err != nil { - panic("running tmsp_app: " + err.Error()) + panic("running abci_app: " + err.Error()) } // TODO a better way to handle this? @@ -32,16 +33,16 @@ func StartApp(tmspApp string) *process.Process { return proc } -func StartClient(tmspType string) tmspcli.Client { +func StartClient(abciType string) abcicli.Client { // Start client - client, err := tmspcli.NewClient("tcp://127.0.0.1:46658", tmspType, true) + client, err := abcicli.NewClient("tcp://127.0.0.1:46658", abciType, true) if err != nil { - panic("connecting to tmsp_app: " + err.Error()) + panic("connecting to abci_app: " + err.Error()) } return client } -func SetOption(client tmspcli.Client, key, value string) { +func SetOption(client abcicli.Client, key, value string) { res := client.SetOptionSync(key, value) _, _, log := res.Code, res.Data, res.Log if res.IsErr() { @@ -49,7 +50,7 @@ func SetOption(client tmspcli.Client, key, value string) { } } -func Commit(client tmspcli.Client, hashExp []byte) { +func Commit(client abcicli.Client, hashExp []byte) { res := client.CommitSync() _, data, log := res.Code, res.Data, res.Log if res.IsErr() { @@ -61,20 +62,20 @@ func Commit(client tmspcli.Client, hashExp []byte) { } } -func AppendTx(client tmspcli.Client, txBytes []byte, codeExp types.CodeType, dataExp []byte) { - res := client.AppendTxSync(txBytes) +func DeliverTx(client abcicli.Client, txBytes []byte, codeExp types.CodeType, dataExp []byte) { + res := client.DeliverTxSync(txBytes) code, data, log := res.Code, res.Data, res.Log if code != codeExp { - panic(Fmt("AppendTx response code was unexpected. Got %v expected %v. Log: %v", + panic(Fmt("DeliverTx response code was unexpected. Got %v expected %v. Log: %v", code, codeExp, log)) } if !bytes.Equal(data, dataExp) { - panic(Fmt("AppendTx response data was unexpected. Got %X expected %X", + panic(Fmt("DeliverTx response data was unexpected. Got %X expected %X", data, dataExp)) } } -func CheckTx(client tmspcli.Client, txBytes []byte, codeExp types.CodeType, dataExp []byte) { +func CheckTx(client abcicli.Client, txBytes []byte, codeExp types.CodeType, dataExp []byte) { res := client.CheckTxSync(txBytes) code, data, log := res.Code, res.Data, res.Log if res.IsErr() { diff --git a/tests/test_app/main.go b/tests/test_app/main.go index ada637181..05f66b07f 100644 --- a/tests/test_app/main.go +++ b/tests/test_app/main.go @@ -4,15 +4,15 @@ import ( "fmt" "os" - "github.com/tendermint/tmsp/types" + "github.com/tendermint/abci/types" ) -var tmspType string +var abciType string func init() { - tmspType = os.Getenv("TMSP") - if tmspType == "" { - tmspType = "socket" + abciType = os.Getenv("ABCI") + if abciType == "" { + abciType = "socket" } } @@ -21,28 +21,28 @@ func main() { } func testCounter() { - tmspApp := os.Getenv("TMSP_APP") - if tmspApp == "" { - panic("No TMSP_APP specified") + abciApp := os.Getenv("ABCI_APP") + if abciApp == "" { + panic("No ABCI_APP specified") } - fmt.Printf("Running %s test with tmsp=%s\n", tmspApp, tmspType) - appProc := StartApp(tmspApp) + fmt.Printf("Running %s test with abci=%s\n", abciApp, abciType) + appProc := StartApp(abciApp) defer appProc.StopProcess(true) - client := StartClient(tmspType) + client := StartClient(abciType) defer client.Stop() SetOption(client, "serial", "on") Commit(client, nil) - AppendTx(client, []byte("abc"), types.CodeType_BadNonce, nil) + DeliverTx(client, []byte("abc"), types.CodeType_BadNonce, nil) Commit(client, nil) - AppendTx(client, []byte{0x00}, types.CodeType_OK, nil) + DeliverTx(client, []byte{0x00}, types.CodeType_OK, nil) Commit(client, []byte{0, 0, 0, 0, 0, 0, 0, 1}) - AppendTx(client, []byte{0x00}, types.CodeType_BadNonce, nil) - AppendTx(client, []byte{0x01}, types.CodeType_OK, nil) - AppendTx(client, []byte{0x00, 0x02}, types.CodeType_OK, nil) - AppendTx(client, []byte{0x00, 0x03}, types.CodeType_OK, nil) - AppendTx(client, []byte{0x00, 0x00, 0x04}, types.CodeType_OK, nil) - AppendTx(client, []byte{0x00, 0x00, 0x06}, types.CodeType_BadNonce, nil) + DeliverTx(client, []byte{0x00}, types.CodeType_BadNonce, nil) + DeliverTx(client, []byte{0x01}, types.CodeType_OK, nil) + DeliverTx(client, []byte{0x00, 0x02}, types.CodeType_OK, nil) + DeliverTx(client, []byte{0x00, 0x03}, types.CodeType_OK, nil) + DeliverTx(client, []byte{0x00, 0x00, 0x04}, types.CodeType_OK, nil) + DeliverTx(client, []byte{0x00, 0x00, 0x06}, types.CodeType_BadNonce, nil) Commit(client, []byte{0, 0, 0, 0, 0, 0, 0, 5}) } diff --git a/tests/test_app/test.sh b/tests/test_app/test.sh index 4c28a831b..a0f2c3ce6 100755 --- a/tests/test_app/test.sh +++ b/tests/test_app/test.sh @@ -1,17 +1,17 @@ #! /bin/bash set -e -# These tests spawn the counter app and server by execing the TMSP_APP command and run some simple client tests against it +# These tests spawn the counter app and server by execing the ABCI_APP command and run some simple client tests against it -ROOT=$GOPATH/src/github.com/tendermint/tmsp/tests/test_app +ROOT=$GOPATH/src/github.com/tendermint/abci/tests/test_app cd $ROOT # test golang counter -TMSP_APP="counter" go run *.go +ABCI_APP="counter" go run *.go # test golang counter via grpc -TMSP_APP="counter -tmsp=grpc" TMSP="grpc" go run *.go +ABCI_APP="counter -abci=grpc" ABCI="grpc" go run *.go # test nodejs counter # TODO: fix node app -#TMSP_APP="node $GOPATH/src/github.com/tendermint/js-tmsp/example/app.js" go test -test.run TestCounter +#ABCI_APP="node $GOPATH/src/github.com/tendermint/js-abci/example/app.js" go test -test.run TestCounter diff --git a/tests/test_cli/ex1.abci b/tests/test_cli/ex1.abci new file mode 100644 index 000000000..e909266ec --- /dev/null +++ b/tests/test_cli/ex1.abci @@ -0,0 +1,10 @@ +echo hello +info +commit +deliver_tx "abc" +info +commit +query "abc" +deliver_tx "def=xyz" +commit +query "def" diff --git a/tests/test_cli/ex1.abci.out b/tests/test_cli/ex1.abci.out new file mode 100644 index 000000000..c8739758c --- /dev/null +++ b/tests/test_cli/ex1.abci.out @@ -0,0 +1,32 @@ +> echo hello +-> data: hello + +> info +-> data: {"size":0} + +> commit +-> data: 0x + +> deliver_tx "abc" +-> code: OK + +> info +-> data: {"size":1} + +> commit +-> data: 0x750502FC7E84BBD788ED589624F06CFA871845D1 + +> query "abc" +-> code: OK +-> data: {"index":0,"value":"abc","valueHex":"616263","exists":true} + +> deliver_tx "def=xyz" +-> code: OK + +> commit +-> data: 0x76393B8A182E450286B0694C629ECB51B286EFD5 + +> query "def" +-> code: OK +-> data: {"index":1,"value":"xyz","valueHex":"78797a","exists":true} + diff --git a/tests/test_cli/ex1.tmsp b/tests/test_cli/ex1.tmsp deleted file mode 100644 index de61c8b2f..000000000 --- a/tests/test_cli/ex1.tmsp +++ /dev/null @@ -1,10 +0,0 @@ -echo hello -info -commit -append_tx abc -info -commit -query abc -append_tx def=xyz -commit -query def diff --git a/tests/test_cli/ex1.tmsp.out b/tests/test_cli/ex1.tmsp.out deleted file mode 100644 index 89bd61c2f..000000000 --- a/tests/test_cli/ex1.tmsp.out +++ /dev/null @@ -1,31 +0,0 @@ -> echo hello --> data: {hello} - -> info --> data: {size:0} - -> commit - -> append_tx abc --> code: OK - -> info --> data: {size:1} - -> commit --> data: {750502FC7E84BBD788ED589624F06CFA871845D1} - -> query abc --> code: OK --> data: {Index=0 value=abc exists=true} - -> append_tx def=xyz --> code: OK - -> commit --> data: {76393B8A182E450286B0694C629ECB51B286EFD5} - -> query def --> code: OK --> data: {Index=1 value=xyz exists=true} - diff --git a/tests/test_cli/ex2.tmsp b/tests/test_cli/ex2.abci similarity index 58% rename from tests/test_cli/ex2.tmsp rename to tests/test_cli/ex2.abci index e9550db80..3b435f22a 100644 --- a/tests/test_cli/ex2.tmsp +++ b/tests/test_cli/ex2.abci @@ -1,8 +1,8 @@ set_option serial on check_tx 0x00 check_tx 0xff -append_tx 0x00 +deliver_tx 0x00 check_tx 0x00 -append_tx 0x01 -append_tx 0x04 +deliver_tx 0x01 +deliver_tx 0x04 info diff --git a/tests/test_cli/ex2.tmsp.out b/tests/test_cli/ex2.abci.out similarity index 71% rename from tests/test_cli/ex2.tmsp.out rename to tests/test_cli/ex2.abci.out index 3aa7744bb..1fab1e841 100644 --- a/tests/test_cli/ex2.tmsp.out +++ b/tests/test_cli/ex2.abci.out @@ -1,5 +1,5 @@ > set_option serial on --> data: {serial=on} +-> data: serial=on > check_tx 0x00 -> code: OK @@ -7,20 +7,20 @@ > check_tx 0xff -> code: OK -> append_tx 0x00 +> deliver_tx 0x00 -> code: OK > check_tx 0x00 -> code: BadNonce -> log: Invalid nonce. Expected >= 1, got 0 -> append_tx 0x01 +> deliver_tx 0x01 -> code: OK -> append_tx 0x04 +> deliver_tx 0x04 -> code: BadNonce -> log: Invalid nonce. Expected 2, got 4 > info --> data: {hashes:0, txs:2} +-> data: {"hashes":0,"txs":2} diff --git a/tests/test_cli/test.sh b/tests/test_cli/test.sh index 00446c45d..a770730be 100644 --- a/tests/test_cli/test.sh +++ b/tests/test_cli/test.sh @@ -1,5 +1,7 @@ #! /bin/bash +cd $GOPATH/src/github.com/tendermint/abci + function testExample() { N=$1 INPUT=$2 @@ -8,7 +10,7 @@ function testExample() { echo "Example $N" $APP &> /dev/null & sleep 2 - tmsp-cli --verbose batch < $INPUT > "${INPUT}.out.new" + abci-cli --verbose batch < $INPUT > "${INPUT}.out.new" killall "$APP" pre=`shasum < "${INPUT}.out"` @@ -26,8 +28,8 @@ function testExample() { rm "${INPUT}".out.new } -testExample 1 tests/test_cli/ex1.tmsp dummy -testExample 2 tests/test_cli/ex2.tmsp counter +testExample 1 tests/test_cli/ex1.abci dummy +testExample 2 tests/test_cli/ex2.abci counter echo "" echo "PASS" diff --git a/testutil/messages.go b/testutil/messages.go index 2890fbd5f..1036e48e4 100644 --- a/testutil/messages.go +++ b/testutil/messages.go @@ -2,7 +2,7 @@ package testutil import ( "github.com/tendermint/go-crypto" - "github.com/tendermint/tmsp/types" + "github.com/tendermint/abci/types" ) //---------------------------------------- diff --git a/types/application.go b/types/application.go index c6e6f24b8..4da5e6f76 100644 --- a/types/application.go +++ b/types/application.go @@ -8,13 +8,13 @@ import ( type Application interface { // Return application info - Info() (info string) + Info() ResponseInfo // Set application option (e.g. mode=mempool, mode=consensus) SetOption(key string, value string) (log string) - // Append a tx - AppendTx(tx []byte) Result + // Deliver a tx + DeliverTx(tx []byte) Result // Validate a tx for the mempool CheckTx(tx []byte) Result @@ -34,11 +34,11 @@ type BlockchainAware interface { InitChain(validators []*Validator) // Signals the beginning of a block - BeginBlock(height uint64) + BeginBlock(hash []byte, header *Header) // Signals the end of a block // diffs: changed validators from app to TendermintCore - EndBlock(height uint64) (diffs []*Validator) + EndBlock(height uint64) ResponseEndBlock } //------------------------------------ @@ -59,16 +59,17 @@ func (app *GRPCApplication) Flush(ctx context.Context, req *RequestFlush) (*Resp } func (app *GRPCApplication) Info(ctx context.Context, req *RequestInfo) (*ResponseInfo, error) { - return &ResponseInfo{app.app.Info()}, nil + resInfo := app.app.Info() + return &resInfo, nil } func (app *GRPCApplication) SetOption(ctx context.Context, req *RequestSetOption) (*ResponseSetOption, error) { return &ResponseSetOption{app.app.SetOption(req.Key, req.Value)}, nil } -func (app *GRPCApplication) AppendTx(ctx context.Context, req *RequestAppendTx) (*ResponseAppendTx, error) { - r := app.app.AppendTx(req.Tx) - return &ResponseAppendTx{r.Code, r.Data, r.Log}, nil +func (app *GRPCApplication) DeliverTx(ctx context.Context, req *RequestDeliverTx) (*ResponseDeliverTx, error) { + r := app.app.DeliverTx(req.Tx) + return &ResponseDeliverTx{r.Code, r.Data, r.Log}, nil } func (app *GRPCApplication) CheckTx(ctx context.Context, req *RequestCheckTx) (*ResponseCheckTx, error) { @@ -95,15 +96,15 @@ func (app *GRPCApplication) InitChain(ctx context.Context, req *RequestInitChain func (app *GRPCApplication) BeginBlock(ctx context.Context, req *RequestBeginBlock) (*ResponseBeginBlock, error) { if chainAware, ok := app.app.(BlockchainAware); ok { - chainAware.BeginBlock(req.Height) + chainAware.BeginBlock(req.Hash, req.Header) } return &ResponseBeginBlock{}, nil } func (app *GRPCApplication) EndBlock(ctx context.Context, req *RequestEndBlock) (*ResponseEndBlock, error) { if chainAware, ok := app.app.(BlockchainAware); ok { - diffs := chainAware.EndBlock(req.Height) - return &ResponseEndBlock{diffs}, nil + resEndBlock := chainAware.EndBlock(req.Height) + return &resEndBlock, nil } return &ResponseEndBlock{}, nil } diff --git a/types/messages.go b/types/messages.go index 6b047d47b..84e6ee0b3 100644 --- a/types/messages.go +++ b/types/messages.go @@ -31,9 +31,9 @@ func ToRequestSetOption(key string, value string) *Request { } } -func ToRequestAppendTx(txBytes []byte) *Request { +func ToRequestDeliverTx(txBytes []byte) *Request { return &Request{ - Value: &Request_AppendTx{&RequestAppendTx{txBytes}}, + Value: &Request_DeliverTx{&RequestDeliverTx{txBytes}}, } } @@ -61,9 +61,9 @@ func ToRequestInitChain(validators []*Validator) *Request { } } -func ToRequestBeginBlock(height uint64) *Request { +func ToRequestBeginBlock(hash []byte, header *Header) *Request { return &Request{ - Value: &Request_BeginBlock{&RequestBeginBlock{height}}, + Value: &Request_BeginBlock{&RequestBeginBlock{hash, header}}, } } @@ -93,9 +93,9 @@ func ToResponseFlush() *Response { } } -func ToResponseInfo(info string) *Response { +func ToResponseInfo(resInfo ResponseInfo) *Response { return &Response{ - Value: &Response_Info{&ResponseInfo{info}}, + Value: &Response_Info{&resInfo}, } } @@ -105,9 +105,9 @@ func ToResponseSetOption(log string) *Response { } } -func ToResponseAppendTx(code CodeType, data []byte, log string) *Response { +func ToResponseDeliverTx(code CodeType, data []byte, log string) *Response { return &Response{ - Value: &Response_AppendTx{&ResponseAppendTx{code, data, log}}, + Value: &Response_DeliverTx{&ResponseDeliverTx{code, data, log}}, } } @@ -141,9 +141,9 @@ func ToResponseBeginBlock() *Response { } } -func ToResponseEndBlock(validators []*Validator) *Response { +func ToResponseEndBlock(resEndBlock ResponseEndBlock) *Response { return &Response{ - Value: &Response_EndBlock{&ResponseEndBlock{validators}}, + Value: &Response_EndBlock{&resEndBlock}, } } diff --git a/types/result.go b/types/result.go index 717ae2fa0..571c5bf8b 100644 --- a/types/result.go +++ b/types/result.go @@ -28,7 +28,7 @@ func (res Result) IsErr() bool { } func (res Result) Error() string { - return fmt.Sprintf("TMSP code:%v, data:%X, log:%v", res.Code, res.Data, res.Log) + return fmt.Sprintf("ABCI code:%v, data:%X, log:%v", res.Code, res.Data, res.Log) } func (res Result) PrependLog(log string) Result { diff --git a/types/types.pb.go b/types/types.pb.go index 40630bf2c..40c3441b8 100644 --- a/types/types.pb.go +++ b/types/types.pb.go @@ -14,7 +14,7 @@ It has these top-level messages: RequestFlush RequestInfo RequestSetOption - RequestAppendTx + RequestDeliverTx RequestCheckTx RequestQuery RequestCommit @@ -27,13 +27,16 @@ It has these top-level messages: ResponseFlush ResponseInfo ResponseSetOption - ResponseAppendTx + ResponseDeliverTx ResponseCheckTx ResponseQuery ResponseCommit ResponseInitChain ResponseBeginBlock ResponseEndBlock + Header + BlockID + PartSetHeader Validator */ package types @@ -71,7 +74,7 @@ const ( MessageType_Info MessageType = 3 MessageType_SetOption MessageType = 4 MessageType_Exception MessageType = 5 - MessageType_AppendTx MessageType = 17 + MessageType_DeliverTx MessageType = 17 MessageType_CheckTx MessageType = 18 MessageType_Commit MessageType = 19 MessageType_Query MessageType = 20 @@ -87,7 +90,7 @@ var MessageType_name = map[int32]string{ 3: "Info", 4: "SetOption", 5: "Exception", - 17: "AppendTx", + 17: "DeliverTx", 18: "CheckTx", 19: "Commit", 20: "Query", @@ -102,7 +105,7 @@ var MessageType_value = map[string]int32{ "Info": 3, "SetOption": 4, "Exception": 5, - "AppendTx": 17, + "DeliverTx": 17, "CheckTx": 18, "Commit": 19, "Query": 20, @@ -230,7 +233,7 @@ type Request struct { // *Request_Flush // *Request_Info // *Request_SetOption - // *Request_AppendTx + // *Request_DeliverTx // *Request_CheckTx // *Request_Commit // *Request_Query @@ -261,8 +264,8 @@ type Request_Info struct { type Request_SetOption struct { SetOption *RequestSetOption `protobuf:"bytes,4,opt,name=set_option,json=setOption,oneof"` } -type Request_AppendTx struct { - AppendTx *RequestAppendTx `protobuf:"bytes,5,opt,name=append_tx,json=appendTx,oneof"` +type Request_DeliverTx struct { + DeliverTx *RequestDeliverTx `protobuf:"bytes,5,opt,name=deliver_tx,json=deliverTx,oneof"` } type Request_CheckTx struct { CheckTx *RequestCheckTx `protobuf:"bytes,6,opt,name=check_tx,json=checkTx,oneof"` @@ -287,7 +290,7 @@ func (*Request_Echo) isRequest_Value() {} func (*Request_Flush) isRequest_Value() {} func (*Request_Info) isRequest_Value() {} func (*Request_SetOption) isRequest_Value() {} -func (*Request_AppendTx) isRequest_Value() {} +func (*Request_DeliverTx) isRequest_Value() {} func (*Request_CheckTx) isRequest_Value() {} func (*Request_Commit) isRequest_Value() {} func (*Request_Query) isRequest_Value() {} @@ -330,9 +333,9 @@ func (m *Request) GetSetOption() *RequestSetOption { return nil } -func (m *Request) GetAppendTx() *RequestAppendTx { - if x, ok := m.GetValue().(*Request_AppendTx); ok { - return x.AppendTx +func (m *Request) GetDeliverTx() *RequestDeliverTx { + if x, ok := m.GetValue().(*Request_DeliverTx); ok { + return x.DeliverTx } return nil } @@ -386,7 +389,7 @@ func (*Request) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error (*Request_Flush)(nil), (*Request_Info)(nil), (*Request_SetOption)(nil), - (*Request_AppendTx)(nil), + (*Request_DeliverTx)(nil), (*Request_CheckTx)(nil), (*Request_Commit)(nil), (*Request_Query)(nil), @@ -420,9 +423,9 @@ func _Request_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { if err := b.EncodeMessage(x.SetOption); err != nil { return err } - case *Request_AppendTx: + case *Request_DeliverTx: b.EncodeVarint(5<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.AppendTx); err != nil { + if err := b.EncodeMessage(x.DeliverTx); err != nil { return err } case *Request_CheckTx: @@ -497,13 +500,13 @@ func _Request_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer err := b.DecodeMessage(msg) m.Value = &Request_SetOption{msg} return true, err - case 5: // value.append_tx + case 5: // value.deliver_tx if wire != proto.WireBytes { return true, proto.ErrInternalBadWireType } - msg := new(RequestAppendTx) + msg := new(RequestDeliverTx) err := b.DecodeMessage(msg) - m.Value = &Request_AppendTx{msg} + m.Value = &Request_DeliverTx{msg} return true, err case 6: // value.check_tx if wire != proto.WireBytes { @@ -582,8 +585,8 @@ func _Request_OneofSizer(msg proto.Message) (n int) { n += proto.SizeVarint(4<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s - case *Request_AppendTx: - s := proto.Size(x.AppendTx) + case *Request_DeliverTx: + s := proto.Size(x.DeliverTx) n += proto.SizeVarint(5<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s @@ -680,16 +683,16 @@ func (m *RequestSetOption) GetValue() string { return "" } -type RequestAppendTx struct { +type RequestDeliverTx struct { Tx []byte `protobuf:"bytes,1,opt,name=tx,proto3" json:"tx,omitempty"` } -func (m *RequestAppendTx) Reset() { *m = RequestAppendTx{} } -func (m *RequestAppendTx) String() string { return proto.CompactTextString(m) } -func (*RequestAppendTx) ProtoMessage() {} -func (*RequestAppendTx) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } +func (m *RequestDeliverTx) Reset() { *m = RequestDeliverTx{} } +func (m *RequestDeliverTx) String() string { return proto.CompactTextString(m) } +func (*RequestDeliverTx) ProtoMessage() {} +func (*RequestDeliverTx) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } -func (m *RequestAppendTx) GetTx() []byte { +func (m *RequestDeliverTx) GetTx() []byte { if m != nil { return m.Tx } @@ -753,7 +756,8 @@ func (m *RequestInitChain) GetValidators() []*Validator { } type RequestBeginBlock struct { - Height uint64 `protobuf:"varint,1,opt,name=height" json:"height,omitempty"` + Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + Header *Header `protobuf:"bytes,2,opt,name=header" json:"header,omitempty"` } func (m *RequestBeginBlock) Reset() { *m = RequestBeginBlock{} } @@ -761,11 +765,18 @@ func (m *RequestBeginBlock) String() string { return proto.CompactTex func (*RequestBeginBlock) ProtoMessage() {} func (*RequestBeginBlock) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} } -func (m *RequestBeginBlock) GetHeight() uint64 { +func (m *RequestBeginBlock) GetHash() []byte { if m != nil { - return m.Height + return m.Hash } - return 0 + return nil +} + +func (m *RequestBeginBlock) GetHeader() *Header { + if m != nil { + return m.Header + } + return nil } type RequestEndBlock struct { @@ -791,7 +802,7 @@ type Response struct { // *Response_Flush // *Response_Info // *Response_SetOption - // *Response_AppendTx + // *Response_DeliverTx // *Response_CheckTx // *Response_Commit // *Response_Query @@ -825,8 +836,8 @@ type Response_Info struct { type Response_SetOption struct { SetOption *ResponseSetOption `protobuf:"bytes,5,opt,name=set_option,json=setOption,oneof"` } -type Response_AppendTx struct { - AppendTx *ResponseAppendTx `protobuf:"bytes,6,opt,name=append_tx,json=appendTx,oneof"` +type Response_DeliverTx struct { + DeliverTx *ResponseDeliverTx `protobuf:"bytes,6,opt,name=deliver_tx,json=deliverTx,oneof"` } type Response_CheckTx struct { CheckTx *ResponseCheckTx `protobuf:"bytes,7,opt,name=check_tx,json=checkTx,oneof"` @@ -852,7 +863,7 @@ func (*Response_Echo) isResponse_Value() {} func (*Response_Flush) isResponse_Value() {} func (*Response_Info) isResponse_Value() {} func (*Response_SetOption) isResponse_Value() {} -func (*Response_AppendTx) isResponse_Value() {} +func (*Response_DeliverTx) isResponse_Value() {} func (*Response_CheckTx) isResponse_Value() {} func (*Response_Commit) isResponse_Value() {} func (*Response_Query) isResponse_Value() {} @@ -902,9 +913,9 @@ func (m *Response) GetSetOption() *ResponseSetOption { return nil } -func (m *Response) GetAppendTx() *ResponseAppendTx { - if x, ok := m.GetValue().(*Response_AppendTx); ok { - return x.AppendTx +func (m *Response) GetDeliverTx() *ResponseDeliverTx { + if x, ok := m.GetValue().(*Response_DeliverTx); ok { + return x.DeliverTx } return nil } @@ -959,7 +970,7 @@ func (*Response) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) erro (*Response_Flush)(nil), (*Response_Info)(nil), (*Response_SetOption)(nil), - (*Response_AppendTx)(nil), + (*Response_DeliverTx)(nil), (*Response_CheckTx)(nil), (*Response_Commit)(nil), (*Response_Query)(nil), @@ -998,9 +1009,9 @@ func _Response_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { if err := b.EncodeMessage(x.SetOption); err != nil { return err } - case *Response_AppendTx: + case *Response_DeliverTx: b.EncodeVarint(6<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.AppendTx); err != nil { + if err := b.EncodeMessage(x.DeliverTx); err != nil { return err } case *Response_CheckTx: @@ -1083,13 +1094,13 @@ func _Response_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffe err := b.DecodeMessage(msg) m.Value = &Response_SetOption{msg} return true, err - case 6: // value.append_tx + case 6: // value.deliver_tx if wire != proto.WireBytes { return true, proto.ErrInternalBadWireType } - msg := new(ResponseAppendTx) + msg := new(ResponseDeliverTx) err := b.DecodeMessage(msg) - m.Value = &Response_AppendTx{msg} + m.Value = &Response_DeliverTx{msg} return true, err case 7: // value.check_tx if wire != proto.WireBytes { @@ -1173,8 +1184,8 @@ func _Response_OneofSizer(msg proto.Message) (n int) { n += proto.SizeVarint(5<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s - case *Response_AppendTx: - s := proto.Size(x.AppendTx) + case *Response_DeliverTx: + s := proto.Size(x.DeliverTx) n += proto.SizeVarint(6<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s @@ -1256,7 +1267,10 @@ func (*ResponseFlush) ProtoMessage() {} func (*ResponseFlush) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} } type ResponseInfo struct { - Info string `protobuf:"bytes,1,opt,name=info" json:"info,omitempty"` + Data string `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"` + Version string `protobuf:"bytes,2,opt,name=version" json:"version,omitempty"` + LastBlockHeight uint64 `protobuf:"varint,3,opt,name=last_block_height,json=lastBlockHeight" json:"last_block_height,omitempty"` + LastBlockAppHash []byte `protobuf:"bytes,4,opt,name=last_block_app_hash,json=lastBlockAppHash,proto3" json:"last_block_app_hash,omitempty"` } func (m *ResponseInfo) Reset() { *m = ResponseInfo{} } @@ -1264,13 +1278,34 @@ func (m *ResponseInfo) String() string { return proto.CompactTextStri func (*ResponseInfo) ProtoMessage() {} func (*ResponseInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} } -func (m *ResponseInfo) GetInfo() string { +func (m *ResponseInfo) GetData() string { if m != nil { - return m.Info + return m.Data } return "" } +func (m *ResponseInfo) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +func (m *ResponseInfo) GetLastBlockHeight() uint64 { + if m != nil { + return m.LastBlockHeight + } + return 0 +} + +func (m *ResponseInfo) GetLastBlockAppHash() []byte { + if m != nil { + return m.LastBlockAppHash + } + return nil +} + type ResponseSetOption struct { Log string `protobuf:"bytes,1,opt,name=log" json:"log,omitempty"` } @@ -1287,32 +1322,32 @@ func (m *ResponseSetOption) GetLog() string { return "" } -type ResponseAppendTx struct { +type ResponseDeliverTx struct { Code CodeType `protobuf:"varint,1,opt,name=code,enum=types.CodeType" json:"code,omitempty"` Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` Log string `protobuf:"bytes,3,opt,name=log" json:"log,omitempty"` } -func (m *ResponseAppendTx) Reset() { *m = ResponseAppendTx{} } -func (m *ResponseAppendTx) String() string { return proto.CompactTextString(m) } -func (*ResponseAppendTx) ProtoMessage() {} -func (*ResponseAppendTx) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18} } +func (m *ResponseDeliverTx) Reset() { *m = ResponseDeliverTx{} } +func (m *ResponseDeliverTx) String() string { return proto.CompactTextString(m) } +func (*ResponseDeliverTx) ProtoMessage() {} +func (*ResponseDeliverTx) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18} } -func (m *ResponseAppendTx) GetCode() CodeType { +func (m *ResponseDeliverTx) GetCode() CodeType { if m != nil { return m.Code } return CodeType_OK } -func (m *ResponseAppendTx) GetData() []byte { +func (m *ResponseDeliverTx) GetData() []byte { if m != nil { return m.Data } return nil } -func (m *ResponseAppendTx) GetLog() string { +func (m *ResponseDeliverTx) GetLog() string { if m != nil { return m.Log } @@ -1447,6 +1482,134 @@ func (m *ResponseEndBlock) GetDiffs() []*Validator { return nil } +type Header struct { + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId" json:"chain_id,omitempty"` + Height uint64 `protobuf:"varint,2,opt,name=height" json:"height,omitempty"` + Time uint64 `protobuf:"varint,3,opt,name=time" json:"time,omitempty"` + NumTxs uint64 `protobuf:"varint,4,opt,name=num_txs,json=numTxs" json:"num_txs,omitempty"` + LastBlockId *BlockID `protobuf:"bytes,5,opt,name=last_block_id,json=lastBlockId" json:"last_block_id,omitempty"` + LastCommitHash []byte `protobuf:"bytes,6,opt,name=last_commit_hash,json=lastCommitHash,proto3" json:"last_commit_hash,omitempty"` + DataHash []byte `protobuf:"bytes,7,opt,name=data_hash,json=dataHash,proto3" json:"data_hash,omitempty"` + ValidatorsHash []byte `protobuf:"bytes,8,opt,name=validators_hash,json=validatorsHash,proto3" json:"validators_hash,omitempty"` + AppHash []byte `protobuf:"bytes,9,opt,name=app_hash,json=appHash,proto3" json:"app_hash,omitempty"` +} + +func (m *Header) Reset() { *m = Header{} } +func (m *Header) String() string { return proto.CompactTextString(m) } +func (*Header) ProtoMessage() {} +func (*Header) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{25} } + +func (m *Header) GetChainId() string { + if m != nil { + return m.ChainId + } + return "" +} + +func (m *Header) GetHeight() uint64 { + if m != nil { + return m.Height + } + return 0 +} + +func (m *Header) GetTime() uint64 { + if m != nil { + return m.Time + } + return 0 +} + +func (m *Header) GetNumTxs() uint64 { + if m != nil { + return m.NumTxs + } + return 0 +} + +func (m *Header) GetLastBlockId() *BlockID { + if m != nil { + return m.LastBlockId + } + return nil +} + +func (m *Header) GetLastCommitHash() []byte { + if m != nil { + return m.LastCommitHash + } + return nil +} + +func (m *Header) GetDataHash() []byte { + if m != nil { + return m.DataHash + } + return nil +} + +func (m *Header) GetValidatorsHash() []byte { + if m != nil { + return m.ValidatorsHash + } + return nil +} + +func (m *Header) GetAppHash() []byte { + if m != nil { + return m.AppHash + } + return nil +} + +type BlockID struct { + Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + Parts *PartSetHeader `protobuf:"bytes,2,opt,name=parts" json:"parts,omitempty"` +} + +func (m *BlockID) Reset() { *m = BlockID{} } +func (m *BlockID) String() string { return proto.CompactTextString(m) } +func (*BlockID) ProtoMessage() {} +func (*BlockID) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{26} } + +func (m *BlockID) GetHash() []byte { + if m != nil { + return m.Hash + } + return nil +} + +func (m *BlockID) GetParts() *PartSetHeader { + if m != nil { + return m.Parts + } + return nil +} + +type PartSetHeader struct { + Total uint64 `protobuf:"varint,1,opt,name=total" json:"total,omitempty"` + Hash []byte `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"` +} + +func (m *PartSetHeader) Reset() { *m = PartSetHeader{} } +func (m *PartSetHeader) String() string { return proto.CompactTextString(m) } +func (*PartSetHeader) ProtoMessage() {} +func (*PartSetHeader) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{27} } + +func (m *PartSetHeader) GetTotal() uint64 { + if m != nil { + return m.Total + } + return 0 +} + +func (m *PartSetHeader) GetHash() []byte { + if m != nil { + return m.Hash + } + return nil +} + type Validator struct { PubKey []byte `protobuf:"bytes,1,opt,name=pubKey,proto3" json:"pubKey,omitempty"` Power uint64 `protobuf:"varint,2,opt,name=power" json:"power,omitempty"` @@ -1455,7 +1618,7 @@ type Validator struct { func (m *Validator) Reset() { *m = Validator{} } func (m *Validator) String() string { return proto.CompactTextString(m) } func (*Validator) ProtoMessage() {} -func (*Validator) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{25} } +func (*Validator) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{28} } func (m *Validator) GetPubKey() []byte { if m != nil { @@ -1477,7 +1640,7 @@ func init() { proto.RegisterType((*RequestFlush)(nil), "types.RequestFlush") proto.RegisterType((*RequestInfo)(nil), "types.RequestInfo") proto.RegisterType((*RequestSetOption)(nil), "types.RequestSetOption") - proto.RegisterType((*RequestAppendTx)(nil), "types.RequestAppendTx") + proto.RegisterType((*RequestDeliverTx)(nil), "types.RequestDeliverTx") proto.RegisterType((*RequestCheckTx)(nil), "types.RequestCheckTx") proto.RegisterType((*RequestQuery)(nil), "types.RequestQuery") proto.RegisterType((*RequestCommit)(nil), "types.RequestCommit") @@ -1490,13 +1653,16 @@ func init() { proto.RegisterType((*ResponseFlush)(nil), "types.ResponseFlush") proto.RegisterType((*ResponseInfo)(nil), "types.ResponseInfo") proto.RegisterType((*ResponseSetOption)(nil), "types.ResponseSetOption") - proto.RegisterType((*ResponseAppendTx)(nil), "types.ResponseAppendTx") + proto.RegisterType((*ResponseDeliverTx)(nil), "types.ResponseDeliverTx") proto.RegisterType((*ResponseCheckTx)(nil), "types.ResponseCheckTx") proto.RegisterType((*ResponseQuery)(nil), "types.ResponseQuery") proto.RegisterType((*ResponseCommit)(nil), "types.ResponseCommit") proto.RegisterType((*ResponseInitChain)(nil), "types.ResponseInitChain") proto.RegisterType((*ResponseBeginBlock)(nil), "types.ResponseBeginBlock") proto.RegisterType((*ResponseEndBlock)(nil), "types.ResponseEndBlock") + proto.RegisterType((*Header)(nil), "types.Header") + proto.RegisterType((*BlockID)(nil), "types.BlockID") + proto.RegisterType((*PartSetHeader)(nil), "types.PartSetHeader") proto.RegisterType((*Validator)(nil), "types.Validator") proto.RegisterEnum("types.MessageType", MessageType_name, MessageType_value) proto.RegisterEnum("types.CodeType", CodeType_name, CodeType_value) @@ -1510,14 +1676,14 @@ var _ grpc.ClientConn // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion4 -// Client API for TMSPApplication service +// Client API for ABCIApplication service -type TMSPApplicationClient interface { +type ABCIApplicationClient interface { Echo(ctx context.Context, in *RequestEcho, opts ...grpc.CallOption) (*ResponseEcho, error) Flush(ctx context.Context, in *RequestFlush, opts ...grpc.CallOption) (*ResponseFlush, error) Info(ctx context.Context, in *RequestInfo, opts ...grpc.CallOption) (*ResponseInfo, error) SetOption(ctx context.Context, in *RequestSetOption, opts ...grpc.CallOption) (*ResponseSetOption, error) - AppendTx(ctx context.Context, in *RequestAppendTx, opts ...grpc.CallOption) (*ResponseAppendTx, error) + DeliverTx(ctx context.Context, in *RequestDeliverTx, opts ...grpc.CallOption) (*ResponseDeliverTx, error) CheckTx(ctx context.Context, in *RequestCheckTx, opts ...grpc.CallOption) (*ResponseCheckTx, error) Query(ctx context.Context, in *RequestQuery, opts ...grpc.CallOption) (*ResponseQuery, error) Commit(ctx context.Context, in *RequestCommit, opts ...grpc.CallOption) (*ResponseCommit, error) @@ -1530,13 +1696,13 @@ type tMSPApplicationClient struct { cc *grpc.ClientConn } -func NewTMSPApplicationClient(cc *grpc.ClientConn) TMSPApplicationClient { +func NewABCIApplicationClient(cc *grpc.ClientConn) ABCIApplicationClient { return &tMSPApplicationClient{cc} } func (c *tMSPApplicationClient) Echo(ctx context.Context, in *RequestEcho, opts ...grpc.CallOption) (*ResponseEcho, error) { out := new(ResponseEcho) - err := grpc.Invoke(ctx, "/types.TMSPApplication/Echo", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/types.ABCIApplication/Echo", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -1545,7 +1711,7 @@ func (c *tMSPApplicationClient) Echo(ctx context.Context, in *RequestEcho, opts func (c *tMSPApplicationClient) Flush(ctx context.Context, in *RequestFlush, opts ...grpc.CallOption) (*ResponseFlush, error) { out := new(ResponseFlush) - err := grpc.Invoke(ctx, "/types.TMSPApplication/Flush", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/types.ABCIApplication/Flush", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -1554,7 +1720,7 @@ func (c *tMSPApplicationClient) Flush(ctx context.Context, in *RequestFlush, opt func (c *tMSPApplicationClient) Info(ctx context.Context, in *RequestInfo, opts ...grpc.CallOption) (*ResponseInfo, error) { out := new(ResponseInfo) - err := grpc.Invoke(ctx, "/types.TMSPApplication/Info", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/types.ABCIApplication/Info", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -1563,16 +1729,16 @@ func (c *tMSPApplicationClient) Info(ctx context.Context, in *RequestInfo, opts func (c *tMSPApplicationClient) SetOption(ctx context.Context, in *RequestSetOption, opts ...grpc.CallOption) (*ResponseSetOption, error) { out := new(ResponseSetOption) - err := grpc.Invoke(ctx, "/types.TMSPApplication/SetOption", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/types.ABCIApplication/SetOption", in, out, c.cc, opts...) if err != nil { return nil, err } return out, nil } -func (c *tMSPApplicationClient) AppendTx(ctx context.Context, in *RequestAppendTx, opts ...grpc.CallOption) (*ResponseAppendTx, error) { - out := new(ResponseAppendTx) - err := grpc.Invoke(ctx, "/types.TMSPApplication/AppendTx", in, out, c.cc, opts...) +func (c *tMSPApplicationClient) DeliverTx(ctx context.Context, in *RequestDeliverTx, opts ...grpc.CallOption) (*ResponseDeliverTx, error) { + out := new(ResponseDeliverTx) + err := grpc.Invoke(ctx, "/types.ABCIApplication/DeliverTx", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -1581,7 +1747,7 @@ func (c *tMSPApplicationClient) AppendTx(ctx context.Context, in *RequestAppendT func (c *tMSPApplicationClient) CheckTx(ctx context.Context, in *RequestCheckTx, opts ...grpc.CallOption) (*ResponseCheckTx, error) { out := new(ResponseCheckTx) - err := grpc.Invoke(ctx, "/types.TMSPApplication/CheckTx", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/types.ABCIApplication/CheckTx", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -1590,7 +1756,7 @@ func (c *tMSPApplicationClient) CheckTx(ctx context.Context, in *RequestCheckTx, func (c *tMSPApplicationClient) Query(ctx context.Context, in *RequestQuery, opts ...grpc.CallOption) (*ResponseQuery, error) { out := new(ResponseQuery) - err := grpc.Invoke(ctx, "/types.TMSPApplication/Query", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/types.ABCIApplication/Query", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -1599,7 +1765,7 @@ func (c *tMSPApplicationClient) Query(ctx context.Context, in *RequestQuery, opt func (c *tMSPApplicationClient) Commit(ctx context.Context, in *RequestCommit, opts ...grpc.CallOption) (*ResponseCommit, error) { out := new(ResponseCommit) - err := grpc.Invoke(ctx, "/types.TMSPApplication/Commit", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/types.ABCIApplication/Commit", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -1608,7 +1774,7 @@ func (c *tMSPApplicationClient) Commit(ctx context.Context, in *RequestCommit, o func (c *tMSPApplicationClient) InitChain(ctx context.Context, in *RequestInitChain, opts ...grpc.CallOption) (*ResponseInitChain, error) { out := new(ResponseInitChain) - err := grpc.Invoke(ctx, "/types.TMSPApplication/InitChain", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/types.ABCIApplication/InitChain", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -1617,7 +1783,7 @@ func (c *tMSPApplicationClient) InitChain(ctx context.Context, in *RequestInitCh func (c *tMSPApplicationClient) BeginBlock(ctx context.Context, in *RequestBeginBlock, opts ...grpc.CallOption) (*ResponseBeginBlock, error) { out := new(ResponseBeginBlock) - err := grpc.Invoke(ctx, "/types.TMSPApplication/BeginBlock", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/types.ABCIApplication/BeginBlock", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -1626,21 +1792,21 @@ func (c *tMSPApplicationClient) BeginBlock(ctx context.Context, in *RequestBegin func (c *tMSPApplicationClient) EndBlock(ctx context.Context, in *RequestEndBlock, opts ...grpc.CallOption) (*ResponseEndBlock, error) { out := new(ResponseEndBlock) - err := grpc.Invoke(ctx, "/types.TMSPApplication/EndBlock", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/types.ABCIApplication/EndBlock", in, out, c.cc, opts...) if err != nil { return nil, err } return out, nil } -// Server API for TMSPApplication service +// Server API for ABCIApplication service -type TMSPApplicationServer interface { +type ABCIApplicationServer interface { Echo(context.Context, *RequestEcho) (*ResponseEcho, error) Flush(context.Context, *RequestFlush) (*ResponseFlush, error) Info(context.Context, *RequestInfo) (*ResponseInfo, error) SetOption(context.Context, *RequestSetOption) (*ResponseSetOption, error) - AppendTx(context.Context, *RequestAppendTx) (*ResponseAppendTx, error) + DeliverTx(context.Context, *RequestDeliverTx) (*ResponseDeliverTx, error) CheckTx(context.Context, *RequestCheckTx) (*ResponseCheckTx, error) Query(context.Context, *RequestQuery) (*ResponseQuery, error) Commit(context.Context, *RequestCommit) (*ResponseCommit, error) @@ -1649,255 +1815,255 @@ type TMSPApplicationServer interface { EndBlock(context.Context, *RequestEndBlock) (*ResponseEndBlock, error) } -func RegisterTMSPApplicationServer(s *grpc.Server, srv TMSPApplicationServer) { - s.RegisterService(&_TMSPApplication_serviceDesc, srv) +func RegisterABCIApplicationServer(s *grpc.Server, srv ABCIApplicationServer) { + s.RegisterService(&_ABCIApplication_serviceDesc, srv) } -func _TMSPApplication_Echo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _ABCIApplication_Echo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(RequestEcho) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(TMSPApplicationServer).Echo(ctx, in) + return srv.(ABCIApplicationServer).Echo(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/types.TMSPApplication/Echo", + FullMethod: "/types.ABCIApplication/Echo", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TMSPApplicationServer).Echo(ctx, req.(*RequestEcho)) + return srv.(ABCIApplicationServer).Echo(ctx, req.(*RequestEcho)) } return interceptor(ctx, in, info, handler) } -func _TMSPApplication_Flush_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _ABCIApplication_Flush_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(RequestFlush) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(TMSPApplicationServer).Flush(ctx, in) + return srv.(ABCIApplicationServer).Flush(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/types.TMSPApplication/Flush", + FullMethod: "/types.ABCIApplication/Flush", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TMSPApplicationServer).Flush(ctx, req.(*RequestFlush)) + return srv.(ABCIApplicationServer).Flush(ctx, req.(*RequestFlush)) } return interceptor(ctx, in, info, handler) } -func _TMSPApplication_Info_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _ABCIApplication_Info_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(RequestInfo) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(TMSPApplicationServer).Info(ctx, in) + return srv.(ABCIApplicationServer).Info(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/types.TMSPApplication/Info", + FullMethod: "/types.ABCIApplication/Info", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TMSPApplicationServer).Info(ctx, req.(*RequestInfo)) + return srv.(ABCIApplicationServer).Info(ctx, req.(*RequestInfo)) } return interceptor(ctx, in, info, handler) } -func _TMSPApplication_SetOption_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _ABCIApplication_SetOption_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(RequestSetOption) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(TMSPApplicationServer).SetOption(ctx, in) + return srv.(ABCIApplicationServer).SetOption(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/types.TMSPApplication/SetOption", + FullMethod: "/types.ABCIApplication/SetOption", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TMSPApplicationServer).SetOption(ctx, req.(*RequestSetOption)) + return srv.(ABCIApplicationServer).SetOption(ctx, req.(*RequestSetOption)) } return interceptor(ctx, in, info, handler) } -func _TMSPApplication_AppendTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RequestAppendTx) +func _ABCIApplication_DeliverTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RequestDeliverTx) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(TMSPApplicationServer).AppendTx(ctx, in) + return srv.(ABCIApplicationServer).DeliverTx(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/types.TMSPApplication/AppendTx", + FullMethod: "/types.ABCIApplication/DeliverTx", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TMSPApplicationServer).AppendTx(ctx, req.(*RequestAppendTx)) + return srv.(ABCIApplicationServer).DeliverTx(ctx, req.(*RequestDeliverTx)) } return interceptor(ctx, in, info, handler) } -func _TMSPApplication_CheckTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _ABCIApplication_CheckTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(RequestCheckTx) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(TMSPApplicationServer).CheckTx(ctx, in) + return srv.(ABCIApplicationServer).CheckTx(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/types.TMSPApplication/CheckTx", + FullMethod: "/types.ABCIApplication/CheckTx", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TMSPApplicationServer).CheckTx(ctx, req.(*RequestCheckTx)) + return srv.(ABCIApplicationServer).CheckTx(ctx, req.(*RequestCheckTx)) } return interceptor(ctx, in, info, handler) } -func _TMSPApplication_Query_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _ABCIApplication_Query_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(RequestQuery) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(TMSPApplicationServer).Query(ctx, in) + return srv.(ABCIApplicationServer).Query(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/types.TMSPApplication/Query", + FullMethod: "/types.ABCIApplication/Query", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TMSPApplicationServer).Query(ctx, req.(*RequestQuery)) + return srv.(ABCIApplicationServer).Query(ctx, req.(*RequestQuery)) } return interceptor(ctx, in, info, handler) } -func _TMSPApplication_Commit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _ABCIApplication_Commit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(RequestCommit) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(TMSPApplicationServer).Commit(ctx, in) + return srv.(ABCIApplicationServer).Commit(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/types.TMSPApplication/Commit", + FullMethod: "/types.ABCIApplication/Commit", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TMSPApplicationServer).Commit(ctx, req.(*RequestCommit)) + return srv.(ABCIApplicationServer).Commit(ctx, req.(*RequestCommit)) } return interceptor(ctx, in, info, handler) } -func _TMSPApplication_InitChain_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _ABCIApplication_InitChain_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(RequestInitChain) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(TMSPApplicationServer).InitChain(ctx, in) + return srv.(ABCIApplicationServer).InitChain(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/types.TMSPApplication/InitChain", + FullMethod: "/types.ABCIApplication/InitChain", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TMSPApplicationServer).InitChain(ctx, req.(*RequestInitChain)) + return srv.(ABCIApplicationServer).InitChain(ctx, req.(*RequestInitChain)) } return interceptor(ctx, in, info, handler) } -func _TMSPApplication_BeginBlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _ABCIApplication_BeginBlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(RequestBeginBlock) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(TMSPApplicationServer).BeginBlock(ctx, in) + return srv.(ABCIApplicationServer).BeginBlock(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/types.TMSPApplication/BeginBlock", + FullMethod: "/types.ABCIApplication/BeginBlock", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TMSPApplicationServer).BeginBlock(ctx, req.(*RequestBeginBlock)) + return srv.(ABCIApplicationServer).BeginBlock(ctx, req.(*RequestBeginBlock)) } return interceptor(ctx, in, info, handler) } -func _TMSPApplication_EndBlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _ABCIApplication_EndBlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(RequestEndBlock) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(TMSPApplicationServer).EndBlock(ctx, in) + return srv.(ABCIApplicationServer).EndBlock(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/types.TMSPApplication/EndBlock", + FullMethod: "/types.ABCIApplication/EndBlock", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TMSPApplicationServer).EndBlock(ctx, req.(*RequestEndBlock)) + return srv.(ABCIApplicationServer).EndBlock(ctx, req.(*RequestEndBlock)) } return interceptor(ctx, in, info, handler) } -var _TMSPApplication_serviceDesc = grpc.ServiceDesc{ - ServiceName: "types.TMSPApplication", - HandlerType: (*TMSPApplicationServer)(nil), +var _ABCIApplication_serviceDesc = grpc.ServiceDesc{ + ServiceName: "types.ABCIApplication", + HandlerType: (*ABCIApplicationServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Echo", - Handler: _TMSPApplication_Echo_Handler, + Handler: _ABCIApplication_Echo_Handler, }, { MethodName: "Flush", - Handler: _TMSPApplication_Flush_Handler, + Handler: _ABCIApplication_Flush_Handler, }, { MethodName: "Info", - Handler: _TMSPApplication_Info_Handler, + Handler: _ABCIApplication_Info_Handler, }, { MethodName: "SetOption", - Handler: _TMSPApplication_SetOption_Handler, + Handler: _ABCIApplication_SetOption_Handler, }, { - MethodName: "AppendTx", - Handler: _TMSPApplication_AppendTx_Handler, + MethodName: "DeliverTx", + Handler: _ABCIApplication_DeliverTx_Handler, }, { MethodName: "CheckTx", - Handler: _TMSPApplication_CheckTx_Handler, + Handler: _ABCIApplication_CheckTx_Handler, }, { MethodName: "Query", - Handler: _TMSPApplication_Query_Handler, + Handler: _ABCIApplication_Query_Handler, }, { MethodName: "Commit", - Handler: _TMSPApplication_Commit_Handler, + Handler: _ABCIApplication_Commit_Handler, }, { MethodName: "InitChain", - Handler: _TMSPApplication_InitChain_Handler, + Handler: _ABCIApplication_InitChain_Handler, }, { MethodName: "BeginBlock", - Handler: _TMSPApplication_BeginBlock_Handler, + Handler: _ABCIApplication_BeginBlock_Handler, }, { MethodName: "EndBlock", - Handler: _TMSPApplication_EndBlock_Handler, + Handler: _ABCIApplication_EndBlock_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -1907,93 +2073,109 @@ var _TMSPApplication_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("types/types.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 1393 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xac, 0x57, 0x59, 0x53, 0xdc, 0xc6, - 0x16, 0x1e, 0xc1, 0xac, 0x67, 0x60, 0x68, 0x0e, 0x03, 0xc8, 0x53, 0xf7, 0xc1, 0x57, 0xf7, 0x26, - 0x01, 0xdb, 0x65, 0xa7, 0x70, 0xd9, 0x65, 0xc7, 0xa9, 0x54, 0x81, 0x8d, 0x81, 0x72, 0xd9, 0x26, - 0xf2, 0xf2, 0x90, 0xa5, 0x28, 0xa1, 0xe9, 0x99, 0x51, 0x18, 0xba, 0x65, 0x2d, 0x18, 0xf2, 0x0f, - 0xfc, 0x83, 0xf2, 0x92, 0xd7, 0x3c, 0x65, 0x5f, 0x7e, 0x51, 0xaa, 0x17, 0x49, 0x23, 0x21, 0xf9, - 0xc9, 0x2f, 0x53, 0xdd, 0x67, 0xeb, 0x9e, 0x73, 0xbe, 0xf3, 0xe9, 0x34, 0x2c, 0x47, 0x17, 0x3e, - 0x0d, 0x6f, 0xc9, 0xdf, 0x9b, 0x7e, 0xc0, 0x23, 0x8e, 0x0d, 0xb9, 0xb1, 0x7e, 0xaa, 0x43, 0xcb, - 0xa6, 0x6f, 0x62, 0x1a, 0x46, 0xb8, 0x01, 0x75, 0xea, 0x4e, 0xb8, 0x69, 0x5c, 0x35, 0x36, 0xba, - 0x5b, 0x78, 0x53, 0x99, 0x6b, 0xed, 0xae, 0x3b, 0xe1, 0xfb, 0x35, 0x5b, 0x5a, 0xe0, 0x75, 0x68, - 0x8c, 0xa6, 0x71, 0x38, 0x31, 0xe7, 0xa4, 0xe9, 0x4a, 0xde, 0xf4, 0xb1, 0x50, 0xed, 0xd7, 0x6c, - 0x65, 0x23, 0xc2, 0x7a, 0x6c, 0xc4, 0xcd, 0xf9, 0xb2, 0xb0, 0x07, 0x6c,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x6e, 0xe9, 0x76, 0xc4, 0xb2, 0x67, 0xcb, 0xa0, 0x74, 0x56, 0x11, 0x87, 0xa8, 0x0f, 0xc9, 0xe5, - 0xd7, 0xcb, 0xa0, 0x6c, 0x60, 0xc1, 0x2f, 0x66, 0xda, 0x1b, 0xab, 0xde, 0x30, 0x83, 0xca, 0xd1, - 0x05, 0x1f, 0x64, 0x04, 0x80, 0x15, 0x2f, 0x99, 0x41, 0xd5, 0xf8, 0x82, 0xf7, 0x52, 0xbe, 0xc0, - 0xf2, 0xf7, 0xcc, 0xa0, 0x62, 0x84, 0x11, 0xb9, 0x51, 0x1f, 0x8a, 0xb2, 0x67, 0xca, 0xa0, 0x74, - 0x2a, 0xc1, 0x3b, 0x09, 0x21, 0x61, 0xe9, 0x53, 0x68, 0x50, 0x3e, 0xfb, 0x88, 0x0c, 0x65, 0xc3, - 0x72, 0xd5, 0x1b, 0x67, 0x50, 0x39, 0xd5, 0xe0, 0xf6, 0x2c, 0xc3, 0x61, 0xe5, 0x4b, 0x67, 0x50, - 0x3d, 0xdb, 0x88, 0x24, 0x67, 0xc3, 0x73, 0xf9, 0x7b, 0x67, 0x50, 0x35, 0xde, 0x1c, 0x37, 0xe5, - 0x3b, 0xfa, 0xf6, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x9c, 0xac, 0x2d, 0x4b, 0x5c, 0x0f, 0x00, - 0x00, + // 1654 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xac, 0x58, 0x49, 0x73, 0x1b, 0xc7, + 0x15, 0xc6, 0x60, 0xc7, 0x03, 0x09, 0x34, 0x1f, 0x41, 0x12, 0x44, 0x72, 0x50, 0x26, 0x71, 0x4c, + 0x29, 0x8e, 0x94, 0xa2, 0xcb, 0x2e, 0x31, 0x4e, 0xa5, 0x8a, 0x94, 0x68, 0x02, 0xe5, 0x92, 0xc4, + 0x8c, 0x68, 0x1f, 0x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xbd, 0x34, 0x70, 0x8e, 0x44, 0x4e, 0x72, 0x24, 0xd2, 0x28, + 0x5d, 0xfe, 0x06, 0x16, 0xf9, 0x34, 0xcb, 0x22, 0xcd, 0x42, 0xf1, 0x49, 0xcf, 0x52, 0x1a, 0xf9, + 0x38, 0x43, 0x23, 0xad, 0x42, 0xf5, 0x48, 0xb7, 0x12, 0x1e, 0x79, 0x96, 0xf0, 0x48, 0xbb, 0xc0, + 0x3c, 0xca, 0xa5, 0x48, 0x24, 0x1f, 0xc5, 0x58, 0xec, 0x94, 0x66, 0xac, 0xc0, 0x24, 0x27, 0x39, + 0x26, 0x81, 0xd2, 0x34, 0x6c, 0xa0, 0x92, 0x5f, 0xe4, 0xa9, 0x44, 0xf2, 0xc1, 0x61, 0xc1, 0x77, + 0x23, 0x97, 0x7c, 0x9a, 0xe5, 0x92, 0xad, 0xd2, 0x24, 0x7e, 0x37, 0x99, 0x3c, 0xa6, 0x32, 0x28, + 0xc0, 0x8c, 0x0a, 0x91, 0xfb, 0xbe, 0xeb, 0x2b, 0x1e, 0x90, 0x03, 0xfd, 0x88, 0xca, 0x35, 0x05, + 0xd7, 0x77, 0x10, 0x8f, 0x28, 0xd9, 0x0c, 0xb4, 0xf4, 0x3f, 0x6a, 0xa9, 0x2f, 0xe1, 0x87, 0x0a, + 0xcd, 0x32, 0x43, 0x53, 0x39, 0x8a, 0x6f, 0x8a, 0x77, 0xcb, 0xfd, 0x80, 0x80, 0x24, 0xb9, 0x26, + 0x1e, 0xe2, 0x13, 0xd8, 0x59, 0x99, 0x41, 0x28, 0xb7, 0x39, 0x55, 0x35, 0x55, 0x13, 0x35, 0xd5, + 0x27, 0x85, 0xdc, 0x9f, 0x10, 0xe3, 0x4f, 0x61, 0x37, 0x63, 0x6b, 0x7a, 0xde, 0x54, 0x54, 0x74, + 0x5d, 0x54, 0x34, 0x4b, 0xac, 0x4f, 0x3d, 0x6f, 0x6c, 0x06, 0x4b, 0xfd, 0x83, 0x74, 0xff, 0x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02, 0x34, 0xe5, 0x41, 0xb1, + 0x5d, 0x8a, 0x2c, 0xea, 0x90, 0x0d, 0x28, 0x40, 0x82, 0x6c, 0xb6, 0x87, 0x3d, 0x80, 0x14, 0xd3, + 0x6c, 0x9f, 0x02, 0xc6, 0x68, 0x66, 0x07, 0x4f, 0xfe, 0xdc, 0x80, 0x76, 0x5c, 0x47, 0xd8, 0x84, + 0xea, 0x9b, 0x2f, 0x58, 0x05, 0x77, 0x60, 0x7b, 0xe2, 0x84, 0xdc, 0x77, 0xcc, 0xd5, 0x39, 0xd1, + 0x34, 0xd3, 0x48, 0x74, 0xee, 0xcc, 0x5c, 0xcb, 0x76, 0x16, 0x52, 0x54, 0xa5, 0x40, 0x67, 0xa6, + 0xf5, 0xda, 0x75, 0x66, 0x9c, 0xd5, 0x90, 0xc1, 0xd6, 0x97, 0x8e, 0x19, 0x85, 0x4b, 0xd7, 0xb7, + 0xff, 0xc0, 0x2d, 0x56, 0xc7, 0x3d, 0xd8, 0x99, 0x38, 0x41, 0x34, 0x9f, 0xdb, 0x33, 0x9b, 0x3b, + 0xe1, 0xe7, 0x91, 0x63, 0x05, 0xac, 0x81, 0x08, 0xbd, 0x2f, 0x9d, 0x1b, 0xc7, 0xfd, 0xda, 0x51, + 0xbd, 0x0d, 0x6b, 0xe2, 0x10, 0x06, 0x67, 0x66, 0xc0, 0x5f, 0x46, 0xde, 0xca, 0x9e, 0x99, 0x21, + 0x3f, 0xb5, 0x2c, 0x9f, 0x07, 0x01, 0xe3, 0x14, 0x84, 0x34, 0xf9, 0xb9, 0xe7, 0xb1, 0x43, 0x2e, + 0x3e, 0xe7, 0x01, 0x5b, 0xe0, 0x21, 0xec, 0x3d, 0xd0, 0x88, 0x99, 0x97, 0xf8, 0x7d, 0x18, 0x16, + 0x55, 0x17, 0x66, 0x70, 0xe9, 0xdb, 0x33, 0xce, 0x6c, 0x1c, 0x00, 0x93, 0x5a, 0x01, 0xdd, 0x89, + 0xe3, 0x45, 0x21, 0xfb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, 0x3e, 0x93, 0x75, 0x86, 0x25, 0x0f, 0xdf, + 0x51, 0x59, 0x2b, 0x8b, 0xc7, 0xaa, 0x1c, 0xb1, 0xec, 0xfd, 0x3b, 0x2a, 0xed, 0x68, 0x69, 0x12, + 0xd9, 0x6d, 0x3c, 0x7c, 0x06, 0x8f, 0xca, 0xda, 0x5a, 0xfc, 0x65, 0xa6, 0xbc, 0x71, 0xd3, 0x63, + 0x78, 0xb4, 0xb1, 0xc1, 0xc5, 0xcf, 0x52, 0x02, 0xc0, 0x0d, 0x4f, 0xe2, 0xd1, 0xa6, 0x26, 0x17, + 0x9f, 0x27, 0x7c, 0x81, 0xe5, 0x0f, 0xe3, 0xd1, 0x86, 0x46, 0x97, 0x72, 0x23, 0x2f, 0xf6, 0xb2, + 0xf7, 0xee, 0xa8, 0xb4, 0x77, 0xc5, 0x4f, 0x62, 0x42, 0xc2, 0xd2, 0x37, 0xf5, 0xa8, 0xbc, 0x43, + 0xa6, 0x0c, 0xa5, 0xaf, 0xae, 0x4d, 0x8f, 0xe5, 0xd1, 0xc6, 0xde, 0x17, 0x4f, 0xb3, 0x0c, 0x87, + 0x1b, 0x9f, 0xcc, 0xa3, 0xcd, 0x1d, 0x30, 0x25, 0x39, 0x7d, 0x62, 0x95, 0x3f, 0x9c, 0x47, 0x9b, + 0x9a, 0xe0, 0xeb, 0xa6, 0xf8, 0x43, 0xe6, 0xe3, 0x6f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xf8, 0xa7, + 0x82, 0x8b, 0xa5, 0x11, 0x00, 0x00, } diff --git a/types/types.proto b/types/types.proto index cb3d82c1a..b3ff1655e 100644 --- a/types/types.proto +++ b/types/types.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package types; -// This file is copied from http://github.com/tendermint/tmsp +// This file is copied from http://github.com/tendermint/abci //---------------------------------------- // Message types @@ -18,7 +18,7 @@ enum MessageType { Info = 0x03; SetOption = 0x04; Exception = 0x05; - AppendTx = 0x11; + DeliverTx = 0x11; CheckTx = 0x12; Commit = 0x13; Query = 0x14; @@ -79,7 +79,7 @@ message Request { RequestFlush flush = 2; RequestInfo info = 3; RequestSetOption set_option = 4; - RequestAppendTx append_tx = 5; + RequestDeliverTx deliver_tx = 5; RequestCheckTx check_tx = 6; RequestCommit commit = 7; RequestQuery query = 8; @@ -104,7 +104,7 @@ message RequestSetOption{ string value = 2; } -message RequestAppendTx{ +message RequestDeliverTx{ bytes tx = 1; } @@ -124,7 +124,8 @@ message RequestInitChain{ } message RequestBeginBlock{ - uint64 height = 1; + bytes hash = 1; + Header header = 2; } message RequestEndBlock{ @@ -142,7 +143,7 @@ message Response { ResponseFlush flush = 3; ResponseInfo info = 4; ResponseSetOption set_option = 5; - ResponseAppendTx append_tx = 6; + ResponseDeliverTx deliver_tx = 6; ResponseCheckTx check_tx = 7; ResponseCommit commit = 8; ResponseQuery query = 9; @@ -164,14 +165,17 @@ message ResponseFlush{ } message ResponseInfo { - string info = 1; + string data = 1; + string version = 2; + uint64 last_block_height = 3; + bytes last_block_app_hash = 4; } message ResponseSetOption{ string log = 1; } -message ResponseAppendTx{ +message ResponseDeliverTx{ CodeType code = 1; bytes data = 2; string log = 3; @@ -207,7 +211,29 @@ message ResponseEndBlock{ } //---------------------------------------- -// Misc types +// Blockchain Types + +message Header { + string chain_id = 1; + uint64 height = 2; + uint64 time = 3; + uint64 num_txs = 4; + BlockID last_block_id = 5; + bytes last_commit_hash = 6; + bytes data_hash = 7; + bytes validators_hash = 8; + bytes app_hash = 9; +} + +message BlockID { + bytes hash = 1; + PartSetHeader parts = 2; +} + +message PartSetHeader { + uint64 total = 1; + bytes hash = 2; +} message Validator { bytes pubKey = 1; @@ -217,12 +243,12 @@ message Validator { //---------------------------------------- // Service Definition -service TMSPApplication { +service ABCIApplication { rpc Echo(RequestEcho) returns (ResponseEcho) ; rpc Flush(RequestFlush) returns (ResponseFlush); rpc Info(RequestInfo) returns (ResponseInfo); rpc SetOption(RequestSetOption) returns (ResponseSetOption); - rpc AppendTx(RequestAppendTx) returns (ResponseAppendTx); + rpc DeliverTx(RequestDeliverTx) returns (ResponseDeliverTx); rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx); rpc Query(RequestQuery) returns (ResponseQuery); rpc Commit(RequestCommit) returns (ResponseCommit); diff --git a/types/validators.go b/types/validators.go new file mode 100644 index 000000000..185355d15 --- /dev/null +++ b/types/validators.go @@ -0,0 +1,41 @@ +package types + +import ( + "bytes" + + "github.com/tendermint/go-wire" +) + +// validators implements sort + +type Validators []*Validator + +func (v Validators) Len() int { + return len(v) +} + +// XXX: doesn't distinguish same validator with different power +func (v Validators) Less(i, j int) bool { + return bytes.Compare(v[i].PubKey, v[j].PubKey) <= 0 +} + +func (v Validators) Swap(i, j int) { + v1 := v[i] + v[i] = v[j] + v[j] = v1 +} + +//------------------------------------- + +type validatorPretty struct { + PubKey []byte `json:"pub_key"` + Power uint64 `json:"power"` +} + +func ValidatorsString(vs Validators) string { + s := make([]validatorPretty, len(vs)) + for i, v := range vs { + s[i] = validatorPretty{v.PubKey, v.Power} + } + return string(wire.JSONBytes(s)) +} diff --git a/types/version.go b/types/version.go new file mode 100644 index 000000000..719c6c98c --- /dev/null +++ b/types/version.go @@ -0,0 +1,7 @@ +package types + +const Maj = "0" +const Min = "3" // ResponseInfo, ResponseEndBlock +const Fix = "0" // + +const Version = Maj + "." + Min + "." + Fix