Browse Source

abci: remove setOption (#5447)

Remove Response/Request SetOption from ABCI.

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
pull/5487/head
Marko 4 years ago
committed by GitHub
parent
commit
82e4693cc5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 353 additions and 1295 deletions
  1. +1
    -1
      CHANGELOG_PENDING.md
  2. +2
    -0
      UPGRADING.md
  3. +2
    -2
      abci/client/client.go
  4. +0
    -14
      abci/client/grpc_client.go
  5. +0
    -19
      abci/client/local_client.go
  6. +1
    -40
      abci/client/mocks/client.go
  7. +0
    -15
      abci/client/socket_client.go
  8. +1
    -33
      abci/cmd/abci-cli/abci-cli.go
  9. +1
    -18
      abci/example/counter/counter.go
  10. +0
    -4
      abci/example/kvstore/persistent_kvstore.go
  11. +0
    -3
      abci/server/socket_server.go
  12. +0
    -11
      abci/tests/server/client.go
  13. +0
    -25
      abci/tests/test_app/app.go
  14. +5
    -7
      abci/tests/test_app/main.go
  15. +0
    -1
      abci/tests/test_cli/ex2.abci
  16. +4
    -10
      abci/tests/test_cli/ex2.abci.out
  17. +2
    -12
      abci/types/application.go
  18. +0
    -13
      abci/types/messages.go
  19. +0
    -11
      abci/types/result.go
  20. +303
    -993
      abci/types/types.pb.go
  21. +0
    -3
      docs/app-dev/abci-cli.md
  22. +0
    -1
      docs/architecture/adr-029-check-tx-consensus.md
  23. +0
    -4
      docs/tutorials/go-built-in.md
  24. +0
    -4
      docs/tutorials/go.md
  25. +1
    -1
      evidence/mocks/block_store.go
  26. +0
    -1
      mempool/clist_mempool_test.go
  27. +1
    -1
      p2p/mocks/peer.go
  28. +22
    -39
      proto/tendermint/abci/types.proto
  29. +0
    -2
      proxy/app_conn.go
  30. +1
    -1
      proxy/mocks/app_conn_consensus.go
  31. +1
    -1
      proxy/mocks/app_conn_mempool.go
  32. +1
    -1
      proxy/mocks/app_conn_query.go
  33. +1
    -1
      proxy/mocks/app_conn_snapshot.go
  34. +1
    -1
      state/mocks/evidence_pool.go
  35. +1
    -1
      state/mocks/store.go
  36. +1
    -1
      statesync/mocks/state_provider.go

+ 1
- 1
CHANGELOG_PENDING.md View File

@ -11,6 +11,7 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
- CLI/RPC/Config - CLI/RPC/Config
- Apps - Apps
- [ABCI] \#5447 Remove `SetOption` method from `ABCI.Client` interface
- P2P Protocol - P2P Protocol
@ -30,4 +31,3 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
### BUG FIXES ### BUG FIXES
- [privval] \#5441 Fix faulty ping message encoding causing nil message errors in logs (@erikgrinaker) - [privval] \#5441 Fix faulty ping message encoding causing nil message errors in logs (@erikgrinaker)

+ 2
- 0
UPGRADING.md View File

@ -38,6 +38,8 @@ the encoding format (see "Protocol Buffers," below) and the block header (see "B
* The field `Proof`, on the ABCI type `ResponseQuery`, is now named `ProofOps`. * The field `Proof`, on the ABCI type `ResponseQuery`, is now named `ProofOps`.
For more, see "Crypto," below. For more, see "Crypto," below.
* The method `SetOption` has been removed from the ABCI.Client interface. This feature was used in the early ABCI implementation's.
### P2P Protocol ### P2P Protocol
The default codec is now proto3, not amino. The schema files can be found in the `/proto` The default codec is now proto3, not amino. The schema files can be found in the `/proto`


+ 2
- 2
abci/client/client.go View File

@ -14,6 +14,8 @@ const (
echoRetryIntervalSeconds = 1 echoRetryIntervalSeconds = 1
) )
//go:generate mockery --case underscore --name Client
// Client defines an interface for an ABCI client. // Client defines an interface for an ABCI client.
// All `Async` methods return a `ReqRes` object. // All `Async` methods return a `ReqRes` object.
// All `Sync` methods return the appropriate protobuf ResponseXxx struct and an error. // All `Sync` methods return the appropriate protobuf ResponseXxx struct and an error.
@ -28,7 +30,6 @@ type Client interface {
FlushAsync() *ReqRes FlushAsync() *ReqRes
EchoAsync(msg string) *ReqRes EchoAsync(msg string) *ReqRes
InfoAsync(types.RequestInfo) *ReqRes InfoAsync(types.RequestInfo) *ReqRes
SetOptionAsync(types.RequestSetOption) *ReqRes
DeliverTxAsync(types.RequestDeliverTx) *ReqRes DeliverTxAsync(types.RequestDeliverTx) *ReqRes
CheckTxAsync(types.RequestCheckTx) *ReqRes CheckTxAsync(types.RequestCheckTx) *ReqRes
QueryAsync(types.RequestQuery) *ReqRes QueryAsync(types.RequestQuery) *ReqRes
@ -44,7 +45,6 @@ type Client interface {
FlushSync() error FlushSync() error
EchoSync(msg string) (*types.ResponseEcho, error) EchoSync(msg string) (*types.ResponseEcho, error)
InfoSync(types.RequestInfo) (*types.ResponseInfo, error) InfoSync(types.RequestInfo) (*types.ResponseInfo, error)
SetOptionSync(types.RequestSetOption) (*types.ResponseSetOption, error)
DeliverTxSync(types.RequestDeliverTx) (*types.ResponseDeliverTx, error) DeliverTxSync(types.RequestDeliverTx) (*types.ResponseDeliverTx, error)
CheckTxSync(types.RequestCheckTx) (*types.ResponseCheckTx, error) CheckTxSync(types.RequestCheckTx) (*types.ResponseCheckTx, error)
QuerySync(types.RequestQuery) (*types.ResponseQuery, error) QuerySync(types.RequestQuery) (*types.ResponseQuery, error)


+ 0
- 14
abci/client/grpc_client.go View File

@ -153,15 +153,6 @@ func (cli *grpcClient) InfoAsync(params types.RequestInfo) *ReqRes {
return cli.finishAsyncCall(req, &types.Response{Value: &types.Response_Info{Info: res}}) return cli.finishAsyncCall(req, &types.Response{Value: &types.Response_Info{Info: res}})
} }
func (cli *grpcClient) SetOptionAsync(params types.RequestSetOption) *ReqRes {
req := types.ToRequestSetOption(params)
res, err := cli.client.SetOption(context.Background(), req.GetSetOption(), grpc.WaitForReady(true))
if err != nil {
cli.StopForError(err)
}
return cli.finishAsyncCall(req, &types.Response{Value: &types.Response_SetOption{SetOption: res}})
}
func (cli *grpcClient) DeliverTxAsync(params types.RequestDeliverTx) *ReqRes { func (cli *grpcClient) DeliverTxAsync(params types.RequestDeliverTx) *ReqRes {
req := types.ToRequestDeliverTx(params) req := types.ToRequestDeliverTx(params)
res, err := cli.client.DeliverTx(context.Background(), req.GetDeliverTx(), grpc.WaitForReady(true)) res, err := cli.client.DeliverTx(context.Background(), req.GetDeliverTx(), grpc.WaitForReady(true))
@ -303,11 +294,6 @@ func (cli *grpcClient) InfoSync(req types.RequestInfo) (*types.ResponseInfo, err
return reqres.Response.GetInfo(), cli.Error() return reqres.Response.GetInfo(), cli.Error()
} }
func (cli *grpcClient) SetOptionSync(req types.RequestSetOption) (*types.ResponseSetOption, error) {
reqres := cli.SetOptionAsync(req)
return reqres.Response.GetSetOption(), cli.Error()
}
func (cli *grpcClient) DeliverTxSync(params types.RequestDeliverTx) (*types.ResponseDeliverTx, error) { func (cli *grpcClient) DeliverTxSync(params types.RequestDeliverTx) (*types.ResponseDeliverTx, error) {
reqres := cli.DeliverTxAsync(params) reqres := cli.DeliverTxAsync(params)
return reqres.Response.GetDeliverTx(), cli.Error() return reqres.Response.GetDeliverTx(), cli.Error()


+ 0
- 19
abci/client/local_client.go View File

@ -69,17 +69,6 @@ func (app *localClient) InfoAsync(req types.RequestInfo) *ReqRes {
) )
} }
func (app *localClient) SetOptionAsync(req types.RequestSetOption) *ReqRes {
app.mtx.Lock()
defer app.mtx.Unlock()
res := app.Application.SetOption(req)
return app.callback(
types.ToRequestSetOption(req),
types.ToResponseSetOption(res),
)
}
func (app *localClient) DeliverTxAsync(params types.RequestDeliverTx) *ReqRes { func (app *localClient) DeliverTxAsync(params types.RequestDeliverTx) *ReqRes {
app.mtx.Lock() app.mtx.Lock()
defer app.mtx.Unlock() defer app.mtx.Unlock()
@ -219,14 +208,6 @@ func (app *localClient) InfoSync(req types.RequestInfo) (*types.ResponseInfo, er
return &res, nil return &res, nil
} }
func (app *localClient) SetOptionSync(req types.RequestSetOption) (*types.ResponseSetOption, error) {
app.mtx.Lock()
defer app.mtx.Unlock()
res := app.Application.SetOption(req)
return &res, nil
}
func (app *localClient) DeliverTxSync(req types.RequestDeliverTx) (*types.ResponseDeliverTx, error) { func (app *localClient) DeliverTxSync(req types.RequestDeliverTx) (*types.ResponseDeliverTx, error) {
app.mtx.Lock() app.mtx.Lock()
defer app.mtx.Unlock() defer app.mtx.Unlock()


+ 1
- 40
abci/client/mocks/client.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v1.1.1. DO NOT EDIT.
// Code generated by mockery v2.3.0. DO NOT EDIT.
package mocks package mocks
@ -649,45 +649,6 @@ func (_m *Client) SetLogger(_a0 log.Logger) {
_m.Called(_a0) _m.Called(_a0)
} }
// SetOptionAsync provides a mock function with given fields: _a0
func (_m *Client) SetOptionAsync(_a0 types.RequestSetOption) *abcicli.ReqRes {
ret := _m.Called(_a0)
var r0 *abcicli.ReqRes
if rf, ok := ret.Get(0).(func(types.RequestSetOption) *abcicli.ReqRes); ok {
r0 = rf(_a0)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*abcicli.ReqRes)
}
}
return r0
}
// SetOptionSync provides a mock function with given fields: _a0
func (_m *Client) SetOptionSync(_a0 types.RequestSetOption) (*types.ResponseSetOption, error) {
ret := _m.Called(_a0)
var r0 *types.ResponseSetOption
if rf, ok := ret.Get(0).(func(types.RequestSetOption) *types.ResponseSetOption); ok {
r0 = rf(_a0)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*types.ResponseSetOption)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(types.RequestSetOption) error); ok {
r1 = rf(_a0)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// SetResponseCallback provides a mock function with given fields: _a0 // SetResponseCallback provides a mock function with given fields: _a0
func (_m *Client) SetResponseCallback(_a0 abcicli.Callback) { func (_m *Client) SetResponseCallback(_a0 abcicli.Callback) {
_m.Called(_a0) _m.Called(_a0)


+ 0
- 15
abci/client/socket_client.go View File

@ -233,10 +233,6 @@ func (cli *socketClient) InfoAsync(req types.RequestInfo) *ReqRes {
return cli.queueRequest(types.ToRequestInfo(req)) return cli.queueRequest(types.ToRequestInfo(req))
} }
func (cli *socketClient) SetOptionAsync(req types.RequestSetOption) *ReqRes {
return cli.queueRequest(types.ToRequestSetOption(req))
}
func (cli *socketClient) DeliverTxAsync(req types.RequestDeliverTx) *ReqRes { func (cli *socketClient) DeliverTxAsync(req types.RequestDeliverTx) *ReqRes {
return cli.queueRequest(types.ToRequestDeliverTx(req)) return cli.queueRequest(types.ToRequestDeliverTx(req))
} }
@ -310,15 +306,6 @@ func (cli *socketClient) InfoSync(req types.RequestInfo) (*types.ResponseInfo, e
return reqres.Response.GetInfo(), cli.Error() return reqres.Response.GetInfo(), cli.Error()
} }
func (cli *socketClient) SetOptionSync(req types.RequestSetOption) (*types.ResponseSetOption, error) {
reqres := cli.queueRequest(types.ToRequestSetOption(req))
if err := cli.FlushSync(); err != nil {
return nil, err
}
return reqres.Response.GetSetOption(), cli.Error()
}
func (cli *socketClient) DeliverTxSync(req types.RequestDeliverTx) (*types.ResponseDeliverTx, error) { func (cli *socketClient) DeliverTxSync(req types.RequestDeliverTx) (*types.ResponseDeliverTx, error) {
reqres := cli.queueRequest(types.ToRequestDeliverTx(req)) reqres := cli.queueRequest(types.ToRequestDeliverTx(req))
if err := cli.FlushSync(); err != nil { if err := cli.FlushSync(); err != nil {
@ -470,8 +457,6 @@ func resMatchesReq(req *types.Request, res *types.Response) (ok bool) {
_, ok = res.Value.(*types.Response_Flush) _, ok = res.Value.(*types.Response_Flush)
case *types.Request_Info: case *types.Request_Info:
_, ok = res.Value.(*types.Response_Info) _, ok = res.Value.(*types.Response_Info)
case *types.Request_SetOption:
_, ok = res.Value.(*types.Response_SetOption)
case *types.Request_DeliverTx: case *types.Request_DeliverTx:
_, ok = res.Value.(*types.Response_DeliverTx) _, ok = res.Value.(*types.Response_DeliverTx)
case *types.Request_CheckTx: case *types.Request_CheckTx:


+ 1
- 33
abci/cmd/abci-cli/abci-cli.go View File

@ -148,7 +148,6 @@ func addCommands() {
RootCmd.AddCommand(consoleCmd) RootCmd.AddCommand(consoleCmd)
RootCmd.AddCommand(echoCmd) RootCmd.AddCommand(echoCmd)
RootCmd.AddCommand(infoCmd) RootCmd.AddCommand(infoCmd)
RootCmd.AddCommand(setOptionCmd)
RootCmd.AddCommand(deliverTxCmd) RootCmd.AddCommand(deliverTxCmd)
RootCmd.AddCommand(checkTxCmd) RootCmd.AddCommand(checkTxCmd)
RootCmd.AddCommand(commitCmd) RootCmd.AddCommand(commitCmd)
@ -176,7 +175,6 @@ you'd like to run:
where example.file looks something like: where example.file looks something like:
set_option serial on
check_tx 0x00 check_tx 0x00
check_tx 0xff check_tx 0xff
deliver_tx 0x00 deliver_tx 0x00
@ -198,7 +196,7 @@ This command opens an interactive console for running any of the other commands
without opening a new connection each time without opening a new connection each time
`, `,
Args: cobra.ExactArgs(0), Args: cobra.ExactArgs(0),
ValidArgs: []string{"echo", "info", "set_option", "deliver_tx", "check_tx", "commit", "query"},
ValidArgs: []string{"echo", "info", "deliver_tx", "check_tx", "commit", "query"},
RunE: cmdConsole, RunE: cmdConsole,
} }
@ -216,13 +214,6 @@ var infoCmd = &cobra.Command{
Args: cobra.ExactArgs(0), Args: cobra.ExactArgs(0),
RunE: cmdInfo, RunE: cmdInfo,
} }
var setOptionCmd = &cobra.Command{
Use: "set_option",
Short: "set an option on the application",
Long: "set an option on the application",
Args: cobra.ExactArgs(2),
RunE: cmdSetOption,
}
var deliverTxCmd = &cobra.Command{ var deliverTxCmd = &cobra.Command{
Use: "deliver_tx", Use: "deliver_tx",
@ -324,7 +315,6 @@ func cmdTest(cmd *cobra.Command, args []string) error {
return compose( return compose(
[]func() error{ []func() error{
func() error { return servertest.InitChain(client) }, func() error { return servertest.InitChain(client) },
func() error { return servertest.SetOption(client, "serial", "on") },
func() error { return servertest.Commit(client, nil) }, func() error { return servertest.Commit(client, nil) },
func() error { return servertest.DeliverTx(client, []byte("abc"), code.CodeTypeBadNonce, nil) }, func() error { return servertest.DeliverTx(client, []byte("abc"), code.CodeTypeBadNonce, nil) },
func() error { return servertest.Commit(client, nil) }, func() error { return servertest.Commit(client, nil) },
@ -439,8 +429,6 @@ func muxOnCommands(cmd *cobra.Command, pArgs []string) error {
return cmdInfo(cmd, actualArgs) return cmdInfo(cmd, actualArgs)
case "query": case "query":
return cmdQuery(cmd, actualArgs) return cmdQuery(cmd, actualArgs)
case "set_option":
return cmdSetOption(cmd, actualArgs)
default: default:
return cmdUnimplemented(cmd, pArgs) return cmdUnimplemented(cmd, pArgs)
} }
@ -464,7 +452,6 @@ func cmdUnimplemented(cmd *cobra.Command, args []string) error {
fmt.Printf("%s: %s\n", deliverTxCmd.Use, deliverTxCmd.Short) fmt.Printf("%s: %s\n", deliverTxCmd.Use, deliverTxCmd.Short)
fmt.Printf("%s: %s\n", queryCmd.Use, queryCmd.Short) fmt.Printf("%s: %s\n", queryCmd.Use, queryCmd.Short)
fmt.Printf("%s: %s\n", commitCmd.Use, commitCmd.Short) fmt.Printf("%s: %s\n", commitCmd.Use, commitCmd.Short)
fmt.Printf("%s: %s\n", setOptionCmd.Use, setOptionCmd.Short)
fmt.Println("Use \"[command] --help\" for more information about a command.") fmt.Println("Use \"[command] --help\" for more information about a command.")
return nil return nil
@ -504,25 +491,6 @@ func cmdInfo(cmd *cobra.Command, args []string) error {
const codeBad uint32 = 10 const codeBad uint32 = 10
// Set an option on the application
func cmdSetOption(cmd *cobra.Command, args []string) error {
if len(args) < 2 {
printResponse(cmd, args, response{
Code: codeBad,
Log: "want at least arguments of the form: <key> <value>",
})
return nil
}
key, val := args[0], args[1]
_, err := client.SetOptionSync(types.RequestSetOption{Key: key, Value: val})
if err != nil {
return err
}
printResponse(cmd, args, response{Log: "OK (SetOption doesn't return anything.)"}) // NOTE: Nothing to show...
return nil
}
// Append a new tx to application // Append a new tx to application
func cmdDeliverTx(cmd *cobra.Command, args []string) error { func cmdDeliverTx(cmd *cobra.Command, args []string) error {
if len(args) == 0 { if len(args) == 0 {


+ 1
- 18
abci/example/counter/counter.go View File

@ -24,24 +24,6 @@ func (app *Application) Info(req types.RequestInfo) types.ResponseInfo {
return types.ResponseInfo{Data: fmt.Sprintf("{\"hashes\":%v,\"txs\":%v}", app.hashCount, app.txCount)} return types.ResponseInfo{Data: fmt.Sprintf("{\"hashes\":%v,\"txs\":%v}", app.hashCount, app.txCount)}
} }
func (app *Application) SetOption(req types.RequestSetOption) types.ResponseSetOption {
key, value := req.Key, req.Value
if key == "serial" && value == "on" {
app.serial = true
} else {
/*
TODO Panic and have the ABCI server pass an exception.
The client can call SetOptionSync() and get an `error`.
return types.ResponseSetOption{
Error: fmt.Sprintf("Unknown key (%s) or value (%s)", key, value),
}
*/
return types.ResponseSetOption{}
}
return types.ResponseSetOption{}
}
func (app *Application) DeliverTx(req types.RequestDeliverTx) types.ResponseDeliverTx { func (app *Application) DeliverTx(req types.RequestDeliverTx) types.ResponseDeliverTx {
if app.serial { if app.serial {
if len(req.Tx) > 8 { if len(req.Tx) > 8 {
@ -69,6 +51,7 @@ func (app *Application) CheckTx(req types.RequestCheckTx) types.ResponseCheckTx
Code: code.CodeTypeEncodingError, Code: code.CodeTypeEncodingError,
Log: fmt.Sprintf("Max tx size is 8 bytes, got %d", len(req.Tx))} Log: fmt.Sprintf("Max tx size is 8 bytes, got %d", len(req.Tx))}
} }
tx8 := make([]byte, 8) tx8 := make([]byte, 8)
copy(tx8[len(tx8)-len(req.Tx):], req.Tx) copy(tx8[len(tx8)-len(req.Tx):], req.Tx)
txValue := binary.BigEndian.Uint64(tx8) txValue := binary.BigEndian.Uint64(tx8)


+ 0
- 4
abci/example/kvstore/persistent_kvstore.go View File

@ -62,10 +62,6 @@ func (app *PersistentKVStoreApplication) Info(req types.RequestInfo) types.Respo
return res return res
} }
func (app *PersistentKVStoreApplication) SetOption(req types.RequestSetOption) types.ResponseSetOption {
return app.app.SetOption(req)
}
// tx is either "val:pubkey!power" or "key=value" or just arbitrary bytes // tx is either "val:pubkey!power" or "key=value" or just arbitrary bytes
func (app *PersistentKVStoreApplication) DeliverTx(req types.RequestDeliverTx) types.ResponseDeliverTx { func (app *PersistentKVStoreApplication) DeliverTx(req types.RequestDeliverTx) types.ResponseDeliverTx {
// if it starts with "val:", update the validator set // if it starts with "val:", update the validator set


+ 0
- 3
abci/server/socket_server.go View File

@ -200,9 +200,6 @@ func (s *SocketServer) handleRequest(req *types.Request, responses chan<- *types
case *types.Request_Info: case *types.Request_Info:
res := s.app.Info(*r.Info) res := s.app.Info(*r.Info)
responses <- types.ToResponseInfo(res) responses <- types.ToResponseInfo(res)
case *types.Request_SetOption:
res := s.app.SetOption(*r.SetOption)
responses <- types.ToResponseSetOption(res)
case *types.Request_DeliverTx: case *types.Request_DeliverTx:
res := s.app.DeliverTx(*r.DeliverTx) res := s.app.DeliverTx(*r.DeliverTx)
responses <- types.ToResponseDeliverTx(res) responses <- types.ToResponseDeliverTx(res)


+ 0
- 11
abci/tests/server/client.go View File

@ -29,17 +29,6 @@ func InitChain(client abcicli.Client) error {
return nil return nil
} }
func SetOption(client abcicli.Client, key, value string) error {
_, err := client.SetOptionSync(types.RequestSetOption{Key: key, Value: value})
if err != nil {
fmt.Println("Failed test: SetOption")
fmt.Printf("error while setting %v=%v: \nerror: %v\n", key, value, err)
return err
}
fmt.Println("Passed test: SetOption")
return nil
}
func Commit(client abcicli.Client, hashExp []byte) error { func Commit(client abcicli.Client, hashExp []byte) error {
res, err := client.CommitSync() res, err := client.CommitSync()
data := res.Data data := res.Data


+ 0
- 25
abci/tests/test_app/app.go View File

@ -25,13 +25,6 @@ func startClient(abciType string) abcicli.Client {
return client return client
} }
func setOption(client abcicli.Client, key, value string) {
_, err := client.SetOptionSync(types.RequestSetOption{Key: key, Value: value})
if err != nil {
panicf("setting %v=%v: \nerr: %v", key, value, err)
}
}
func commit(client abcicli.Client, hashExp []byte) { func commit(client abcicli.Client, hashExp []byte) {
res, err := client.CommitSync() res, err := client.CommitSync()
if err != nil { if err != nil {
@ -55,24 +48,6 @@ func deliverTx(client abcicli.Client, txBytes []byte, codeExp uint32, dataExp []
} }
} }
/*func checkTx(client abcicli.Client, txBytes []byte, codeExp uint32, dataExp []byte) {
res, err := client.CheckTxSync(txBytes)
if err != nil {
panicf("client error: %v", err)
}
if res.IsErr() {
panicf("checking tx %X: %v\nlog: %v", txBytes, res.Log)
}
if res.Code != codeExp {
panicf("CheckTx response code was unexpected. Got %v expected %v. Log: %v",
res.Code, codeExp, res.Log)
}
if !bytes.Equal(res.Data, dataExp) {
panicf("CheckTx response data was unexpected. Got %X expected %X",
res.Data, dataExp)
}
}*/
func panicf(format string, a ...interface{}) { func panicf(format string, a ...interface{}) {
panic(fmt.Sprintf(format, a...)) panic(fmt.Sprintf(format, a...))
} }

+ 5
- 7
abci/tests/test_app/main.go View File

@ -7,7 +7,6 @@ import (
"os/exec" "os/exec"
"time" "time"
"github.com/tendermint/tendermint/abci/example/code"
"github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/abci/types"
) )
@ -41,7 +40,7 @@ func ensureABCIIsUp(typ string, n int) error {
if err == nil { if err == nil {
break break
} }
<-time.After(500 * time.Millisecond)
time.Sleep(500 * time.Millisecond)
} }
return err return err
} }
@ -79,17 +78,16 @@ func testCounter() {
} }
}() }()
setOption(client, "serial", "on")
commit(client, nil)
deliverTx(client, []byte("abc"), code.CodeTypeBadNonce, nil)
// commit(client, nil)
// deliverTx(client, []byte("abc"), code.CodeTypeBadNonce, nil)
commit(client, nil) commit(client, nil)
deliverTx(client, []byte{0x00}, types.CodeTypeOK, nil) deliverTx(client, []byte{0x00}, types.CodeTypeOK, nil)
commit(client, []byte{0, 0, 0, 0, 0, 0, 0, 1}) commit(client, []byte{0, 0, 0, 0, 0, 0, 0, 1})
deliverTx(client, []byte{0x00}, code.CodeTypeBadNonce, nil)
// deliverTx(client, []byte{0x00}, code.CodeTypeBadNonce, nil)
deliverTx(client, []byte{0x01}, types.CodeTypeOK, nil) deliverTx(client, []byte{0x01}, types.CodeTypeOK, nil)
deliverTx(client, []byte{0x00, 0x02}, types.CodeTypeOK, nil) deliverTx(client, []byte{0x00, 0x02}, types.CodeTypeOK, nil)
deliverTx(client, []byte{0x00, 0x03}, types.CodeTypeOK, nil) deliverTx(client, []byte{0x00, 0x03}, types.CodeTypeOK, nil)
deliverTx(client, []byte{0x00, 0x00, 0x04}, types.CodeTypeOK, nil) deliverTx(client, []byte{0x00, 0x00, 0x04}, types.CodeTypeOK, nil)
deliverTx(client, []byte{0x00, 0x00, 0x06}, code.CodeTypeBadNonce, nil)
// deliverTx(client, []byte{0x00, 0x00, 0x06}, code.CodeTypeBadNonce, nil)
commit(client, []byte{0, 0, 0, 0, 0, 0, 0, 5}) commit(client, []byte{0, 0, 0, 0, 0, 0, 0, 5})
} }

+ 0
- 1
abci/tests/test_cli/ex2.abci View File

@ -1,4 +1,3 @@
set_option serial on
check_tx 0x00 check_tx 0x00
check_tx 0xff check_tx 0xff
deliver_tx 0x00 deliver_tx 0x00


+ 4
- 10
abci/tests/test_cli/ex2.abci.out View File

@ -1,7 +1,3 @@
> set_option serial on
-> code: OK
-> log: OK (SetOption doesn't return anything.)
> check_tx 0x00 > check_tx 0x00
-> code: OK -> code: OK
@ -12,18 +8,16 @@
-> code: OK -> code: OK
> check_tx 0x00 > check_tx 0x00
-> code: 2
-> log: Invalid nonce. Expected >= 1, got 0
-> code: OK
> deliver_tx 0x01 > deliver_tx 0x01
-> code: OK -> code: OK
> deliver_tx 0x04 > deliver_tx 0x04
-> code: 2
-> log: Invalid nonce. Expected 2, got 4
-> code: OK
> info > info
-> code: OK -> code: OK
-> data: {"hashes":0,"txs":2}
-> data.hex: 0x7B22686173686573223A302C22747873223A327D
-> data: {"hashes":0,"txs":3}
-> data.hex: 0x7B22686173686573223A302C22747873223A337D

+ 2
- 12
abci/types/application.go View File

@ -10,9 +10,8 @@ import (
// except CheckTx/DeliverTx, which take `tx []byte`, and `Commit`, which takes nothing. // except CheckTx/DeliverTx, which take `tx []byte`, and `Commit`, which takes nothing.
type Application interface { type Application interface {
// Info/Query Connection // Info/Query Connection
Info(RequestInfo) ResponseInfo // Return application info
SetOption(RequestSetOption) ResponseSetOption // Set application option
Query(RequestQuery) ResponseQuery // Query for state
Info(RequestInfo) ResponseInfo // Return application info
Query(RequestQuery) ResponseQuery // Query for state
// Mempool Connection // Mempool Connection
CheckTx(RequestCheckTx) ResponseCheckTx // Validate a tx for the mempool CheckTx(RequestCheckTx) ResponseCheckTx // Validate a tx for the mempool
@ -47,10 +46,6 @@ func (BaseApplication) Info(req RequestInfo) ResponseInfo {
return ResponseInfo{} return ResponseInfo{}
} }
func (BaseApplication) SetOption(req RequestSetOption) ResponseSetOption {
return ResponseSetOption{}
}
func (BaseApplication) DeliverTx(req RequestDeliverTx) ResponseDeliverTx { func (BaseApplication) DeliverTx(req RequestDeliverTx) ResponseDeliverTx {
return ResponseDeliverTx{Code: CodeTypeOK} return ResponseDeliverTx{Code: CodeTypeOK}
} }
@ -119,11 +114,6 @@ func (app *GRPCApplication) Info(ctx context.Context, req *RequestInfo) (*Respon
return &res, nil return &res, nil
} }
func (app *GRPCApplication) SetOption(ctx context.Context, req *RequestSetOption) (*ResponseSetOption, error) {
res := app.app.SetOption(*req)
return &res, nil
}
func (app *GRPCApplication) DeliverTx(ctx context.Context, req *RequestDeliverTx) (*ResponseDeliverTx, error) { func (app *GRPCApplication) DeliverTx(ctx context.Context, req *RequestDeliverTx) (*ResponseDeliverTx, error) {
res := app.app.DeliverTx(*req) res := app.app.DeliverTx(*req)
return &res, nil return &res, nil


+ 0
- 13
abci/types/messages.go View File

@ -87,12 +87,6 @@ func ToRequestInfo(req RequestInfo) *Request {
} }
} }
func ToRequestSetOption(req RequestSetOption) *Request {
return &Request{
Value: &Request_SetOption{&req},
}
}
func ToRequestDeliverTx(req RequestDeliverTx) *Request { func ToRequestDeliverTx(req RequestDeliverTx) *Request {
return &Request{ return &Request{
Value: &Request_DeliverTx{&req}, Value: &Request_DeliverTx{&req},
@ -184,13 +178,6 @@ func ToResponseInfo(res ResponseInfo) *Response {
Value: &Response_Info{&res}, Value: &Response_Info{&res},
} }
} }
func ToResponseSetOption(res ResponseSetOption) *Response {
return &Response{
Value: &Response_SetOption{&res},
}
}
func ToResponseDeliverTx(res ResponseDeliverTx) *Response { func ToResponseDeliverTx(res ResponseDeliverTx) *Response {
return &Response{ return &Response{
Value: &Response_DeliverTx{&res}, Value: &Response_DeliverTx{&res},


+ 0
- 11
abci/types/result.go View File

@ -52,16 +52,6 @@ var (
jsonpbUnmarshaller = jsonpb.Unmarshaler{} jsonpbUnmarshaller = jsonpb.Unmarshaler{}
) )
func (r *ResponseSetOption) MarshalJSON() ([]byte, error) {
s, err := jsonpbMarshaller.MarshalToString(r)
return []byte(s), err
}
func (r *ResponseSetOption) UnmarshalJSON(b []byte) error {
reader := bytes.NewBuffer(b)
return jsonpbUnmarshaller.Unmarshal(reader, r)
}
func (r *ResponseCheckTx) MarshalJSON() ([]byte, error) { func (r *ResponseCheckTx) MarshalJSON() ([]byte, error) {
s, err := jsonpbMarshaller.MarshalToString(r) s, err := jsonpbMarshaller.MarshalToString(r)
return []byte(s), err return []byte(s), err
@ -126,6 +116,5 @@ var _ jsonRoundTripper = (*ResponseCommit)(nil)
var _ jsonRoundTripper = (*ResponseQuery)(nil) var _ jsonRoundTripper = (*ResponseQuery)(nil)
var _ jsonRoundTripper = (*ResponseDeliverTx)(nil) var _ jsonRoundTripper = (*ResponseDeliverTx)(nil)
var _ jsonRoundTripper = (*ResponseCheckTx)(nil) var _ jsonRoundTripper = (*ResponseCheckTx)(nil)
var _ jsonRoundTripper = (*ResponseSetOption)(nil)
var _ jsonRoundTripper = (*EventAttribute)(nil) var _ jsonRoundTripper = (*EventAttribute)(nil)

+ 303
- 993
abci/types/types.pb.go
File diff suppressed because it is too large
View File


+ 0
- 3
docs/app-dev/abci-cli.md View File

@ -285,9 +285,6 @@ abci-cli counter
In another window, start the `abci-cli console`: In another window, start the `abci-cli console`:
```sh ```sh
> set_option serial on
-> code: OK
-> log: OK (SetOption doesn't return anything.)
> check_tx 0x00 > check_tx 0x00
-> code: OK -> code: OK


+ 0
- 1
docs/architecture/adr-029-check-tx-consensus.md View File

@ -43,7 +43,6 @@ However, this method should not be implemented like that, because checkTx will s
type Application interface { type Application interface {
// Info/Query Connection // Info/Query Connection
Info(RequestInfo) ResponseInfo // Return application info Info(RequestInfo) ResponseInfo // Return application info
SetOption(RequestSetOption) ResponseSetOption // Set application option
Query(RequestQuery) ResponseQuery // Query for state Query(RequestQuery) ResponseQuery // Query for state
// Mempool Connection // Mempool Connection


+ 0
- 4
docs/tutorials/go-built-in.md View File

@ -102,10 +102,6 @@ func (KVStoreApplication) Info(req abcitypes.RequestInfo) abcitypes.ResponseInfo
return abcitypes.ResponseInfo{} return abcitypes.ResponseInfo{}
} }
func (KVStoreApplication) SetOption(req abcitypes.RequestSetOption) abcitypes.ResponseSetOption {
return abcitypes.ResponseSetOption{}
}
func (KVStoreApplication) DeliverTx(req abcitypes.RequestDeliverTx) abcitypes.ResponseDeliverTx { func (KVStoreApplication) DeliverTx(req abcitypes.RequestDeliverTx) abcitypes.ResponseDeliverTx {
return abcitypes.ResponseDeliverTx{Code: 0} return abcitypes.ResponseDeliverTx{Code: 0}
} }


+ 0
- 4
docs/tutorials/go.md View File

@ -105,10 +105,6 @@ func (KVStoreApplication) Info(req abcitypes.RequestInfo) abcitypes.ResponseInfo
return abcitypes.ResponseInfo{} return abcitypes.ResponseInfo{}
} }
func (KVStoreApplication) SetOption(req abcitypes.RequestSetOption) abcitypes.ResponseSetOption {
return abcitypes.ResponseSetOption{}
}
func (KVStoreApplication) DeliverTx(req abcitypes.RequestDeliverTx) abcitypes.ResponseDeliverTx { func (KVStoreApplication) DeliverTx(req abcitypes.RequestDeliverTx) abcitypes.ResponseDeliverTx {
return abcitypes.ResponseDeliverTx{Code: 0} return abcitypes.ResponseDeliverTx{Code: 0}
} }


+ 1
- 1
evidence/mocks/block_store.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v2.1.0. DO NOT EDIT.
// Code generated by mockery v2.3.0. DO NOT EDIT.
package mocks package mocks


+ 0
- 1
mempool/clist_mempool_test.go View File

@ -262,7 +262,6 @@ func TestTxsAvailable(t *testing.T) {
func TestSerialReap(t *testing.T) { func TestSerialReap(t *testing.T) {
app := counter.NewApplication(true) app := counter.NewApplication(true)
app.SetOption(abci.RequestSetOption{Key: "serial", Value: "on"})
cc := proxy.NewLocalClientCreator(app) cc := proxy.NewLocalClientCreator(app)
mempool, cleanup := newMempoolWithApp(cc) mempool, cleanup := newMempoolWithApp(cc)


+ 1
- 1
p2p/mocks/peer.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v2.1.0. DO NOT EDIT.
// Code generated by mockery v2.3.0. DO NOT EDIT.
package mocks package mocks


+ 22
- 39
proto/tendermint/abci/types.proto View File

@ -24,18 +24,17 @@ message Request {
RequestEcho echo = 1; RequestEcho echo = 1;
RequestFlush flush = 2; RequestFlush flush = 2;
RequestInfo info = 3; RequestInfo info = 3;
RequestSetOption set_option = 4;
RequestInitChain init_chain = 5;
RequestQuery query = 6;
RequestBeginBlock begin_block = 7;
RequestCheckTx check_tx = 8;
RequestDeliverTx deliver_tx = 9;
RequestEndBlock end_block = 10;
RequestCommit commit = 11;
RequestListSnapshots list_snapshots = 12;
RequestOfferSnapshot offer_snapshot = 13;
RequestLoadSnapshotChunk load_snapshot_chunk = 14;
RequestApplySnapshotChunk apply_snapshot_chunk = 15;
RequestInitChain init_chain = 4;
RequestQuery query = 5;
RequestBeginBlock begin_block = 6;
RequestCheckTx check_tx = 7;
RequestDeliverTx deliver_tx = 8;
RequestEndBlock end_block = 9;
RequestCommit commit = 10;
RequestListSnapshots list_snapshots = 11;
RequestOfferSnapshot offer_snapshot = 12;
RequestLoadSnapshotChunk load_snapshot_chunk = 13;
RequestApplySnapshotChunk apply_snapshot_chunk = 14;
} }
} }
@ -51,12 +50,6 @@ message RequestInfo {
uint64 p2p_version = 3; uint64 p2p_version = 3;
} }
// nondeterministic
message RequestSetOption {
string key = 1;
string value = 2;
}
message RequestInitChain { message RequestInitChain {
google.protobuf.Timestamp time = 1 google.protobuf.Timestamp time = 1
[(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
@ -134,18 +127,17 @@ message Response {
ResponseEcho echo = 2; ResponseEcho echo = 2;
ResponseFlush flush = 3; ResponseFlush flush = 3;
ResponseInfo info = 4; ResponseInfo info = 4;
ResponseSetOption set_option = 5;
ResponseInitChain init_chain = 6;
ResponseQuery query = 7;
ResponseBeginBlock begin_block = 8;
ResponseCheckTx check_tx = 9;
ResponseDeliverTx deliver_tx = 10;
ResponseEndBlock end_block = 11;
ResponseCommit commit = 12;
ResponseListSnapshots list_snapshots = 13;
ResponseOfferSnapshot offer_snapshot = 14;
ResponseLoadSnapshotChunk load_snapshot_chunk = 15;
ResponseApplySnapshotChunk apply_snapshot_chunk = 16;
ResponseInitChain init_chain = 5;
ResponseQuery query = 6;
ResponseBeginBlock begin_block = 7;
ResponseCheckTx check_tx = 8;
ResponseDeliverTx deliver_tx = 9;
ResponseEndBlock end_block = 10;
ResponseCommit commit = 11;
ResponseListSnapshots list_snapshots = 12;
ResponseOfferSnapshot offer_snapshot = 13;
ResponseLoadSnapshotChunk load_snapshot_chunk = 14;
ResponseApplySnapshotChunk apply_snapshot_chunk = 15;
} }
} }
@ -170,14 +162,6 @@ message ResponseInfo {
bytes last_block_app_hash = 5; bytes last_block_app_hash = 5;
} }
// nondeterministic
message ResponseSetOption {
uint32 code = 1;
// bytes data = 2;
string log = 3;
string info = 4;
}
message ResponseInitChain { message ResponseInitChain {
ConsensusParams consensus_params = 1; ConsensusParams consensus_params = 1;
repeated ValidatorUpdate validators = 2 [(gogoproto.nullable) = false]; repeated ValidatorUpdate validators = 2 [(gogoproto.nullable) = false];
@ -392,7 +376,6 @@ service ABCIApplication {
rpc Echo(RequestEcho) returns (ResponseEcho); rpc Echo(RequestEcho) returns (ResponseEcho);
rpc Flush(RequestFlush) returns (ResponseFlush); rpc Flush(RequestFlush) returns (ResponseFlush);
rpc Info(RequestInfo) returns (ResponseInfo); rpc Info(RequestInfo) returns (ResponseInfo);
rpc SetOption(RequestSetOption) returns (ResponseSetOption);
rpc DeliverTx(RequestDeliverTx) returns (ResponseDeliverTx); rpc DeliverTx(RequestDeliverTx) returns (ResponseDeliverTx);
rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx); rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx);
rpc Query(RequestQuery) returns (ResponseQuery); rpc Query(RequestQuery) returns (ResponseQuery);


+ 0
- 2
proxy/app_conn.go View File

@ -39,8 +39,6 @@ type AppConnQuery interface {
EchoSync(string) (*types.ResponseEcho, error) EchoSync(string) (*types.ResponseEcho, error)
InfoSync(types.RequestInfo) (*types.ResponseInfo, error) InfoSync(types.RequestInfo) (*types.ResponseInfo, error)
QuerySync(types.RequestQuery) (*types.ResponseQuery, error) QuerySync(types.RequestQuery) (*types.ResponseQuery, error)
// SetOptionSync(key string, value string) (res types.Result)
} }
type AppConnSnapshot interface { type AppConnSnapshot interface {


+ 1
- 1
proxy/mocks/app_conn_consensus.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v2.1.0. DO NOT EDIT.
// Code generated by mockery v2.3.0. DO NOT EDIT.
package mocks package mocks


+ 1
- 1
proxy/mocks/app_conn_mempool.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v2.1.0. DO NOT EDIT.
// Code generated by mockery v2.3.0. DO NOT EDIT.
package mocks package mocks


+ 1
- 1
proxy/mocks/app_conn_query.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v2.1.0. DO NOT EDIT.
// Code generated by mockery v2.3.0. DO NOT EDIT.
package mocks package mocks


+ 1
- 1
proxy/mocks/app_conn_snapshot.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v2.1.0. DO NOT EDIT.
// Code generated by mockery v2.3.0. DO NOT EDIT.
package mocks package mocks


+ 1
- 1
state/mocks/evidence_pool.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v2.1.0. DO NOT EDIT.
// Code generated by mockery v2.3.0. DO NOT EDIT.
package mocks package mocks


+ 1
- 1
state/mocks/store.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v2.1.0. DO NOT EDIT.
// Code generated by mockery v2.3.0. DO NOT EDIT.
package mocks package mocks


+ 1
- 1
statesync/mocks/state_provider.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v2.1.0. DO NOT EDIT.
// Code generated by mockery v2.3.0. DO NOT EDIT.
package mocks package mocks


Loading…
Cancel
Save