You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
14 KiB

crypto: Use a different library for ed25519/sr25519 (#6526) At Oasis we have spend some time writing a new Ed25519/X25519/sr25519 implementation called curve25519-voi. This PR switches the import from ed25519consensus/go-schnorrkel, which should lead to performance gains on most systems. Summary of changes: * curve25519-voi is now used for Ed25519 operations, following the existing ZIP-215 semantics. * curve25519-voi's public key cache is enabled (hardcoded size of 4096 entries, should be tuned, see the code comment) to accelerate repeated Ed25519 verification with the same public key(s). * (BREAKING) curve25519-voi is now used for sr25519 operations. This is a breaking change as the current sr25519 support does something decidedly non-standard when going from a MiniSecretKey to a SecretKey and or PublicKey (The expansion routine is called twice). While I believe the new behavior (that expands once and only once) to be more "correct", this changes the semantics as implemented. * curve25519-voi is now used for merlin since the included STROBE implementation produces much less garbage on the heap. Side issues fixed: * The version of go-schnorrkel that is currently imported by tendermint has a badly broken batch verification implementation. Upstream has fixed the issue after I reported it, so the version should be bumped in the interim. Open design questions/issues: * As noted, the public key cache size should be tuned. It is currently backed by a trivial thread-safe LRU cache, which is not scan-resistant, but replacing it with something better is a matter of implementing an interface. * As far as I can tell, the only reason why serial verification on batch failure is necessary is to provide more detailed error messages (that are only used in some unit tests). If you trust the batch verification to be consistent with serial verification then the fallback can be eliminated entirely (the BatchVerifier provided by the new library supports an option that omits the fallback if this is chosen as the way forward). * curve25519-voi's sr25519 support could use more optimization and more eyes on the code. The algorithm unfortunately is woefully under-specified, and the implementation was done primarily because I got really sad when I actually looked at go-schnorrkel, and we do not use the algorithm at this time.
3 years ago
crypto: Use a different library for ed25519/sr25519 (#6526) At Oasis we have spend some time writing a new Ed25519/X25519/sr25519 implementation called curve25519-voi. This PR switches the import from ed25519consensus/go-schnorrkel, which should lead to performance gains on most systems. Summary of changes: * curve25519-voi is now used for Ed25519 operations, following the existing ZIP-215 semantics. * curve25519-voi's public key cache is enabled (hardcoded size of 4096 entries, should be tuned, see the code comment) to accelerate repeated Ed25519 verification with the same public key(s). * (BREAKING) curve25519-voi is now used for sr25519 operations. This is a breaking change as the current sr25519 support does something decidedly non-standard when going from a MiniSecretKey to a SecretKey and or PublicKey (The expansion routine is called twice). While I believe the new behavior (that expands once and only once) to be more "correct", this changes the semantics as implemented. * curve25519-voi is now used for merlin since the included STROBE implementation produces much less garbage on the heap. Side issues fixed: * The version of go-schnorrkel that is currently imported by tendermint has a badly broken batch verification implementation. Upstream has fixed the issue after I reported it, so the version should be bumped in the interim. Open design questions/issues: * As noted, the public key cache size should be tuned. It is currently backed by a trivial thread-safe LRU cache, which is not scan-resistant, but replacing it with something better is a matter of implementing an interface. * As far as I can tell, the only reason why serial verification on batch failure is necessary is to provide more detailed error messages (that are only used in some unit tests). If you trust the batch verification to be consistent with serial verification then the fallback can be eliminated entirely (the BatchVerifier provided by the new library supports an option that omits the fallback if this is chosen as the way forward). * curve25519-voi's sr25519 support could use more optimization and more eyes on the code. The algorithm unfortunately is woefully under-specified, and the implementation was done primarily because I got really sad when I actually looked at go-schnorrkel, and we do not use the algorithm at this time.
3 years ago
rpc/jsonrpc: Unmarshal RPCRequest correctly (#6191) i.e. without double pointer. With double pointer, it was possible to submit `null` value, which will crash the server. ``` panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x189ddc0] goroutine 1 [running]: github.com/tendermint/tendermint/rpc/jsonrpc/types.(*RPCRequest).UnmarshalJSON(0xc0000147e0, 0xc00029f201, 0x4, 0x1ff, 0x883baa0, 0xc0000147e0) /Users/anton/go/src/github.com/tendermint/tendermint/rpc/jsonrpc/types/types.go:70 +0x100 encoding/json.(*decodeState).literalStore(0xc000216bb0, 0xc00029f201, 0x4, 0x1ff, 0x1998800, 0xc0000147e0, 0x199, 0xc000231700, 0x10e0a5e, 0x197) /usr/local/Cellar/go/1.16/libexec/src/encoding/json/decode.go:860 +0x30ce encoding/json.(*decodeState).value(0xc000216bb0, 0x1998800, 0xc0000147e0, 0x199, 0x1998800, 0xc0000147e0) /usr/local/Cellar/go/1.16/libexec/src/encoding/json/decode.go:384 +0x40c encoding/json.(*decodeState).array(0xc000216bb0, 0x18df040, 0xc0001be540, 0x16, 0xc000216bd8, 0x10e405b) /usr/local/Cellar/go/1.16/libexec/src/encoding/json/decode.go:558 +0x365 encoding/json.(*decodeState).value(0xc000216bb0, 0x18df040, 0xc0001be540, 0x16, 0x16, 0x6e) /usr/local/Cellar/go/1.16/libexec/src/encoding/json/decode.go:360 +0x22f encoding/json.(*decodeState).unmarshal(0xc000216bb0, 0x18df040, 0xc0001be540, 0xc000216bd8, 0x0) /usr/local/Cellar/go/1.16/libexec/src/encoding/json/decode.go:180 +0x2c9 encoding/json.Unmarshal(0xc00029f200, 0x6, 0x200, 0x18df040, 0xc0001be540, 0x0, 0x0) /usr/local/Cellar/go/1.16/libexec/src/encoding/json/decode.go:107 +0x15d ```
4 years ago
  1. # Unreleased Changes
  2. ## vX.X
  3. Special thanks to external contributors on this release:
  4. Friendly reminder: We have a [bug bounty program](https://hackerone.com/tendermint).
  5. ### BREAKING CHANGES
  6. - CLI/RPC/Config
  7. - [pubsub/events] \#6634 The `ResultEvent.Events` field is now of type `[]abci.Event` preserving event order instead of `map[string][]string`. (@alexanderbez)
  8. - [config] \#5598 The `test_fuzz` and `test_fuzz_config` P2P settings have been removed. (@erikgrinaker)
  9. - [config] \#5728 `fast_sync = "v1"` is no longer supported (@melekes)
  10. - [cli] \#5772 `gen_node_key` prints JSON-encoded `NodeKey` rather than ID and does not save it to `node_key.json` (@melekes)
  11. - [cli] \#5777 use hyphen-case instead of snake_case for all cli commands and config parameters (@cmwaters)
  12. - [rpc] \#6019 standardise RPC errors and return the correct status code (@bipulprasad & @cmwaters)
  13. - [rpc] \#6168 Change default sorting to desc for `/tx_search` results (@melekes)
  14. - [cli] \#6282 User must specify the node mode when using `tendermint init` (@cmwaters)
  15. - [state/indexer] \#6382 reconstruct indexer, move txindex into the indexer package (@JayT106)
  16. - [cli] \#6372 Introduce `BootstrapPeers` as part of the new p2p stack. Peers to be connected on startup (@cmwaters)
  17. - [config] \#6462 Move `PrivValidator` configuration out of `BaseConfig` into its own section. (@tychoish)
  18. - [rpc] \#6610 Add MaxPeerBlockHeight into /status rpc call (@JayT106)
  19. - [fastsync/rpc] \#6620 Add TotalSyncedTime & RemainingTime to SyncInfo in /status RPC (@JayT106)
  20. - [rpc/grpc] \#6725 Mark gRPC in the RPC layer as deprecated.
  21. - [blockchain/v2] \#6730 Fast Sync v2 is deprecated, please use v0
  22. - [rpc] Add genesis_chunked method to support paginated and parallel fetching of large genesis documents.
  23. - [rpc/jsonrpc/server] \#6785 `Listen` function updated to take an `int` argument, `maxOpenConnections`, instead of an entire config object. (@williambanfield)
  24. - [rpc] \#6820 Update RPC methods to reflect changes in the p2p layer, disabling support for `UnsafeDialPeers` and `UnsafeDialPeers` when used with the new p2p layer, and changing the response format of the peer list in `NetInfo` for all users.
  25. - [cli] \#6854 Remove deprecated snake case commands. (@tychoish)
  26. - Apps
  27. - [ABCI] \#6408 Change the `key` and `value` fields from `[]byte` to `string` in the `EventAttribute` type. (@alexanderbez)
  28. - [ABCI] \#5447 Remove `SetOption` method from `ABCI.Client` interface
  29. - [ABCI] \#5447 Reset `Oneof` indexes for `Request` and `Response`.
  30. - [ABCI] \#5818 Use protoio for msg length delimitation. Migrates from int64 to uint64 length delimiters.
  31. - [ABCI] \#3546 Add `mempool_error` field to `ResponseCheckTx`. This field will contain an error string if Tendermint encountered an error while adding a transaction to the mempool. (@williambanfield)
  32. - [Version] \#6494 `TMCoreSemVer` has been renamed to `TMVersion`.
  33. - It is not required any longer to set ldflags to set version strings
  34. - [abci/counter] \#6684 Delete counter example app
  35. - P2P Protocol
  36. - Go API
  37. - [pubsub] \#6634 The `Query#Matches` method along with other pubsub methods, now accepts a `[]abci.Event` instead of `map[string][]string`. (@alexanderbez)
  38. - [p2p] \#6618 Move `p2p.NodeInfo` into `types` to support use of the SDK. (@tychoish)
  39. - [p2p] \#6583 Make `p2p.NodeID` and `p2p.NetAddress` exported types to support their use in the RPC layer. (@tychoish)
  40. - [node] \#6540 Reduce surface area of the `node` package by making most of the implementation details private. (@tychoish)
  41. - [p2p] \#6547 Move the entire `p2p` package and all reactor implementations into `internal`. (@tychoish)
  42. - [libs/log] \#6534 Remove the existing custom Tendermint logger backed by go-kit. The logging interface, `Logger`, remains. Tendermint still provides a default logger backed by the performant zerolog logger. (@alexanderbez)
  43. - [libs/time] \#6495 Move types/time to libs/time to improve consistency. (@tychoish)
  44. - [mempool] \#6529 The `Context` field has been removed from the `TxInfo` type. `CheckTx` now requires a `Context` argument. (@alexanderbez)
  45. - [abci/client, proxy] \#5673 `Async` funcs return an error, `Sync` and `Async` funcs accept `context.Context` (@melekes)
  46. - [p2p] Remove unused function `MakePoWTarget`. (@erikgrinaker)
  47. - [libs/bits] \#5720 Validate `BitArray` in `FromProto`, which now returns an error (@melekes)
  48. - [proto/p2p] Rename `DefaultNodeInfo` and `DefaultNodeInfoOther` to `NodeInfo` and `NodeInfoOther` (@erikgrinaker)
  49. - [proto/p2p] Rename `NodeInfo.default_node_id` to `node_id` (@erikgrinaker)
  50. - [libs/os] Kill() and {Must,}{Read,Write}File() functions have been removed. (@alessio)
  51. - [store] \#5848 Remove block store state in favor of using the db iterators directly (@cmwaters)
  52. - [state] \#5864 Use an iterator when pruning state (@cmwaters)
  53. - [types] \#6023 Remove `tm2pb.Header`, `tm2pb.BlockID`, `tm2pb.PartSetHeader` and `tm2pb.NewValidatorUpdate`.
  54. - Each of the above types has a `ToProto` and `FromProto` method or function which replaced this logic.
  55. - [light] \#6054 Move `MaxRetryAttempt` option from client to provider.
  56. - `NewWithOptions` now sets the max retry attempts and timeouts (@cmwaters)
  57. - [all] \#6077 Change spelling from British English to American (@cmwaters)
  58. - Rename "Subscription.Cancelled()" to "Subscription.Canceled()" in libs/pubsub
  59. - Rename "behaviour" pkg to "behavior" and internalized it in blockchain v2
  60. - [rpc/client/http] \#6176 Remove `endpoint` arg from `New`, `NewWithTimeout` and `NewWithClient` (@melekes)
  61. - [rpc/client/http] \#6176 Unexpose `WSEvents` (@melekes)
  62. - [rpc/jsonrpc/client/ws_client] \#6176 `NewWS` no longer accepts options (use `NewWSWithOptions` and `OnReconnect` funcs to configure the client) (@melekes)
  63. - [internal/libs] \#6366 Move `autofile`, `clist`,`fail`,`flowrate`, `protoio`, `sync`, `tempfile`, `test` and `timer` lib packages to an internal folder
  64. - [libs/rand] \#6364 Remove most of libs/rand in favour of standard lib's `math/rand` (@liamsi)
  65. - [mempool] \#6466 The original mempool reactor has been versioned as `v0` and moved to a sub-package under the root `mempool` package.
  66. Some core types have been kept in the `mempool` package such as `TxCache` and it's implementations, the `Mempool` interface itself
  67. and `TxInfo`. (@alexanderbez)
  68. - [crypto/sr25519] \#6526 Do not re-execute the Ed25519-style key derivation step when doing signing and verification. The derivation is now done once and only once. This breaks `sr25519.GenPrivKeyFromSecret` output compatibility. (@Yawning)
  69. - [types] \#6627 Move `NodeKey` to types to make the type public.
  70. - [config] \#6627 Extend `config` to contain methods `LoadNodeKeyID` and `LoadorGenNodeKeyID`
  71. - [blocksync] \#6755 Rename `FastSync` and `Blockchain` package to `BlockSync`
  72. (@cmwaters)
  73. - Blockchain Protocol
  74. - Data Storage
  75. - [store/state/evidence/light] \#5771 Use an order-preserving varint key encoding (@cmwaters)
  76. - [mempool] \#6396 Remove mempool's write ahead log (WAL), (previously unused by the tendermint code). (@tychoish)
  77. - [state] \#6541 Move pruneBlocks from consensus/state to state/execution. (@JayT106)
  78. - Tooling
  79. - [tools] \#6498 Set OS home dir to instead of the hardcoded PATH. (@JayT106)
  80. - [cli/indexer] \#6676 Reindex events command line tooling. (@JayT106)
  81. ### FEATURES
  82. - [config] Add `--mode` flag and config variable. See [ADR-52](https://github.com/tendermint/tendermint/blob/master/docs/architecture/adr-052-tendermint-mode.md) @dongsam
  83. - [rpc] \#6329 Don't cap page size in unsafe mode (@gotjoshua, @cmwaters)
  84. - [pex] \#6305 v2 pex reactor with backwards compatability. Introduces two new pex messages to
  85. accomodate for the new p2p stack. Removes the notion of seeds and crawling. All peer
  86. exchange reactors behave the same. (@cmwaters)
  87. - [crypto] \#6376 Enable sr25519 as a validator key
  88. - [mempool] \#6466 Introduction of a prioritized mempool. (@alexanderbez)
  89. - `Priority` and `Sender` have been introduced into the `ResponseCheckTx` type, where the `priority` will determine the prioritization of
  90. the transaction when a proposer reaps transactions for a block proposal. The `sender` field acts as an index.
  91. - Operators may toggle between the legacy mempool reactor, `v0`, and the new prioritized reactor, `v1`, by setting the
  92. `mempool.version` configuration, where `v1` is the default configuration.
  93. - Applications that do not specify a priority, i.e. zero, will have transactions reaped by the order in which they are received by the node.
  94. - Transactions are gossiped in FIFO order as they are in `v0`.
  95. - [config/indexer] \#6411 Introduce support for custom event indexing data sources, specifically PostgreSQL. (@JayT106)
  96. - [fastsync/event] \#6619 Emit fastsync status event when switching consensus/fastsync (@JayT106)
  97. - [statesync/event] \#6700 Emit statesync status start/end event (@JayT106)
  98. - [inspect] \#6785 Add a new `inspect` command for introspecting the state and block store of a crashed tendermint node. (@williambanfield)
  99. ### IMPROVEMENTS
  100. - [libs/log] Console log formatting changes as a result of \#6534 and \#6589. (@tychoish)
  101. - [statesync] \#6566 Allow state sync fetchers and request timeout to be configurable. (@alexanderbez)
  102. - [types] \#6478 Add `block_id` to `newblock` event (@jeebster)
  103. - [crypto/ed25519] \#5632 Adopt zip215 `ed25519` verification. (@marbar3778)
  104. - [crypto/ed25519] \#6526 Use [curve25519-voi](https://github.com/oasisprotocol/curve25519-voi) for `ed25519` signing and verification. (@Yawning)
  105. - [crypto/sr25519] \#6526 Use [curve25519-voi](https://github.com/oasisprotocol/curve25519-voi) for `sr25519` signing and verification. (@Yawning)
  106. - [privval] \#5603 Add `--key` to `init`, `gen_validator`, `testnet` & `unsafe_reset_priv_validator` for use in generating `secp256k1` keys.
  107. - [privval] \#5725 Add gRPC support to private validator.
  108. - [privval] \#5876 `tendermint show-validator` will query the remote signer if gRPC is being used (@marbar3778)
  109. - [abci/client] \#5673 `Async` requests return an error if queue is full (@melekes)
  110. - [mempool] \#5673 Cancel `CheckTx` requests if RPC client disconnects or times out (@melekes)
  111. - [abci] \#5706 Added `AbciVersion` to `RequestInfo` allowing applications to check ABCI version when connecting to Tendermint. (@marbar3778)
  112. - [blockchain/v1] \#5728 Remove in favor of v2 (@melekes)
  113. - [blockchain/v0] \#5741 Relax termination conditions and increase sync timeout (@melekes)
  114. - [cli] \#5772 `gen_node_key` output now contains node ID (`id` field) (@melekes)
  115. - [blockchain/v2] \#5774 Send status request when new peer joins (@melekes)
  116. - [consensus] \#5792 Deprecates the `time_iota_ms` consensus parameter, to reduce the bug surface. The parameter is no longer used. (@valardragon)
  117. - [store] \#5888 store.SaveBlock saves using batches instead of transactions for now to improve ACID properties. This is a quick fix for underlying issues around tm-db and ACID guarantees. (@githubsands)
  118. - [consensus] \#5987 Remove `time_iota_ms` from consensus params. Merge `tmproto.ConsensusParams` and `abci.ConsensusParams`. (@marbar3778)
  119. - [types] \#5994 Reduce the use of protobuf types in core logic. (@marbar3778)
  120. - `ConsensusParams`, `BlockParams`, `ValidatorParams`, `EvidenceParams`, `VersionParams`, `sm.Version` and `version.Consensus` have become native types. They still utilize protobuf when being sent over the wire or written to disk.
  121. - [rpc/client/http] \#6163 Do not drop events even if the `out` channel is full (@melekes)
  122. - [node] \#6059 Validate and complete genesis doc before saving to state store (@silasdavis)
  123. - [state] \#6067 Batch save state data (@githubsands & @cmwaters)
  124. - [crypto] \#6120 Implement batch verification interface for ed25519 and sr25519. (@marbar3778)
  125. - [types] \#6120 use batch verification for verifying commits signatures.
  126. - If the key type supports the batch verification API it will try to batch verify. If the verification fails we will single verify each signature.
  127. - [privval/file] \#6185 Return error on `LoadFilePV`, `LoadFilePVEmptyState`. Allows for better programmatic control of Tendermint.
  128. - [privval] \#6240 Add `context.Context` to privval interface.
  129. - [rpc] \#6265 set cache control in http-rpc response header (@JayT106)
  130. - [statesync] \#6378 Retry requests for snapshots and add a minimum discovery time (5s) for new snapshots.
  131. - [node/state] \#6370 graceful shutdown in the consensus reactor (@JayT106)
  132. - [crypto/merkle] \#6443 Improve HashAlternatives performance (@cuonglm)
  133. - [crypto/merkle] \#6513 Optimize HashAlternatives (@marbar3778)
  134. - [p2p/pex] \#6509 Improve addrBook.hash performance (@cuonglm)
  135. - [consensus/metrics] \#6549 Change block_size gauge to a histogram for better observability over time (@marbar3778)
  136. - [statesync] \#6587 Increase chunk priority and re-request chunks that don't arrive (@cmwaters)
  137. - [state/privval] \#6578 No GetPubKey retry beyond the proposal/voting window (@JayT106)
  138. - [rpc] \#6615 Add TotalGasUsed to block_results response (@crypto-facs)
  139. - [cmd/tendermint/commands] \#6623 replace `$HOME/.some/test/dir` with `t.TempDir` (@tanyabouman)
  140. ### BUG FIXES
  141. - [privval] \#5638 Increase read/write timeout to 5s and calculate ping interval based on it (@JoeKash)
  142. - [blockchain/v1] [\#5701](https://github.com/tendermint/tendermint/pull/5701) Handle peers without blocks (@melekes)
  143. - [blockchain/v1] \#5711 Fix deadlock (@melekes)
  144. - [evidence] \#6375 Fix bug with inconsistent LightClientAttackEvidence hashing (cmwaters)
  145. - [rpc] \#6507 Ensure RPC client can handle URLs without ports (@JayT106)
  146. - [statesync] \#6463 Adds Reverse Sync feature to fetch historical light blocks after state sync in order to verify any evidence (@cmwaters)
  147. - [fastsync] \#6590 Update the metrics during fast-sync (@JayT106)
  148. - [gitignore] \#6668 Fix gitignore of abci-cli (@tanyabouman)