├── .circleci └── config.yml ├── .clang-format ├── .dockerignore ├── .editorconfig ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug-report.md │ ├── feature-request.md │ └── proposal.md ├── PULL_REQUEST_TEMPLATE.md ├── auto-comment.yml ├── mergify.yml └── workflows │ ├── check-generated.yml │ ├── coverage.yml │ ├── docker.yml │ ├── e2e-manual.yml │ ├── e2e-nightly-34x.yml │ ├── e2e-nightly-master.yml │ ├── e2e.yml │ ├── fuzz-nightly.yml │ ├── lint.yml │ ├── linter.yml │ ├── pre-release.yml │ ├── proto-lint.yml │ ├── release.yml │ ├── stale.yml │ └── tests.yml ├── .gitignore ├── .golangci.yml ├── .goreleaser.yml ├── .markdownlint.yml ├── .markdownlintignore ├── .mergify.yml ├── .vscode └── settings.json ├── CHANGELOG.md ├── CHANGELOG_PENDING.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── DOCKER ├── .gitignore ├── Dockerfile ├── Dockerfile.build_c-amazonlinux ├── Dockerfile.testing ├── Makefile ├── README.md ├── build.sh ├── docker-entrypoint.sh └── push.sh ├── LICENSE ├── Makefile ├── PHILOSOPHY.md ├── README.md ├── SECURITY.md ├── STYLE_GUIDE.md ├── UPGRADING.md ├── Vagrantfile ├── abci ├── README.md ├── client │ ├── client.go │ ├── grpc_client.go │ ├── local_client.go │ ├── mocks │ │ └── client.go │ ├── socket_client.go │ └── socket_client_test.go ├── cmd │ └── abci-cli │ │ ├── abci-cli.go │ │ └── main.go ├── example │ ├── code │ │ └── code.go │ ├── counter │ │ └── counter.go │ ├── example.go │ ├── example_test.go │ └── kvstore │ │ ├── README.md │ │ ├── helpers.go │ │ ├── kvstore.go │ │ ├── kvstore_test.go │ │ └── persistent_kvstore.go ├── server │ ├── grpc_server.go │ ├── server.go │ └── socket_server.go ├── tests │ ├── benchmarks │ │ ├── blank.go │ │ ├── parallel │ │ │ └── parallel.go │ │ └── simple │ │ │ └── simple.go │ ├── client_server_test.go │ ├── server │ │ └── client.go │ ├── test_app │ │ ├── app.go │ │ ├── main.go │ │ └── test.sh │ ├── test_cli │ │ ├── ex1.abci │ │ ├── ex1.abci.out │ │ ├── ex2.abci │ │ ├── ex2.abci.out │ │ └── test.sh │ └── tests.go ├── types │ ├── application.go │ ├── messages.go │ ├── messages_test.go │ ├── pubkey.go │ ├── result.go │ ├── types.pb.go │ └── util.go └── version │ └── version.go ├── appveyor.yml ├── behaviour ├── doc.go ├── peer_behaviour.go ├── reporter.go └── reporter_test.go ├── blockchain ├── msgs.go ├── msgs_test.go ├── v0 │ ├── pool.go │ ├── pool_test.go │ ├── reactor.go │ └── reactor_test.go ├── v1 │ ├── peer.go │ ├── peer_test.go │ ├── pool.go │ ├── pool_test.go │ ├── reactor.go │ ├── reactor_fsm.go │ ├── reactor_fsm_test.go │ └── reactor_test.go └── v2 │ ├── io.go │ ├── metrics.go │ ├── processor.go │ ├── processor_context.go │ ├── processor_test.go │ ├── reactor.go │ ├── reactor_test.go │ ├── routine.go │ ├── routine_test.go │ ├── scheduler.go │ ├── scheduler_test.go │ └── types.go ├── buf.gen.yaml ├── buf.work.yaml ├── buf.yaml ├── cmd ├── contract_tests │ └── main.go ├── priv_val_server │ └── main.go └── tendermint │ ├── commands │ ├── compact.go │ ├── debug │ │ ├── debug.go │ │ ├── dump.go │ │ ├── io.go │ │ ├── kill.go │ │ └── util.go │ ├── gen_node_key.go │ ├── gen_validator.go │ ├── init.go │ ├── light.go │ ├── probe_upnp.go │ ├── reindex_event.go │ ├── reindex_event_test.go │ ├── replay.go │ ├── reset.go │ ├── reset_test.go │ ├── rollback.go │ ├── root.go │ ├── root_test.go │ ├── run_node.go │ ├── show_node_id.go │ ├── show_validator.go │ ├── testnet.go │ └── version.go │ └── main.go ├── codecov.yml ├── config ├── config.go ├── config_test.go ├── toml.go └── toml_test.go ├── consensus ├── README.md ├── byzantine_test.go ├── common_test.go ├── invalid_test.go ├── mempool_test.go ├── metrics.go ├── msgs.go ├── msgs_test.go ├── reactor.go ├── reactor_test.go ├── replay.go ├── replay_file.go ├── replay_stubs.go ├── replay_test.go ├── state.go ├── state_test.go ├── ticker.go ├── types │ ├── height_vote_set.go │ ├── height_vote_set_test.go │ ├── peer_round_state.go │ └── round_state.go ├── wal.go ├── wal_fuzz.go ├── wal_generator.go └── wal_test.go ├── crypto ├── CHANGELOG.md ├── README.md ├── armor │ ├── armor.go │ └── armor_test.go ├── crypto.go ├── doc.go ├── ed25519 │ ├── bench_test.go │ ├── ed25519.go │ └── ed25519_test.go ├── encoding │ └── codec.go ├── example_test.go ├── hash.go ├── internal │ └── benchmarking │ │ └── bench.go ├── merkle │ ├── README.md │ ├── doc.go │ ├── hash.go │ ├── proof.go │ ├── proof_key_path.go │ ├── proof_key_path_test.go │ ├── proof_op.go │ ├── proof_test.go │ ├── proof_value.go │ ├── rfc6962_test.go │ ├── tree.go │ ├── tree_test.go │ └── types.go ├── random.go ├── random_test.go ├── secp256k1 │ ├── secp256k1.go │ ├── secp256k1_internal_test.go │ └── secp256k1_test.go ├── sr25519 │ ├── bench_test.go │ ├── encoding.go │ ├── privkey.go │ ├── pubkey.go │ └── sr25519_test.go ├── tmhash │ ├── hash.go │ └── hash_test.go ├── version.go ├── xchacha20poly1305 │ ├── vector_test.go │ ├── xchachapoly.go │ └── xchachapoly_test.go └── xsalsa20symmetric │ ├── symmetric.go │ └── symmetric_test.go ├── docker-compose.yml ├── docs ├── .textlintrc.json ├── .vuepress │ ├── config.js │ ├── public │ │ └── logo-bw.svg │ ├── redirects │ └── styles │ │ └── index.styl ├── DEV_SESSIONS.md ├── DOCS_README.md ├── README.md ├── app-dev │ ├── abci-cli.md │ ├── app-architecture.md │ ├── getting-started.md │ ├── indexing-transactions.md │ └── readme.md ├── imgs │ ├── abci.png │ ├── bifurcation-point.png │ ├── consensus_logic.png │ ├── contributing.png │ ├── cosmos-tendermint-stack-4k.jpg │ ├── evidence_lifecycle.png │ ├── light-client-detector.png │ ├── light_client_bisection_alg.png │ ├── tcp-window.png │ ├── tm-amnesia-attack.png │ ├── tm-application-example.png │ ├── tm-transaction-flow.png │ └── tmint-logo-blue.png ├── introduction │ ├── README.md │ ├── architecture.md │ ├── install.md │ ├── quick-start.md │ └── what-is-tendermint.md ├── networks │ ├── README.md │ ├── docker-compose.md │ └── terraform-and-ansible.md ├── package-lock.json ├── package.json ├── post.sh ├── pre.sh ├── qa │ ├── README.md │ ├── method.md │ └── v034 │ │ ├── README.md │ │ └── img │ │ ├── v034_200node_latencies.png │ │ ├── v034_200node_latencies_zoomed.png │ │ ├── v034_latency_throughput.png │ │ ├── v034_r200c2_heights.png │ │ ├── v034_r200c2_load-runner.png │ │ ├── v034_r200c2_load1.png │ │ ├── v034_r200c2_mempool_size.png │ │ ├── v034_r200c2_mempool_size_avg.png │ │ ├── v034_r200c2_peers.png │ │ ├── v034_r200c2_rounds.png │ │ ├── v034_r200c2_rss.png │ │ ├── v034_r200c2_rss_avg.png │ │ ├── v034_r200c2_total-txs.png │ │ ├── v034_report_tabbed.txt │ │ ├── v034_rotating_heights.png │ │ ├── v034_rotating_heights_ephe.png │ │ ├── v034_rotating_latencies.png │ │ ├── v034_rotating_latencies_uniq.png │ │ ├── v034_rotating_load1.png │ │ ├── v034_rotating_peers.png │ │ ├── v034_rotating_rss_avg.png │ │ └── v034_rotating_total-txs.png ├── stop-words.txt ├── tendermint-core-image.jpg ├── tendermint-core │ ├── README.md │ ├── block-structure.md │ ├── configuration.md │ ├── fast-sync.md │ ├── how-to-read-logs.md │ ├── light-client.md │ ├── local_config.png │ ├── mempool.md │ ├── metrics.md │ ├── rpc.md │ ├── running-in-production.md │ ├── sentry_layout.png │ ├── state-sync.md │ ├── subscription.md │ ├── using-tendermint.md │ └── validators.md ├── tools │ ├── README.md │ ├── debugging.md │ └── remote-signer-validation.md ├── tutorials │ ├── go-built-in.md │ ├── go.md │ ├── java.md │ ├── kotlin.md │ └── readme.md └── versions ├── dredd.yml ├── evidence ├── doc.go ├── mocks │ └── block_store.go ├── pool.go ├── pool_test.go ├── reactor.go ├── reactor_test.go ├── services.go ├── verify.go └── verify_test.go ├── go.mod ├── go.sum ├── libs ├── CHANGELOG.md ├── async │ ├── async.go │ └── async_test.go ├── autofile │ ├── README.md │ ├── autofile.go │ ├── autofile_test.go │ ├── cmd │ │ └── logjack.go │ ├── group.go │ └── group_test.go ├── bits │ ├── bit_array.go │ └── bit_array_test.go ├── bytes │ ├── bytes.go │ ├── bytes_test.go │ └── byteslice.go ├── cli │ ├── flags │ │ ├── log_level.go │ │ └── log_level_test.go │ ├── helper.go │ ├── setup.go │ └── setup_test.go ├── clist │ ├── bench_test.go │ ├── clist.go │ └── clist_test.go ├── cmap │ ├── cmap.go │ └── cmap_test.go ├── events │ ├── Makefile │ ├── README.md │ ├── event_cache.go │ ├── event_cache_test.go │ ├── events.go │ └── events_test.go ├── fail │ └── fail.go ├── flowrate │ ├── README.md │ ├── flowrate.go │ ├── io.go │ ├── io_test.go │ └── util.go ├── json │ ├── decoder.go │ ├── decoder_test.go │ ├── doc.go │ ├── encoder.go │ ├── encoder_test.go │ ├── helpers_test.go │ ├── structs.go │ └── types.go ├── log │ ├── filter.go │ ├── filter_test.go │ ├── lazy.go │ ├── logger.go │ ├── nop_logger.go │ ├── testing_logger.go │ ├── tm_json_logger.go │ ├── tm_logger.go │ ├── tm_logger_test.go │ ├── tmfmt_logger.go │ ├── tmfmt_logger_test.go │ ├── tracing_logger.go │ └── tracing_logger_test.go ├── math │ ├── fraction.go │ ├── fraction_test.go │ ├── math.go │ └── safemath.go ├── net │ ├── net.go │ └── net_test.go ├── os │ ├── os.go │ └── os_test.go ├── progressbar │ ├── progressbar.go │ └── progressbar_test.go ├── protoio │ ├── io.go │ ├── io_test.go │ ├── reader.go │ └── writer.go ├── pubsub │ ├── example_test.go │ ├── pubsub.go │ ├── pubsub_test.go │ ├── query │ │ ├── Makefile │ │ ├── empty.go │ │ ├── empty_test.go │ │ ├── fuzz_test │ │ │ └── main.go │ │ ├── parser_test.go │ │ ├── peg.go │ │ ├── query.go │ │ ├── query.peg │ │ ├── query.peg.go │ │ └── query_test.go │ └── subscription.go ├── rand │ ├── random.go │ └── random_test.go ├── service │ ├── service.go │ └── service_test.go ├── strings │ ├── string.go │ └── string_test.go ├── sync │ ├── deadlock.go │ └── sync.go ├── tempfile │ ├── tempfile.go │ └── tempfile_test.go ├── test │ └── mutate.go └── timer │ ├── throttle_timer.go │ └── throttle_timer_test.go ├── light ├── client.go ├── client_benchmark_test.go ├── client_test.go ├── detector.go ├── detector_test.go ├── doc.go ├── errors.go ├── example_test.go ├── helpers_test.go ├── provider │ ├── errors.go │ ├── http │ │ ├── http.go │ │ └── http_test.go │ ├── mock │ │ ├── deadmock.go │ │ └── mock.go │ └── provider.go ├── proxy │ ├── proxy.go │ └── routes.go ├── rpc │ ├── client.go │ └── mocks │ │ └── light_client.go ├── setup.go ├── store │ ├── db │ │ ├── db.go │ │ └── db_test.go │ ├── errors.go │ └── store.go ├── trust_options.go ├── verifier.go └── verifier_test.go ├── mempool ├── cache.go ├── cache_bench_test.go ├── cache_test.go ├── ids.go ├── ids_test.go ├── mempool.go ├── metrics.go ├── mock │ └── mempool.go ├── tx.go ├── v0 │ ├── bench_test.go │ ├── cache_test.go │ ├── clist_mempool.go │ ├── clist_mempool_test.go │ ├── doc.go │ ├── reactor.go │ └── reactor_test.go └── v1 │ ├── mempool.go │ ├── mempool_bench_test.go │ ├── mempool_test.go │ ├── reactor.go │ ├── reactor_test.go │ └── tx.go ├── networks ├── local │ ├── Makefile │ ├── README.md │ └── localnode │ │ ├── Dockerfile │ │ ├── config-template.toml │ │ └── wrapper.sh └── remote │ ├── README.md │ ├── ansible │ ├── .gitignore │ ├── ansible.cfg │ ├── config.yml │ ├── install.yml │ ├── inventory │ │ ├── COPYING │ │ ├── digital_ocean.ini │ │ └── digital_ocean.py │ ├── logzio.yml │ ├── reset.yml │ ├── restart.yml │ ├── roles │ │ ├── config │ │ │ └── tasks │ │ │ │ └── main.yml │ │ ├── install │ │ │ ├── handlers │ │ │ │ └── main.yml │ │ │ ├── tasks │ │ │ │ └── main.yml │ │ │ └── templates │ │ │ │ └── systemd.service.j2 │ │ ├── logzio │ │ │ ├── files │ │ │ │ └── journalbeat.service │ │ │ ├── handlers │ │ │ │ └── main.yml │ │ │ ├── tasks │ │ │ │ └── main.yml │ │ │ └── templates │ │ │ │ └── journalbeat.yml.j2 │ │ ├── start │ │ │ └── tasks │ │ │ │ └── main.yml │ │ ├── status │ │ │ └── tasks │ │ │ │ └── main.yml │ │ ├── stop │ │ │ └── tasks │ │ │ │ └── main.yml │ │ └── unsafe_reset │ │ │ └── tasks │ │ │ └── main.yml │ ├── start.yml │ ├── status.yml │ └── stop.yml │ ├── integration.sh │ └── terraform │ ├── .gitignore │ ├── cluster │ ├── main.tf │ ├── outputs.tf │ └── variables.tf │ └── main.tf ├── node ├── doc.go ├── id.go ├── node.go └── node_test.go ├── p2p ├── README.md ├── base_reactor.go ├── conn │ ├── conn_go110.go │ ├── conn_notgo110.go │ ├── connection.go │ ├── connection_test.go │ ├── evil_secret_connection_test.go │ ├── secret_connection.go │ ├── secret_connection_test.go │ └── testdata │ │ └── TestDeriveSecretsAndChallengeGolden.golden ├── conn_set.go ├── errors.go ├── fuzz.go ├── key.go ├── key_test.go ├── metrics.go ├── mock │ ├── peer.go │ └── reactor.go ├── mocks │ └── peer.go ├── netaddress.go ├── netaddress_test.go ├── node_info.go ├── node_info_test.go ├── peer.go ├── peer_set.go ├── peer_set_test.go ├── peer_test.go ├── pex │ ├── addrbook.go │ ├── addrbook_test.go │ ├── errors.go │ ├── file.go │ ├── known_address.go │ ├── params.go │ ├── pex_reactor.go │ └── pex_reactor_test.go ├── switch.go ├── switch_test.go ├── test_util.go ├── transport.go ├── transport_test.go ├── trust │ ├── config.go │ ├── metric.go │ ├── metric_test.go │ ├── store.go │ ├── store_test.go │ └── ticker.go ├── types.go └── upnp │ ├── probe.go │ └── upnp.go ├── privval ├── doc.go ├── errors.go ├── file.go ├── file_test.go ├── msgs.go ├── msgs_test.go ├── retry_signer_client.go ├── signer_client.go ├── signer_client_test.go ├── signer_dialer_endpoint.go ├── signer_endpoint.go ├── signer_listener_endpoint.go ├── signer_listener_endpoint_test.go ├── signer_requestHandler.go ├── signer_server.go ├── socket_dialers.go ├── socket_dialers_test.go ├── socket_listeners.go ├── socket_listeners_test.go ├── utils.go └── utils_test.go ├── proto ├── README.md ├── buf.lock ├── buf.yaml └── tendermint │ ├── abci │ └── types.proto │ ├── blockchain │ ├── message.go │ ├── types.pb.go │ └── types.proto │ ├── consensus │ ├── message.go │ ├── types.pb.go │ ├── types.proto │ ├── wal.pb.go │ └── wal.proto │ ├── crypto │ ├── keys.pb.go │ ├── keys.proto │ ├── proof.pb.go │ └── proof.proto │ ├── libs │ └── bits │ │ ├── types.pb.go │ │ └── types.proto │ ├── mempool │ ├── message.go │ ├── types.pb.go │ └── types.proto │ ├── p2p │ ├── conn.pb.go │ ├── conn.proto │ ├── pex.go │ ├── pex.pb.go │ ├── pex.proto │ ├── types.pb.go │ └── types.proto │ ├── privval │ ├── types.pb.go │ └── types.proto │ ├── rpc │ └── grpc │ │ ├── types.pb.go │ │ └── types.proto │ ├── state │ ├── types.pb.go │ └── types.proto │ ├── statesync │ ├── message.go │ ├── types.pb.go │ └── types.proto │ ├── store │ ├── types.pb.go │ └── types.proto │ ├── types │ ├── block.pb.go │ ├── block.proto │ ├── canonical.pb.go │ ├── canonical.proto │ ├── events.pb.go │ ├── events.proto │ ├── evidence.pb.go │ ├── evidence.proto │ ├── params.pb.go │ ├── params.proto │ ├── types.pb.go │ ├── types.proto │ ├── validator.pb.go │ └── validator.proto │ └── version │ ├── types.pb.go │ └── types.proto ├── proxy ├── app_conn.go ├── app_conn_test.go ├── client.go ├── mocks │ ├── app_conn_consensus.go │ ├── app_conn_mempool.go │ ├── app_conn_query.go │ ├── app_conn_snapshot.go │ └── client_creator.go ├── multi_app_conn.go ├── multi_app_conn_test.go └── version.go ├── release_notes.md ├── rpc ├── client │ ├── event_test.go │ ├── evidence_test.go │ ├── examples_test.go │ ├── helpers.go │ ├── helpers_test.go │ ├── http │ │ └── http.go │ ├── interface.go │ ├── local │ │ └── local.go │ ├── main_test.go │ ├── mock │ │ ├── abci.go │ │ ├── abci_test.go │ │ ├── client.go │ │ ├── status.go │ │ └── status_test.go │ ├── mocks │ │ └── client.go │ ├── rpc_test.go │ └── types.go ├── core │ ├── CONTRIBUTING.md │ ├── README.md │ ├── abci.go │ ├── blocks.go │ ├── blocks_test.go │ ├── consensus.go │ ├── dev.go │ ├── doc.go │ ├── doc_template.txt │ ├── env.go │ ├── env_test.go │ ├── events.go │ ├── evidence.go │ ├── health.go │ ├── mempool.go │ ├── net.go │ ├── net_test.go │ ├── routes.go │ ├── status.go │ ├── tx.go │ └── types │ │ ├── responses.go │ │ └── responses_test.go ├── grpc │ ├── api.go │ ├── client_server.go │ ├── grpc_test.go │ └── types.pb.go ├── jsonrpc │ ├── client │ │ ├── args_test.go │ │ ├── decode.go │ │ ├── encode.go │ │ ├── http_json_client.go │ │ ├── http_json_client_test.go │ │ ├── http_uri_client.go │ │ ├── integration_test.go │ │ ├── ws_client.go │ │ └── ws_client_test.go │ ├── doc.go │ ├── jsonrpc_test.go │ ├── server │ │ ├── http_json_handler.go │ │ ├── http_json_handler_test.go │ │ ├── http_server.go │ │ ├── http_server_test.go │ │ ├── http_uri_handler.go │ │ ├── parse_test.go │ │ ├── rpc_func.go │ │ ├── test.crt │ │ ├── test.key │ │ ├── ws_handler.go │ │ └── ws_handler_test.go │ ├── test │ │ ├── data.json │ │ ├── integration_test.sh │ │ └── main.go │ └── types │ │ ├── types.go │ │ └── types_test.go ├── openapi │ ├── index.html │ └── openapi.yaml └── test │ └── helpers.go ├── scripts ├── README.md ├── authors.sh ├── dist.sh ├── get_nodejs.sh ├── json2wal │ └── main.go ├── linkify_changelog.py ├── mockery_generate.sh ├── proto-gen.sh ├── qa │ └── reporting │ │ ├── README.md │ │ ├── latency_throughput.py │ │ └── requirements.txt ├── txs │ └── random.sh └── wal2json │ └── main.go ├── spec ├── README.md ├── abci │ ├── README.md │ ├── abci.md │ ├── apps.md │ └── client-server.md ├── blockchain │ ├── blockchain.md │ ├── encoding.md │ ├── readme.md │ └── state.md ├── consensus │ ├── bft-time.md │ ├── consensus-paper │ │ ├── IEEEtran.bst │ │ ├── IEEEtran.cls │ │ ├── README.md │ │ ├── algorithmicplus.sty │ │ ├── conclusion.tex │ │ ├── consensus.tex │ │ ├── definitions.tex │ │ ├── homodel.sty │ │ ├── intro.tex │ │ ├── latex8.bst │ │ ├── latex8.sty │ │ ├── lit.bib │ │ ├── paper.tex │ │ ├── proof.tex │ │ ├── rounddiag.sty │ │ └── technote.sty │ ├── consensus.md │ ├── creating-proposal.md │ ├── evidence.md │ ├── light-client │ │ ├── README.md │ │ ├── accountability.md │ │ ├── assets │ │ │ └── light-node-image.png │ │ ├── detection.md │ │ └── verification.md │ ├── proposer-based-timestamp │ │ ├── README.md │ │ ├── pbts-algorithm_001_draft.md │ │ ├── pbts-sysmodel_001_draft.md │ │ ├── pbts_001_draft.md │ │ └── tla │ │ │ └── TendermintPBT_001_draft.tla │ ├── proposer-selection.md │ ├── readme.md │ ├── signing.md │ └── wal.md ├── core │ ├── data_structures.md │ ├── encoding.md │ ├── genesis.md │ ├── readme.md │ └── state.md ├── ivy-proofs │ ├── Dockerfile │ ├── README.md │ ├── abstract_tendermint.ivy │ ├── accountable_safety_1.ivy │ ├── accountable_safety_2.ivy │ ├── check_proofs.sh │ ├── classic_safety.ivy │ ├── count_lines.sh │ ├── docker-compose.yml │ ├── domain_model.ivy │ ├── network_shim.ivy │ ├── output │ │ └── .gitignore │ ├── tendermint.ivy │ └── tendermint_test.ivy ├── light-client │ ├── README.md │ ├── accountability │ │ ├── 001indinv-apalache.csv │ │ ├── MC_n4_f1.tla │ │ ├── MC_n4_f2.tla │ │ ├── MC_n4_f2_amnesia.tla │ │ ├── MC_n4_f3.tla │ │ ├── MC_n5_f1.tla │ │ ├── MC_n5_f2.tla │ │ ├── MC_n6_f1.tla │ │ ├── README.md │ │ ├── Synopsis.md │ │ ├── TendermintAccDebug_004_draft.tla │ │ ├── TendermintAccInv_004_draft.tla │ │ ├── TendermintAccTrace_004_draft.tla │ │ ├── TendermintAcc_004_draft.tla │ │ ├── results │ │ │ ├── 001indinv-apalache-mem-log.svg │ │ │ ├── 001indinv-apalache-mem.svg │ │ │ ├── 001indinv-apalache-ncells.svg │ │ │ ├── 001indinv-apalache-nclauses.svg │ │ │ ├── 001indinv-apalache-report.md │ │ │ ├── 001indinv-apalache-time-log.svg │ │ │ ├── 001indinv-apalache-time.svg │ │ │ └── 001indinv-apalache-unstable.csv │ │ └── run.sh │ ├── assets │ │ └── light-node-image.png │ ├── attacks │ │ ├── Blockchain_003_draft.tla │ │ ├── Isolation_001_draft.tla │ │ ├── LCVerificationApi_003_draft.tla │ │ ├── MC_5_3.tla │ │ ├── isolate-attackers_001_draft.md │ │ ├── isolate-attackers_002_reviewed.md │ │ └── notes-on-evidence-handling.md │ ├── detection │ │ ├── 004bmc-apalache-ok.csv │ │ ├── 005bmc-apalache-error.csv │ │ ├── Blockchain_003_draft.tla │ │ ├── LCD_MC3_3_faulty.tla │ │ ├── LCD_MC3_4_faulty.tla │ │ ├── LCD_MC4_4_faulty.tla │ │ ├── LCD_MC5_5_faulty.tla │ │ ├── LCDetector_003_draft.tla │ │ ├── LCVerificationApi_003_draft.tla │ │ ├── README.md │ │ ├── detection_001_reviewed.md │ │ ├── detection_003_reviewed.md │ │ ├── discussions.md │ │ ├── draft-functions.md │ │ └── req-ibc-detection.md │ ├── experiments.png │ ├── supervisor │ │ ├── supervisor_001_draft.md │ │ ├── supervisor_001_draft.tla │ │ └── supervisor_002_draft.md │ └── verification │ │ ├── 001bmc-apalache.csv │ │ ├── 002bmc-apalache-ok.csv │ │ ├── 003bmc-apalache-error.csv │ │ ├── 004bmc-apalache-ok.csv │ │ ├── 005bmc-apalache-error.csv │ │ ├── Blockchain_002_draft.tla │ │ ├── Blockchain_003_draft.tla │ │ ├── Blockchain_A_1.tla │ │ ├── LCVerificationApi_003_draft.tla │ │ ├── Lightclient_002_draft.tla │ │ ├── Lightclient_003_draft.tla │ │ ├── Lightclient_A_1.tla │ │ ├── MC4_3_correct.tla │ │ ├── MC4_3_faulty.tla │ │ ├── MC4_4_correct.tla │ │ ├── MC4_4_correct_drifted.tla │ │ ├── MC4_4_faulty.tla │ │ ├── MC4_4_faulty_drifted.tla │ │ ├── MC4_5_correct.tla │ │ ├── MC4_5_faulty.tla │ │ ├── MC4_6_faulty.tla │ │ ├── MC4_7_faulty.tla │ │ ├── MC5_5_correct.tla │ │ ├── MC5_5_correct_peer_two_thirds_faulty.tla │ │ ├── MC5_5_faulty.tla │ │ ├── MC5_5_faulty_peer_two_thirds_faulty.tla │ │ ├── MC5_7_faulty.tla │ │ ├── MC7_5_faulty.tla │ │ ├── MC7_7_faulty.tla │ │ ├── README.md │ │ ├── verification_001_published.md │ │ ├── verification_002_draft.md │ │ └── verification_003_draft.md ├── p2p │ ├── config.md │ ├── connection.md │ ├── messages │ │ ├── README.md │ │ ├── block-sync.md │ │ ├── consensus.md │ │ ├── evidence.md │ │ ├── mempool.md │ │ ├── pex.md │ │ └── state-sync.md │ ├── node.md │ ├── peer.md │ └── readme.md └── rpc │ └── README.md ├── state ├── errors.go ├── execution.go ├── execution_test.go ├── export_test.go ├── helpers_test.go ├── indexer │ ├── block.go │ ├── block │ │ ├── kv │ │ │ ├── kv.go │ │ │ ├── kv_test.go │ │ │ └── util.go │ │ └── null │ │ │ └── null.go │ ├── mocks │ │ └── block_indexer.go │ ├── query_range.go │ └── sink │ │ └── psql │ │ ├── backport.go │ │ ├── backport_test.go │ │ ├── psql.go │ │ ├── psql_test.go │ │ └── schema.sql ├── metrics.go ├── mocks │ ├── block_store.go │ ├── evidence_pool.go │ └── store.go ├── rollback.go ├── rollback_test.go ├── services.go ├── state.go ├── state_test.go ├── store.go ├── store_test.go ├── tx_filter.go ├── tx_filter_test.go ├── txindex │ ├── indexer.go │ ├── indexer_service.go │ ├── indexer_service_test.go │ ├── kv │ │ ├── kv.go │ │ ├── kv_bench_test.go │ │ ├── kv_test.go │ │ ├── utils.go │ │ └── utils_test.go │ ├── mocks │ │ └── tx_indexer.go │ └── null │ │ └── null.go ├── validation.go └── validation_test.go ├── statesync ├── chunks.go ├── chunks_test.go ├── messages.go ├── messages_test.go ├── mocks │ └── state_provider.go ├── reactor.go ├── reactor_test.go ├── snapshots.go ├── snapshots_test.go ├── stateprovider.go ├── syncer.go └── syncer_test.go ├── store ├── store.go └── store_test.go ├── test ├── README.md ├── app │ ├── clean.sh │ ├── counter_test.sh │ ├── grpc_client.go │ ├── kvstore_test.sh │ └── test.sh ├── docker │ ├── Dockerfile │ ├── build.sh │ └── config-template.toml ├── e2e │ ├── Makefile │ ├── README.md │ ├── app │ │ ├── app.go │ │ ├── snapshots.go │ │ └── state.go │ ├── docker │ │ ├── Dockerfile │ │ ├── entrypoint │ │ ├── entrypoint-builtin │ │ └── entrypoint-maverick │ ├── generator │ │ ├── generate.go │ │ ├── main.go │ │ ├── random.go │ │ └── random_test.go │ ├── networks │ │ ├── ci.toml │ │ ├── simple.toml │ │ └── single.toml │ ├── node │ │ ├── built-in.toml │ │ ├── config.go │ │ ├── main.go │ │ └── socket.toml │ ├── pkg │ │ ├── infra │ │ │ ├── docker │ │ │ │ └── docker.go │ │ │ └── provider.go │ │ ├── infrastructure.go │ │ ├── manifest.go │ │ └── testnet.go │ ├── run-multiple.sh │ ├── runner │ │ ├── benchmark.go │ │ ├── cleanup.go │ │ ├── exec.go │ │ ├── load.go │ │ ├── main.go │ │ ├── perturb.go │ │ ├── rpc.go │ │ ├── setup.go │ │ ├── start.go │ │ ├── test.go │ │ └── wait.go │ └── tests │ │ ├── app_test.go │ │ ├── block_test.go │ │ ├── e2e_test.go │ │ ├── evidence_test.go │ │ ├── net_test.go │ │ └── validator_test.go ├── fuzz │ ├── Makefile │ ├── README.md │ ├── mempool │ │ ├── v0 │ │ │ ├── checktx.go │ │ │ ├── fuzz_test.go │ │ │ └── testdata │ │ │ │ └── cases │ │ │ │ └── empty │ │ └── v1 │ │ │ ├── checktx.go │ │ │ ├── fuzz_test.go │ │ │ └── testdata │ │ │ └── cases │ │ │ └── empty │ ├── p2p │ │ ├── addrbook │ │ │ ├── fuzz.go │ │ │ └── init-corpus │ │ │ │ └── main.go │ │ ├── pex │ │ │ ├── init-corpus │ │ │ │ └── main.go │ │ │ ├── reactor_receive.go │ │ │ └── testdata │ │ │ │ └── addrbook1 │ │ └── secret_connection │ │ │ ├── init-corpus │ │ │ └── main.go │ │ │ └── read_write.go │ └── rpc │ │ └── jsonrpc │ │ └── server │ │ └── handler.go ├── loadtime │ ├── Makefile │ ├── README.md │ ├── basic.sh │ ├── cmd │ │ ├── load │ │ │ └── main.go │ │ └── report │ │ │ └── main.go │ ├── payload │ │ ├── payload.go │ │ ├── payload.pb.go │ │ ├── payload.proto │ │ └── payload_test.go │ └── report │ │ ├── report.go │ │ └── report_test.go ├── maverick │ ├── README.md │ ├── consensus │ │ ├── misbehavior.go │ │ ├── msgs.go │ │ ├── reactor.go │ │ ├── replay.go │ │ ├── replay_file.go │ │ ├── replay_stubs.go │ │ ├── state.go │ │ ├── ticker.go │ │ ├── wal.go │ │ └── wal_generator.go │ ├── main.go │ └── node │ │ ├── node.go │ │ └── privval.go └── test_cover.sh ├── tests.mk ├── third_party └── proto │ └── gogoproto │ └── gogo.proto ├── tools ├── README.md ├── mintnet-kubernetes │ ├── README.rst │ ├── app.template.yaml │ ├── assets │ │ ├── gce1.png │ │ ├── gce2.png │ │ ├── statefulset.png │ │ └── t_plus_k.png │ └── examples │ │ ├── counter │ │ ├── Makefile │ │ └── app.yaml │ │ └── dummy │ │ ├── Makefile │ │ ├── app.yaml │ │ ├── tm-monitor-pod.yaml │ │ └── transacter-pod.yaml ├── proto │ └── Dockerfile ├── tm-signer-harness │ ├── Dockerfile │ ├── Makefile │ ├── README.md │ ├── internal │ │ ├── test_harness.go │ │ ├── test_harness_test.go │ │ └── utils.go │ └── main.go └── tools.go ├── types ├── block.go ├── block_meta.go ├── block_meta_test.go ├── block_test.go ├── canonical.go ├── canonical_test.go ├── encoding_helper.go ├── errors.go ├── event_bus.go ├── event_bus_test.go ├── events.go ├── events_test.go ├── evidence.go ├── evidence_test.go ├── genesis.go ├── genesis_test.go ├── keys.go ├── light.go ├── light_test.go ├── params.go ├── params_test.go ├── part_set.go ├── part_set_test.go ├── priv_validator.go ├── proposal.go ├── proposal_test.go ├── protobuf.go ├── protobuf_test.go ├── results.go ├── results_test.go ├── signable.go ├── signed_msg_type.go ├── test_util.go ├── time │ ├── time.go │ └── time_test.go ├── tx.go ├── tx_test.go ├── utils.go ├── validation.go ├── validator.go ├── validator_set.go ├── validator_set_test.go ├── validator_test.go ├── vote.go ├── vote_set.go ├── vote_set_test.go └── vote_test.go └── version └── version.go /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Proto 3 | BasedOnStyle: Google 4 | IndentWidth: 2 5 | ColumnLimit: 0 6 | AlignConsecutiveAssignments: true 7 | AlignConsecutiveDeclarations: true 8 | SpacesInSquareBrackets: true 9 | ReflowComments: true 10 | SortIncludes: true 11 | SortUsingDeclarations: true 12 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | build 2 | test/e2e/build 3 | test/e2e/networks 4 | test/logs 5 | test/p2p/data 6 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | # Unix-style newlines with a newline ending every file 5 | [*] 6 | charset = utf-8 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.{sh,Makefile}] 12 | indent_style = tab 13 | 14 | [*.proto] 15 | indent_style = space 16 | indent_size = 2 17 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # CODEOWNERS: https://help.github.com/articles/about-codeowners/ 2 | 3 | # Everything goes through the following "global owners" by default. 4 | # Unless a later match takes precedence, these three will be 5 | # requested for review when someone opens a PR. 6 | # Note that the last matching pattern takes precedence, so 7 | # global owners are only requested if there isn't a more specific 8 | # codeowner specified below. For this reason, the global codeowners 9 | # are often repeated in package-level definitions. 10 | * @ebuchman @tendermint/tendermint-engineering @adizere @lasarojc 11 | 12 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | _Please add a description of the changes that this PR introduces and the files that 4 | are the most critical to review._ 5 | 6 | Closes: #XXX 7 | 8 | -------------------------------------------------------------------------------- /.github/auto-comment.yml: -------------------------------------------------------------------------------- 1 | pullRequestOpened: | 2 | :wave: Thanks for creating a PR! 3 | 4 | Before we can merge this PR, please make sure that all the following items have been 5 | checked off. If any of the checklist items are not applicable, please leave them but 6 | write a little note why. 7 | 8 | - [ ] Wrote tests 9 | - [ ] Updated CHANGELOG_PENDING.md 10 | - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. 11 | - [ ] Updated relevant documentation (`docs/`) and code comments 12 | - [ ] Re-reviewed `Files changed` in the Github PR explorer 13 | - [ ] Applied Appropriate Labels 14 | 15 | 16 | Thank you for your contribution to Tendermint! :rocket: -------------------------------------------------------------------------------- /.github/mergify.yml: -------------------------------------------------------------------------------- 1 | queue_rules: 2 | - name: default 3 | conditions: 4 | - base=v0.34.x 5 | - label=S:automerge 6 | 7 | pull_request_rules: 8 | - name: Automerge to v0.34.x 9 | conditions: 10 | - base=v0.34.x 11 | - label=S:automerge 12 | actions: 13 | queue: 14 | method: squash 15 | name: default 16 | commit_message_template: | 17 | {{ title }} (#{{ number }}) 18 | 19 | {{ body }} 20 | -------------------------------------------------------------------------------- /.github/workflows/linter.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | on: 3 | push: 4 | branches: 5 | - master 6 | paths: 7 | - "**.md" 8 | - "**.yml" 9 | - "**.yaml" 10 | pull_request: 11 | branches: [master] 12 | paths: 13 | - "**.md" 14 | - "**.yml" 15 | 16 | jobs: 17 | build: 18 | name: Super linter 19 | runs-on: ubuntu-latest 20 | steps: 21 | - name: Checkout Code 22 | uses: actions/checkout@v3 23 | - name: Lint Code Base 24 | uses: docker://github/super-linter:v3 25 | env: 26 | LINTER_RULES_PATH: . 27 | VALIDATE_ALL_CODEBASE: true 28 | DEFAULT_BRANCH: master 29 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 30 | VALIDATE_MD: true 31 | VALIDATE_OPENAPI: true 32 | VALIDATE_YAML: true 33 | -------------------------------------------------------------------------------- /.github/workflows/proto-lint.yml: -------------------------------------------------------------------------------- 1 | name: Protobuf Lint 2 | on: 3 | pull_request: 4 | paths: 5 | - 'proto/**' 6 | push: 7 | branches: 8 | - v0.34.x 9 | paths: 10 | - 'proto/**' 11 | 12 | jobs: 13 | lint: 14 | runs-on: ubuntu-latest 15 | timeout-minutes: 5 16 | steps: 17 | - uses: actions/checkout@v3 18 | - uses: bufbuild/buf-setup-action@v1.8.0 19 | - uses: bufbuild/buf-lint-action@v1 20 | with: 21 | input: 'proto' 22 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: "Close stale pull requests" 2 | on: 3 | schedule: 4 | - cron: "0 0 * * *" 5 | 6 | jobs: 7 | stale: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/stale@v6 11 | with: 12 | repo-token: ${{ secrets.GITHUB_TOKEN }} 13 | stale-pr-message: "This pull request has been automatically marked as stale because it has not had 14 | recent activity. It will be closed if no further activity occurs. Thank you 15 | for your contributions." 16 | days-before-stale: 10 17 | days-before-close: 4 18 | exempt-pr-labels: "S:wip" 19 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | linters: 2 | enable: 3 | - asciicheck 4 | - bodyclose 5 | - depguard 6 | - dogsled 7 | - dupl 8 | - errcheck 9 | - exportloopref 10 | - goconst 11 | - gofmt 12 | - goimports 13 | - revive 14 | - gosec 15 | - gosimple 16 | - govet 17 | - ineffassign 18 | - misspell 19 | - nakedret 20 | - nolintlint 21 | - prealloc 22 | - staticcheck 23 | # - structcheck // to be fixed by golangci-lint 24 | - stylecheck 25 | - typecheck 26 | - unconvert 27 | - unused 28 | 29 | issues: 30 | exclude-rules: 31 | - path: _test\.go 32 | linters: 33 | - gosec 34 | max-same-issues: 50 35 | 36 | linters-settings: 37 | dogsled: 38 | max-blank-identifiers: 3 39 | golint: 40 | min-confidence: 0 41 | maligned: 42 | suggest-new: true 43 | 44 | run: 45 | skip-files: 46 | - libs/pubsub/query/query.peg.go 47 | -------------------------------------------------------------------------------- /.goreleaser.yml: -------------------------------------------------------------------------------- 1 | project_name: tendermint 2 | 3 | env: 4 | # Require use of Go modules. 5 | - GO111MODULE=on 6 | 7 | builds: 8 | - id: "Tendermint" 9 | main: ./cmd/tendermint/main.go 10 | ldflags: 11 | - -s -w -X github.com/tendermint/tendermint/version.TMCoreSemVer={{ .Version }} 12 | env: 13 | - CGO_ENABLED=0 14 | goos: 15 | - darwin 16 | - linux 17 | - windows 18 | goarch: 19 | - amd64 20 | - arm 21 | - arm64 22 | 23 | checksum: 24 | name_template: SHA256SUMS-{{.Version}}.txt 25 | algorithm: sha256 26 | 27 | release: 28 | prerelease: auto 29 | name_template: "{{.Version}}" 30 | 31 | archives: 32 | - files: 33 | - LICENSE 34 | - README.md 35 | - UPGRADING.md 36 | - SECURITY.md 37 | - CHANGELOG.md 38 | -------------------------------------------------------------------------------- /.markdownlint.yml: -------------------------------------------------------------------------------- 1 | default: true 2 | MD001: false 3 | MD007: {indent: 4} 4 | MD013: false 5 | MD024: {siblings_only: true} 6 | MD025: false 7 | MD033: false 8 | MD036: false 9 | MD010: false 10 | MD012: false 11 | MD028: false 12 | -------------------------------------------------------------------------------- /.markdownlintignore: -------------------------------------------------------------------------------- 1 | docs/node_modules 2 | CHANGELOG.md 3 | docs/architecture/* 4 | crypto/secp256k1/** 5 | scripts/* 6 | .github 7 | -------------------------------------------------------------------------------- /.mergify.yml: -------------------------------------------------------------------------------- 1 | pull_request_rules: 2 | - name: Automerge to master 3 | conditions: 4 | - base=master 5 | - label=S:automerge 6 | actions: 7 | merge: 8 | method: squash 9 | strict: true 10 | commit_message: title+body 11 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "protoc": { 3 | "options": [ 4 | "--proto_path=${workspaceRoot}/proto", 5 | "--proto_path=${workspaceRoot}/third_party/proto" 6 | ] 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /CHANGELOG_PENDING.md: -------------------------------------------------------------------------------- 1 | # Unreleased Changes 2 | 3 | ## v0.34.25 4 | 5 | ### BREAKING CHANGES 6 | 7 | - CLI/RPC/Config 8 | 9 | - Apps 10 | 11 | - P2P Protocol 12 | 13 | - Go API 14 | 15 | - Blockchain Protocol 16 | 17 | ### FEATURES 18 | 19 | ### IMPROVEMENTS 20 | 21 | ### BUG FIXES 22 | 23 | -------------------------------------------------------------------------------- /DOCKER/.gitignore: -------------------------------------------------------------------------------- 1 | tendermint 2 | -------------------------------------------------------------------------------- /DOCKER/Dockerfile.build_c-amazonlinux: -------------------------------------------------------------------------------- 1 | FROM amazonlinux:2 2 | 3 | RUN yum -y update && \ 4 | yum -y install wget 5 | 6 | RUN wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \ 7 | rpm -ivh epel-release-latest-7.noarch.rpm 8 | 9 | RUN yum -y groupinstall "Development Tools" 10 | RUN yum -y install leveldb-devel which 11 | 12 | ENV GOVERSION=1.12.9 13 | 14 | RUN cd /tmp && \ 15 | wget https://dl.google.com/go/go${GOVERSION}.linux-amd64.tar.gz && \ 16 | tar -C /usr/local -xf go${GOVERSION}.linux-amd64.tar.gz && \ 17 | mkdir -p /go/src && \ 18 | mkdir -p /go/bin 19 | 20 | ENV PATH=$PATH:/usr/local/go/bin:/go/bin 21 | ENV GOBIN=/go/bin 22 | ENV GOPATH=/go/src 23 | 24 | RUN mkdir -p /tendermint 25 | WORKDIR /tendermint 26 | 27 | CMD ["/usr/bin/make", "build", "TENDERMINT_BUILD_OPTIONS=cleveldb"] 28 | 29 | -------------------------------------------------------------------------------- /DOCKER/Dockerfile.testing: -------------------------------------------------------------------------------- 1 | FROM golang:latest 2 | 3 | # Grab deps (jq, hexdump, xxd, killall) 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | jq bsdmainutils vim-common psmisc netcat 7 | 8 | # Add testing deps for curl 9 | RUN echo 'deb http://httpredir.debian.org/debian testing main non-free contrib' >> /etc/apt/sources.list && \ 10 | apt-get update && \ 11 | apt-get install -y --no-install-recommends curl 12 | 13 | VOLUME /go 14 | 15 | EXPOSE 26656 16 | EXPOSE 26657 17 | -------------------------------------------------------------------------------- /DOCKER/Makefile: -------------------------------------------------------------------------------- 1 | build: 2 | @sh -c "'$(CURDIR)/build.sh'" 3 | 4 | push: 5 | @sh -c "'$(CURDIR)/push.sh'" 6 | 7 | build_testing: 8 | docker build --tag tendermint/testing -f ./Dockerfile.testing . 9 | 10 | build_amazonlinux_buildimage: 11 | docker build -t "tendermint/tendermint:build_c-amazonlinux" -f Dockerfile.build_c-amazonlinux . 12 | 13 | .PHONY: build push build_testing build_amazonlinux_buildimage 14 | -------------------------------------------------------------------------------- /DOCKER/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # Get the tag from the version, or try to figure it out. 5 | if [ -z "$TAG" ]; then 6 | TAG=$(awk -F\" '/TMCoreSemVer =/ { print $2; exit }' < ../version/version.go) 7 | fi 8 | if [ -z "$TAG" ]; then 9 | echo "Please specify a tag." 10 | exit 1 11 | fi 12 | 13 | TAG_NO_PATCH=${TAG%.*} 14 | 15 | read -p "==> Build 3 docker images with the following tags (latest, $TAG, $TAG_NO_PATCH)? y/n" -n 1 -r 16 | echo 17 | if [[ $REPLY =~ ^[Yy]$ ]] 18 | then 19 | docker build -t "tendermint/tendermint" -t "tendermint/tendermint:$TAG" -t "tendermint/tendermint:$TAG_NO_PATCH" . 20 | fi 21 | -------------------------------------------------------------------------------- /DOCKER/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [ ! -d "$TMHOME/config" ]; then 5 | echo "Running tendermint init to create (default) configuration for docker run." 6 | tendermint init 7 | 8 | sed -i \ 9 | -e "s/^proxy_app\s*=.*/proxy_app = \"$PROXY_APP\"/" \ 10 | -e "s/^moniker\s*=.*/moniker = \"$MONIKER\"/" \ 11 | -e 's/^addr_book_strict\s*=.*/addr_book_strict = false/' \ 12 | -e 's/^timeout_commit\s*=.*/timeout_commit = "500ms"/' \ 13 | -e 's/^index_all_tags\s*=.*/index_all_tags = true/' \ 14 | -e 's,^laddr = "tcp://127.0.0.1:26657",laddr = "tcp://0.0.0.0:26657",' \ 15 | -e 's/^prometheus\s*=.*/prometheus = true/' \ 16 | "$TMHOME/config/config.toml" 17 | 18 | jq ".chain_id = \"$CHAIN_ID\" | .consensus_params.block.time_iota_ms = \"500\"" \ 19 | "$TMHOME/config/genesis.json" > "$TMHOME/config/genesis.json.new" 20 | mv "$TMHOME/config/genesis.json.new" "$TMHOME/config/genesis.json" 21 | fi 22 | 23 | exec tendermint "$@" 24 | -------------------------------------------------------------------------------- /DOCKER/push.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # Get the tag from the version, or try to figure it out. 5 | if [ -z "$TAG" ]; then 6 | TAG=$(awk -F\" '/TMCoreSemVer =/ { print $2; exit }' < ../version/version.go) 7 | fi 8 | if [ -z "$TAG" ]; then 9 | echo "Please specify a tag." 10 | exit 1 11 | fi 12 | 13 | TAG_NO_PATCH=${TAG%.*} 14 | 15 | read -p "==> Push 3 docker images with the following tags (latest, $TAG, $TAG_NO_PATCH)? y/n" -n 1 -r 16 | echo 17 | if [[ $REPLY =~ ^[Yy]$ ]] 18 | then 19 | docker push "tendermint/tendermint:latest" 20 | docker push "tendermint/tendermint:$TAG" 21 | docker push "tendermint/tendermint:$TAG_NO_PATCH" 22 | fi 23 | -------------------------------------------------------------------------------- /abci/cmd/abci-cli/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | ) 7 | 8 | func main() { 9 | err := Execute() 10 | if err != nil { 11 | fmt.Print(err) 12 | os.Exit(1) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /abci/example/code/code.go: -------------------------------------------------------------------------------- 1 | package code 2 | 3 | // Return codes for the examples 4 | const ( 5 | CodeTypeOK uint32 = 0 6 | CodeTypeEncodingError uint32 = 1 7 | CodeTypeBadNonce uint32 = 2 8 | CodeTypeUnauthorized uint32 = 3 9 | CodeTypeUnknownError uint32 = 4 10 | ) 11 | -------------------------------------------------------------------------------- /abci/example/example.go: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | // so the go tool doesn't return errors about no buildable go files ... 4 | -------------------------------------------------------------------------------- /abci/server/server.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package server is used to start a new ABCI server. 3 | 4 | It contains two server implementation: 5 | - gRPC server 6 | - socket server 7 | */ 8 | package server 9 | 10 | import ( 11 | "fmt" 12 | 13 | "github.com/tendermint/tendermint/abci/types" 14 | "github.com/tendermint/tendermint/libs/service" 15 | ) 16 | 17 | func NewServer(protoAddr, transport string, app types.Application) (service.Service, error) { 18 | var s service.Service 19 | var err error 20 | switch transport { 21 | case "socket": 22 | s = NewSocketServer(protoAddr, app) 23 | case "grpc": 24 | s = NewGRPCServer(protoAddr, types.NewGRPCApplication(app)) 25 | default: 26 | err = fmt.Errorf("unknown server type %s", transport) 27 | } 28 | return s, err 29 | } 30 | -------------------------------------------------------------------------------- /abci/tests/benchmarks/blank.go: -------------------------------------------------------------------------------- 1 | package benchmarks 2 | -------------------------------------------------------------------------------- /abci/tests/client_server_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | 8 | abciclient "github.com/tendermint/tendermint/abci/client" 9 | "github.com/tendermint/tendermint/abci/example/kvstore" 10 | abciserver "github.com/tendermint/tendermint/abci/server" 11 | ) 12 | 13 | func TestClientServerNoAddrPrefix(t *testing.T) { 14 | addr := "localhost:26658" 15 | transport := "socket" 16 | app := kvstore.NewApplication() 17 | 18 | server, err := abciserver.NewServer(addr, transport, app) 19 | assert.NoError(t, err, "expected no error on NewServer") 20 | err = server.Start() 21 | assert.NoError(t, err, "expected no error on server.Start") 22 | 23 | client, err := abciclient.NewClient(addr, transport, true) 24 | assert.NoError(t, err, "expected no error on NewClient") 25 | err = client.Start() 26 | assert.NoError(t, err, "expected no error on client.Start") 27 | } 28 | -------------------------------------------------------------------------------- /abci/tests/test_app/test.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | set -e 3 | 4 | # These tests spawn the counter app and server by execing the ABCI_APP command and run some simple client tests against it 5 | 6 | # Get the directory of where this script is. 7 | export PATH="$GOBIN:$PATH" 8 | SOURCE="${BASH_SOURCE[0]}" 9 | while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done 10 | DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" 11 | 12 | # Change into that dir because we expect that. 13 | cd "$DIR" 14 | 15 | echo "RUN COUNTER OVER SOCKET" 16 | # test golang counter 17 | ABCI_APP="counter" go run -mod=readonly ./*.go 18 | echo "----------------------" 19 | 20 | 21 | echo "RUN COUNTER OVER GRPC" 22 | # test golang counter via grpc 23 | ABCI_APP="counter --abci=grpc" ABCI="grpc" go run -mod=readonly ./*.go 24 | echo "----------------------" 25 | 26 | # test nodejs counter 27 | # TODO: fix node app 28 | #ABCI_APP="node $GOPATH/src/github.com/tendermint/js-abci/example/app.js" go test -test.run TestCounter 29 | -------------------------------------------------------------------------------- /abci/tests/test_cli/ex1.abci: -------------------------------------------------------------------------------- 1 | echo hello 2 | info 3 | commit 4 | deliver_tx "abc" 5 | info 6 | commit 7 | query "abc" 8 | deliver_tx "def=xyz" 9 | commit 10 | query "def" 11 | -------------------------------------------------------------------------------- /abci/tests/test_cli/ex1.abci.out: -------------------------------------------------------------------------------- 1 | > echo hello 2 | -> code: OK 3 | -> data: hello 4 | -> data.hex: 0x68656C6C6F 5 | 6 | > info 7 | -> code: OK 8 | -> data: {"size":0} 9 | -> data.hex: 0x7B2273697A65223A307D 10 | 11 | > commit 12 | -> code: OK 13 | -> data.hex: 0x0000000000000000 14 | 15 | > deliver_tx "abc" 16 | -> code: OK 17 | 18 | > info 19 | -> code: OK 20 | -> data: {"size":1} 21 | -> data.hex: 0x7B2273697A65223A317D 22 | 23 | > commit 24 | -> code: OK 25 | -> data.hex: 0x0200000000000000 26 | 27 | > query "abc" 28 | -> code: OK 29 | -> log: exists 30 | -> height: 2 31 | -> key: abc 32 | -> key.hex: 616263 33 | -> value: abc 34 | -> value.hex: 616263 35 | 36 | > deliver_tx "def=xyz" 37 | -> code: OK 38 | 39 | > commit 40 | -> code: OK 41 | -> data.hex: 0x0400000000000000 42 | 43 | > query "def" 44 | -> code: OK 45 | -> log: exists 46 | -> height: 3 47 | -> key: def 48 | -> key.hex: 646566 49 | -> value: xyz 50 | -> value.hex: 78797A 51 | 52 | -------------------------------------------------------------------------------- /abci/tests/test_cli/ex2.abci: -------------------------------------------------------------------------------- 1 | set_option serial on 2 | check_tx 0x00 3 | check_tx 0xff 4 | deliver_tx 0x00 5 | check_tx 0x00 6 | deliver_tx 0x01 7 | deliver_tx 0x04 8 | info 9 | -------------------------------------------------------------------------------- /abci/tests/test_cli/ex2.abci.out: -------------------------------------------------------------------------------- 1 | > set_option serial on 2 | -> code: OK 3 | -> log: OK (SetOption doesn't return anything.) 4 | 5 | > check_tx 0x00 6 | -> code: OK 7 | 8 | > check_tx 0xff 9 | -> code: OK 10 | 11 | > deliver_tx 0x00 12 | -> code: OK 13 | 14 | > check_tx 0x00 15 | -> code: 2 16 | -> log: Invalid nonce. Expected >= 1, got 0 17 | 18 | > deliver_tx 0x01 19 | -> code: OK 20 | 21 | > deliver_tx 0x04 22 | -> code: 2 23 | -> log: Invalid nonce. Expected 2, got 4 24 | 25 | > info 26 | -> code: OK 27 | -> data: {"hashes":0,"txs":2} 28 | -> data.hex: 0x7B22686173686573223A302C22747873223A327D 29 | 30 | -------------------------------------------------------------------------------- /abci/tests/test_cli/test.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | set -e 3 | 4 | # Get the root directory. 5 | export PATH="$GOBIN:$PATH" 6 | SOURCE="${BASH_SOURCE[0]}" 7 | while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done 8 | DIR="$( cd -P "$( dirname "$SOURCE" )/../.." && pwd )" 9 | 10 | # Change into that dir because we expect that. 11 | cd "$DIR" || exit 12 | 13 | function testExample() { 14 | N=$1 15 | INPUT=$2 16 | APP="$3 $4" 17 | 18 | echo "Example $N: $APP" 19 | $APP &> /dev/null & 20 | sleep 2 21 | abci-cli --log_level=error --verbose batch < "$INPUT" > "${INPUT}.out.new" 22 | killall "$3" 23 | 24 | pre=$(shasum < "${INPUT}.out") 25 | post=$(shasum < "${INPUT}.out.new") 26 | 27 | if [[ "$pre" != "$post" ]]; then 28 | echo "You broke the tutorial" 29 | echo "Got:" 30 | cat "${INPUT}.out.new" 31 | echo "Expected:" 32 | cat "${INPUT}.out" 33 | exit 1 34 | fi 35 | 36 | rm "${INPUT}".out.new 37 | } 38 | 39 | testExample 1 tests/test_cli/ex1.abci abci-cli kvstore 40 | testExample 2 tests/test_cli/ex2.abci abci-cli counter 41 | 42 | echo "" 43 | echo "PASS" 44 | -------------------------------------------------------------------------------- /abci/tests/tests.go: -------------------------------------------------------------------------------- 1 | package tests 2 | -------------------------------------------------------------------------------- /abci/types/pubkey.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | fmt "fmt" 5 | 6 | "github.com/tendermint/tendermint/crypto/ed25519" 7 | cryptoenc "github.com/tendermint/tendermint/crypto/encoding" 8 | "github.com/tendermint/tendermint/crypto/secp256k1" 9 | ) 10 | 11 | func Ed25519ValidatorUpdate(pk []byte, power int64) ValidatorUpdate { 12 | pke := ed25519.PubKey(pk) 13 | 14 | pkp, err := cryptoenc.PubKeyToProto(pke) 15 | if err != nil { 16 | panic(err) 17 | } 18 | 19 | return ValidatorUpdate{ 20 | // Address: 21 | PubKey: pkp, 22 | Power: power, 23 | } 24 | } 25 | 26 | func UpdateValidator(pk []byte, power int64, keyType string) ValidatorUpdate { 27 | switch keyType { 28 | case "", ed25519.KeyType: 29 | return Ed25519ValidatorUpdate(pk, power) 30 | case secp256k1.KeyType: 31 | pke := secp256k1.PubKey(pk) 32 | pkp, err := cryptoenc.PubKeyToProto(pke) 33 | if err != nil { 34 | panic(err) 35 | } 36 | return ValidatorUpdate{ 37 | // Address: 38 | PubKey: pkp, 39 | Power: power, 40 | } 41 | default: 42 | panic(fmt.Sprintf("key type %s not supported", keyType)) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /abci/types/util.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "sort" 5 | ) 6 | 7 | //------------------------------------------------------------------------------ 8 | 9 | // ValidatorUpdates is a list of validators that implements the Sort interface 10 | type ValidatorUpdates []ValidatorUpdate 11 | 12 | var _ sort.Interface = (ValidatorUpdates)(nil) 13 | 14 | // All these methods for ValidatorUpdates: 15 | // Len, Less and Swap 16 | // are for ValidatorUpdates to implement sort.Interface 17 | // which will be used by the sort package. 18 | // See Issue https://github.com/tendermint/abci/issues/212 19 | 20 | func (v ValidatorUpdates) Len() int { 21 | return len(v) 22 | } 23 | 24 | // XXX: doesn't distinguish same validator with different power 25 | func (v ValidatorUpdates) Less(i, j int) bool { 26 | return v[i].PubKey.Compare(v[j].PubKey) <= 0 27 | } 28 | 29 | func (v ValidatorUpdates) Swap(i, j int) { 30 | v[i], v[j] = v[j], v[i] 31 | } 32 | -------------------------------------------------------------------------------- /abci/version/version.go: -------------------------------------------------------------------------------- 1 | package version 2 | 3 | import ( 4 | "github.com/tendermint/tendermint/version" 5 | ) 6 | 7 | // TODO: eliminate this after some version refactor 8 | 9 | const Version = version.ABCIVersion 10 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | configuration: Release 3 | platform: 4 | - x64 5 | - x86 6 | clone_folder: c:\go\path\src\github.com\tendermint\tendermint 7 | before_build: 8 | - cmd: set GOPATH=%GOROOT%\path 9 | - cmd: set PATH=%GOPATH%\bin;%PATH% 10 | build_script: 11 | - cmd: make test 12 | test: off 13 | -------------------------------------------------------------------------------- /behaviour/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package Behaviour provides a mechanism for reactors to report behaviour of peers. 3 | 4 | Instead of a reactor calling the switch directly it will call the behaviour module which will 5 | handle the stoping and marking peer as good on behalf of the reactor. 6 | 7 | There are four different behaviours a reactor can report. 8 | 9 | 1. bad message 10 | 11 | type badMessage struct { 12 | explanation string 13 | } 14 | 15 | # This message will request the peer be stopped for an error 16 | 17 | 2. message out of order 18 | 19 | type messageOutOfOrder struct { 20 | explanation string 21 | } 22 | 23 | # This message will request the peer be stopped for an error 24 | 25 | 3. consesnsus Vote 26 | 27 | type consensusVote struct { 28 | explanation string 29 | } 30 | 31 | # This message will request the peer be marked as good 32 | 33 | 4. block part 34 | 35 | type blockPart struct { 36 | explanation string 37 | } 38 | 39 | This message will request the peer be marked as good 40 | */ 41 | package behaviour 42 | -------------------------------------------------------------------------------- /buf.gen.yaml: -------------------------------------------------------------------------------- 1 | version: v1 2 | plugins: 3 | - name: gogofaster 4 | out: ./proto/ 5 | opt: 6 | - Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types 7 | - Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration 8 | - plugins=grpc 9 | - paths=source_relative 10 | -------------------------------------------------------------------------------- /buf.work.yaml: -------------------------------------------------------------------------------- 1 | version: v1 2 | directories: 3 | - proto 4 | -------------------------------------------------------------------------------- /buf.yaml: -------------------------------------------------------------------------------- 1 | build: 2 | roots: 3 | - proto 4 | - third_party/proto 5 | lint: 6 | use: 7 | - BASIC 8 | - FILE_LOWER_SNAKE_CASE 9 | - UNARY_RPC 10 | ignore: 11 | - gogoproto 12 | breaking: 13 | use: 14 | - FILE 15 | -------------------------------------------------------------------------------- /cmd/tendermint/commands/debug/debug.go: -------------------------------------------------------------------------------- 1 | package debug 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/spf13/cobra" 7 | 8 | "github.com/tendermint/tendermint/libs/log" 9 | ) 10 | 11 | var ( 12 | nodeRPCAddr string 13 | profAddr string 14 | frequency uint 15 | 16 | flagNodeRPCAddr = "rpc-laddr" 17 | flagProfAddr = "pprof-laddr" 18 | flagFrequency = "frequency" 19 | 20 | logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout)) 21 | ) 22 | 23 | // DebugCmd defines the root command containing subcommands that assist in 24 | // debugging running Tendermint processes. 25 | var DebugCmd = &cobra.Command{ 26 | Use: "debug", 27 | Short: "A utility to kill or watch a Tendermint process while aggregating debugging data", 28 | } 29 | 30 | func init() { 31 | DebugCmd.PersistentFlags().SortFlags = true 32 | DebugCmd.PersistentFlags().StringVar( 33 | &nodeRPCAddr, 34 | flagNodeRPCAddr, 35 | "tcp://localhost:26657", 36 | "the Tendermint node's RPC address (<host>:<port>)", 37 | ) 38 | 39 | DebugCmd.AddCommand(killCmd) 40 | DebugCmd.AddCommand(dumpCmd) 41 | } 42 | -------------------------------------------------------------------------------- /cmd/tendermint/commands/gen_node_key.go: -------------------------------------------------------------------------------- 1 | package commands 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/spf13/cobra" 7 | 8 | tmos "github.com/tendermint/tendermint/libs/os" 9 | "github.com/tendermint/tendermint/p2p" 10 | ) 11 | 12 | // GenNodeKeyCmd allows the generation of a node key. It prints node's ID to 13 | // the standard output. 14 | var GenNodeKeyCmd = &cobra.Command{ 15 | Use: "gen-node-key", 16 | Aliases: []string{"gen_node_key"}, 17 | Short: "Generate a node key for this node and print its ID", 18 | PreRun: deprecateSnakeCase, 19 | RunE: genNodeKey, 20 | } 21 | 22 | func genNodeKey(cmd *cobra.Command, args []string) error { 23 | nodeKeyFile := config.NodeKeyFile() 24 | if tmos.FileExists(nodeKeyFile) { 25 | return fmt.Errorf("node key at %s already exists", nodeKeyFile) 26 | } 27 | 28 | nodeKey, err := p2p.LoadOrGenNodeKey(nodeKeyFile) 29 | if err != nil { 30 | return err 31 | } 32 | fmt.Println(nodeKey.ID()) 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /cmd/tendermint/commands/gen_validator.go: -------------------------------------------------------------------------------- 1 | package commands 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/spf13/cobra" 7 | 8 | tmjson "github.com/tendermint/tendermint/libs/json" 9 | "github.com/tendermint/tendermint/privval" 10 | ) 11 | 12 | // GenValidatorCmd allows the generation of a keypair for a 13 | // validator. 14 | var GenValidatorCmd = &cobra.Command{ 15 | Use: "gen-validator", 16 | Aliases: []string{"gen_validator"}, 17 | Short: "Generate new validator keypair", 18 | PreRun: deprecateSnakeCase, 19 | Run: genValidator, 20 | } 21 | 22 | func genValidator(cmd *cobra.Command, args []string) { 23 | pv := privval.GenFilePV("", "") 24 | jsbz, err := tmjson.Marshal(pv) 25 | if err != nil { 26 | panic(err) 27 | } 28 | fmt.Printf(`%v 29 | `, string(jsbz)) 30 | } 31 | -------------------------------------------------------------------------------- /cmd/tendermint/commands/probe_upnp.go: -------------------------------------------------------------------------------- 1 | package commands 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/spf13/cobra" 7 | 8 | tmjson "github.com/tendermint/tendermint/libs/json" 9 | "github.com/tendermint/tendermint/p2p/upnp" 10 | ) 11 | 12 | // ProbeUpnpCmd adds capabilities to test the UPnP functionality. 13 | var ProbeUpnpCmd = &cobra.Command{ 14 | Use: "probe-upnp", 15 | Aliases: []string{"probe_upnp"}, 16 | Short: "Test UPnP functionality", 17 | RunE: probeUpnp, 18 | PreRun: deprecateSnakeCase, 19 | } 20 | 21 | func probeUpnp(cmd *cobra.Command, args []string) error { 22 | capabilities, err := upnp.Probe(logger) 23 | if err != nil { 24 | fmt.Println("Probe failed: ", err) 25 | } else { 26 | fmt.Println("Probe success!") 27 | jsonBytes, err := tmjson.Marshal(capabilities) 28 | if err != nil { 29 | return err 30 | } 31 | fmt.Println(string(jsonBytes)) 32 | } 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /cmd/tendermint/commands/replay.go: -------------------------------------------------------------------------------- 1 | package commands 2 | 3 | import ( 4 | "github.com/spf13/cobra" 5 | 6 | "github.com/tendermint/tendermint/consensus" 7 | ) 8 | 9 | // ReplayCmd allows replaying of messages from the WAL. 10 | var ReplayCmd = &cobra.Command{ 11 | Use: "replay", 12 | Short: "Replay messages from WAL", 13 | Run: func(cmd *cobra.Command, args []string) { 14 | consensus.RunReplayFile(config.BaseConfig, config.Consensus, false) 15 | }, 16 | } 17 | 18 | // ReplayConsoleCmd allows replaying of messages from the WAL in a 19 | // console. 20 | var ReplayConsoleCmd = &cobra.Command{ 21 | Use: "replay-console", 22 | Aliases: []string{"replay_console"}, 23 | Short: "Replay messages from WAL in a console", 24 | Run: func(cmd *cobra.Command, args []string) { 25 | consensus.RunReplayFile(config.BaseConfig, config.Consensus, true) 26 | }, 27 | PreRun: deprecateSnakeCase, 28 | } 29 | -------------------------------------------------------------------------------- /cmd/tendermint/commands/show_node_id.go: -------------------------------------------------------------------------------- 1 | package commands 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/spf13/cobra" 7 | 8 | "github.com/tendermint/tendermint/p2p" 9 | ) 10 | 11 | // ShowNodeIDCmd dumps node's ID to the standard output. 12 | var ShowNodeIDCmd = &cobra.Command{ 13 | Use: "show-node-id", 14 | Aliases: []string{"show_node_id"}, 15 | Short: "Show this node's ID", 16 | RunE: showNodeID, 17 | PreRun: deprecateSnakeCase, 18 | } 19 | 20 | func showNodeID(cmd *cobra.Command, args []string) error { 21 | nodeKey, err := p2p.LoadNodeKey(config.NodeKeyFile()) 22 | if err != nil { 23 | return err 24 | } 25 | 26 | fmt.Println(nodeKey.ID()) 27 | return nil 28 | } 29 | -------------------------------------------------------------------------------- /cmd/tendermint/commands/version.go: -------------------------------------------------------------------------------- 1 | package commands 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/tendermint/tendermint/version" 10 | ) 11 | 12 | // VersionCmd ... 13 | var VersionCmd = &cobra.Command{ 14 | Use: "version", 15 | Short: "Show version info", 16 | Run: func(cmd *cobra.Command, args []string) { 17 | if verbose { 18 | values, _ := json.MarshalIndent(struct { 19 | Tendermint string `json:"tendermint"` 20 | ABCI string `json:"abci"` 21 | BlockProtocol uint64 `json:"block_protocol"` 22 | P2PProtocol uint64 `json:"p2p_protocol"` 23 | }{ 24 | Tendermint: version.TMCoreSemVer, 25 | ABCI: version.ABCIVersion, 26 | BlockProtocol: version.BlockProtocol, 27 | P2PProtocol: version.P2PProtocol, 28 | }, "", " ") 29 | fmt.Println(string(values)) 30 | } else { 31 | fmt.Println(version.TMCoreSemVer) 32 | } 33 | }, 34 | } 35 | 36 | func init() { 37 | VersionCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "Show protocol and library versions") 38 | } 39 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | precision: 2 3 | round: down 4 | range: "70...100" 5 | github_checks: 6 | annotations: false 7 | 8 | status: 9 | project: 10 | default: 11 | threshold: 1% 12 | patch: on 13 | changes: off 14 | 15 | comment: 16 | layout: "diff, files" 17 | behavior: default 18 | require_changes: no 19 | require_base: no 20 | require_head: yes 21 | 22 | ignore: 23 | - "docs" 24 | - "DOCKER" 25 | - "scripts" 26 | - "**/*.pb.go" 27 | - "libs/pubsub/query/query.peg.go" 28 | -------------------------------------------------------------------------------- /consensus/README.md: -------------------------------------------------------------------------------- 1 | # Consensus 2 | 3 | See the [consensus spec](https://github.com/tendermint/tendermint/tree/v0.34.x/spec/consensus) and the [reactor consensus spec](https://github.com/tendermint/tendermint/tree/v0.34.x/spec/reactors/consensus) for more information. 4 | -------------------------------------------------------------------------------- /consensus/wal_fuzz.go: -------------------------------------------------------------------------------- 1 | //go:build gofuzz 2 | // +build gofuzz 3 | 4 | package consensus 5 | 6 | import ( 7 | "bytes" 8 | "io" 9 | ) 10 | 11 | func Fuzz(data []byte) int { 12 | dec := NewWALDecoder(bytes.NewReader(data)) 13 | for { 14 | msg, err := dec.Decode() 15 | if err == io.EOF { 16 | break 17 | } 18 | if err != nil { 19 | if msg != nil { 20 | panic("msg != nil on error") 21 | } 22 | return 0 23 | } 24 | var w bytes.Buffer 25 | enc := NewWALEncoder(&w) 26 | err = enc.Encode(msg) 27 | if err != nil { 28 | panic(err) 29 | } 30 | } 31 | return 1 32 | } 33 | -------------------------------------------------------------------------------- /crypto/armor/armor.go: -------------------------------------------------------------------------------- 1 | package armor 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io" 7 | 8 | "golang.org/x/crypto/openpgp/armor" //nolint: staticcheck 9 | ) 10 | 11 | func EncodeArmor(blockType string, headers map[string]string, data []byte) string { 12 | buf := new(bytes.Buffer) 13 | w, err := armor.Encode(buf, blockType, headers) 14 | if err != nil { 15 | panic(fmt.Errorf("could not encode ascii armor: %s", err)) 16 | } 17 | _, err = w.Write(data) 18 | if err != nil { 19 | panic(fmt.Errorf("could not encode ascii armor: %s", err)) 20 | } 21 | err = w.Close() 22 | if err != nil { 23 | panic(fmt.Errorf("could not encode ascii armor: %s", err)) 24 | } 25 | return buf.String() 26 | } 27 | 28 | func DecodeArmor(armorStr string) (blockType string, headers map[string]string, data []byte, err error) { 29 | buf := bytes.NewBufferString(armorStr) 30 | block, err := armor.Decode(buf) 31 | if err != nil { 32 | return "", nil, nil, err 33 | } 34 | data, err = io.ReadAll(block.Body) 35 | if err != nil { 36 | return "", nil, nil, err 37 | } 38 | return block.Type, block.Header, data, nil 39 | } 40 | -------------------------------------------------------------------------------- /crypto/armor/armor_test.go: -------------------------------------------------------------------------------- 1 | package armor 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | "github.com/stretchr/testify/require" 8 | ) 9 | 10 | func TestArmor(t *testing.T) { 11 | blockType := "MINT TEST" 12 | data := []byte("somedata") 13 | armorStr := EncodeArmor(blockType, nil, data) 14 | 15 | // Decode armorStr and test for equivalence. 16 | blockType2, _, data2, err := DecodeArmor(armorStr) 17 | require.Nil(t, err, "%+v", err) 18 | assert.Equal(t, blockType, blockType2) 19 | assert.Equal(t, data, data2) 20 | } 21 | -------------------------------------------------------------------------------- /crypto/ed25519/bench_test.go: -------------------------------------------------------------------------------- 1 | package ed25519 2 | 3 | import ( 4 | "io" 5 | "testing" 6 | 7 | "github.com/tendermint/tendermint/crypto" 8 | "github.com/tendermint/tendermint/crypto/internal/benchmarking" 9 | ) 10 | 11 | func BenchmarkKeyGeneration(b *testing.B) { 12 | benchmarkKeygenWrapper := func(reader io.Reader) crypto.PrivKey { 13 | return genPrivKey(reader) 14 | } 15 | benchmarking.BenchmarkKeyGeneration(b, benchmarkKeygenWrapper) 16 | } 17 | 18 | func BenchmarkSigning(b *testing.B) { 19 | priv := GenPrivKey() 20 | benchmarking.BenchmarkSigning(b, priv) 21 | } 22 | 23 | func BenchmarkVerification(b *testing.B) { 24 | priv := GenPrivKey() 25 | benchmarking.BenchmarkVerification(b, priv) 26 | } 27 | -------------------------------------------------------------------------------- /crypto/ed25519/ed25519_test.go: -------------------------------------------------------------------------------- 1 | package ed25519_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | "github.com/stretchr/testify/require" 8 | 9 | "github.com/tendermint/tendermint/crypto" 10 | "github.com/tendermint/tendermint/crypto/ed25519" 11 | ) 12 | 13 | func TestSignAndValidateEd25519(t *testing.T) { 14 | 15 | privKey := ed25519.GenPrivKey() 16 | pubKey := privKey.PubKey() 17 | 18 | msg := crypto.CRandBytes(128) 19 | sig, err := privKey.Sign(msg) 20 | require.Nil(t, err) 21 | 22 | // Test the signature 23 | assert.True(t, pubKey.VerifySignature(msg, sig)) 24 | 25 | // Mutate the signature, just one bit. 26 | // TODO: Replace this with a much better fuzzer, tendermint/ed25519/issues/10 27 | sig[7] ^= byte(0x01) 28 | 29 | assert.False(t, pubKey.VerifySignature(msg, sig)) 30 | } 31 | -------------------------------------------------------------------------------- /crypto/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Tendermint. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package crypto_test 16 | 17 | import ( 18 | "fmt" 19 | 20 | "github.com/tendermint/tendermint/crypto" 21 | ) 22 | 23 | func ExampleSha256() { 24 | sum := crypto.Sha256([]byte("This is Tendermint")) 25 | fmt.Printf("%x\n", sum) 26 | // Output: 27 | // f91afb642f3d1c87c17eb01aae5cb65c242dfdbe7cf1066cc260f4ce5d33b94e 28 | } 29 | -------------------------------------------------------------------------------- /crypto/hash.go: -------------------------------------------------------------------------------- 1 | package crypto 2 | 3 | import ( 4 | "crypto/sha256" 5 | ) 6 | 7 | func Sha256(bytes []byte) []byte { 8 | hasher := sha256.New() 9 | hasher.Write(bytes) 10 | return hasher.Sum(nil) 11 | } 12 | -------------------------------------------------------------------------------- /crypto/merkle/README.md: -------------------------------------------------------------------------------- 1 | # Merkle Tree 2 | 3 | For smaller static data structures that don't require immutable snapshots or mutability; 4 | for instance the transactions and validation signatures of a block can be hashed using this simple merkle tree logic. 5 | -------------------------------------------------------------------------------- /crypto/merkle/hash.go: -------------------------------------------------------------------------------- 1 | package merkle 2 | 3 | import ( 4 | "github.com/tendermint/tendermint/crypto/tmhash" 5 | ) 6 | 7 | // TODO: make these have a large predefined capacity 8 | var ( 9 | leafPrefix = []byte{0} 10 | innerPrefix = []byte{1} 11 | ) 12 | 13 | // returns tmhash(<empty>) 14 | func emptyHash() []byte { 15 | return tmhash.Sum([]byte{}) 16 | } 17 | 18 | // returns tmhash(0x00 || leaf) 19 | func leafHash(leaf []byte) []byte { 20 | return tmhash.Sum(append(leafPrefix, leaf...)) 21 | } 22 | 23 | // returns tmhash(0x01 || left || right) 24 | func innerHash(left []byte, right []byte) []byte { 25 | return tmhash.Sum(append(innerPrefix, append(left, right...)...)) 26 | } 27 | -------------------------------------------------------------------------------- /crypto/random.go: -------------------------------------------------------------------------------- 1 | package crypto 2 | 3 | import ( 4 | crand "crypto/rand" 5 | "encoding/hex" 6 | "io" 7 | ) 8 | 9 | // This only uses the OS's randomness 10 | func randBytes(numBytes int) []byte { 11 | b := make([]byte, numBytes) 12 | _, err := crand.Read(b) 13 | if err != nil { 14 | panic(err) 15 | } 16 | return b 17 | } 18 | 19 | // This only uses the OS's randomness 20 | func CRandBytes(numBytes int) []byte { 21 | return randBytes(numBytes) 22 | } 23 | 24 | // CRandHex returns a hex encoded string that's floor(numDigits/2) * 2 long. 25 | // 26 | // Note: CRandHex(24) gives 96 bits of randomness that 27 | // are usually strong enough for most purposes. 28 | func CRandHex(numDigits int) string { 29 | return hex.EncodeToString(CRandBytes(numDigits / 2)) 30 | } 31 | 32 | // Returns a crand.Reader. 33 | func CReader() io.Reader { 34 | return crand.Reader 35 | } 36 | -------------------------------------------------------------------------------- /crypto/random_test.go: -------------------------------------------------------------------------------- 1 | package crypto_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | 8 | "github.com/tendermint/tendermint/crypto" 9 | ) 10 | 11 | // the purpose of this test is primarily to ensure that the randomness 12 | // generation won't error. 13 | func TestRandomConsistency(t *testing.T) { 14 | x1 := crypto.CRandBytes(256) 15 | x2 := crypto.CRandBytes(256) 16 | x3 := crypto.CRandBytes(256) 17 | x4 := crypto.CRandBytes(256) 18 | x5 := crypto.CRandBytes(256) 19 | require.NotEqual(t, x1, x2) 20 | require.NotEqual(t, x3, x4) 21 | require.NotEqual(t, x4, x5) 22 | require.NotEqual(t, x1, x5) 23 | } 24 | -------------------------------------------------------------------------------- /crypto/sr25519/bench_test.go: -------------------------------------------------------------------------------- 1 | package sr25519 2 | 3 | import ( 4 | "io" 5 | "testing" 6 | 7 | "github.com/tendermint/tendermint/crypto" 8 | "github.com/tendermint/tendermint/crypto/internal/benchmarking" 9 | ) 10 | 11 | func BenchmarkKeyGeneration(b *testing.B) { 12 | benchmarkKeygenWrapper := func(reader io.Reader) crypto.PrivKey { 13 | return genPrivKey(reader) 14 | } 15 | benchmarking.BenchmarkKeyGeneration(b, benchmarkKeygenWrapper) 16 | } 17 | 18 | func BenchmarkSigning(b *testing.B) { 19 | priv := GenPrivKey() 20 | benchmarking.BenchmarkSigning(b, priv) 21 | } 22 | 23 | func BenchmarkVerification(b *testing.B) { 24 | priv := GenPrivKey() 25 | benchmarking.BenchmarkVerification(b, priv) 26 | } 27 | -------------------------------------------------------------------------------- /crypto/sr25519/encoding.go: -------------------------------------------------------------------------------- 1 | package sr25519 2 | 3 | import ( 4 | "github.com/tendermint/tendermint/crypto" 5 | tmjson "github.com/tendermint/tendermint/libs/json" 6 | ) 7 | 8 | var _ crypto.PrivKey = PrivKey{} 9 | 10 | const ( 11 | PrivKeyName = "tendermint/PrivKeySr25519" 12 | PubKeyName = "tendermint/PubKeySr25519" 13 | 14 | // SignatureSize is the size of an Edwards25519 signature. Namely the size of a compressed 15 | // Sr25519 point, and a field element. Both of which are 32 bytes. 16 | SignatureSize = 64 17 | ) 18 | 19 | func init() { 20 | 21 | tmjson.RegisterType(PubKey{}, PubKeyName) 22 | tmjson.RegisterType(PrivKey{}, PrivKeyName) 23 | } 24 | -------------------------------------------------------------------------------- /crypto/sr25519/sr25519_test.go: -------------------------------------------------------------------------------- 1 | package sr25519_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | "github.com/stretchr/testify/require" 8 | 9 | "github.com/tendermint/tendermint/crypto" 10 | "github.com/tendermint/tendermint/crypto/sr25519" 11 | ) 12 | 13 | func TestSignAndValidateSr25519(t *testing.T) { 14 | 15 | privKey := sr25519.GenPrivKey() 16 | pubKey := privKey.PubKey() 17 | 18 | msg := crypto.CRandBytes(128) 19 | sig, err := privKey.Sign(msg) 20 | require.Nil(t, err) 21 | 22 | // Test the signature 23 | assert.True(t, pubKey.VerifySignature(msg, sig)) 24 | assert.True(t, pubKey.VerifySignature(msg, sig)) 25 | 26 | // Mutate the signature, just one bit. 27 | // TODO: Replace this with a much better fuzzer, tendermint/ed25519/issues/10 28 | sig[7] ^= byte(0x01) 29 | 30 | assert.False(t, pubKey.VerifySignature(msg, sig)) 31 | } 32 | -------------------------------------------------------------------------------- /crypto/version.go: -------------------------------------------------------------------------------- 1 | package crypto 2 | 3 | const Version = "0.9.0-dev" 4 | -------------------------------------------------------------------------------- /docs/.textlintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "stop-words": { 4 | "severity": "warning", 5 | "defaultWords": false, 6 | "words": "stop-words.txt" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /docs/.vuepress/styles/index.styl: -------------------------------------------------------------------------------- 1 | :root 2 | --color-link #018A01 3 | --color-primary #00BB00 4 | -------------------------------------------------------------------------------- /docs/app-dev/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | order: false 3 | parent: 4 | order: 3 5 | --- 6 | 7 | # Apps 8 | -------------------------------------------------------------------------------- /docs/imgs/abci.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/imgs/abci.png -------------------------------------------------------------------------------- /docs/imgs/bifurcation-point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/imgs/bifurcation-point.png -------------------------------------------------------------------------------- /docs/imgs/consensus_logic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/imgs/consensus_logic.png -------------------------------------------------------------------------------- /docs/imgs/contributing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/imgs/contributing.png -------------------------------------------------------------------------------- /docs/imgs/cosmos-tendermint-stack-4k.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/imgs/cosmos-tendermint-stack-4k.jpg -------------------------------------------------------------------------------- /docs/imgs/evidence_lifecycle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/imgs/evidence_lifecycle.png -------------------------------------------------------------------------------- /docs/imgs/light-client-detector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/imgs/light-client-detector.png -------------------------------------------------------------------------------- /docs/imgs/light_client_bisection_alg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/imgs/light_client_bisection_alg.png -------------------------------------------------------------------------------- /docs/imgs/tcp-window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/imgs/tcp-window.png -------------------------------------------------------------------------------- /docs/imgs/tm-amnesia-attack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/imgs/tm-amnesia-attack.png -------------------------------------------------------------------------------- /docs/imgs/tm-application-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/imgs/tm-application-example.png -------------------------------------------------------------------------------- /docs/imgs/tm-transaction-flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/imgs/tm-transaction-flow.png -------------------------------------------------------------------------------- /docs/imgs/tmint-logo-blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/imgs/tmint-logo-blue.png -------------------------------------------------------------------------------- /docs/introduction/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | order: false 3 | parent: 4 | title: Introduction 5 | order: 1 6 | --- 7 | 8 | # Overview 9 | 10 | ## Quick Start 11 | 12 | Get Tendermint up-and-running quickly with the [quick-start guide](./quick-start.md)! 13 | 14 | ## Install 15 | 16 | Detailed [installation instructions](./install.md). 17 | 18 | ## What is Tendermint 19 | 20 | Dive into [what Tendermint is and why](./what-is-tendermint.md)! 21 | -------------------------------------------------------------------------------- /docs/networks/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | order: 1 3 | parent: 4 | title: Networks 5 | order: 5 6 | --- 7 | 8 | # Overview 9 | 10 | Use [Docker Compose](./docker-compose.md) to spin up Tendermint testnets on your 11 | local machine. 12 | 13 | Use [Terraform and Ansible](./terraform-and-ansible.md) to deploy Tendermint 14 | testnets to the cloud. 15 | 16 | See the `tendermint testnet --help` command for more help initializing testnets. 17 | -------------------------------------------------------------------------------- /docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docs", 3 | "version": "1.0.0", 4 | "description": "Tendermint Core Documentation", 5 | "main": "index.js", 6 | "dependencies": { 7 | "vuepress-theme-cosmos": "^1.0.183" 8 | }, 9 | "devDependencies": { 10 | "@vuepress/plugin-html-redirect": "^0.1.4", 11 | "watchpack": "^2.3.1" 12 | }, 13 | "scripts": { 14 | "preserve": "./pre.sh", 15 | "serve": "trap 'exit 0' SIGINT; vuepress dev --no-cache", 16 | "postserve": "./post.sh", 17 | "prebuild": "./pre.sh", 18 | "build": "trap 'exit 0' SIGINT; vuepress build --no-cache", 19 | "postbuild": "./post.sh" 20 | }, 21 | "author": "", 22 | "license": "ISC" 23 | } 24 | -------------------------------------------------------------------------------- /docs/post.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rm -rf ./.vuepress/public/rpc 4 | -------------------------------------------------------------------------------- /docs/pre.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cp -a ../rpc/openapi/ .vuepress/public/rpc/ 4 | -------------------------------------------------------------------------------- /docs/qa/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | order: 1 3 | parent: 4 | title: Tendermint Quality Assurance 5 | description: This is a report on the process followed and results obtained when running v0.34.x on testnets 6 | order: 2 7 | --- 8 | 9 | # Tendermint Quality Assurance 10 | 11 | This directory keeps track of the process followed by the Tendermint Core team 12 | for Quality Assurance before cutting a release. 13 | This directory is to live in multiple branches. On each release branch, 14 | the contents of this directory reflect the status of the process 15 | at the time the Quality Assurance process was applied for that release. 16 | 17 | File [method](./method.md) keeps track of the process followed to obtain the results 18 | used to decide if a release is passing the Quality Assurance process. 19 | The results obtained in each release are stored in their own directory. 20 | The following releases have undergone the Quality Assurance process: 21 | 22 | * [v0.34.x](./v034/), which was tested just before releasing v0.34.22 23 | -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_200node_latencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_200node_latencies.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_200node_latencies_zoomed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_200node_latencies_zoomed.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_latency_throughput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_latency_throughput.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_r200c2_heights.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_r200c2_heights.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_r200c2_load-runner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_r200c2_load-runner.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_r200c2_load1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_r200c2_load1.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_r200c2_mempool_size.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_r200c2_mempool_size.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_r200c2_mempool_size_avg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_r200c2_mempool_size_avg.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_r200c2_peers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_r200c2_peers.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_r200c2_rounds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_r200c2_rounds.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_r200c2_rss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_r200c2_rss.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_r200c2_rss_avg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_r200c2_rss_avg.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_r200c2_total-txs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_r200c2_total-txs.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_rotating_heights.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_rotating_heights.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_rotating_heights_ephe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_rotating_heights_ephe.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_rotating_latencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_rotating_latencies.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_rotating_latencies_uniq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_rotating_latencies_uniq.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_rotating_load1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_rotating_load1.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_rotating_peers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_rotating_peers.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_rotating_rss_avg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_rotating_rss_avg.png -------------------------------------------------------------------------------- /docs/qa/v034/img/v034_rotating_total-txs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/qa/v034/img/v034_rotating_total-txs.png -------------------------------------------------------------------------------- /docs/stop-words.txt: -------------------------------------------------------------------------------- 1 | investor 2 | invest 3 | investing 4 | token distribution 5 | atom distribution 6 | distribution of atoms 7 | -------------------------------------------------------------------------------- /docs/tendermint-core-image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/tendermint-core-image.jpg -------------------------------------------------------------------------------- /docs/tendermint-core/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | order: 1 3 | parent: 4 | title: Tendermint Core 5 | order: 4 6 | --- 7 | 8 | # Overview 9 | 10 | This section dives into the internals of Tendermint the implementation. 11 | 12 | - [Using Tendermint](./using-tendermint.md) 13 | - [Configuration](./configuration.md) 14 | - [Running in Production](./running-in-production.md) 15 | - [Metrics](./metrics.md) 16 | - [Validators](./validators.md) 17 | - [Subscribing to events](./subscription.md) 18 | - [Block Structure](./block-structure.md) 19 | - [RPC](./rpc.md) 20 | - [Fast Sync](./fast-sync.md) 21 | - [State Sync](./state-sync.md) 22 | - [Mempool](./mempool.md) 23 | - [Light Client](./light-client.md) 24 | -------------------------------------------------------------------------------- /docs/tendermint-core/block-structure.md: -------------------------------------------------------------------------------- 1 | --- 2 | order: 8 3 | --- 4 | 5 | # Block Structure 6 | 7 | The Tendermint consensus engine records all agreements by a 8 | supermajority of nodes into a blockchain, which is replicated among all 9 | nodes. This blockchain is accessible via various RPC endpoints, mainly 10 | `/block?height=` to get the full block, as well as 11 | `/blockchain?minHeight=_&maxHeight=_` to get a list of headers. But what 12 | exactly is stored in these blocks? 13 | 14 | The [specification](https://github.com/tendermint/spec/blob/8dd2ed4c6fe12459edeb9b783bdaaaeb590ec15c/spec/core/data_structures.md) contains a detailed description of each component - that's the best place to get started. 15 | 16 | To dig deeper, check out the [types package documentation](https://godoc.org/github.com/tendermint/tendermint/types). 17 | -------------------------------------------------------------------------------- /docs/tendermint-core/local_config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/tendermint-core/local_config.png -------------------------------------------------------------------------------- /docs/tendermint-core/rpc.md: -------------------------------------------------------------------------------- 1 | --- 2 | order: 9 3 | --- 4 | 5 | # RPC 6 | 7 | The RPC documentation is hosted here: 8 | 9 | - [https://docs.tendermint.com/v0.34/rpc/](https://docs.tendermint.com/v0.34/rpc/) 10 | 11 | To update the documentation, edit the relevant `godoc` comments in the [rpc/core directory](https://github.com/tendermint/tendermint/blob/v0.34.x/rpc/core). 12 | -------------------------------------------------------------------------------- /docs/tendermint-core/sentry_layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/docs/tendermint-core/sentry_layout.png -------------------------------------------------------------------------------- /docs/tools/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | order: 1 3 | parent: 4 | title: Tools 5 | order: 6 6 | --- 7 | 8 | # Overview 9 | 10 | Tendermint has some tools that are associated with it for: 11 | 12 | - [Debugging](./debugging.md) 13 | - [Benchmarking](#benchmarking) 14 | - [Testnets](#testnets) 15 | - [Validation of remote signers](./remote-signer-validation.md) 16 | 17 | ## Benchmarking 18 | 19 | - <https://github.com/informalsystems/tm-load-test> 20 | 21 | `tm-load-test` is a distributed load testing tool (and framework) for load 22 | testing Tendermint networks. 23 | 24 | ## Testnets 25 | 26 | - <https://github.com/informalsystems/testnets> 27 | 28 | This repository contains various different configurations of test networks for, 29 | and relating to, Tendermint. 30 | -------------------------------------------------------------------------------- /docs/tutorials/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | order: false 3 | parent: 4 | order: 2 5 | --- 6 | 7 | # Guides 8 | -------------------------------------------------------------------------------- /docs/versions: -------------------------------------------------------------------------------- 1 | main main 2 | v0.33.x v0.33 3 | v0.34.x v0.34 4 | -------------------------------------------------------------------------------- /dredd.yml: -------------------------------------------------------------------------------- 1 | color: true 2 | dry-run: null 3 | hookfiles: build/contract_tests 4 | language: go 5 | require: null 6 | server: make localnet-start 7 | server-wait: 30 8 | init: false 9 | custom: {} 10 | names: false 11 | only: [] 12 | reporter: [] 13 | output: [] 14 | header: [] 15 | sorted: false 16 | user: null 17 | inline-errors: false 18 | details: false 19 | method: [GET] 20 | loglevel: warning 21 | path: [] 22 | hooks-worker-timeout: 5000 23 | hooks-worker-connect-timeout: 1500 24 | hooks-worker-connect-retry: 500 25 | hooks-worker-after-connect-wait: 100 26 | hooks-worker-term-timeout: 5000 27 | hooks-worker-term-retry: 500 28 | hooks-worker-handler-host: 127.0.0.1 29 | hooks-worker-handler-port: 61321 30 | config: ./dredd.yml 31 | # This path accepts no variables 32 | blueprint: ./rpc/openapi/openapi.yaml 33 | endpoint: "http://127.0.0.1:26657/" 34 | -------------------------------------------------------------------------------- /evidence/services.go: -------------------------------------------------------------------------------- 1 | package evidence 2 | 3 | import ( 4 | "github.com/tendermint/tendermint/types" 5 | ) 6 | 7 | //go:generate ../scripts/mockery_generate.sh BlockStore 8 | 9 | type BlockStore interface { 10 | LoadBlockMeta(height int64) *types.BlockMeta 11 | LoadBlockCommit(height int64) *types.Commit 12 | Height() int64 13 | } 14 | -------------------------------------------------------------------------------- /libs/autofile/README.md: -------------------------------------------------------------------------------- 1 | # go-autofile 2 | -------------------------------------------------------------------------------- /libs/bytes/byteslice.go: -------------------------------------------------------------------------------- 1 | package bytes 2 | 3 | // Fingerprint returns the first 6 bytes of a byte slice. 4 | // If the slice is less than 6 bytes, the fingerprint 5 | // contains trailing zeroes. 6 | func Fingerprint(slice []byte) []byte { 7 | fingerprint := make([]byte, 6) 8 | copy(fingerprint, slice) 9 | return fingerprint 10 | } 11 | -------------------------------------------------------------------------------- /libs/clist/bench_test.go: -------------------------------------------------------------------------------- 1 | package clist 2 | 3 | import "testing" 4 | 5 | func BenchmarkDetaching(b *testing.B) { 6 | lst := New() 7 | for i := 0; i < b.N+1; i++ { 8 | lst.PushBack(i) 9 | } 10 | start := lst.Front() 11 | nxt := start.Next() 12 | b.ResetTimer() 13 | for i := 0; i < b.N; i++ { 14 | start.removed = true 15 | start.DetachNext() 16 | start.DetachPrev() 17 | tmp := nxt 18 | nxt = nxt.Next() 19 | start = tmp 20 | } 21 | } 22 | 23 | // This is used to benchmark the time of RMutex. 24 | func BenchmarkRemoved(b *testing.B) { 25 | lst := New() 26 | for i := 0; i < b.N+1; i++ { 27 | lst.PushBack(i) 28 | } 29 | start := lst.Front() 30 | nxt := start.Next() 31 | b.ResetTimer() 32 | for i := 0; i < b.N; i++ { 33 | start.Removed() 34 | tmp := nxt 35 | nxt = nxt.Next() 36 | start = tmp 37 | } 38 | } 39 | 40 | func BenchmarkPushBack(b *testing.B) { 41 | lst := New() 42 | b.ResetTimer() 43 | for i := 0; i < b.N; i++ { 44 | lst.PushBack(i) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /libs/events/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: docs 2 | REPO:=github.com/tendermint/tendermint/libs/events 3 | 4 | docs: 5 | @go get github.com/davecheney/godoc2md 6 | godoc2md $(REPO) > README.md 7 | 8 | test: 9 | go test -v ./... 10 | -------------------------------------------------------------------------------- /libs/fail/fail.go: -------------------------------------------------------------------------------- 1 | package fail 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "strconv" 7 | ) 8 | 9 | func envSet() int { 10 | callIndexToFailS := os.Getenv("FAIL_TEST_INDEX") 11 | 12 | if callIndexToFailS == "" { 13 | return -1 14 | } 15 | 16 | var err error 17 | callIndexToFail, err := strconv.Atoi(callIndexToFailS) 18 | if err != nil { 19 | return -1 20 | } 21 | 22 | return callIndexToFail 23 | } 24 | 25 | // Fail when FAIL_TEST_INDEX == callIndex 26 | var callIndex int // indexes Fail calls 27 | 28 | func Fail() { 29 | callIndexToFail := envSet() 30 | if callIndexToFail < 0 { 31 | return 32 | } 33 | 34 | if callIndex == callIndexToFail { 35 | Exit() 36 | } 37 | 38 | callIndex++ 39 | } 40 | 41 | func Exit() { 42 | fmt.Printf("*** fail-test %d ***\n", callIndex) 43 | os.Exit(1) 44 | // proc, _ := os.FindProcess(os.Getpid()) 45 | // proc.Signal(os.Interrupt) 46 | // panic(fmt.Sprintf("*** fail-test %d ***", callIndex)) 47 | } 48 | -------------------------------------------------------------------------------- /libs/flowrate/README.md: -------------------------------------------------------------------------------- 1 | Data Flow Rate Control 2 | ====================== 3 | 4 | To download and install this package run: 5 | 6 | go get github.com/mxk/go-flowrate/flowrate 7 | 8 | The documentation is available at: 9 | 10 | <http://godoc.org/github.com/mxk/go-flowrate/flowrate> 11 | -------------------------------------------------------------------------------- /libs/log/logger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "io" 5 | 6 | kitlog "github.com/go-kit/log" 7 | ) 8 | 9 | // Logger is what any Tendermint library should take. 10 | type Logger interface { 11 | Debug(msg string, keyvals ...interface{}) 12 | Info(msg string, keyvals ...interface{}) 13 | Error(msg string, keyvals ...interface{}) 14 | 15 | With(keyvals ...interface{}) Logger 16 | } 17 | 18 | // NewSyncWriter returns a new writer that is safe for concurrent use by 19 | // multiple goroutines. Writes to the returned writer are passed on to w. If 20 | // another write is already in progress, the calling goroutine blocks until 21 | // the writer is available. 22 | // 23 | // If w implements the following interface, so does the returned writer. 24 | // 25 | // interface { 26 | // Fd() uintptr 27 | // } 28 | func NewSyncWriter(w io.Writer) io.Writer { 29 | return kitlog.NewSyncWriter(w) 30 | } 31 | -------------------------------------------------------------------------------- /libs/log/nop_logger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | type nopLogger struct{} 4 | 5 | // Interface assertions 6 | var _ Logger = (*nopLogger)(nil) 7 | 8 | // NewNopLogger returns a logger that doesn't do anything. 9 | func NewNopLogger() Logger { return &nopLogger{} } 10 | 11 | func (nopLogger) Info(string, ...interface{}) {} 12 | func (nopLogger) Debug(string, ...interface{}) {} 13 | func (nopLogger) Error(string, ...interface{}) {} 14 | 15 | func (l *nopLogger) With(...interface{}) Logger { 16 | return l 17 | } 18 | -------------------------------------------------------------------------------- /libs/log/tm_json_logger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "io" 5 | 6 | kitlog "github.com/go-kit/log" 7 | ) 8 | 9 | // NewTMJSONLogger returns a Logger that encodes keyvals to the Writer as a 10 | // single JSON object. Each log event produces no more than one call to 11 | // w.Write. The passed Writer must be safe for concurrent use by multiple 12 | // goroutines if the returned Logger will be used concurrently. 13 | func NewTMJSONLogger(w io.Writer) Logger { 14 | logger := kitlog.NewJSONLogger(w) 15 | logger = kitlog.With(logger, "ts", kitlog.DefaultTimestampUTC) 16 | return &tmLogger{logger} 17 | } 18 | 19 | // NewTMJSONLoggerNoTS is the same as NewTMJSONLogger, but without the 20 | // timestamp. 21 | func NewTMJSONLoggerNoTS(w io.Writer) Logger { 22 | logger := kitlog.NewJSONLogger(w) 23 | return &tmLogger{logger} 24 | } 25 | -------------------------------------------------------------------------------- /libs/math/math.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | func MaxInt64(a, b int64) int64 { 4 | if a > b { 5 | return a 6 | } 7 | return b 8 | } 9 | 10 | func MaxInt(a, b int) int { 11 | if a > b { 12 | return a 13 | } 14 | return b 15 | } 16 | 17 | //----------------------------------------------------------------------------- 18 | 19 | func MinInt64(a, b int64) int64 { 20 | if a < b { 21 | return a 22 | } 23 | return b 24 | } 25 | 26 | func MinInt(a, b int) int { 27 | if a < b { 28 | return a 29 | } 30 | return b 31 | } 32 | -------------------------------------------------------------------------------- /libs/net/net_test.go: -------------------------------------------------------------------------------- 1 | package net 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func TestProtocolAndAddress(t *testing.T) { 10 | 11 | cases := []struct { 12 | fullAddr string 13 | proto string 14 | addr string 15 | }{ 16 | { 17 | "tcp://mydomain:80", 18 | "tcp", 19 | "mydomain:80", 20 | }, 21 | { 22 | "mydomain:80", 23 | "tcp", 24 | "mydomain:80", 25 | }, 26 | { 27 | "unix://mydomain:80", 28 | "unix", 29 | "mydomain:80", 30 | }, 31 | } 32 | 33 | for _, c := range cases { 34 | proto, addr := ProtocolAndAddress(c.fullAddr) 35 | assert.Equal(t, proto, c.proto) 36 | assert.Equal(t, addr, c.addr) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /libs/progressbar/progressbar_test.go: -------------------------------------------------------------------------------- 1 | package progressbar 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | 7 | "github.com/stretchr/testify/require" 8 | ) 9 | 10 | func TestProgressBar(t *testing.T) { 11 | zero := int64(0) 12 | hundred := int64(100) 13 | 14 | var bar Bar 15 | bar.NewOption(zero, hundred) 16 | 17 | require.Equal(t, zero, bar.start) 18 | require.Equal(t, zero, bar.cur) 19 | require.Equal(t, hundred, bar.total) 20 | require.Equal(t, zero, bar.percent) 21 | require.Equal(t, "█", bar.graph) 22 | require.Equal(t, "", bar.rate) 23 | 24 | defer bar.Finish() 25 | for i := zero; i <= hundred; i++ { 26 | time.Sleep(1 * time.Millisecond) 27 | bar.Play(i) 28 | } 29 | 30 | require.Equal(t, zero, bar.start) 31 | require.Equal(t, hundred, bar.cur) 32 | require.Equal(t, hundred, bar.total) 33 | require.Equal(t, hundred, bar.percent) 34 | 35 | var rate string 36 | for i := zero; i < hundred/2; i++ { 37 | rate += "█" 38 | } 39 | 40 | require.Equal(t, rate, bar.rate) 41 | } 42 | -------------------------------------------------------------------------------- /libs/pubsub/example_test.go: -------------------------------------------------------------------------------- 1 | package pubsub_test 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/require" 8 | 9 | "github.com/tendermint/tendermint/libs/log" 10 | 11 | "github.com/tendermint/tendermint/libs/pubsub" 12 | "github.com/tendermint/tendermint/libs/pubsub/query" 13 | ) 14 | 15 | func TestExample(t *testing.T) { 16 | s := pubsub.NewServer() 17 | s.SetLogger(log.TestingLogger()) 18 | err := s.Start() 19 | require.NoError(t, err) 20 | t.Cleanup(func() { 21 | if err := s.Stop(); err != nil { 22 | t.Error(err) 23 | } 24 | }) 25 | 26 | ctx := context.Background() 27 | subscription, err := s.Subscribe(ctx, "example-client", query.MustParse("abci.account.name='John'")) 28 | require.NoError(t, err) 29 | err = s.PublishWithEvents(ctx, "Tombstone", map[string][]string{"abci.account.name": {"John"}}) 30 | require.NoError(t, err) 31 | assertReceive(t, "Tombstone", subscription.Out()) 32 | } 33 | -------------------------------------------------------------------------------- /libs/pubsub/query/Makefile: -------------------------------------------------------------------------------- 1 | gen_query_parser: 2 | go get -u -v github.com/pointlander/peg 3 | peg -inline -switch query.peg 4 | 5 | fuzzy_test: 6 | go get -u -v github.com/dvyukov/go-fuzz/go-fuzz 7 | go get -u -v github.com/dvyukov/go-fuzz/go-fuzz-build 8 | go-fuzz-build github.com/tendermint/tendermint/libs/pubsub/query/fuzz_test 9 | go-fuzz -bin=./fuzz_test-fuzz.zip -workdir=./fuzz_test/output 10 | 11 | .PHONY: gen_query_parser fuzzy_test 12 | -------------------------------------------------------------------------------- /libs/pubsub/query/empty.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | // Empty query matches any set of events. 4 | type Empty struct { 5 | } 6 | 7 | // Matches always returns true. 8 | func (Empty) Matches(tags map[string][]string) (bool, error) { 9 | return true, nil 10 | } 11 | 12 | func (Empty) String() string { 13 | return "empty" 14 | } 15 | -------------------------------------------------------------------------------- /libs/pubsub/query/empty_test.go: -------------------------------------------------------------------------------- 1 | package query_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | 8 | "github.com/tendermint/tendermint/libs/pubsub/query" 9 | ) 10 | 11 | func TestEmptyQueryMatchesAnything(t *testing.T) { 12 | q := query.Empty{} 13 | 14 | testCases := []struct { 15 | query map[string][]string 16 | }{ 17 | {map[string][]string{}}, 18 | {map[string][]string{"Asher": {"Roth"}}}, 19 | {map[string][]string{"Route": {"66"}}}, 20 | {map[string][]string{"Route": {"66"}, "Billy": {"Blue"}}}, 21 | } 22 | 23 | for _, tc := range testCases { 24 | match, err := q.Matches(tc.query) 25 | assert.Nil(t, err) 26 | assert.True(t, match) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /libs/pubsub/query/fuzz_test/main.go: -------------------------------------------------------------------------------- 1 | package fuzz_test 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/tendermint/tendermint/libs/pubsub/query" 7 | ) 8 | 9 | func Fuzz(data []byte) int { 10 | sdata := string(data) 11 | q0, err := query.New(sdata) 12 | if err != nil { 13 | return 0 14 | } 15 | 16 | sdata1 := q0.String() 17 | q1, err := query.New(sdata1) 18 | if err != nil { 19 | panic(err) 20 | } 21 | 22 | sdata2 := q1.String() 23 | if sdata1 != sdata2 { 24 | fmt.Printf("q0: %q\n", sdata1) 25 | fmt.Printf("q1: %q\n", sdata2) 26 | panic("query changed") 27 | } 28 | 29 | return 1 30 | } 31 | -------------------------------------------------------------------------------- /libs/pubsub/query/peg.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | //go:generate peg -inline -switch query.peg 4 | -------------------------------------------------------------------------------- /libs/sync/deadlock.go: -------------------------------------------------------------------------------- 1 | //go:build deadlock 2 | // +build deadlock 3 | 4 | package sync 5 | 6 | import ( 7 | deadlock "github.com/sasha-s/go-deadlock" 8 | ) 9 | 10 | // A Mutex is a mutual exclusion lock. 11 | type Mutex struct { 12 | deadlock.Mutex 13 | } 14 | 15 | // An RWMutex is a reader/writer mutual exclusion lock. 16 | type RWMutex struct { 17 | deadlock.RWMutex 18 | } 19 | -------------------------------------------------------------------------------- /libs/sync/sync.go: -------------------------------------------------------------------------------- 1 | //go:build !deadlock 2 | // +build !deadlock 3 | 4 | package sync 5 | 6 | import "sync" 7 | 8 | // A Mutex is a mutual exclusion lock. 9 | type Mutex struct { 10 | sync.Mutex 11 | } 12 | 13 | // An RWMutex is a reader/writer mutual exclusion lock. 14 | type RWMutex struct { 15 | sync.RWMutex 16 | } 17 | -------------------------------------------------------------------------------- /libs/test/mutate.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | tmrand "github.com/tendermint/tendermint/libs/rand" 5 | ) 6 | 7 | // Contract: !bytes.Equal(input, output) && len(input) >= len(output) 8 | func MutateByteSlice(bytez []byte) []byte { 9 | // If bytez is empty, panic 10 | if len(bytez) == 0 { 11 | panic("Cannot mutate an empty bytez") 12 | } 13 | 14 | // Copy bytez 15 | mBytez := make([]byte, len(bytez)) 16 | copy(mBytez, bytez) 17 | bytez = mBytez 18 | 19 | // Try a random mutation 20 | switch tmrand.Int() % 2 { 21 | case 0: // Mutate a single byte 22 | bytez[tmrand.Int()%len(bytez)] += byte(tmrand.Int()%255 + 1) 23 | case 1: // Remove an arbitrary byte 24 | pos := tmrand.Int() % len(bytez) 25 | bytez = append(bytez[:pos], bytez[pos+1:]...) 26 | } 27 | return bytez 28 | } 29 | -------------------------------------------------------------------------------- /light/provider/errors.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | ) 7 | 8 | var ( 9 | // ErrHeightTooHigh is returned when the height is higher than the last 10 | // block that the provider has. The light client will not remove the provider 11 | ErrHeightTooHigh = errors.New("height requested is too high") 12 | // ErrLightBlockNotFound is returned when a provider can't find the 13 | // requested header (i.e. it has been pruned). 14 | // The light client will not remove the provider 15 | ErrLightBlockNotFound = errors.New("light block not found") 16 | // ErrNoResponse is returned if the provider doesn't respond to the 17 | // request in a gieven time 18 | ErrNoResponse = errors.New("client failed to respond") 19 | ) 20 | 21 | // ErrBadLightBlock is returned when a provider returns an invalid 22 | // light block. 23 | type ErrBadLightBlock struct { 24 | Reason error 25 | } 26 | 27 | func (e ErrBadLightBlock) Error() string { 28 | return fmt.Sprintf("client provided bad signed header: %s", e.Reason.Error()) 29 | } 30 | -------------------------------------------------------------------------------- /light/provider/mock/deadmock.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/tendermint/tendermint/light/provider" 7 | "github.com/tendermint/tendermint/types" 8 | ) 9 | 10 | type deadMock struct { 11 | chainID string 12 | } 13 | 14 | // NewDeadMock creates a mock provider that always errors. 15 | func NewDeadMock(chainID string) provider.Provider { 16 | return &deadMock{chainID: chainID} 17 | } 18 | 19 | func (p *deadMock) ChainID() string { return p.chainID } 20 | 21 | func (p *deadMock) String() string { return "deadMock" } 22 | 23 | func (p *deadMock) LightBlock(_ context.Context, height int64) (*types.LightBlock, error) { 24 | return nil, provider.ErrNoResponse 25 | } 26 | 27 | func (p *deadMock) ReportEvidence(_ context.Context, ev types.Evidence) error { 28 | return provider.ErrNoResponse 29 | } 30 | -------------------------------------------------------------------------------- /light/provider/provider.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/tendermint/tendermint/types" 7 | ) 8 | 9 | // Provider provides information for the light client to sync (verification 10 | // happens in the client). 11 | type Provider interface { 12 | // ChainID returns the blockchain ID. 13 | ChainID() string 14 | 15 | // LightBlock returns the LightBlock that corresponds to the given 16 | // height. 17 | // 18 | // 0 - the latest. 19 | // height must be >= 0. 20 | // 21 | // If the provider fails to fetch the LightBlock due to the IO or other 22 | // issues, an error will be returned. 23 | // If there's no LightBlock for the given height, ErrLightBlockNotFound 24 | // error is returned. 25 | LightBlock(ctx context.Context, height int64) (*types.LightBlock, error) 26 | 27 | // ReportEvidence reports an evidence of misbehavior. 28 | ReportEvidence(context.Context, types.Evidence) error 29 | } 30 | -------------------------------------------------------------------------------- /light/store/errors.go: -------------------------------------------------------------------------------- 1 | package store 2 | 3 | import "errors" 4 | 5 | var ( 6 | // ErrLightBlockNotFound is returned when a store does not have the 7 | // requested header. 8 | ErrLightBlockNotFound = errors.New("light block not found") 9 | ) 10 | -------------------------------------------------------------------------------- /mempool/cache_bench_test.go: -------------------------------------------------------------------------------- 1 | package mempool 2 | 3 | import ( 4 | "encoding/binary" 5 | "testing" 6 | ) 7 | 8 | func BenchmarkCacheInsertTime(b *testing.B) { 9 | cache := NewLRUTxCache(b.N) 10 | 11 | txs := make([][]byte, b.N) 12 | for i := 0; i < b.N; i++ { 13 | txs[i] = make([]byte, 8) 14 | binary.BigEndian.PutUint64(txs[i], uint64(i)) 15 | } 16 | 17 | b.ResetTimer() 18 | 19 | for i := 0; i < b.N; i++ { 20 | cache.Push(txs[i]) 21 | } 22 | } 23 | 24 | // This benchmark is probably skewed, since we actually will be removing 25 | // txs in parallel, which may cause some overhead due to mutex locking. 26 | func BenchmarkCacheRemoveTime(b *testing.B) { 27 | cache := NewLRUTxCache(b.N) 28 | 29 | txs := make([][]byte, b.N) 30 | for i := 0; i < b.N; i++ { 31 | txs[i] = make([]byte, 8) 32 | binary.BigEndian.PutUint64(txs[i], uint64(i)) 33 | cache.Push(txs[i]) 34 | } 35 | 36 | b.ResetTimer() 37 | 38 | for i := 0; i < b.N; i++ { 39 | cache.Remove(txs[i]) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /mempool/cache_test.go: -------------------------------------------------------------------------------- 1 | package mempool 2 | 3 | import ( 4 | "crypto/rand" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/require" 8 | ) 9 | 10 | func TestCacheRemove(t *testing.T) { 11 | cache := NewLRUTxCache(100) 12 | numTxs := 10 13 | 14 | txs := make([][]byte, numTxs) 15 | for i := 0; i < numTxs; i++ { 16 | // probability of collision is 2**-256 17 | txBytes := make([]byte, 32) 18 | _, err := rand.Read(txBytes) 19 | require.NoError(t, err) 20 | 21 | txs[i] = txBytes 22 | cache.Push(txBytes) 23 | 24 | // make sure its added to both the linked list and the map 25 | require.Equal(t, i+1, len(cache.cacheMap)) 26 | require.Equal(t, i+1, cache.list.Len()) 27 | } 28 | 29 | for i := 0; i < numTxs; i++ { 30 | cache.Remove(txs[i]) 31 | // make sure its removed from both the map and the linked list 32 | require.Equal(t, numTxs-(i+1), len(cache.cacheMap)) 33 | require.Equal(t, numTxs-(i+1), cache.list.Len()) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /mempool/ids.go: -------------------------------------------------------------------------------- 1 | package mempool 2 | 3 | // These functions were moved into v0/reactor.go and v1/reactor.go 4 | -------------------------------------------------------------------------------- /mempool/ids_test.go: -------------------------------------------------------------------------------- 1 | package mempool 2 | 3 | // import ( 4 | // "testing" 5 | 6 | // "github.com/stretchr/testify/require" 7 | // "github.com/tendermint/tendermint/types" 8 | // ) 9 | 10 | // func TestMempoolIDsBasic(t *testing.T) { 11 | // ids := NewMempoolIDs() 12 | 13 | // peerID, err := types.NewNodeID("0011223344556677889900112233445566778899") 14 | // require.NoError(t, err) 15 | 16 | // ids.ReserveForPeer(peerID) 17 | // require.EqualValues(t, 1, ids.GetForPeer(peerID)) 18 | // ids.Reclaim(peerID) 19 | 20 | // ids.ReserveForPeer(peerID) 21 | // require.EqualValues(t, 2, ids.GetForPeer(peerID)) 22 | // ids.Reclaim(peerID) 23 | // } 24 | -------------------------------------------------------------------------------- /mempool/tx.go: -------------------------------------------------------------------------------- 1 | package mempool 2 | 3 | import ( 4 | "github.com/tendermint/tendermint/p2p" 5 | ) 6 | 7 | // TxInfo are parameters that get passed when attempting to add a tx to the 8 | // mempool. 9 | type TxInfo struct { 10 | // SenderID is the internal peer ID used in the mempool to identify the 11 | // sender, storing two bytes with each transaction instead of 20 bytes for 12 | // the types.NodeID. 13 | SenderID uint16 14 | 15 | // SenderP2PID is the actual p2p.ID of the sender, used e.g. for logging. 16 | SenderP2PID p2p.ID 17 | } 18 | -------------------------------------------------------------------------------- /mempool/v1/mempool_bench_test.go: -------------------------------------------------------------------------------- 1 | package v1 2 | 3 | import ( 4 | "fmt" 5 | "math/rand" 6 | "testing" 7 | "time" 8 | 9 | "github.com/stretchr/testify/require" 10 | 11 | "github.com/tendermint/tendermint/mempool" 12 | ) 13 | 14 | func BenchmarkTxMempool_CheckTx(b *testing.B) { 15 | txmp := setup(b, 10000) 16 | rng := rand.New(rand.NewSource(time.Now().UnixNano())) 17 | 18 | b.ResetTimer() 19 | 20 | for n := 0; n < b.N; n++ { 21 | b.StopTimer() 22 | prefix := make([]byte, 20) 23 | _, err := rng.Read(prefix) 24 | require.NoError(b, err) 25 | 26 | priority := int64(rng.Intn(9999-1000) + 1000) 27 | tx := []byte(fmt.Sprintf("%X=%d", prefix, priority)) 28 | b.StartTimer() 29 | 30 | require.NoError(b, txmp.CheckTx(tx, nil, mempool.TxInfo{})) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /networks/local/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for the "localnode" docker image. 2 | 3 | all: 4 | docker build --tag tendermint/localnode localnode 5 | 6 | .PHONY: all 7 | 8 | -------------------------------------------------------------------------------- /networks/local/README.md: -------------------------------------------------------------------------------- 1 | # Local Cluster with Docker Compose 2 | 3 | See the [docs](https://docs.tendermint.com/v0.34/networks/docker-compose.html). 4 | -------------------------------------------------------------------------------- /networks/local/localnode/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | 3 | RUN apk update && \ 4 | apk upgrade && \ 5 | apk --no-cache add curl jq file 6 | 7 | VOLUME [ /tendermint ] 8 | WORKDIR /tendermint 9 | EXPOSE 26656 26657 10 | ENTRYPOINT ["/usr/bin/wrapper.sh"] 11 | CMD ["node", "--proxy_app", "kvstore"] 12 | STOPSIGNAL SIGTERM 13 | 14 | COPY wrapper.sh /usr/bin/wrapper.sh 15 | COPY config-template.toml /etc/tendermint/config-template.toml 16 | -------------------------------------------------------------------------------- /networks/local/localnode/config-template.toml: -------------------------------------------------------------------------------- 1 | [rpc] 2 | laddr = "tcp://0.0.0.0:26657" 3 | -------------------------------------------------------------------------------- /networks/local/localnode/wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ## 4 | ## Input parameters 5 | ## 6 | BINARY=/tendermint/${BINARY:-tendermint} 7 | ID=${ID:-0} 8 | LOG=${LOG:-tendermint.log} 9 | 10 | ## 11 | ## Assert linux binary 12 | ## 13 | if ! [ -f "${BINARY}" ]; then 14 | echo "The binary $(basename "${BINARY}") cannot be found. Please add the binary to the shared folder. Please use the BINARY environment variable if the name of the binary is not 'tendermint' E.g.: -e BINARY=tendermint_my_test_version" 15 | exit 1 16 | fi 17 | BINARY_CHECK="$(file "$BINARY" | grep 'ELF 64-bit LSB executable, x86-64')" 18 | if [ -z "${BINARY_CHECK}" ]; then 19 | echo "Binary needs to be OS linux, ARCH amd64" 20 | exit 1 21 | fi 22 | 23 | ## 24 | ## Run binary with all parameters 25 | ## 26 | export TMHOME="/tendermint/node${ID}" 27 | 28 | if [ -d "`dirname ${TMHOME}/${LOG}`" ]; then 29 | "$BINARY" "$@" | tee "${TMHOME}/${LOG}" 30 | else 31 | "$BINARY" "$@" 32 | fi 33 | 34 | chmod 777 -R /tendermint 35 | 36 | -------------------------------------------------------------------------------- /networks/remote/README.md: -------------------------------------------------------------------------------- 1 | # Remote Cluster with Terraform and Ansible 2 | 3 | See the [docs](https://docs.tendermint.com/v0.34/networks/terraform-and-ansible.html). 4 | -------------------------------------------------------------------------------- /networks/remote/ansible/.gitignore: -------------------------------------------------------------------------------- 1 | *.retry 2 | -------------------------------------------------------------------------------- /networks/remote/ansible/ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | retry_files_enabled = False 3 | host_key_checking = False 4 | 5 | -------------------------------------------------------------------------------- /networks/remote/ansible/config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | #Requires BINARY and CONFIGDIR variables set. 4 | #N=4 hosts by default. 5 | 6 | - hosts: all 7 | user: root 8 | any_errors_fatal: true 9 | gather_facts: yes 10 | vars: 11 | - service: tendermint 12 | - N: 4 13 | roles: 14 | - stop 15 | - config 16 | - unsafe_reset 17 | - start 18 | 19 | -------------------------------------------------------------------------------- /networks/remote/ansible/install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - hosts: all 4 | user: root 5 | any_errors_fatal: true 6 | gather_facts: no 7 | vars: 8 | - service: tendermint 9 | roles: 10 | - install 11 | 12 | -------------------------------------------------------------------------------- /networks/remote/ansible/inventory/digital_ocean.ini: -------------------------------------------------------------------------------- 1 | # Ansible DigitalOcean external inventory script settings 2 | # 3 | 4 | [digital_ocean] 5 | 6 | # The module needs your DigitalOcean API Token. 7 | # It may also be specified on the command line via --api-token 8 | # or via the environment variables DO_API_TOKEN or DO_API_KEY 9 | # 10 | #api_token = 123456abcdefg 11 | 12 | 13 | # API calls to DigitalOcean may be slow. For this reason, we cache the results 14 | # of an API call. Set this to the path you want cache files to be written to. 15 | # One file will be written to this directory: 16 | # - ansible-digital_ocean.cache 17 | # 18 | cache_path = /tmp 19 | 20 | 21 | # The number of seconds a cache file is considered valid. After this many 22 | # seconds, a new API call will be made, and the cache file will be updated. 23 | # 24 | cache_max_age = 300 25 | 26 | # Use the private network IP address instead of the public when available. 27 | # 28 | use_private_network = False 29 | 30 | # Pass variables to every group, e.g.: 31 | # 32 | # group_variables = { 'ansible_user': 'root' } 33 | # 34 | group_variables = {} 35 | -------------------------------------------------------------------------------- /networks/remote/ansible/logzio.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | #Note: You need to add LOGZIO_TOKEN variable with your API key. Like tihs: ansible-playbook -e LOGZIO_TOKEN=ABCXYZ123456 4 | 5 | - hosts: all 6 | user: root 7 | any_errors_fatal: true 8 | gather_facts: no 9 | vars: 10 | - service: tendermint 11 | - JOURNALBEAT_BINARY: "{{lookup('env', 'GOPATH')}}/bin/journalbeat" 12 | roles: 13 | - logzio 14 | 15 | -------------------------------------------------------------------------------- /networks/remote/ansible/reset.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - hosts: all 4 | user: root 5 | any_errors_fatal: true 6 | gather_facts: no 7 | vars: 8 | - service: tendermint 9 | roles: 10 | - stop 11 | - unsafe_reset 12 | - start 13 | 14 | 15 | -------------------------------------------------------------------------------- /networks/remote/ansible/restart.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - hosts: all 4 | user: root 5 | any_errors_fatal: true 6 | gather_facts: no 7 | vars: 8 | - service: tendermint 9 | roles: 10 | - stop 11 | - start 12 | 13 | -------------------------------------------------------------------------------- /networks/remote/ansible/roles/config/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Copy binary 4 | copy: 5 | src: "{{BINARY}}" 6 | dest: /usr/bin 7 | mode: 0755 8 | 9 | - name: Copy config 10 | when: item <= N and ansible_hostname == 'sentrynet-node' ~ item 11 | copy: 12 | src: "{{CONFIGDIR}}/node{{item}}/" 13 | dest: "/home/{{service}}/.{{service}}/" 14 | owner: "{{service}}" 15 | group: "{{service}}" 16 | loop: [ 0, 1, 2, 3, 4, 5, 6, 7 ] 17 | 18 | -------------------------------------------------------------------------------- /networks/remote/ansible/roles/install/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: reload services 4 | systemd: "name={{service}} daemon_reload=yes enabled=yes" 5 | 6 | -------------------------------------------------------------------------------- /networks/remote/ansible/roles/install/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Create service group 4 | group: "name={{service}}" 5 | 6 | - name: Create service user 7 | user: "name={{service}} group={{service}} home=/home/{{service}}" 8 | 9 | - name: Change user folder to more permissive 10 | file: "path=/home/{{service}} mode=0755" 11 | 12 | - name: Create service 13 | template: "src=systemd.service.j2 dest=/etc/systemd/system/{{service}}.service" 14 | notify: reload services 15 | 16 | -------------------------------------------------------------------------------- /networks/remote/ansible/roles/install/templates/systemd.service.j2: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description={{service}} 3 | Requires=network-online.target 4 | After=network-online.target 5 | 6 | [Service] 7 | Restart=on-failure 8 | User={{service}} 9 | Group={{service}} 10 | PermissionsStartOnly=true 11 | ExecStart=/usr/bin/tendermint node --proxy_app=kvstore 12 | ExecReload=/bin/kill -HUP $MAINPID 13 | KillSignal=SIGTERM 14 | 15 | [Install] 16 | WantedBy=multi-user.target 17 | 18 | -------------------------------------------------------------------------------- /networks/remote/ansible/roles/logzio/files/journalbeat.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=journalbeat 3 | #propagates activation, deactivation and activation fails. 4 | Requires=network-online.target 5 | After=network-online.target 6 | 7 | [Service] 8 | Restart=on-failure 9 | ExecStart=/usr/bin/journalbeat -c /etc/journalbeat/journalbeat.yml -path.home /usr/share/journalbeat -path.config /etc/journalbeat -path.data /var/lib/journalbeat -path.logs /var/log/journalbeat 10 | Restart=always 11 | 12 | [Install] 13 | WantedBy=multi-user.target 14 | 15 | 16 | -------------------------------------------------------------------------------- /networks/remote/ansible/roles/logzio/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: reload daemon 4 | command: "systemctl daemon-reload" 5 | 6 | - name: restart journalbeat 7 | service: name=journalbeat state=restarted 8 | 9 | -------------------------------------------------------------------------------- /networks/remote/ansible/roles/logzio/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Copy journalbeat binary 4 | copy: src="{{JOURNALBEAT_BINARY}}" dest=/usr/bin/journalbeat mode=0755 5 | notify: restart journalbeat 6 | 7 | - name: Create folders 8 | file: "path={{item}} state=directory recurse=yes" 9 | with_items: 10 | - /etc/journalbeat 11 | - /etc/pki/tls/certs 12 | - /usr/share/journalbeat 13 | - /var/log/journalbeat 14 | 15 | - name: Copy journalbeat config 16 | template: src=journalbeat.yml.j2 dest=/etc/journalbeat/journalbeat.yml mode=0600 17 | notify: restart journalbeat 18 | 19 | - name: Get server certificate for Logz.io 20 | get_url: "url=https://raw.githubusercontent.com/logzio/public-certificates/master/COMODORSADomainValidationSecureServerCA.crt force=yes dest=/etc/pki/tls/certs/COMODORSADomainValidationSecureServerCA.crt" 21 | 22 | - name: Copy journalbeat service config 23 | copy: src=journalbeat.service dest=/etc/systemd/system/journalbeat.service 24 | notify: 25 | - reload daemon 26 | - restart journalbeat 27 | 28 | -------------------------------------------------------------------------------- /networks/remote/ansible/roles/start/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: start service 4 | service: "name={{service}} state=started" 5 | 6 | -------------------------------------------------------------------------------- /networks/remote/ansible/roles/status/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: application service status 4 | command: "service {{service}} status" 5 | changed_when: false 6 | register: status 7 | 8 | - name: Result 9 | debug: var=status.stdout_lines 10 | 11 | -------------------------------------------------------------------------------- /networks/remote/ansible/roles/stop/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: stop service 4 | service: "name={{service}} state=stopped" 5 | 6 | -------------------------------------------------------------------------------- /networks/remote/ansible/roles/unsafe_reset/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - command: "{{service}} unsafe_reset_all {{ (service != 'tendermint') | ternary('node','') }} --home /home/{{service}}/.{{service}}" 2 | become_user: "{{service}}" 3 | become: yes 4 | 5 | -------------------------------------------------------------------------------- /networks/remote/ansible/start.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - hosts: all 4 | user: root 5 | any_errors_fatal: true 6 | gather_facts: no 7 | vars: 8 | - service: tendermint 9 | roles: 10 | - start 11 | 12 | -------------------------------------------------------------------------------- /networks/remote/ansible/status.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - hosts: all 4 | user: root 5 | any_errors_fatal: true 6 | gather_facts: no 7 | vars: 8 | - service: tendermint 9 | roles: 10 | - status 11 | 12 | -------------------------------------------------------------------------------- /networks/remote/ansible/stop.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - hosts: all 4 | user: root 5 | any_errors_fatal: true 6 | gather_facts: no 7 | vars: 8 | - service: tendermint 9 | roles: 10 | - stop 11 | 12 | -------------------------------------------------------------------------------- /networks/remote/terraform/.gitignore: -------------------------------------------------------------------------------- 1 | .terraform 2 | terraform.tfstate 3 | terraform.tfstate.backup 4 | terraform.tfstate.d 5 | -------------------------------------------------------------------------------- /networks/remote/terraform/cluster/main.tf: -------------------------------------------------------------------------------- 1 | resource "digitalocean_tag" "cluster" { 2 | name = "${var.name}" 3 | } 4 | 5 | resource "digitalocean_ssh_key" "cluster" { 6 | name = "${var.name}" 7 | public_key = "${file(var.ssh_key)}" 8 | } 9 | 10 | resource "digitalocean_droplet" "cluster" { 11 | name = "${var.name}-node${count.index}" 12 | image = "centos-7-x64" 13 | size = "${var.instance_size}" 14 | region = "${element(var.regions, count.index)}" 15 | ssh_keys = ["${digitalocean_ssh_key.cluster.id}"] 16 | count = "${var.servers}" 17 | tags = ["${digitalocean_tag.cluster.id}"] 18 | 19 | lifecycle = { 20 | prevent_destroy = false 21 | } 22 | 23 | connection { 24 | timeout = "30s" 25 | } 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /networks/remote/terraform/cluster/outputs.tf: -------------------------------------------------------------------------------- 1 | // The cluster name 2 | output "name" { 3 | value = "${var.name}" 4 | } 5 | 6 | // The list of cluster instance IDs 7 | output "instances" { 8 | value = ["${digitalocean_droplet.cluster.*.id}"] 9 | } 10 | 11 | // The list of cluster instance public IPs 12 | output "public_ips" { 13 | value = ["${digitalocean_droplet.cluster.*.ipv4_address}"] 14 | } 15 | 16 | -------------------------------------------------------------------------------- /networks/remote/terraform/cluster/variables.tf: -------------------------------------------------------------------------------- 1 | variable "name" { 2 | description = "The cluster name, e.g cdn" 3 | } 4 | 5 | variable "regions" { 6 | description = "Regions to launch in" 7 | type = "list" 8 | default = ["AMS3", "FRA1", "LON1", "NYC3", "SFO2", "SGP1", "TOR1"] 9 | } 10 | 11 | variable "ssh_key" { 12 | description = "SSH key filename to copy to the nodes" 13 | type = "string" 14 | } 15 | 16 | variable "instance_size" { 17 | description = "The instance size to use" 18 | default = "2gb" 19 | } 20 | 21 | variable "servers" { 22 | description = "Desired instance count" 23 | default = 4 24 | } 25 | 26 | -------------------------------------------------------------------------------- /networks/remote/terraform/main.tf: -------------------------------------------------------------------------------- 1 | #Terraform Configuration 2 | 3 | variable "DO_API_TOKEN" { 4 | description = "DigitalOcean Access Token" 5 | } 6 | 7 | variable "TESTNET_NAME" { 8 | description = "Name of the testnet" 9 | default = "sentrynet" 10 | } 11 | 12 | variable "SSH_KEY_FILE" { 13 | description = "SSH public key file to be used on the nodes" 14 | type = "string" 15 | } 16 | 17 | variable "SERVERS" { 18 | description = "Number of nodes in testnet" 19 | default = "4" 20 | } 21 | 22 | provider "digitalocean" { 23 | token = "${var.DO_API_TOKEN}" 24 | } 25 | 26 | module "cluster" { 27 | source = "./cluster" 28 | name = "${var.TESTNET_NAME}" 29 | ssh_key = "${var.SSH_KEY_FILE}" 30 | servers = "${var.SERVERS}" 31 | } 32 | 33 | 34 | output "public_ips" { 35 | value = "${module.cluster.public_ips}" 36 | } 37 | 38 | -------------------------------------------------------------------------------- /node/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package node is the main entry point, where the Node struct, which 3 | represents a full node, is defined. 4 | 5 | Adding new p2p.Reactor(s) 6 | 7 | To add a new p2p.Reactor, use the CustomReactors option: 8 | 9 | node, err := NewNode( 10 | config, 11 | privVal, 12 | nodeKey, 13 | clientCreator, 14 | genesisDocProvider, 15 | dbProvider, 16 | metricsProvider, 17 | logger, 18 | CustomReactors(map[string]p2p.Reactor{"CUSTOM": customReactor}), 19 | ) 20 | 21 | Replacing existing p2p.Reactor(s) 22 | 23 | To replace the built-in p2p.Reactor, use the CustomReactors option: 24 | 25 | node, err := NewNode( 26 | config, 27 | privVal, 28 | nodeKey, 29 | clientCreator, 30 | genesisDocProvider, 31 | dbProvider, 32 | metricsProvider, 33 | logger, 34 | CustomReactors(map[string]p2p.Reactor{"BLOCKCHAIN": customBlockchainReactor}), 35 | ) 36 | 37 | The list of existing reactors can be found in CustomReactors documentation. 38 | */ 39 | package node 40 | -------------------------------------------------------------------------------- /node/id.go: -------------------------------------------------------------------------------- 1 | package node 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/tendermint/tendermint/crypto" 7 | ) 8 | 9 | type ID struct { 10 | Name string 11 | PubKey crypto.PubKey 12 | } 13 | 14 | type PrivNodeID struct { 15 | ID 16 | PrivKey crypto.PrivKey 17 | } 18 | 19 | type Greeting struct { 20 | ID 21 | Version string 22 | ChainID string 23 | Message string 24 | Time time.Time 25 | } 26 | 27 | type SignedNodeGreeting struct { 28 | Greeting 29 | Signature []byte 30 | } 31 | 32 | func (pnid *PrivNodeID) SignGreeting() *SignedNodeGreeting { 33 | // greeting := NodeGreeting{} 34 | return nil 35 | } 36 | -------------------------------------------------------------------------------- /p2p/README.md: -------------------------------------------------------------------------------- 1 | # p2p 2 | 3 | The p2p package provides an abstraction around peer-to-peer communication. 4 | 5 | Docs: 6 | 7 | - [Connection](https://github.com/tendermint/tendermint/blob/v0.34.x/spec/p2p/connection.md) for details on how connections and multiplexing work 8 | - [Peer](https://github.com/tendermint/tendermint/blob/v0.34.x/spec/p2p/node.md) for details on peer ID, handshakes, and peer exchange 9 | - [Node](https://github.com/tendermint/tendermint/blob/v0.34.x/spec/p2p/node.md) for details about different types of nodes and how they should work 10 | - [Pex](https://github.com/tendermint/tendermint/blob/v0.34.x/spec/reactors/pex/pex.md) for details on peer discovery and exchange 11 | - [Config](https://github.com/tendermint/tendermint/blob/v0.34.x/spec/p2p/config.md) for details on some config option 12 | -------------------------------------------------------------------------------- /p2p/conn/conn_go110.go: -------------------------------------------------------------------------------- 1 | //go:build go1.10 2 | // +build go1.10 3 | 4 | package conn 5 | 6 | // Go1.10 has a proper net.Conn implementation that 7 | // has the SetDeadline method implemented as per 8 | // https://github.com/golang/go/commit/e2dd8ca946be884bb877e074a21727f1a685a706 9 | // lest we run into problems like 10 | // https://github.com/tendermint/tendermint/issues/851 11 | 12 | import "net" 13 | 14 | func NetPipe() (net.Conn, net.Conn) { 15 | return net.Pipe() 16 | } 17 | -------------------------------------------------------------------------------- /p2p/conn/conn_notgo110.go: -------------------------------------------------------------------------------- 1 | //go:build !go1.10 2 | // +build !go1.10 3 | 4 | package conn 5 | 6 | import ( 7 | "net" 8 | "time" 9 | ) 10 | 11 | // Only Go1.10 has a proper net.Conn implementation that 12 | // has the SetDeadline method implemented as per 13 | // 14 | // https://github.com/golang/go/commit/e2dd8ca946be884bb877e074a21727f1a685a706 15 | // 16 | // lest we run into problems like 17 | // 18 | // https://github.com/tendermint/tendermint/issues/851 19 | // 20 | // so for go versions < Go1.10 use our custom net.Conn creator 21 | // that doesn't return an `Unimplemented error` for net.Conn. 22 | // Before https://github.com/tendermint/tendermint/commit/49faa79bdce5663894b3febbf4955fb1d172df04 23 | // we hadn't cared about errors from SetDeadline so swallow them up anyways. 24 | type pipe struct { 25 | net.Conn 26 | } 27 | 28 | func (p *pipe) SetDeadline(t time.Time) error { 29 | return nil 30 | } 31 | 32 | func NetPipe() (net.Conn, net.Conn) { 33 | p1, p2 := net.Pipe() 34 | return &pipe{p1}, &pipe{p2} 35 | } 36 | 37 | var _ net.Conn = (*pipe)(nil) 38 | -------------------------------------------------------------------------------- /p2p/mock/reactor.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "github.com/tendermint/tendermint/libs/log" 5 | "github.com/tendermint/tendermint/p2p" 6 | "github.com/tendermint/tendermint/p2p/conn" 7 | ) 8 | 9 | type Reactor struct { 10 | p2p.BaseReactor 11 | 12 | Channels []*conn.ChannelDescriptor 13 | } 14 | 15 | func NewReactor() *Reactor { 16 | r := &Reactor{} 17 | r.BaseReactor = *p2p.NewBaseReactor("Mock-PEX", r) 18 | r.SetLogger(log.TestingLogger()) 19 | return r 20 | } 21 | 22 | func (r *Reactor) GetChannels() []*conn.ChannelDescriptor { return r.Channels } 23 | func (r *Reactor) AddPeer(peer p2p.Peer) {} 24 | func (r *Reactor) RemovePeer(peer p2p.Peer, reason interface{}) {} 25 | func (r *Reactor) ReceiveEnvelope(e p2p.Envelope) {} 26 | func (r *Reactor) Receive(chID byte, peer p2p.Peer, msgBytes []byte) {} 27 | -------------------------------------------------------------------------------- /privval/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package privval provides different implementations of the types.PrivValidator. 3 | 4 | # FilePV 5 | 6 | FilePV is the simplest implementation and developer default. 7 | It uses one file for the private key and another to store state. 8 | 9 | # SignerListenerEndpoint 10 | 11 | SignerListenerEndpoint establishes a connection to an external process, 12 | like a Key Management Server (KMS), using a socket. 13 | SignerListenerEndpoint listens for the external KMS process to dial in. 14 | SignerListenerEndpoint takes a listener, which determines the type of connection 15 | (ie. encrypted over tcp, or unencrypted over unix). 16 | 17 | # SignerDialerEndpoint 18 | 19 | SignerDialerEndpoint is a simple wrapper around a net.Conn. It's used by both IPCVal and TCPVal. 20 | 21 | # SignerClient 22 | 23 | SignerClient handles remote validator connections that provide signing services. 24 | In production, it's recommended to wrap it with RetrySignerClient to avoid 25 | termination in case of temporary errors. 26 | */ 27 | package privval 28 | -------------------------------------------------------------------------------- /privval/utils_test.go: -------------------------------------------------------------------------------- 1 | package privval 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "testing" 7 | 8 | "github.com/stretchr/testify/assert" 9 | ) 10 | 11 | func TestIsConnTimeoutForNonTimeoutErrors(t *testing.T) { 12 | assert.False(t, IsConnTimeout(fmt.Errorf("max retries exceeded: %w", ErrDialRetryMax))) 13 | assert.False(t, IsConnTimeout(errors.New("completely irrelevant error"))) 14 | } 15 | -------------------------------------------------------------------------------- /proto/buf.lock: -------------------------------------------------------------------------------- 1 | # Generated by buf. DO NOT EDIT. 2 | version: v1 3 | deps: 4 | - remote: buf.build 5 | owner: gogo 6 | repository: protobuf 7 | commit: 4df00b267f944190a229ce3695781e99 8 | -------------------------------------------------------------------------------- /proto/buf.yaml: -------------------------------------------------------------------------------- 1 | version: v1 2 | deps: 3 | - buf.build/gogo/protobuf 4 | breaking: 5 | use: 6 | - FILE 7 | lint: 8 | use: 9 | - BASIC 10 | - FILE_LOWER_SNAKE_CASE 11 | - UNARY_RPC 12 | -------------------------------------------------------------------------------- /proto/tendermint/crypto/keys.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package tendermint.crypto; 3 | 4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/crypto"; 5 | 6 | import "gogoproto/gogo.proto"; 7 | 8 | // PublicKey defines the keys available for use with Tendermint Validators 9 | message PublicKey { 10 | option (gogoproto.compare) = true; 11 | option (gogoproto.equal) = true; 12 | 13 | oneof sum { 14 | bytes ed25519 = 1; 15 | bytes secp256k1 = 2; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /proto/tendermint/crypto/proof.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package tendermint.crypto; 3 | 4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/crypto"; 5 | 6 | import "gogoproto/gogo.proto"; 7 | 8 | message Proof { 9 | int64 total = 1; 10 | int64 index = 2; 11 | bytes leaf_hash = 3; 12 | repeated bytes aunts = 4; 13 | } 14 | 15 | message ValueOp { 16 | // Encoded in ProofOp.Key. 17 | bytes key = 1; 18 | 19 | // To encode in ProofOp.Data 20 | Proof proof = 2; 21 | } 22 | 23 | message DominoOp { 24 | string key = 1; 25 | string input = 2; 26 | string output = 3; 27 | } 28 | 29 | // ProofOp defines an operation used for calculating Merkle root 30 | // The data could be arbitrary format, providing nessecary data 31 | // for example neighbouring node hash 32 | message ProofOp { 33 | string type = 1; 34 | bytes key = 2; 35 | bytes data = 3; 36 | } 37 | 38 | // ProofOps is Merkle proof defined by the list of ProofOps 39 | message ProofOps { 40 | repeated ProofOp ops = 1 [(gogoproto.nullable) = false]; 41 | } 42 | -------------------------------------------------------------------------------- /proto/tendermint/libs/bits/types.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package tendermint.libs.bits; 3 | 4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/libs/bits"; 5 | 6 | message BitArray { 7 | int64 bits = 1; 8 | repeated uint64 elems = 2; 9 | } 10 | -------------------------------------------------------------------------------- /proto/tendermint/mempool/message.go: -------------------------------------------------------------------------------- 1 | package mempool 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/gogo/protobuf/proto" 7 | "github.com/tendermint/tendermint/p2p" 8 | ) 9 | 10 | var _ p2p.Wrapper = &Txs{} 11 | var _ p2p.Unwrapper = &Message{} 12 | 13 | // Wrap implements the p2p Wrapper interface and wraps a mempool message. 14 | func (m *Txs) Wrap() proto.Message { 15 | mm := &Message{} 16 | mm.Sum = &Message_Txs{Txs: m} 17 | return mm 18 | } 19 | 20 | // Unwrap implements the p2p Wrapper interface and unwraps a wrapped mempool 21 | // message. 22 | func (m *Message) Unwrap() (proto.Message, error) { 23 | switch msg := m.Sum.(type) { 24 | case *Message_Txs: 25 | return m.GetTxs(), nil 26 | 27 | default: 28 | return nil, fmt.Errorf("unknown message: %T", msg) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /proto/tendermint/mempool/types.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package tendermint.mempool; 3 | 4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/mempool"; 5 | 6 | message Txs { 7 | repeated bytes txs = 1; 8 | } 9 | 10 | message Message { 11 | oneof sum { 12 | Txs txs = 1; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /proto/tendermint/p2p/conn.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package tendermint.p2p; 3 | 4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/p2p"; 5 | 6 | import "gogoproto/gogo.proto"; 7 | import "tendermint/crypto/keys.proto"; 8 | 9 | message PacketPing {} 10 | 11 | message PacketPong {} 12 | 13 | message PacketMsg { 14 | int32 channel_id = 1 [(gogoproto.customname) = "ChannelID"]; 15 | bool eof = 2 [(gogoproto.customname) = "EOF"]; 16 | bytes data = 3; 17 | } 18 | 19 | message Packet { 20 | oneof sum { 21 | PacketPing packet_ping = 1; 22 | PacketPong packet_pong = 2; 23 | PacketMsg packet_msg = 3; 24 | } 25 | } 26 | 27 | message AuthSigMessage { 28 | tendermint.crypto.PublicKey pub_key = 1 [(gogoproto.nullable) = false]; 29 | bytes sig = 2; 30 | } 31 | -------------------------------------------------------------------------------- /proto/tendermint/p2p/pex.go: -------------------------------------------------------------------------------- 1 | package p2p 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/gogo/protobuf/proto" 7 | ) 8 | 9 | func (m *PexAddrs) Wrap() proto.Message { 10 | pm := &Message{} 11 | pm.Sum = &Message_PexAddrs{PexAddrs: m} 12 | return pm 13 | } 14 | 15 | func (m *PexRequest) Wrap() proto.Message { 16 | pm := &Message{} 17 | pm.Sum = &Message_PexRequest{PexRequest: m} 18 | return pm 19 | } 20 | 21 | // Unwrap implements the p2p Wrapper interface and unwraps a wrapped PEX 22 | // message. 23 | func (m *Message) Unwrap() (proto.Message, error) { 24 | switch msg := m.Sum.(type) { 25 | case *Message_PexRequest: 26 | return msg.PexRequest, nil 27 | case *Message_PexAddrs: 28 | return msg.PexAddrs, nil 29 | default: 30 | return nil, fmt.Errorf("unknown pex message: %T", msg) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /proto/tendermint/p2p/pex.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package tendermint.p2p; 3 | 4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/p2p"; 5 | 6 | import "tendermint/p2p/types.proto"; 7 | import "gogoproto/gogo.proto"; 8 | 9 | message PexRequest {} 10 | 11 | message PexAddrs { 12 | repeated NetAddress addrs = 1 [(gogoproto.nullable) = false]; 13 | } 14 | 15 | message Message { 16 | oneof sum { 17 | PexRequest pex_request = 1; 18 | PexAddrs pex_addrs = 2; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /proto/tendermint/rpc/grpc/types.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package tendermint.rpc.grpc; 3 | option go_package = "github.com/tendermint/tendermint/rpc/grpc;coregrpc"; 4 | 5 | import "tendermint/abci/types.proto"; 6 | 7 | //---------------------------------------- 8 | // Request types 9 | 10 | message RequestPing {} 11 | 12 | message RequestBroadcastTx { 13 | bytes tx = 1; 14 | } 15 | 16 | //---------------------------------------- 17 | // Response types 18 | 19 | message ResponsePing {} 20 | 21 | message ResponseBroadcastTx { 22 | tendermint.abci.ResponseCheckTx check_tx = 1; 23 | tendermint.abci.ResponseDeliverTx deliver_tx = 2; 24 | } 25 | 26 | //---------------------------------------- 27 | // Service Definition 28 | 29 | service BroadcastAPI { 30 | rpc Ping(RequestPing) returns (ResponsePing); 31 | rpc BroadcastTx(RequestBroadcastTx) returns (ResponseBroadcastTx); 32 | } 33 | -------------------------------------------------------------------------------- /proto/tendermint/statesync/types.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package tendermint.statesync; 3 | 4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/statesync"; 5 | 6 | message Message { 7 | oneof sum { 8 | SnapshotsRequest snapshots_request = 1; 9 | SnapshotsResponse snapshots_response = 2; 10 | ChunkRequest chunk_request = 3; 11 | ChunkResponse chunk_response = 4; 12 | } 13 | } 14 | 15 | message SnapshotsRequest {} 16 | 17 | message SnapshotsResponse { 18 | uint64 height = 1; 19 | uint32 format = 2; 20 | uint32 chunks = 3; 21 | bytes hash = 4; 22 | bytes metadata = 5; 23 | } 24 | 25 | message ChunkRequest { 26 | uint64 height = 1; 27 | uint32 format = 2; 28 | uint32 index = 3; 29 | } 30 | 31 | message ChunkResponse { 32 | uint64 height = 1; 33 | uint32 format = 2; 34 | uint32 index = 3; 35 | bytes chunk = 4; 36 | bool missing = 5; 37 | } 38 | -------------------------------------------------------------------------------- /proto/tendermint/store/types.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package tendermint.store; 3 | 4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/store"; 5 | 6 | message BlockStoreState { 7 | int64 base = 1; 8 | int64 height = 2; 9 | } 10 | -------------------------------------------------------------------------------- /proto/tendermint/types/block.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package tendermint.types; 3 | 4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; 5 | 6 | import "gogoproto/gogo.proto"; 7 | import "tendermint/types/types.proto"; 8 | import "tendermint/types/evidence.proto"; 9 | 10 | message Block { 11 | Header header = 1 [(gogoproto.nullable) = false]; 12 | Data data = 2 [(gogoproto.nullable) = false]; 13 | tendermint.types.EvidenceList evidence = 3 [(gogoproto.nullable) = false]; 14 | Commit last_commit = 4; 15 | } 16 | -------------------------------------------------------------------------------- /proto/tendermint/types/events.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package tendermint.types; 3 | 4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; 5 | 6 | message EventDataRoundState { 7 | int64 height = 1; 8 | int32 round = 2; 9 | string step = 3; 10 | } 11 | -------------------------------------------------------------------------------- /proto/tendermint/types/validator.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package tendermint.types; 3 | 4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; 5 | 6 | import "gogoproto/gogo.proto"; 7 | import "tendermint/crypto/keys.proto"; 8 | 9 | message ValidatorSet { 10 | repeated Validator validators = 1; 11 | Validator proposer = 2; 12 | int64 total_voting_power = 3; 13 | } 14 | 15 | message Validator { 16 | bytes address = 1; 17 | tendermint.crypto.PublicKey pub_key = 2 [(gogoproto.nullable) = false]; 18 | int64 voting_power = 3; 19 | int64 proposer_priority = 4; 20 | } 21 | 22 | message SimpleValidator { 23 | tendermint.crypto.PublicKey pub_key = 1; 24 | int64 voting_power = 2; 25 | } 26 | -------------------------------------------------------------------------------- /proto/tendermint/version/types.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package tendermint.version; 3 | 4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/version"; 5 | 6 | import "gogoproto/gogo.proto"; 7 | 8 | // App includes the protocol and software version for the application. 9 | // This information is included in ResponseInfo. The App.Protocol can be 10 | // updated in ResponseEndBlock. 11 | message App { 12 | uint64 protocol = 1; 13 | string software = 2; 14 | } 15 | 16 | // Consensus captures the consensus rules for processing a block in the blockchain, 17 | // including all blockchain data structures and the rules of the application's 18 | // state transition machine. 19 | message Consensus { 20 | option (gogoproto.equal) = true; 21 | 22 | uint64 block = 1; 23 | uint64 app = 2; 24 | } 25 | -------------------------------------------------------------------------------- /proxy/version.go: -------------------------------------------------------------------------------- 1 | package proxy 2 | 3 | import ( 4 | abci "github.com/tendermint/tendermint/abci/types" 5 | "github.com/tendermint/tendermint/version" 6 | ) 7 | 8 | // RequestInfo contains all the information for sending 9 | // the abci.RequestInfo message during handshake with the app. 10 | // It contains only compile-time version information. 11 | var RequestInfo = abci.RequestInfo{ 12 | Version: version.TMCoreSemVer, 13 | BlockVersion: version.BlockProtocol, 14 | P2PVersion: version.P2PProtocol, 15 | } 16 | -------------------------------------------------------------------------------- /release_notes.md: -------------------------------------------------------------------------------- 1 | Tendermint Core v0.34.0 is the Tendermint Core release which supports the Stargate upgrade. 2 | 3 | For more information on how to upgrade to Tendermint 0.34, please see [UPGRADING.md](https://github.com/tendermint/tendermint/blob/release/v0.34.0/UPGRADING.md). 4 | For a full list of user-facing changes, please see [CHANGELOG.md](https://github.com/tendermint/tendermint/blob/release/v0.34.0/CHANGELOG.md). -------------------------------------------------------------------------------- /rpc/client/main_test.go: -------------------------------------------------------------------------------- 1 | package client_test 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | 7 | "github.com/tendermint/tendermint/abci/example/kvstore" 8 | nm "github.com/tendermint/tendermint/node" 9 | rpctest "github.com/tendermint/tendermint/rpc/test" 10 | ) 11 | 12 | var node *nm.Node 13 | 14 | func TestMain(m *testing.M) { 15 | // start a tendermint node (and kvstore) in the background to test against 16 | dir, err := os.MkdirTemp("/tmp", "rpc-client-test") 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | app := kvstore.NewPersistentKVStoreApplication(dir) 22 | node = rpctest.StartTendermint(app) 23 | 24 | code := m.Run() 25 | 26 | // and shut down proper at the end 27 | rpctest.StopTendermint(node) 28 | _ = os.RemoveAll(dir) 29 | os.Exit(code) 30 | } 31 | -------------------------------------------------------------------------------- /rpc/client/types.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | // ABCIQueryOptions can be used to provide options for ABCIQuery call other 4 | // than the DefaultABCIQueryOptions. 5 | type ABCIQueryOptions struct { 6 | Height int64 7 | Prove bool 8 | } 9 | 10 | // DefaultABCIQueryOptions are latest height (0) and prove false. 11 | var DefaultABCIQueryOptions = ABCIQueryOptions{Height: 0, Prove: false} 12 | -------------------------------------------------------------------------------- /rpc/core/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Openapi docs 2 | 3 | Do not forget to update ../openapi/openapi.yaml if making changes to any 4 | endpoint. 5 | -------------------------------------------------------------------------------- /rpc/core/README.md: -------------------------------------------------------------------------------- 1 | # Tendermint RPC 2 | 3 | ## Pagination 4 | 5 | Requests that return multiple items will be paginated to 30 items by default. 6 | You can specify further pages with the ?page parameter. You can also set a 7 | custom page size up to 100 with the ?per_page parameter. 8 | 9 | ## Subscribing to events 10 | 11 | The user can subscribe to events emitted by Tendermint, using `/subscribe`. If 12 | the maximum number of clients is reached or the client has too many 13 | subscriptions, an error will be returned. The subscription timeout is 5 sec. 14 | Each subscription has a buffer to accommodate short bursts of events or some 15 | slowness in clients. If the buffer gets full, the subscription will be canceled 16 | ("client is not pulling messages fast enough"). If Tendermint exits, all 17 | subscriptions are canceled ("Tendermint exited"). The user can unsubscribe 18 | using either `/unsubscribe` or `/unsubscribe_all`. 19 | -------------------------------------------------------------------------------- /rpc/core/dev.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | ctypes "github.com/tendermint/tendermint/rpc/core/types" 5 | rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types" 6 | ) 7 | 8 | // UnsafeFlushMempool removes all transactions from the mempool. 9 | func UnsafeFlushMempool(ctx *rpctypes.Context) (*ctypes.ResultUnsafeFlushMempool, error) { 10 | env.Mempool.Flush() 11 | return &ctypes.ResultUnsafeFlushMempool{}, nil 12 | } 13 | -------------------------------------------------------------------------------- /rpc/core/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package core defines the Tendermint RPC endpoints. 3 | 4 | Tendermint ships with its own JSONRPC library - 5 | https://github.com/tendermint/tendermint/tree/v0.34.x/rpc/jsonrpc. 6 | 7 | ## Get the list 8 | 9 | An HTTP Get request to the root RPC endpoint shows a list of available endpoints. 10 | 11 | ```bash 12 | curl 'localhost:26657' 13 | ``` 14 | 15 | > Response: 16 | 17 | ```plain 18 | Available endpoints: 19 | /abci_info 20 | /dump_consensus_state 21 | /genesis 22 | /net_info 23 | /num_unconfirmed_txs 24 | /status 25 | /health 26 | /unconfirmed_txs 27 | /unsafe_flush_mempool 28 | /validators 29 | 30 | Endpoints that require arguments: 31 | /abci_query?path=_&data=_&prove=_ 32 | /block?height=_ 33 | /blockchain?minHeight=_&maxHeight=_ 34 | /broadcast_tx_async?tx=_ 35 | /broadcast_tx_commit?tx=_ 36 | /broadcast_tx_sync?tx=_ 37 | /commit?height=_ 38 | /dial_seeds?seeds=_ 39 | /dial_persistent_peers?persistent_peers=_ 40 | /subscribe?event=_ 41 | /tx?hash=_&prove=_ 42 | /unsubscribe?event=_ 43 | ``` 44 | */ 45 | package core 46 | -------------------------------------------------------------------------------- /rpc/core/doc_template.txt: -------------------------------------------------------------------------------- 1 | {{with .PDoc}} 2 | {{comment_md .Doc}} 3 | {{example_html $ ""}} 4 | 5 | {{range .Funcs}}{{$name_html := html .Name}}## [{{$name_html}}]({{posLink_url $ .Decl}}) 6 | {{comment_md .Doc}}{{end}} 7 | {{end}} 8 | --- 9 | -------------------------------------------------------------------------------- /rpc/core/evidence.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | 7 | ctypes "github.com/tendermint/tendermint/rpc/core/types" 8 | rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types" 9 | "github.com/tendermint/tendermint/types" 10 | ) 11 | 12 | // BroadcastEvidence broadcasts evidence of the misbehavior. 13 | // More: https://docs.tendermint.com/v0.34/rpc/#/Info/broadcast_evidence 14 | func BroadcastEvidence(ctx *rpctypes.Context, ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error) { 15 | if ev == nil { 16 | return nil, errors.New("no evidence was provided") 17 | } 18 | 19 | if err := ev.ValidateBasic(); err != nil { 20 | return nil, fmt.Errorf("evidence.ValidateBasic failed: %w", err) 21 | } 22 | 23 | if err := env.EvidencePool.AddEvidence(ev); err != nil { 24 | return nil, fmt.Errorf("failed to add evidence: %w", err) 25 | } 26 | return &ctypes.ResultBroadcastEvidence{Hash: ev.Hash()}, nil 27 | } 28 | -------------------------------------------------------------------------------- /rpc/core/health.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | ctypes "github.com/tendermint/tendermint/rpc/core/types" 5 | rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types" 6 | ) 7 | 8 | // Health gets node health. Returns empty result (200 OK) on success, no 9 | // response - in case of an error. 10 | // More: https://docs.tendermint.com/v0.34/rpc/#/Info/health 11 | func Health(ctx *rpctypes.Context) (*ctypes.ResultHealth, error) { 12 | return &ctypes.ResultHealth{}, nil 13 | } 14 | -------------------------------------------------------------------------------- /rpc/core/types/responses_test.go: -------------------------------------------------------------------------------- 1 | package coretypes 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | 8 | "github.com/tendermint/tendermint/p2p" 9 | ) 10 | 11 | func TestStatusIndexer(t *testing.T) { 12 | var status *ResultStatus 13 | assert.False(t, status.TxIndexEnabled()) 14 | 15 | status = &ResultStatus{} 16 | assert.False(t, status.TxIndexEnabled()) 17 | 18 | status.NodeInfo = p2p.DefaultNodeInfo{} 19 | assert.False(t, status.TxIndexEnabled()) 20 | 21 | cases := []struct { 22 | expected bool 23 | other p2p.DefaultNodeInfoOther 24 | }{ 25 | {false, p2p.DefaultNodeInfoOther{}}, 26 | {false, p2p.DefaultNodeInfoOther{TxIndex: "aa"}}, 27 | {false, p2p.DefaultNodeInfoOther{TxIndex: "off"}}, 28 | {true, p2p.DefaultNodeInfoOther{TxIndex: "on"}}, 29 | } 30 | 31 | for _, tc := range cases { 32 | status.NodeInfo.Other = tc.other 33 | assert.Equal(t, tc.expected, status.TxIndexEnabled()) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /rpc/grpc/grpc_test.go: -------------------------------------------------------------------------------- 1 | package coregrpc_test 2 | 3 | import ( 4 | "context" 5 | "os" 6 | "testing" 7 | 8 | "github.com/stretchr/testify/require" 9 | 10 | "github.com/tendermint/tendermint/abci/example/kvstore" 11 | core_grpc "github.com/tendermint/tendermint/rpc/grpc" 12 | rpctest "github.com/tendermint/tendermint/rpc/test" 13 | ) 14 | 15 | func TestMain(m *testing.M) { 16 | // start a tendermint node in the background to test against 17 | app := kvstore.NewApplication() 18 | node := rpctest.StartTendermint(app) 19 | 20 | code := m.Run() 21 | 22 | // and shut down proper at the end 23 | rpctest.StopTendermint(node) 24 | os.Exit(code) 25 | } 26 | 27 | func TestBroadcastTx(t *testing.T) { 28 | res, err := rpctest.GetGRPCClient().BroadcastTx( 29 | context.Background(), 30 | &core_grpc.RequestBroadcastTx{Tx: []byte("this is a tx")}, 31 | ) 32 | require.NoError(t, err) 33 | require.EqualValues(t, 0, res.CheckTx.Code) 34 | require.EqualValues(t, 0, res.DeliverTx.Code) 35 | } 36 | -------------------------------------------------------------------------------- /rpc/jsonrpc/client/args_test.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | "github.com/stretchr/testify/require" 8 | ) 9 | 10 | type Tx []byte 11 | 12 | type Foo struct { 13 | Bar int 14 | Baz string 15 | } 16 | 17 | func TestArgToJSON(t *testing.T) { 18 | assert := assert.New(t) 19 | require := require.New(t) 20 | 21 | cases := []struct { 22 | input interface{} 23 | expected string 24 | }{ 25 | {[]byte("1234"), "0x31323334"}, 26 | {Tx("654"), "0x363534"}, 27 | {Foo{7, "hello"}, `{"Bar":"7","Baz":"hello"}`}, 28 | } 29 | 30 | for i, tc := range cases { 31 | args := map[string]interface{}{"data": tc.input} 32 | err := argsToJSON(args) 33 | require.Nil(err, "%d: %+v", i, err) 34 | require.Equal(1, len(args), "%d", i) 35 | data, ok := args["data"].(string) 36 | require.True(ok, "%d: %#v", i, args["data"]) 37 | assert.Equal(tc.expected, data, "%d", i) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /rpc/jsonrpc/client/encode.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "fmt" 5 | "net/url" 6 | "reflect" 7 | 8 | tmjson "github.com/tendermint/tendermint/libs/json" 9 | ) 10 | 11 | func argsToURLValues(args map[string]interface{}) (url.Values, error) { 12 | values := make(url.Values) 13 | if len(args) == 0 { 14 | return values, nil 15 | } 16 | 17 | err := argsToJSON(args) 18 | if err != nil { 19 | return nil, err 20 | } 21 | 22 | for key, val := range args { 23 | values.Set(key, val.(string)) 24 | } 25 | 26 | return values, nil 27 | } 28 | 29 | func argsToJSON(args map[string]interface{}) error { 30 | for k, v := range args { 31 | rt := reflect.TypeOf(v) 32 | isByteSlice := rt.Kind() == reflect.Slice && rt.Elem().Kind() == reflect.Uint8 33 | if isByteSlice { 34 | bytes := reflect.ValueOf(v).Bytes() 35 | args[k] = fmt.Sprintf("0x%X", bytes) 36 | continue 37 | } 38 | 39 | data, err := tmjson.Marshal(v) 40 | if err != nil { 41 | return err 42 | } 43 | args[k] = string(data) 44 | } 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /rpc/jsonrpc/test/data.json: -------------------------------------------------------------------------------- 1 | { 2 | "jsonrpc": "2.0", 3 | "id": "", 4 | "method": "hello_world", 5 | "params": { 6 | "name": "my_world", 7 | "num": 5 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /rpc/openapi/index.html: -------------------------------------------------------------------------------- 1 | <!-- HTML for static distribution bundle build --> 2 | <!DOCTYPE html> 3 | <html lang="en"> 4 | 5 | <head> 6 | <meta charset="UTF-8"> 7 | <title>Tendermint RPC</title> 8 | <link rel="stylesheet" type="text/css" href="//unpkg.com/swagger-ui-dist@3.25.0/swagger-ui.css"> 9 | <link rel="icon" type="image/png" href="//unpkg.com/swagger-ui-dist@3.25.0/favicon-16x16.png" /> 10 | <script src="//unpkg.com/swagger-ui-dist@3.25.0/swagger-ui-bundle.js"></script> 11 | </head> 12 | 13 | <body> 14 | <div id="swagger-ui"></div> 15 | <script> 16 | window.onload = function () { 17 | window.ui = SwaggerUIBundle({ 18 | url: "./openapi.yaml", 19 | dom_id: '#swagger-ui', 20 | deepLinking: true, 21 | layout: "BaseLayout" 22 | }); 23 | } 24 | </script> 25 | </body> 26 | 27 | </html> 28 | -------------------------------------------------------------------------------- /scripts/README.md: -------------------------------------------------------------------------------- 1 | * http://redsymbol.net/articles/unofficial-bash-strict-mode/ 2 | -------------------------------------------------------------------------------- /scripts/authors.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Usage: 4 | # `./authors.sh` 5 | # Print a list of all authors who have committed to develop since master. 6 | # 7 | # `./authors.sh <email address>` 8 | # Lookup the email address on Github and print the associated username 9 | 10 | author=$1 11 | 12 | if [[ "$author" == "" ]]; then 13 | git log master..develop | grep Author | sort | uniq 14 | else 15 | curl -s "https://api.github.com/search/users?q=$author+in%3Aemail&type=Users&utf8=%E2%9C%93" | jq .items[0].login 16 | fi 17 | -------------------------------------------------------------------------------- /scripts/get_nodejs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | VERSION=v12.9.0 4 | NODE_FULL=node-${VERSION}-linux-x64 5 | 6 | mkdir -p ~/.local/bin 7 | mkdir -p ~/.local/node 8 | wget http://nodejs.org/dist/${VERSION}/${NODE_FULL}.tar.gz -O ~/.local/node/${NODE_FULL}.tar.gz 9 | tar -xzf ~/.local/node/${NODE_FULL}.tar.gz -C ~/.local/node/ 10 | ln -s ~/.local/node/${NODE_FULL}/bin/node ~/.local/bin/node 11 | ln -s ~/.local/node/${NODE_FULL}/bin/npm ~/.local/bin/npm 12 | export PATH=~/.local/bin:$PATH 13 | npm i -g dredd 14 | ln -s ~/.local/node/${NODE_FULL}/bin/dredd ~/.local/bin/dredd 15 | -------------------------------------------------------------------------------- /scripts/linkify_changelog.py: -------------------------------------------------------------------------------- 1 | import fileinput 2 | import re 3 | 4 | # This script goes through the provided file, and replaces any " \#<number>", 5 | # with the valid mark down formatted link to it. e.g. 6 | # " [\#number](https://github.com/tendermint/tendermint/issues/<number>) 7 | # Note that if the number is for a PR, github will auto-redirect you when you click the link. 8 | # It is safe to run the script multiple times in succession. 9 | # 10 | # Example usage $ python3 linkify_changelog.py ../CHANGELOG_PENDING.md 11 | for line in fileinput.input(inplace=1): 12 | line = re.sub(r"\s\\#([0-9]*)", r" [\\#\1](https://github.com/tendermint/tendermint/issues/\1)", line.rstrip()) 13 | print(line) -------------------------------------------------------------------------------- /scripts/mockery_generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Invoke Mockery v2 to update generated mocks for the given type. 4 | # 5 | # This script runs a locally-installed "mockery" if available, otherwise it 6 | # runs the published Docker container. This legerdemain is so that the CI build 7 | # and a local build can work off the same script. 8 | # 9 | if ! which mockery ; then 10 | mockery() { 11 | docker run --rm -v "$PWD":/w --workdir=/w vektra/mockery:v2.12.3 12 | } 13 | fi 14 | 15 | mockery --disable-version-string --case underscore --name "$@" 16 | -------------------------------------------------------------------------------- /scripts/proto-gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Update the generated code for protocol buffers in the Tendermint repository. 4 | # This must be run from inside a Tendermint working directory. 5 | # 6 | set -euo pipefail 7 | 8 | # Work from the root of the repository. 9 | cd "$(git rev-parse --show-toplevel)" 10 | 11 | # Run inside Docker to install the correct versions of the required tools 12 | # without polluting the local system. 13 | docker run --rm -i -v "$PWD":/w --workdir=/w golang:1.18-alpine sh <<"EOF" 14 | apk add git make 15 | 16 | go install github.com/bufbuild/buf/cmd/buf 17 | go install github.com/gogo/protobuf/protoc-gen-gogofaster@latest 18 | make proto-gen 19 | EOF 20 | -------------------------------------------------------------------------------- /scripts/qa/reporting/requirements.txt: -------------------------------------------------------------------------------- 1 | contourpy==1.0.5 2 | cycler==0.11.0 3 | fonttools==4.37.4 4 | kiwisolver==1.4.4 5 | matplotlib==3.6.1 6 | numpy==1.23.4 7 | packaging==21.3 8 | Pillow==9.2.0 9 | pyparsing==3.0.9 10 | python-dateutil==2.8.2 11 | six==1.16.0 12 | -------------------------------------------------------------------------------- /scripts/txs/random.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | set -u 3 | 4 | function toHex() { 5 | echo -n $1 | hexdump -ve '1/1 "%.2X"' 6 | } 7 | 8 | N=$1 9 | PORT=$2 10 | 11 | for i in `seq 1 $N`; do 12 | # store key value pair 13 | KEY=$(head -c 10 /dev/urandom) 14 | VALUE="$i" 15 | echo $(toHex $KEY=$VALUE) 16 | curl 127.0.0.1:$PORT/broadcast_tx_sync?tx=0x$(toHex $KEY=$VALUE) 17 | done 18 | 19 | 20 | -------------------------------------------------------------------------------- /spec/blockchain/blockchain.md: -------------------------------------------------------------------------------- 1 | # Blockchain 2 | 3 | Deprecated see [core/data_structures.md](../core/data_structures.md) 4 | -------------------------------------------------------------------------------- /spec/blockchain/encoding.md: -------------------------------------------------------------------------------- 1 | # Encoding 2 | 3 | Deprecated see [core/data_structures.md](../core/encoding.md) 4 | -------------------------------------------------------------------------------- /spec/blockchain/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | order: 1 3 | parent: 4 | title: Blockchain 5 | order: false 6 | --- 7 | 8 | # Blockchain 9 | 10 | This section describes the core types and functionality of the Tendermint protocol implementation. 11 | 12 | [Core Data Structures](../core/data_structures.md) 13 | [Encoding](../core/encoding.md) 14 | [State](../core/state.md) 15 | -------------------------------------------------------------------------------- /spec/blockchain/state.md: -------------------------------------------------------------------------------- 1 | # State 2 | 3 | Deprecated see [core/state.md](../core/state.md) 4 | -------------------------------------------------------------------------------- /spec/consensus/consensus-paper/README.md: -------------------------------------------------------------------------------- 1 | # Tendermint-spec 2 | 3 | The repository contains the specification (and the proofs) of the Tendermint 4 | consensus protocol. 5 | 6 | ## How to install Latex on Mac OS 7 | 8 | MacTex is Latex distribution for Mac OS. You can download it [here](http://www.tug.org/mactex/mactex-download.html). 9 | 10 | Popular IDE for Latex-based projects is TexStudio. It can be downloaded 11 | [here](https://www.texstudio.org/). 12 | 13 | ## How to build project 14 | 15 | In order to compile the latex files (and write bibliography), execute 16 | 17 | `$ pdflatex paper` <br/> 18 | `$ bibtex paper` <br/> 19 | `$ pdflatex paper` <br/> 20 | `$ pdflatex paper` <br/> 21 | 22 | The generated file is paper.pdf. You can open it with 23 | 24 | `$ open paper.pdf` 25 | -------------------------------------------------------------------------------- /spec/consensus/light-client/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | order: 1 3 | parent: 4 | title: Light Client 5 | order: false 6 | --- 7 | # Tendermint Light Client Protocol 8 | 9 | Deprecated, please see [light-client](../../light-client/README.md). 10 | -------------------------------------------------------------------------------- /spec/consensus/light-client/accountability.md: -------------------------------------------------------------------------------- 1 | # Fork accountability 2 | 3 | Deprecated, please see [light-client/accountability](../../light-client/accountability.md). 4 | -------------------------------------------------------------------------------- /spec/consensus/light-client/assets/light-node-image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/spec/consensus/light-client/assets/light-node-image.png -------------------------------------------------------------------------------- /spec/consensus/light-client/detection.md: -------------------------------------------------------------------------------- 1 | # Detection 2 | 3 | Deprecated, please see [light-client/detection](../../light-client/detection.md). 4 | -------------------------------------------------------------------------------- /spec/consensus/light-client/verification.md: -------------------------------------------------------------------------------- 1 | # Core Verification 2 | 3 | Deprecated, please see [light-client/accountability](../../light-client/verification.md). 4 | -------------------------------------------------------------------------------- /spec/consensus/proposer-based-timestamp/README.md: -------------------------------------------------------------------------------- 1 | # Proposer-Based Timestamps 2 | 3 | This section describes a version of the Tendermint consensus protocol, 4 | which uses proposer-based timestamps. 5 | 6 | ## Contents 7 | 8 | - [Proposer-Based Time][main] (entry point) 9 | - [Part I - System Model and Properties][sysmodel] 10 | - [Part II - Protocol Specification][algorithm] 11 | - [TLA+ Specification][proposertla] 12 | 13 | 14 | [algorithm]: ./pbts-algorithm_001_draft.md 15 | 16 | [sysmodel]: ./pbts-sysmodel_001_draft.md 17 | 18 | [main]: ./pbts_001_draft.md 19 | 20 | [proposertla]: ./tla/TendermintPBT_001_draft.tla 21 | -------------------------------------------------------------------------------- /spec/core/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | order: 1 3 | parent: 4 | title: Core 5 | order: 3 6 | --- 7 | 8 | This section describes the core types and functionality of the Tendermint protocol implementation. 9 | 10 | - [Core Data Structures](./data_structures.md) 11 | - [Encoding](./encoding.md) 12 | - [Genesis](./genesis.md) 13 | - [State](./state.md) 14 | -------------------------------------------------------------------------------- /spec/ivy-proofs/check_proofs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # returns non-zero error code if any proof fails 4 | 5 | success=0 6 | log_dir=$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 6) 7 | cmd="ivy_check seed=$RANDOM" 8 | mkdir -p output/$log_dir 9 | 10 | echo "Checking classic safety:" 11 | res=$($cmd classic_safety.ivy | tee "output/$log_dir/classic_safety.txt" | tail -n 1) 12 | if [ "$res" = "OK" ]; then 13 | echo "OK" 14 | else 15 | echo "FAILED" 16 | success=1 17 | fi 18 | 19 | echo "Checking accountable safety 1:" 20 | res=$($cmd accountable_safety_1.ivy | tee "output/$log_dir/accountable_safety_1.txt" | tail -n 1) 21 | if [ "$res" = "OK" ]; then 22 | echo "OK" 23 | else 24 | echo "FAILED" 25 | success=1 26 | fi 27 | 28 | echo "Checking accountable safety 2:" 29 | res=$($cmd complete=fo accountable_safety_2.ivy | tee "output/$log_dir/accountable_safety_2.txt" | tail -n 1) 30 | if [ "$res" = "OK" ]; then 31 | echo "OK" 32 | else 33 | echo "FAILED" 34 | success=1 35 | fi 36 | 37 | echo 38 | echo "See ivy_check output in the output/ folder" 39 | exit $success 40 | -------------------------------------------------------------------------------- /spec/ivy-proofs/count_lines.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | r='^\s*$\|^\s*\#\|^\s*\}\s*$\|^\s*{\s*#39; # removes comments and blank lines and lines that contain only { or } 4 | N1=`cat tendermint.ivy domain_model.ivy network_shim.ivy | grep -v $r'\|.*invariant.*' | wc -l` 5 | N2=`cat abstract_tendermint.ivy | grep "observed_" | wc -l` # the observed_* variables specify the observations of the nodes 6 | SPEC_LINES=`expr $N1 + $N2` 7 | echo "spec lines: $SPEC_LINES" 8 | N3=`cat abstract_tendermint.ivy | grep -v $r'\|.*observed_.*' | wc -l` 9 | N4=`cat accountable_safety_1.ivy | grep -v $r | wc -l` 10 | PROOF_LINES=`expr $N3 + $N4` 11 | echo "proof lines: $PROOF_LINES" 12 | RATIO=`bc <<< "scale=2;$PROOF_LINES / $SPEC_LINES"` 13 | echo "proof-to-code ratio for the accountable-safety property: $RATIO" 14 | -------------------------------------------------------------------------------- /spec/ivy-proofs/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | tendermint-proof: 4 | build: . 5 | volumes: 6 | - ./:/home/user/tendermint-proof:ro 7 | - ./output:/home/user/tendermint-proof/output:rw 8 | 9 | -------------------------------------------------------------------------------- /spec/ivy-proofs/output/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /spec/light-client/accountability/001indinv-apalache.csv: -------------------------------------------------------------------------------- 1 | no,filename,tool,timeout,init,inv,next,args 2 | 1,MC_n4_f1.tla,apalache,10h,TypedInv,TypedInv,,--length=1 --cinit=ConstInit 3 | 2,MC_n4_f2.tla,apalache,10h,TypedInv,TypedInv,,--length=1 --cinit=ConstInit 4 | 3,MC_n5_f1.tla,apalache,10h,TypedInv,TypedInv,,--length=1 --cinit=ConstInit 5 | 4,MC_n5_f2.tla,apalache,10h,TypedInv,TypedInv,,--length=1 --cinit=ConstInit 6 | 5,MC_n4_f1.tla,apalache,20h,Init,TypedInv,,--length=0 --cinit=ConstInit 7 | 6,MC_n4_f2.tla,apalache,20h,Init,TypedInv,,--length=0 --cinit=ConstInit 8 | 7,MC_n5_f1.tla,apalache,20h,Init,TypedInv,,--length=0 --cinit=ConstInit 9 | 8,MC_n5_f2.tla,apalache,20h,Init,TypedInv,,--length=0 --cinit=ConstInit 10 | 9,MC_n4_f1.tla,apalache,20h,TypedInv,Agreement,,--length=0 --cinit=ConstInit 11 | 10,MC_n4_f2.tla,apalache,20h,TypedInv,Accountability,,--length=0 --cinit=ConstInit 12 | 11,MC_n5_f1.tla,apalache,20h,TypedInv,Agreement,,--length=0 --cinit=ConstInit 13 | 12,MC_n5_f2.tla,apalache,20h,TypedInv,Accountability,,--length=0 --cinit=ConstInit 14 | -------------------------------------------------------------------------------- /spec/light-client/accountability/MC_n4_f1.tla: -------------------------------------------------------------------------------- 1 | ----------------------------- MODULE MC_n4_f1 ------------------------------- 2 | CONSTANT Proposer \* the proposer function from 0..NRounds to 1..N 3 | 4 | \* the variables declared in TendermintAcc3 5 | VARIABLES 6 | round, step, decision, lockedValue, lockedRound, validValue, validRound, 7 | msgsPropose, msgsPrevote, msgsPrecommit, evidence, action 8 | 9 | INSTANCE TendermintAccDebug_004_draft WITH 10 | Corr <- {"c1", "c2", "c3"}, 11 | Faulty <- {"f1"}, 12 | N <- 4, 13 | T <- 1, 14 | ValidValues <- { "v0", "v1" }, 15 | InvalidValues <- {"v2"}, 16 | MaxRound <- 2 17 | 18 | \* run Apalache with --cinit=ConstInit 19 | ConstInit == \* the proposer is arbitrary -- works for safety 20 | Proposer \in [Rounds -> AllProcs] 21 | 22 | ============================================================================= 23 | -------------------------------------------------------------------------------- /spec/light-client/accountability/MC_n4_f2.tla: -------------------------------------------------------------------------------- 1 | ----------------------------- MODULE MC_n4_f2 ------------------------------- 2 | CONSTANT Proposer \* the proposer function from 0..NRounds to 1..N 3 | 4 | \* the variables declared in TendermintAcc3 5 | VARIABLES 6 | round, step, decision, lockedValue, lockedRound, validValue, validRound, 7 | msgsPropose, msgsPrevote, msgsPrecommit, evidence, action 8 | 9 | INSTANCE TendermintAccDebug_004_draft WITH 10 | Corr <- {"c1", "c2"}, 11 | Faulty <- {"f3", "f4"}, 12 | N <- 4, 13 | T <- 1, 14 | ValidValues <- { "v0", "v1" }, 15 | InvalidValues <- {"v2"}, 16 | MaxRound <- 2 17 | 18 | \* run Apalache with --cinit=ConstInit 19 | ConstInit == \* the proposer is arbitrary -- works for safety 20 | Proposer \in [Rounds -> AllProcs] 21 | 22 | ============================================================================= 23 | -------------------------------------------------------------------------------- /spec/light-client/accountability/MC_n4_f3.tla: -------------------------------------------------------------------------------- 1 | ----------------------------- MODULE MC_n4_f3 ------------------------------- 2 | CONSTANT Proposer \* the proposer function from 0..NRounds to 1..N 3 | 4 | \* the variables declared in TendermintAcc3 5 | VARIABLES 6 | round, step, decision, lockedValue, lockedRound, validValue, validRound, 7 | msgsPropose, msgsPrevote, msgsPrecommit, evidence, action 8 | 9 | INSTANCE TendermintAccDebug_004_draft WITH 10 | Corr <- {"c1"}, 11 | Faulty <- {"f2", "f3", "f4"}, 12 | N <- 4, 13 | T <- 1, 14 | ValidValues <- { "v0", "v1" }, 15 | InvalidValues <- {"v2"}, 16 | MaxRound <- 2 17 | 18 | \* run Apalache with --cinit=ConstInit 19 | ConstInit == \* the proposer is arbitrary -- works for safety 20 | Proposer \in [Rounds -> AllProcs] 21 | 22 | ============================================================================= 23 | -------------------------------------------------------------------------------- /spec/light-client/accountability/MC_n5_f1.tla: -------------------------------------------------------------------------------- 1 | ----------------------------- MODULE MC_n5_f1 ------------------------------- 2 | CONSTANT Proposer \* the proposer function from 0..NRounds to 1..N 3 | 4 | \* the variables declared in TendermintAcc3 5 | VARIABLES 6 | round, step, decision, lockedValue, lockedRound, validValue, validRound, 7 | msgsPropose, msgsPrevote, msgsPrecommit, evidence, action 8 | 9 | INSTANCE TendermintAccDebug_004_draft WITH 10 | Corr <- {"c1", "c2", "c3", "c4"}, 11 | Faulty <- {"f5"}, 12 | N <- 5, 13 | T <- 1, 14 | ValidValues <- { "v0", "v1" }, 15 | InvalidValues <- {"v2"}, 16 | MaxRound <- 2 17 | 18 | \* run Apalache with --cinit=ConstInit 19 | ConstInit == \* the proposer is arbitrary -- works for safety 20 | Proposer \in [Rounds -> AllProcs] 21 | 22 | ============================================================================= 23 | -------------------------------------------------------------------------------- /spec/light-client/accountability/MC_n5_f2.tla: -------------------------------------------------------------------------------- 1 | ----------------------------- MODULE MC_n5_f2 ------------------------------- 2 | CONSTANT Proposer \* the proposer function from 0..NRounds to 1..N 3 | 4 | \* the variables declared in TendermintAcc3 5 | VARIABLES 6 | round, step, decision, lockedValue, lockedRound, validValue, validRound, 7 | msgsPropose, msgsPrevote, msgsPrecommit, evidence, action 8 | 9 | INSTANCE TendermintAccDebug_004_draft WITH 10 | Corr <- {"c1", "c2", "c3"}, 11 | Faulty <- {"f4", "f5"}, 12 | N <- 5, 13 | T <- 1, 14 | ValidValues <- { "v0", "v1" }, 15 | InvalidValues <- {"v2"}, 16 | MaxRound <- 2 17 | 18 | \* run Apalache with --cinit=ConstInit 19 | ConstInit == \* the proposer is arbitrary -- works for safety 20 | Proposer \in [Rounds -> AllProcs] 21 | 22 | ============================================================================= 23 | -------------------------------------------------------------------------------- /spec/light-client/accountability/MC_n6_f1.tla: -------------------------------------------------------------------------------- 1 | ----------------------------- MODULE MC_n6_f1 ------------------------------- 2 | CONSTANT Proposer \* the proposer function from 0..NRounds to 1..N 3 | 4 | \* the variables declared in TendermintAcc3 5 | VARIABLES 6 | round, step, decision, lockedValue, lockedRound, validValue, validRound, 7 | msgsPropose, msgsPrevote, msgsPrecommit, evidence, action 8 | 9 | INSTANCE TendermintAccDebug_004_draft WITH 10 | Corr <- {"c1", "c2", "c3", "c4", "c5"}, 11 | Faulty <- {"f6"}, 12 | N <- 4, 13 | T <- 1, 14 | ValidValues <- { "v0", "v1" }, 15 | InvalidValues <- {"v2"}, 16 | MaxRound <- 2 17 | 18 | \* run Apalache with --cinit=ConstInit 19 | ConstInit == \* the proposer is arbitrary -- works for safety 20 | Proposer \in [Rounds -> AllProcs] 21 | 22 | ============================================================================= 23 | -------------------------------------------------------------------------------- /spec/light-client/accountability/TendermintAccTrace_004_draft.tla: -------------------------------------------------------------------------------- 1 | ------------------ MODULE TendermintAccTrace_004_draft ------------------------- 2 | (* 3 | When Apalache is running too slow and we have an idea of a counterexample, 4 | we use this module to restrict the behaviors only to certain actions. 5 | Once the whole trace is replayed, the system deadlocks. 6 | 7 | Version 1. 8 | 9 | Igor Konnov, 2020. 10 | *) 11 | 12 | EXTENDS Sequences, Apalache, TendermintAcc_004_draft 13 | 14 | \* a sequence of action names that should appear in the given order, 15 | \* excluding "Init" 16 | CONSTANT Trace 17 | 18 | VARIABLE toReplay 19 | 20 | TraceInit == 21 | /\ toReplay = Trace 22 | /\ action' := "Init" 23 | /\ Init 24 | 25 | TraceNext == 26 | /\ Len(toReplay) > 0 27 | /\ toReplay' = Tail(toReplay) 28 | \* Here is the trick. We restrict the action to the expected one, 29 | \* so the other actions will be pruned 30 | /\ action' := Head(toReplay) 31 | /\ Next 32 | 33 | ================================================================================ 34 | -------------------------------------------------------------------------------- /spec/light-client/accountability/results/001indinv-apalache-unstable.csv: -------------------------------------------------------------------------------- 1 | 01:no,02:tool,03:status,04:time_sec,05:depth,05:mem_kb,10:ninit_trans,11:ninit_trans,12:ncells,13:nclauses,14:navg_clause_len 2 | 1,apalache,NoError,704,1,3215424,0,0,217385,1305718,89 3 | 2,apalache,NoError,699,1,3195020,0,0,207969,1341979,88 4 | 3,apalache,NoError,1018,1,4277060,0,0,311798,2028544,101 5 | 4,apalache,NoError,889,1,4080012,0,0,290989,1951616,103 6 | 5,apalache,NoError,9,0,577100,0,0,2045,14655,42 7 | 6,apalache,NoError,10,0,673772,0,0,2913,28213,43 8 | 7,apalache,NoError,8,0,651008,0,0,2214,17077,44 9 | 8,apalache,NoError,10,0,683188,0,0,3082,32651,45 10 | 9,apalache,NoError,340,0,3053848,0,0,196943,889859,108 11 | 10,apalache,NoError,517,0,6424536,0,0,2856378,3802779,34 12 | 11,apalache,NoError,587,0,4028516,0,0,284369,1343296,128 13 | 12,apalache,NoError,880,0,7881148,0,0,4382556,5778072,38 14 | -------------------------------------------------------------------------------- /spec/light-client/accountability/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # The script to run all experiments at once 4 | 5 | export SCRIPTS_DIR=~/devl/apalache-tests/scripts 6 | export BUILDS="unstable" 7 | export BENCHMARK=001indinv-apalache 8 | export RUN_SCRIPT=./run-all.sh # alternatively, use ./run-parallel.sh 9 | make -e -f ~/devl/apalache-tests/Makefile.common 10 | -------------------------------------------------------------------------------- /spec/light-client/assets/light-node-image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/spec/light-client/assets/light-node-image.png -------------------------------------------------------------------------------- /spec/light-client/attacks/MC_5_3.tla: -------------------------------------------------------------------------------- 1 | ------------------------- MODULE MC_5_3 ------------------------------------- 2 | 3 | AllNodes == {"n1", "n2", "n3", "n4", "n5"} 4 | COMMON_HEIGHT == 1 5 | CONFLICT_HEIGHT == 3 6 | TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-) 7 | FAULTY_RATIO == <<1, 2>> \* < 1 / 2 faulty validators 8 | 9 | VARIABLES 10 | blockchain, \* the reference blockchain 11 | refClock, \* current time in the reference blockchain 12 | Faulty, \* the set of faulty validators 13 | state, \* the state of the light client detector 14 | conflictingBlock, \* an evidence that two peers reported conflicting blocks 15 | attackers 16 | 17 | INSTANCE Isolation_001_draft 18 | ============================================================================ 19 | -------------------------------------------------------------------------------- /spec/light-client/detection/004bmc-apalache-ok.csv: -------------------------------------------------------------------------------- 1 | no;filename;tool;timeout;init;inv;next;args 2 | 1;LCD_MC3_3_faulty.tla;apalache;1h;;CommonHeightOnEvidenceInv;;--length=10 3 | 2;LCD_MC3_3_faulty.tla;apalache;1h;;AccuracyInv;;--length=10 4 | 3;LCD_MC3_3_faulty.tla;apalache;1h;;PrecisionInvLocal;;--length=10 5 | 4;LCD_MC3_4_faulty.tla;apalache;1h;;CommonHeightOnEvidenceInv;;--length=10 6 | 5;LCD_MC3_4_faulty.tla;apalache;1h;;AccuracyInv;;--length=10 7 | 6;LCD_MC3_4_faulty.tla;apalache;1h;;PrecisionInvLocal;;--length=10 8 | 7;LCD_MC4_4_faulty.tla;apalache;1h;;CommonHeightOnEvidenceInv;;--length=10 9 | 8;LCD_MC4_4_faulty.tla;apalache;1h;;AccuracyInv;;--length=10 10 | 9;LCD_MC4_4_faulty.tla;apalache;1h;;PrecisionInvLocal;;--length=10 11 | -------------------------------------------------------------------------------- /spec/light-client/detection/005bmc-apalache-error.csv: -------------------------------------------------------------------------------- 1 | no;filename;tool;timeout;init;inv;next;args 2 | 1;LCD_MC3_3_faulty.tla;apalache;1h;;PrecisionInvGrayZone;;--length=10 3 | 2;LCD_MC3_4_faulty.tla;apalache;1h;;PrecisionInvGrayZone;;--length=10 4 | 3;LCD_MC4_4_faulty.tla;apalache;1h;;PrecisionInvGrayZone;;--length=10 5 | -------------------------------------------------------------------------------- /spec/light-client/experiments.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/spec/light-client/experiments.png -------------------------------------------------------------------------------- /spec/light-client/verification/004bmc-apalache-ok.csv: -------------------------------------------------------------------------------- 1 | no;filename;tool;timeout;init;inv;next;args 2 | 1;LCD_MC3_3_faulty.tla;apalache;1h;;CommonHeightOnEvidenceInv;;--length=10 3 | 2;LCD_MC3_3_faulty.tla;apalache;1h;;AccuracyInv;;--length=10 4 | 3;LCD_MC3_3_faulty.tla;apalache;1h;;PrecisionInvLocal;;--length=10 5 | 4;LCD_MC3_4_faulty.tla;apalache;1h;;CommonHeightOnEvidenceInv;;--length=10 6 | 5;LCD_MC3_4_faulty.tla;apalache;1h;;AccuracyInv;;--length=10 7 | 6;LCD_MC3_4_faulty.tla;apalache;1h;;PrecisionInvLocal;;--length=10 8 | 7;LCD_MC4_4_faulty.tla;apalache;1h;;CommonHeightOnEvidenceInv;;--length=10 9 | 8;LCD_MC4_4_faulty.tla;apalache;1h;;AccuracyInv;;--length=10 10 | 9;LCD_MC4_4_faulty.tla;apalache;1h;;PrecisionInvLocal;;--length=10 11 | -------------------------------------------------------------------------------- /spec/light-client/verification/005bmc-apalache-error.csv: -------------------------------------------------------------------------------- 1 | no;filename;tool;timeout;init;inv;next;args 2 | 1;LCD_MC3_3_faulty.tla;apalache;1h;;PrecisionInvGrayZone;;--length=10 3 | 2;LCD_MC3_4_faulty.tla;apalache;1h;;PrecisionInvGrayZone;;--length=10 4 | 3;LCD_MC4_4_faulty.tla;apalache;1h;;PrecisionInvGrayZone;;--length=10 5 | -------------------------------------------------------------------------------- /spec/light-client/verification/MC4_3_correct.tla: -------------------------------------------------------------------------------- 1 | ---------------------------- MODULE MC4_3_correct --------------------------- 2 | 3 | AllNodes == {"n1", "n2", "n3", "n4"} 4 | TRUSTED_HEIGHT == 1 5 | TARGET_HEIGHT == 3 6 | TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-) 7 | CLOCK_DRIFT == 10 \* how much we assume the local clock is drifting 8 | REAL_CLOCK_DRIFT == 3 \* how much the local clock is actually drifting 9 | IS_PRIMARY_CORRECT == TRUE 10 | FAULTY_RATIO == <<1, 3>> \* < 1 / 3 faulty validators 11 | 12 | VARIABLES 13 | state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified, 14 | nprobes, 15 | localClock, 16 | refClock, blockchain, Faulty 17 | 18 | (* the light client previous state components, used for monitoring *) 19 | VARIABLES 20 | prevVerified, 21 | prevCurrent, 22 | prevLocalClock, 23 | prevVerdict 24 | 25 | INSTANCE Lightclient_003_draft 26 | ============================================================================== 27 | -------------------------------------------------------------------------------- /spec/light-client/verification/MC4_3_faulty.tla: -------------------------------------------------------------------------------- 1 | ---------------------------- MODULE MC4_3_faulty --------------------------- 2 | 3 | AllNodes == {"n1", "n2", "n3", "n4"} 4 | TRUSTED_HEIGHT == 1 5 | TARGET_HEIGHT == 3 6 | TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-) 7 | CLOCK_DRIFT == 10 \* how much we assume the local clock is drifting 8 | REAL_CLOCK_DRIFT == 3 \* how much the local clock is actually drifting 9 | IS_PRIMARY_CORRECT == FALSE 10 | FAULTY_RATIO == <<1, 3>> \* < 1 / 3 faulty validators 11 | 12 | VARIABLES 13 | state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified, 14 | nprobes, 15 | localClock, 16 | refClock, blockchain, Faulty 17 | 18 | (* the light client previous state components, used for monitoring *) 19 | VARIABLES 20 | prevVerified, 21 | prevCurrent, 22 | prevLocalClock, 23 | prevVerdict 24 | 25 | INSTANCE Lightclient_003_draft 26 | ============================================================================== 27 | -------------------------------------------------------------------------------- /spec/light-client/verification/MC4_4_correct.tla: -------------------------------------------------------------------------------- 1 | ------------------------- MODULE MC4_4_correct --------------------------- 2 | 3 | AllNodes == {"n1", "n2", "n3", "n4"} 4 | TRUSTED_HEIGHT == 1 5 | TARGET_HEIGHT == 4 6 | TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-) 7 | CLOCK_DRIFT == 10 \* how much we assume the local clock is drifting 8 | REAL_CLOCK_DRIFT == 3 \* how much the local clock is actually drifting 9 | IS_PRIMARY_CORRECT == TRUE 10 | FAULTY_RATIO == <<1, 3>> \* < 1 / 3 faulty validators 11 | 12 | VARIABLES 13 | state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified, 14 | nprobes, 15 | localClock, 16 | refClock, blockchain, Faulty 17 | 18 | (* the light client previous state components, used for monitoring *) 19 | VARIABLES 20 | prevVerified, 21 | prevCurrent, 22 | prevLocalClock, 23 | prevVerdict 24 | 25 | INSTANCE Lightclient_003_draft 26 | ============================================================================ 27 | -------------------------------------------------------------------------------- /spec/light-client/verification/MC4_4_correct_drifted.tla: -------------------------------------------------------------------------------- 1 | ---------------------- MODULE MC4_4_correct_drifted --------------------------- 2 | 3 | AllNodes == {"n1", "n2", "n3", "n4"} 4 | TRUSTED_HEIGHT == 1 5 | TARGET_HEIGHT == 4 6 | TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-) 7 | CLOCK_DRIFT == 10 \* how much we assume the local clock is drifting 8 | REAL_CLOCK_DRIFT == 30 \* how much the local clock is actually drifting 9 | IS_PRIMARY_CORRECT == TRUE 10 | FAULTY_RATIO == <<1, 3>> \* < 1 / 3 faulty validators 11 | 12 | VARIABLES 13 | state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified, 14 | nprobes, 15 | localClock, 16 | refClock, blockchain, Faulty 17 | 18 | (* the light client previous state components, used for monitoring *) 19 | VARIABLES 20 | prevVerified, 21 | prevCurrent, 22 | prevLocalClock, 23 | prevVerdict 24 | 25 | INSTANCE Lightclient_003_draft 26 | ============================================================================== 27 | -------------------------------------------------------------------------------- /spec/light-client/verification/MC4_4_faulty.tla: -------------------------------------------------------------------------------- 1 | ---------------------------- MODULE MC4_4_faulty --------------------------- 2 | 3 | AllNodes == {"n1", "n2", "n3", "n4"} 4 | TRUSTED_HEIGHT == 1 5 | TARGET_HEIGHT == 4 6 | TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-) 7 | CLOCK_DRIFT == 10 \* how much we assume the local clock is drifting 8 | REAL_CLOCK_DRIFT == 3 \* how much the local clock is actually drifting 9 | IS_PRIMARY_CORRECT == FALSE 10 | FAULTY_RATIO == <<1, 3>> \* < 1 / 3 faulty validators 11 | 12 | VARIABLES 13 | state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified, 14 | nprobes, 15 | localClock, 16 | refClock, blockchain, Faulty 17 | 18 | (* the light client previous state components, used for monitoring *) 19 | VARIABLES 20 | prevVerified, 21 | prevCurrent, 22 | prevLocalClock, 23 | prevVerdict 24 | 25 | INSTANCE Lightclient_003_draft 26 | ============================================================================== 27 | -------------------------------------------------------------------------------- /spec/light-client/verification/MC4_4_faulty_drifted.tla: -------------------------------------------------------------------------------- 1 | ---------------------- MODULE MC4_4_faulty_drifted --------------------------- 2 | 3 | AllNodes == {"n1", "n2", "n3", "n4"} 4 | TRUSTED_HEIGHT == 1 5 | TARGET_HEIGHT == 4 6 | TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-) 7 | CLOCK_DRIFT == 10 \* how much we assume the local clock is drifting 8 | REAL_CLOCK_DRIFT == 30 \* how much the local clock is actually drifting 9 | IS_PRIMARY_CORRECT == FALSE 10 | FAULTY_RATIO == <<1, 3>> \* < 1 / 3 faulty validators 11 | 12 | VARIABLES 13 | state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified, 14 | nprobes, 15 | localClock, 16 | refClock, blockchain, Faulty 17 | 18 | (* the light client previous state components, used for monitoring *) 19 | VARIABLES 20 | prevVerified, 21 | prevCurrent, 22 | prevLocalClock, 23 | prevVerdict 24 | 25 | INSTANCE Lightclient_003_draft 26 | ============================================================================== 27 | -------------------------------------------------------------------------------- /spec/light-client/verification/MC4_5_correct.tla: -------------------------------------------------------------------------------- 1 | ------------------------- MODULE MC4_5_correct --------------------------- 2 | 3 | AllNodes == {"n1", "n2", "n3", "n4"} 4 | TRUSTED_HEIGHT == 1 5 | TARGET_HEIGHT == 5 6 | TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-) 7 | CLOCK_DRIFT == 10 \* how much we assume the local clock is drifting 8 | REAL_CLOCK_DRIFT == 3 \* how much the local clock is actually drifting 9 | IS_PRIMARY_CORRECT == TRUE 10 | FAULTY_RATIO == <<1, 3>> \* < 1 / 3 faulty validators 11 | 12 | VARIABLES 13 | state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified, 14 | nprobes, 15 | localClock, 16 | refClock, blockchain, Faulty 17 | 18 | (* the light client previous state components, used for monitoring *) 19 | VARIABLES 20 | prevVerified, 21 | prevCurrent, 22 | prevLocalClock, 23 | prevVerdict 24 | 25 | INSTANCE Lightclient_003_draft 26 | ============================================================================ 27 | -------------------------------------------------------------------------------- /spec/light-client/verification/MC4_5_faulty.tla: -------------------------------------------------------------------------------- 1 | ------------------------- MODULE MC4_5_faulty --------------------------- 2 | 3 | AllNodes == {"n1", "n2", "n3", "n4"} 4 | TRUSTED_HEIGHT == 1 5 | TARGET_HEIGHT == 5 6 | TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-) 7 | IS_PRICLOCK_DRIFT == 10 \* how much we assume the local clock is drifting 8 | REAL_CLOCK_DRIFT == 3 \* how much the local clock is actually drifting 9 | MARY_CORRECT == FALSE 10 | FAULTY_RATIO == <<1, 3>> \* < 1 / 3 faulty validators 11 | 12 | VARIABLES 13 | state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified, 14 | nprobes, 15 | localClock, 16 | refClock, blockchain, Faulty 17 | 18 | (* the light client previous state components, used for monitoring *) 19 | VARIABLES 20 | prevVerified, 21 | prevCurrent, 22 | prevLocalClock, 23 | prevVerdict 24 | 25 | INSTANCE Lightclient_003_draft 26 | ============================================================================ 27 | -------------------------------------------------------------------------------- /spec/light-client/verification/MC4_6_faulty.tla: -------------------------------------------------------------------------------- 1 | ------------------------- MODULE MC4_6_faulty --------------------------- 2 | 3 | AllNodes == {"n1", "n2", "n3", "n4"} 4 | TRUSTED_HEIGHT == 1 5 | TARGET_HEIGHT == 6 6 | TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-) 7 | IS_PRCLOCK_DRIFT == 10 \* how much we assume the local clock is drifting 8 | REAL_CLOCK_DRIFT == 3 \* how much the local clock is actually drifting 9 | IMARY_CORRECT == FALSE 10 | FAULTY_RATIO == <<1, 3>> \* < 1 / 3 faulty validators 11 | 12 | VARIABLES 13 | state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified, 14 | nprobes, 15 | localClock, 16 | refClock, blockchain, Faulty 17 | 18 | (* the light client previous state components, used for monitoring *) 19 | VARIABLES 20 | prevVerified, 21 | prevCurrent, 22 | prevLocalClock, 23 | prevVerdict 24 | 25 | INSTANCE Lightclient_003_draft 26 | ============================================================================ 27 | -------------------------------------------------------------------------------- /spec/light-client/verification/MC4_7_faulty.tla: -------------------------------------------------------------------------------- 1 | ------------------------- MODULE MC4_7_faulty --------------------------- 2 | 3 | AllNodes == {"n1", "n2", "n3", "n4"} 4 | TRUSTED_HEIGHT == 1 5 | TARGET_HEIGHT == 7 6 | TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-) 7 | CLOCK_DRIFT == 10 \* how much we assume the local clock is drifting 8 | REAL_CLOCK_DRIFT == 3 \* how much the local clock is actually drifting 9 | IS_PRIMARY_CORRECT == FALSE 10 | FAULTY_RATIO == <<1, 3>> \* < 1 / 3 faulty validators 11 | 12 | VARIABLES 13 | state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified, 14 | nprobes, 15 | localClock, 16 | refClock, blockchain, Faulty 17 | 18 | (* the light client previous state components, used for monitoring *) 19 | VARIABLES 20 | prevVerified, 21 | prevCurrent, 22 | prevLocalClock, 23 | prevVerdict 24 | 25 | INSTANCE Lightclient_003_draft 26 | ============================================================================ 27 | -------------------------------------------------------------------------------- /spec/light-client/verification/MC5_5_correct.tla: -------------------------------------------------------------------------------- 1 | ------------------------- MODULE MC5_5_correct --------------------------- 2 | 3 | AllNodes == {"n1", "n2", "n3", "n4", "n5"} 4 | TRUSTED_HEIGHT == 1 5 | TARGET_HEIGHT == 5 6 | TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-) 7 | CLOCK_DRIFT == 10 \* how much we assume the local clock is drifting 8 | REAL_CLOCK_DRIFT == 3 \* how much the local clock is actually drifting 9 | IS_PRIMARY_CORRECT == TRUE 10 | FAULTY_RATIO == <<1, 3>> \* < 1 / 3 faulty validators 11 | 12 | VARIABLES 13 | state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified, 14 | nprobes, 15 | localClock, 16 | refClock, blockchain, Faulty 17 | 18 | (* the light client previous state components, used for monitoring *) 19 | VARIABLES 20 | prevVerified, 21 | prevCurrent, 22 | prevLocalClock, 23 | prevVerdict 24 | 25 | INSTANCE Lightclient_003_draft 26 | ============================================================================ 27 | -------------------------------------------------------------------------------- /spec/light-client/verification/MC5_5_correct_peer_two_thirds_faulty.tla: -------------------------------------------------------------------------------- 1 | ------------------- MODULE MC5_5_correct_peer_two_thirds_faulty ---------------------- 2 | 3 | AllNodes == {"n1", "n2", "n3", "n4", "n5"} 4 | TRUSTED_HEIGHT == 1 5 | TARGET_HEIGHT == 5 6 | TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-) 7 | CLOCK_DRIFT == 10 \* how much we assume the local clock is drifting 8 | REAL_CLOCK_DRIFT == 3 \* how much the local clock is actually drifting 9 | IS_PRIMARY_CORRECT == TRUE 10 | FAULTY_RATIO == <<2, 3>> \* < 1 / 3 faulty validators 11 | 12 | VARIABLES 13 | state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified, 14 | nprobes, 15 | localClock, 16 | refClock, blockchain, Faulty 17 | 18 | (* the light client previous state components, used for monitoring *) 19 | VARIABLES 20 | prevVerified, 21 | prevCurrent, 22 | prevLocalClock, 23 | prevVerdict 24 | 25 | INSTANCE Lightclient_003_draft 26 | ============================================================================ 27 | -------------------------------------------------------------------------------- /spec/light-client/verification/MC5_5_faulty.tla: -------------------------------------------------------------------------------- 1 | ----------------- MODULE MC5_5_faulty --------------------- 2 | 3 | AllNodes == {"n1", "n2", "n3", "n4", "n5"} 4 | TRUSTED_HEIGHT == 1 5 | TARGET_HEIGHT == 5 6 | TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-) 7 | CLOCK_DRIFT == 10 \* how much we assume the local clock is drifting 8 | REAL_CLOCK_DRIFT == 3 \* how much the local clock is actually drifting 9 | IS_PRIMARY_CORRECT == FALSE 10 | FAULTY_RATIO == <<2, 3>> \* < 1 / 3 faulty validators 11 | 12 | VARIABLES 13 | state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified, 14 | nprobes, 15 | localClock, 16 | refClock, blockchain, Faulty 17 | 18 | (* the light client previous state components, used for monitoring *) 19 | VARIABLES 20 | prevVerified, 21 | prevCurrent, 22 | prevLocalClock, 23 | prevVerdict 24 | 25 | INSTANCE Lightclient_003_draft 26 | ============================================================================ 27 | -------------------------------------------------------------------------------- /spec/light-client/verification/MC5_5_faulty_peer_two_thirds_faulty.tla: -------------------------------------------------------------------------------- 1 | ----------------- MODULE MC5_5_faulty_peer_two_thirds_faulty --------------------- 2 | 3 | AllNodes == {"n1", "n2", "n3", "n4", "n5"} 4 | TRUSTED_HEIGHT == 1 5 | TARGET_HEIGHT == 5 6 | TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-) 7 | CLOCK_DRIFT == 10 \* how much we assume the local clock is drifting 8 | REAL_CLOCK_DRIFT == 3 \* how much the local clock is actually drifting 9 | IS_PRIMARY_CORRECT == FALSE 10 | FAULTY_RATIO == <<2, 3>> \* < 2 / 3 faulty validators 11 | 12 | VARIABLES 13 | state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified, 14 | nprobes, 15 | localClock, 16 | refClock, blockchain, Faulty 17 | 18 | (* the light client previous state components, used for monitoring *) 19 | VARIABLES 20 | prevVerified, 21 | prevCurrent, 22 | prevLocalClock, 23 | prevVerdict 24 | 25 | INSTANCE Lightclient_003_draft 26 | ============================================================================ 27 | -------------------------------------------------------------------------------- /spec/light-client/verification/MC5_7_faulty.tla: -------------------------------------------------------------------------------- 1 | ------------------------- MODULE MC5_7_faulty --------------------------- 2 | 3 | AllNodes == {"n1", "n2", "n3", "n4", "n5"} 4 | TRUSTED_HEIGHT == 1 5 | TARGET_HEIGHT == 7 6 | TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-) 7 | CLOCK_DRIFT == 10 \* how much we assume the local clock is drifting 8 | REAL_CLOCK_DRIFT == 3 \* how much the local clock is actually drifting 9 | IS_PRIMARY_CORRECT == FALSE 10 | FAULTY_RATIO == <<1, 3>> \* < 1 / 3 faulty validators 11 | 12 | VARIABLES 13 | state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified, 14 | nprobes, 15 | localClock, 16 | refClock, blockchain, Faulty 17 | 18 | (* the light client previous state components, used for monitoring *) 19 | VARIABLES 20 | prevVerified, 21 | prevCurrent, 22 | prevLocalClock, 23 | prevVerdict 24 | 25 | INSTANCE Lightclient_003_draft 26 | ============================================================================ 27 | -------------------------------------------------------------------------------- /spec/light-client/verification/MC7_5_faulty.tla: -------------------------------------------------------------------------------- 1 | ------------------------- MODULE MC7_5_faulty --------------------------- 2 | 3 | AllNodes == {"n1", "n2", "n3", "n4", "n5", "n6", "n7"} 4 | TRUSTED_HEIGHT == 1 5 | TARGET_HEIGHT == 5 6 | TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-) 7 | CLOCK_DRIFT == 10 \* how much we assume the local clock is drifting 8 | REAL_CLOCK_DRIFT == 3 \* how much the local clock is actually drifting 9 | IS_PRIMARY_CORRECT == FALSE 10 | FAULTY_RATIO == <<1, 3>> \* < 1 / 3 faulty validators 11 | 12 | VARIABLES 13 | state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified, 14 | nprobes, 15 | localClock, 16 | refClock, blockchain, Faulty 17 | 18 | (* the light client previous state components, used for monitoring *) 19 | VARIABLES 20 | prevVerified, 21 | prevCurrent, 22 | prevLocalClock, 23 | prevVerdict 24 | 25 | INSTANCE Lightclient_003_draft 26 | ============================================================================ 27 | -------------------------------------------------------------------------------- /spec/light-client/verification/MC7_7_faulty.tla: -------------------------------------------------------------------------------- 1 | ------------------------- MODULE MC7_7_faulty --------------------------- 2 | 3 | AllNodes == {"n1", "n2", "n3", "n4", "n5", "n6", "n7"} 4 | TRUSTED_HEIGHT == 1 5 | TARGET_HEIGHT == 7 6 | TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-) 7 | CLOCK_DRIFT == 10 \* how much we assume the local clock is drifting 8 | REAL_CLOCK_DRIFT == 3 \* how much the local clock is actually drifting 9 | IS_PRIMARY_CORRECT == FALSE 10 | FAULTY_RATIO == <<1, 3>> \* < 1 / 3 faulty validators 11 | 12 | VARIABLES 13 | state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified, 14 | nprobes, 15 | localClock, 16 | refClock, blockchain, Faulty 17 | 18 | (* the light client previous state components, used for monitoring *) 19 | VARIABLES 20 | prevVerified, 21 | prevCurrent, 22 | prevLocalClock, 23 | prevVerdict 24 | 25 | INSTANCE Lightclient_003_draft 26 | ============================================================================ 27 | -------------------------------------------------------------------------------- /spec/p2p/messages/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | order: 1 3 | parent: 4 | title: Messages 5 | order: 1 6 | --- 7 | 8 | # Messages 9 | 10 | An implementation of the spec consists of many components. While many parts of these components are implementation specific, the p2p messages are not. In this section we will be covering all the p2p messages of components. 11 | 12 | There are two parts to the P2P messages, the message and the channel. The channel is message specific and messages are specific to components of Tendermint. When a node connect to a peer it will tell the other node which channels are available. This notifies the peer what services the connecting node offers. You can read more on channels in [connection.md](../connection.md#mconnection) 13 | 14 | - [Block Sync](./block-sync.md) 15 | - [Mempool](./mempool.md) 16 | - [Evidence](./evidence.md) 17 | - [State Sync](./state-sync.md) 18 | - [Pex](./pex.md) 19 | - [Consensus](./consensus.md) 20 | -------------------------------------------------------------------------------- /spec/p2p/messages/evidence.md: -------------------------------------------------------------------------------- 1 | --- 2 | order: 3 3 | --- 4 | 5 | # Evidence 6 | 7 | ## Channel 8 | 9 | Evidence has one channel. The channel identifier is listed below. 10 | 11 | | Name | Number | 12 | |-----------------|--------| 13 | | EvidenceChannel | 56 | 14 | 15 | ## Message Types 16 | 17 | ### EvidenceList 18 | 19 | EvidenceList consists of a list of verified evidence. This evidence will already have been propagated throughout the network. EvidenceList is used in two places, as a p2p message and within the block [block](../../core/data_structures.md#block) as well. 20 | 21 | | Name | Type | Description | Field Number | 22 | |----------|-------------------------------------------------------------|------------------------|--------------| 23 | | evidence | repeated [Evidence](../../core/data_structures.md#evidence) | List of valid evidence | 1 | 24 | -------------------------------------------------------------------------------- /spec/p2p/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | order: 1 3 | parent: 4 | title: P2P 5 | order: 6 6 | --- 7 | -------------------------------------------------------------------------------- /state/indexer/block.go: -------------------------------------------------------------------------------- 1 | package indexer 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/tendermint/tendermint/libs/pubsub/query" 7 | "github.com/tendermint/tendermint/types" 8 | ) 9 | 10 | //go:generate ../../scripts/mockery_generate.sh BlockIndexer 11 | 12 | // BlockIndexer defines an interface contract for indexing block events. 13 | type BlockIndexer interface { 14 | // Has returns true if the given height has been indexed. An error is returned 15 | // upon database query failure. 16 | Has(height int64) (bool, error) 17 | 18 | // Index indexes BeginBlock and EndBlock events for a given block by its height. 19 | Index(types.EventDataNewBlockHeader) error 20 | 21 | // Search performs a query for block heights that match a given BeginBlock 22 | // and Endblock event search criteria. 23 | Search(ctx context.Context, q *query.Query) ([]int64, error) 24 | } 25 | -------------------------------------------------------------------------------- /state/indexer/block/null/null.go: -------------------------------------------------------------------------------- 1 | package null 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | 7 | "github.com/tendermint/tendermint/libs/pubsub/query" 8 | "github.com/tendermint/tendermint/state/indexer" 9 | "github.com/tendermint/tendermint/types" 10 | ) 11 | 12 | var _ indexer.BlockIndexer = (*BlockerIndexer)(nil) 13 | 14 | // TxIndex implements a no-op block indexer. 15 | type BlockerIndexer struct{} 16 | 17 | func (idx *BlockerIndexer) Has(height int64) (bool, error) { 18 | return false, errors.New(`indexing is disabled (set 'tx_index = "kv"' in config)`) 19 | } 20 | 21 | func (idx *BlockerIndexer) Index(types.EventDataNewBlockHeader) error { 22 | return nil 23 | } 24 | 25 | func (idx *BlockerIndexer) Search(ctx context.Context, q *query.Query) ([]int64, error) { 26 | return []int64{}, nil 27 | } 28 | -------------------------------------------------------------------------------- /state/indexer/sink/psql/backport_test.go: -------------------------------------------------------------------------------- 1 | package psql 2 | 3 | import ( 4 | "github.com/tendermint/tendermint/state/indexer" 5 | "github.com/tendermint/tendermint/state/txindex" 6 | ) 7 | 8 | var ( 9 | _ indexer.BlockIndexer = BackportBlockIndexer{} 10 | _ txindex.TxIndexer = BackportTxIndexer{} 11 | ) 12 | -------------------------------------------------------------------------------- /state/tx_filter.go: -------------------------------------------------------------------------------- 1 | package state 2 | 3 | import ( 4 | mempl "github.com/tendermint/tendermint/mempool" 5 | "github.com/tendermint/tendermint/types" 6 | ) 7 | 8 | // TxPreCheck returns a function to filter transactions before processing. 9 | // The function limits the size of a transaction to the block's maximum data size. 10 | func TxPreCheck(state State) mempl.PreCheckFunc { 11 | maxDataBytes := types.MaxDataBytesNoEvidence( 12 | state.ConsensusParams.Block.MaxBytes, 13 | state.Validators.Size(), 14 | ) 15 | return mempl.PreCheckMaxBytes(maxDataBytes) 16 | } 17 | 18 | // TxPostCheck returns a function to filter transactions after processing. 19 | // The function limits the gas wanted by a transaction to the block's maximum total gas. 20 | func TxPostCheck(state State) mempl.PostCheckFunc { 21 | return mempl.PostCheckMaxGas(state.ConsensusParams.Block.MaxGas) 22 | } 23 | -------------------------------------------------------------------------------- /state/txindex/kv/utils.go: -------------------------------------------------------------------------------- 1 | package kv 2 | 3 | // IntInSlice returns true if a is found in the list. 4 | func intInSlice(a int, list []int) bool { 5 | for _, b := range list { 6 | if b == a { 7 | return true 8 | } 9 | } 10 | return false 11 | } 12 | -------------------------------------------------------------------------------- /state/txindex/kv/utils_test.go: -------------------------------------------------------------------------------- 1 | package kv 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func TestIntInSlice(t *testing.T) { 10 | assert.True(t, intInSlice(1, []int{1, 2, 3})) 11 | assert.False(t, intInSlice(4, []int{1, 2, 3})) 12 | assert.True(t, intInSlice(0, []int{0})) 13 | assert.False(t, intInSlice(0, []int{})) 14 | } 15 | -------------------------------------------------------------------------------- /state/txindex/null/null.go: -------------------------------------------------------------------------------- 1 | package null 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | 7 | abci "github.com/tendermint/tendermint/abci/types" 8 | "github.com/tendermint/tendermint/libs/pubsub/query" 9 | "github.com/tendermint/tendermint/state/txindex" 10 | ) 11 | 12 | var _ txindex.TxIndexer = (*TxIndex)(nil) 13 | 14 | // TxIndex acts as a /dev/null. 15 | type TxIndex struct{} 16 | 17 | // Get on a TxIndex is disabled and panics when invoked. 18 | func (txi *TxIndex) Get(hash []byte) (*abci.TxResult, error) { 19 | return nil, errors.New(`indexing is disabled (set 'tx_index = "kv"' in config)`) 20 | } 21 | 22 | // AddBatch is a noop and always returns nil. 23 | func (txi *TxIndex) AddBatch(batch *txindex.Batch) error { 24 | return nil 25 | } 26 | 27 | // Index is a noop and always returns nil. 28 | func (txi *TxIndex) Index(result *abci.TxResult) error { 29 | return nil 30 | } 31 | 32 | func (txi *TxIndex) Search(ctx context.Context, q *query.Query) ([]*abci.TxResult, error) { 33 | return []*abci.TxResult{}, nil 34 | } 35 | -------------------------------------------------------------------------------- /test/README.md: -------------------------------------------------------------------------------- 1 | # Tendermint Tests 2 | 3 | The unit tests (ie. the `go test` s) can be run with `make test`. 4 | The integration tests can be run with `make test_integrations`. 5 | 6 | Running the integrations test will build a docker container with local version of tendermint 7 | and run the following tests in docker containers: 8 | 9 | - go tests, with --race 10 | - includes test coverage 11 | - app tests 12 | - kvstore app over socket 13 | - counter app over socket 14 | - counter app over grpc 15 | - persistence tests 16 | - crash tendermint at each of many predefined points, restart, and ensure it syncs properly with the app 17 | 18 | ## Fuzzing 19 | 20 | [Fuzzing](https://en.wikipedia.org/wiki/Fuzzing) of various system inputs. 21 | 22 | See `./fuzz/README.md` for more details. 23 | -------------------------------------------------------------------------------- /test/app/clean.sh: -------------------------------------------------------------------------------- 1 | killall tendermint 2 | killall abci-cli 3 | rm -rf ~/.tendermint_app 4 | -------------------------------------------------------------------------------- /test/app/grpc_client.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/hex" 5 | "fmt" 6 | "os" 7 | 8 | "context" 9 | 10 | tmjson "github.com/tendermint/tendermint/libs/json" 11 | coregrpc "github.com/tendermint/tendermint/rpc/grpc" 12 | ) 13 | 14 | var grpcAddr = "tcp://localhost:36656" 15 | 16 | func main() { 17 | args := os.Args 18 | if len(args) == 1 { 19 | fmt.Println("Must enter a transaction to send (hex)") 20 | os.Exit(1) 21 | } 22 | tx := args[1] 23 | txBytes, err := hex.DecodeString(tx) 24 | if err != nil { 25 | fmt.Println("Invalid hex", err) 26 | os.Exit(1) 27 | } 28 | 29 | clientGRPC := coregrpc.StartGRPCClient(grpcAddr) 30 | res, err := clientGRPC.BroadcastTx(context.Background(), &coregrpc.RequestBroadcastTx{Tx: txBytes}) 31 | if err != nil { 32 | fmt.Println(err) 33 | os.Exit(1) 34 | } 35 | 36 | bz, err := tmjson.Marshal(res) 37 | if err != nil { 38 | fmt.Println(err) 39 | os.Exit(1) 40 | } 41 | fmt.Println(string(bz)) 42 | } 43 | -------------------------------------------------------------------------------- /test/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.18 2 | 3 | # Grab deps (jq, hexdump, xxd, killall) 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | jq bsdmainutils vim-common psmisc netcat curl 7 | 8 | # Setup tendermint repo 9 | ENV REPO $GOPATH/src/github.com/tendermint/tendermint 10 | ENV GOBIN $GOPATH/bin 11 | WORKDIR $REPO 12 | 13 | # Copy in the code 14 | # TODO: rewrite to only copy Makefile & other files? 15 | COPY . $REPO 16 | 17 | # Install the vendored dependencies 18 | # docker caching prevents reinstall on code change! 19 | RUN make tools 20 | 21 | # install ABCI CLI 22 | RUN make install_abci 23 | 24 | # install Tendermint 25 | RUN make install 26 | 27 | RUN tendermint testnet \ 28 | --config $REPO/test/docker/config-template.toml \ 29 | --node-dir-prefix="mach" \ 30 | --v=4 \ 31 | --populate-persistent-peers=false \ 32 | --o=$REPO/test/p2p/data 33 | 34 | # Now copy in the code 35 | # NOTE: this will overwrite whatever is in vendor/ 36 | COPY . $REPO 37 | 38 | # expose the volume for debugging 39 | VOLUME $REPO 40 | 41 | EXPOSE 26656 42 | EXPOSE 26657 43 | -------------------------------------------------------------------------------- /test/docker/build.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | docker build -t tester -f ./test/docker/Dockerfile . 4 | -------------------------------------------------------------------------------- /test/docker/config-template.toml: -------------------------------------------------------------------------------- 1 | [rpc] 2 | laddr = "tcp://0.0.0.0:26657" 3 | -------------------------------------------------------------------------------- /test/e2e/Makefile: -------------------------------------------------------------------------------- 1 | all: docker generator runner 2 | 3 | docker: 4 | docker build --tag tendermint/e2e-node -f docker/Dockerfile ../.. 5 | 6 | # We need to build support for database backends into the app in 7 | # order to build a binary with a Tendermint node in it (for built-in 8 | # ABCI testing). 9 | node: 10 | go build -o build/node -tags badgerdb,boltdb,cleveldb,rocksdb ./node 11 | 12 | # To be used primarily by the e2e docker instance. If you want to produce this binary 13 | # elsewhere, then run go build in the maverick directory. 14 | maverick: 15 | go build -o build/maverick -tags badgerdb,boltdb,cleveldb,rocksdb ../maverick 16 | 17 | generator: 18 | go build -o build/generator ./generator 19 | 20 | runner: 21 | go build -o build/runner ./runner 22 | 23 | .PHONY: all node docker generator maverick runner 24 | -------------------------------------------------------------------------------- /test/e2e/docker/entrypoint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Forcibly remove any stray UNIX sockets left behind from previous runs 4 | rm -rf /var/run/privval.sock /var/run/app.sock 5 | 6 | /usr/bin/app /tendermint/config/app.toml & 7 | 8 | sleep 1 9 | 10 | /usr/bin/tendermint "$@" 11 | -------------------------------------------------------------------------------- /test/e2e/docker/entrypoint-builtin: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Forcibly remove any stray UNIX sockets left behind from previous runs 4 | rm -rf /var/run/privval.sock /var/run/app.sock 5 | 6 | /usr/bin/app /tendermint/config/app.toml 7 | -------------------------------------------------------------------------------- /test/e2e/docker/entrypoint-maverick: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Forcibly remove any stray UNIX sockets left behind from previous runs 4 | rm -rf /var/run/privval.sock /var/run/app.sock 5 | 6 | /usr/bin/app /tendermint/config/app.toml & 7 | 8 | sleep 1 9 | 10 | /usr/bin/maverick "$@" 11 | -------------------------------------------------------------------------------- /test/e2e/generator/random_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func TestCombinations(t *testing.T) { 10 | input := map[string][]interface{}{ 11 | "bool": {false, true}, 12 | "int": {1, 2, 3}, 13 | "string": {"foo", "bar"}, 14 | } 15 | 16 | c := combinations(input) 17 | assert.Equal(t, []map[string]interface{}{ 18 | {"bool": false, "int": 1, "string": "foo"}, 19 | {"bool": false, "int": 1, "string": "bar"}, 20 | {"bool": false, "int": 2, "string": "foo"}, 21 | {"bool": false, "int": 2, "string": "bar"}, 22 | {"bool": false, "int": 3, "string": "foo"}, 23 | {"bool": false, "int": 3, "string": "bar"}, 24 | {"bool": true, "int": 1, "string": "foo"}, 25 | {"bool": true, "int": 1, "string": "bar"}, 26 | {"bool": true, "int": 2, "string": "foo"}, 27 | {"bool": true, "int": 2, "string": "bar"}, 28 | {"bool": true, "int": 3, "string": "foo"}, 29 | {"bool": true, "int": 3, "string": "bar"}, 30 | }, c) 31 | } 32 | -------------------------------------------------------------------------------- /test/e2e/networks/simple.toml: -------------------------------------------------------------------------------- 1 | [node.validator01] 2 | [node.validator02] 3 | [node.validator03] 4 | [node.validator04] 5 | 6 | -------------------------------------------------------------------------------- /test/e2e/networks/single.toml: -------------------------------------------------------------------------------- 1 | [node.validator] 2 | -------------------------------------------------------------------------------- /test/e2e/node/built-in.toml: -------------------------------------------------------------------------------- 1 | snapshot_interval = 100 2 | persist_interval = 1 3 | chain_id = "test-chain" 4 | protocol = "builtin" 5 | -------------------------------------------------------------------------------- /test/e2e/node/socket.toml: -------------------------------------------------------------------------------- 1 | snapshot_interval = 100 2 | persist_interval = 1 3 | chain_id = "test-chain" 4 | protocol = "socket" 5 | listen = "tcp://127.0.0.1:26658" 6 | -------------------------------------------------------------------------------- /test/e2e/pkg/infra/provider.go: -------------------------------------------------------------------------------- 1 | package infra 2 | 3 | // Provider defines an API for manipulating the infrastructure of a 4 | // specific set of testnet infrastructure. 5 | type Provider interface { 6 | 7 | // Setup generates any necessary configuration for the infrastructure 8 | // provider during testnet setup. 9 | Setup() error 10 | } 11 | 12 | // NoopProvider implements the provider interface by performing noops for every 13 | // interface method. This may be useful if the infrastructure is managed by a 14 | // separate process. 15 | type NoopProvider struct { 16 | } 17 | 18 | func (NoopProvider) Setup() error { return nil } 19 | 20 | var _ Provider = NoopProvider{} 21 | -------------------------------------------------------------------------------- /test/e2e/runner/test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | e2e "github.com/tendermint/tendermint/test/e2e/pkg" 7 | ) 8 | 9 | // Test runs test cases under tests/ 10 | func Test(testnet *e2e.Testnet) error { 11 | logger.Info("Running tests in ./tests/...") 12 | 13 | err := os.Setenv("E2E_MANIFEST", testnet.File) 14 | if err != nil { 15 | return err 16 | } 17 | 18 | return execVerbose("go", "test", "-count", "1", "./tests/...") 19 | } 20 | -------------------------------------------------------------------------------- /test/fuzz/Makefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | .PHONY: fuzz-mempool 4 | fuzz-mempool: 5 | cd mempool && \ 6 | rm -f *-fuzz.zip && \ 7 | go-fuzz-build && \ 8 | go-fuzz 9 | 10 | .PHONY: fuzz-p2p-addrbook 11 | fuzz-p2p-addrbook: 12 | cd p2p/addrbook && \ 13 | rm -f *-fuzz.zip && \ 14 | go run ./init-corpus/main.go && \ 15 | go-fuzz-build && \ 16 | go-fuzz 17 | 18 | .PHONY: fuzz-p2p-pex 19 | fuzz-p2p-pex: 20 | cd p2p/pex && \ 21 | rm -f *-fuzz.zip && \ 22 | go run ./init-corpus/main.go && \ 23 | go-fuzz-build && \ 24 | go-fuzz 25 | 26 | .PHONY: fuzz-p2p-sc 27 | fuzz-p2p-sc: 28 | cd p2p/secret_connection && \ 29 | rm -f *-fuzz.zip && \ 30 | go run ./init-corpus/main.go && \ 31 | go-fuzz-build && \ 32 | go-fuzz 33 | 34 | .PHONY: fuzz-rpc-server 35 | fuzz-rpc-server: 36 | cd rpc/jsonrpc/server && \ 37 | rm -f *-fuzz.zip && \ 38 | go-fuzz-build && \ 39 | go-fuzz 40 | -------------------------------------------------------------------------------- /test/fuzz/mempool/v0/checktx.go: -------------------------------------------------------------------------------- 1 | package v0 2 | 3 | import ( 4 | "github.com/tendermint/tendermint/abci/example/kvstore" 5 | "github.com/tendermint/tendermint/config" 6 | mempl "github.com/tendermint/tendermint/mempool" 7 | mempoolv0 "github.com/tendermint/tendermint/mempool/v0" 8 | "github.com/tendermint/tendermint/proxy" 9 | ) 10 | 11 | var mempool mempl.Mempool 12 | 13 | func init() { 14 | app := kvstore.NewApplication() 15 | cc := proxy.NewLocalClientCreator(app) 16 | appConnMem, _ := cc.NewABCIClient() 17 | err := appConnMem.Start() 18 | if err != nil { 19 | panic(err) 20 | } 21 | 22 | cfg := config.DefaultMempoolConfig() 23 | cfg.Broadcast = false 24 | mempool = mempoolv0.NewCListMempool(cfg, appConnMem, 0) 25 | } 26 | 27 | func Fuzz(data []byte) int { 28 | err := mempool.CheckTx(data, nil, mempl.TxInfo{}) 29 | if err != nil { 30 | return 0 31 | } 32 | 33 | return 1 34 | } 35 | -------------------------------------------------------------------------------- /test/fuzz/mempool/v0/fuzz_test.go: -------------------------------------------------------------------------------- 1 | package v0_test 2 | 3 | import ( 4 | "io" 5 | "os" 6 | "path/filepath" 7 | "testing" 8 | 9 | "github.com/stretchr/testify/require" 10 | 11 | mempoolv0 "github.com/tendermint/tendermint/test/fuzz/mempool/v0" 12 | ) 13 | 14 | const testdataCasesDir = "testdata/cases" 15 | 16 | func TestMempoolTestdataCases(t *testing.T) { 17 | entries, err := os.ReadDir(testdataCasesDir) 18 | require.NoError(t, err) 19 | 20 | for _, e := range entries { 21 | entry := e 22 | t.Run(entry.Name(), func(t *testing.T) { 23 | defer func() { 24 | r := recover() 25 | require.Nilf(t, r, "testdata/cases test panic") 26 | }() 27 | f, err := os.Open(filepath.Join(testdataCasesDir, entry.Name())) 28 | require.NoError(t, err) 29 | input, err := io.ReadAll(f) 30 | require.NoError(t, err) 31 | mempoolv0.Fuzz(input) 32 | }) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /test/fuzz/mempool/v0/testdata/cases/empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/test/fuzz/mempool/v0/testdata/cases/empty -------------------------------------------------------------------------------- /test/fuzz/mempool/v1/checktx.go: -------------------------------------------------------------------------------- 1 | package v1 2 | 3 | import ( 4 | "github.com/tendermint/tendermint/abci/example/kvstore" 5 | "github.com/tendermint/tendermint/config" 6 | "github.com/tendermint/tendermint/libs/log" 7 | mempl "github.com/tendermint/tendermint/mempool" 8 | "github.com/tendermint/tendermint/proxy" 9 | 10 | mempoolv1 "github.com/tendermint/tendermint/mempool/v1" 11 | ) 12 | 13 | var mempool mempl.Mempool 14 | 15 | func init() { 16 | app := kvstore.NewApplication() 17 | cc := proxy.NewLocalClientCreator(app) 18 | appConnMem, _ := cc.NewABCIClient() 19 | err := appConnMem.Start() 20 | if err != nil { 21 | panic(err) 22 | } 23 | cfg := config.DefaultMempoolConfig() 24 | cfg.Broadcast = false 25 | log := log.NewNopLogger() 26 | mempool = mempoolv1.NewTxMempool(log, cfg, appConnMem, 0) 27 | } 28 | 29 | func Fuzz(data []byte) int { 30 | 31 | err := mempool.CheckTx(data, nil, mempl.TxInfo{}) 32 | if err != nil { 33 | return 0 34 | } 35 | 36 | return 1 37 | } 38 | -------------------------------------------------------------------------------- /test/fuzz/mempool/v1/fuzz_test.go: -------------------------------------------------------------------------------- 1 | package v1_test 2 | 3 | import ( 4 | "io" 5 | "os" 6 | "path/filepath" 7 | "testing" 8 | 9 | "github.com/stretchr/testify/require" 10 | 11 | mempoolv1 "github.com/tendermint/tendermint/test/fuzz/mempool/v1" 12 | ) 13 | 14 | const testdataCasesDir = "testdata/cases" 15 | 16 | func TestMempoolTestdataCases(t *testing.T) { 17 | entries, err := os.ReadDir(testdataCasesDir) 18 | require.NoError(t, err) 19 | 20 | for _, e := range entries { 21 | entry := e 22 | t.Run(entry.Name(), func(t *testing.T) { 23 | defer func() { 24 | r := recover() 25 | require.Nilf(t, r, "testdata/cases test panic") 26 | }() 27 | f, err := os.Open(filepath.Join(testdataCasesDir, entry.Name())) 28 | require.NoError(t, err) 29 | input, err := io.ReadAll(f) 30 | require.NoError(t, err) 31 | mempoolv1.Fuzz(input) 32 | }) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /test/fuzz/mempool/v1/testdata/cases/empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/test/fuzz/mempool/v1/testdata/cases/empty -------------------------------------------------------------------------------- /test/fuzz/p2p/addrbook/fuzz.go: -------------------------------------------------------------------------------- 1 | package addr 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "math/rand" 7 | 8 | "github.com/tendermint/tendermint/p2p" 9 | "github.com/tendermint/tendermint/p2p/pex" 10 | ) 11 | 12 | var addrBook = pex.NewAddrBook("./testdata/addrbook.json", true) 13 | 14 | func Fuzz(data []byte) int { 15 | addr := new(p2p.NetAddress) 16 | if err := json.Unmarshal(data, addr); err != nil { 17 | return -1 18 | } 19 | 20 | // Fuzz AddAddress. 21 | err := addrBook.AddAddress(addr, addr) 22 | if err != nil { 23 | return 0 24 | } 25 | 26 | // Also, make sure PickAddress always returns a non-nil address. 27 | //nolint:gosec // G404: Use of weak random number generator (math/rand instead of crypto/rand) 28 | bias := rand.Intn(100) 29 | if p := addrBook.PickAddress(bias); p == nil { 30 | panic(fmt.Sprintf("picked a nil address (bias: %d, addrBook size: %v)", 31 | bias, addrBook.Size())) 32 | } 33 | 34 | return 1 35 | } 36 | -------------------------------------------------------------------------------- /test/loadtime/basic.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -euo pipefail 4 | 5 | # A basic invocation of the loadtime tool. 6 | 7 | ./build/load \ 8 | -c 1 -T 10 -r 1000 -s 1024 \ 9 | --broadcast-tx-method sync \ 10 | --endpoints ws://localhost:26657/websocket 11 | 12 | -------------------------------------------------------------------------------- /test/loadtime/payload/payload.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package loadtime.payload; 3 | 4 | option go_package = "github.com/tendermint/tendermint/test/loadtime/payload"; 5 | 6 | import "google/protobuf/timestamp.proto"; 7 | 8 | // Payload is the structure of the loadtime transaction. Proto has a compact 9 | // encoded representation, making it ideal for the loadtime usecase which aims to 10 | // keep the generated transactions small. 11 | message Payload { 12 | uint64 connections = 1; 13 | uint64 rate = 2; 14 | uint64 size = 3; 15 | google.protobuf.Timestamp time = 4; 16 | bytes id = 5; 17 | bytes padding = 6; 18 | } 19 | -------------------------------------------------------------------------------- /test/test_cover.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | PKGS=$(go list github.com/tendermint/tendermint/...) 4 | 5 | set -e 6 | 7 | echo "mode: atomic" > coverage.txt 8 | for pkg in ${PKGS[@]}; do 9 | go test -timeout 5m -race -coverprofile=profile.out -covermode=atomic "$pkg" 10 | if [ -f profile.out ]; then 11 | tail -n +2 profile.out >> coverage.txt; 12 | rm profile.out 13 | fi 14 | done 15 | -------------------------------------------------------------------------------- /tools/README.md: -------------------------------------------------------------------------------- 1 | # tools 2 | 3 | Tools for working with Tendermint and associated technologies. Documentation for 4 | these tools can be found online in the [Tendermint tools 5 | documentation](https://docs.tendermint.com/v0.34/tools/). 6 | -------------------------------------------------------------------------------- /tools/mintnet-kubernetes/assets/gce1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/tools/mintnet-kubernetes/assets/gce1.png -------------------------------------------------------------------------------- /tools/mintnet-kubernetes/assets/gce2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/tools/mintnet-kubernetes/assets/gce2.png -------------------------------------------------------------------------------- /tools/mintnet-kubernetes/assets/statefulset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/tools/mintnet-kubernetes/assets/statefulset.png -------------------------------------------------------------------------------- /tools/mintnet-kubernetes/assets/t_plus_k.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tendermint/tendermint/9d1be86031365f6f56668d2f5f0e7312eb8fef62/tools/mintnet-kubernetes/assets/t_plus_k.png -------------------------------------------------------------------------------- /tools/mintnet-kubernetes/examples/counter/Makefile: -------------------------------------------------------------------------------- 1 | create: 2 | @echo "==> Creating deployment" 3 | @kubectl create -f app.yaml 4 | 5 | destroy: 6 | @echo "==> Destroying deployment" 7 | @kubectl delete -f app.yaml 8 | @kubectl delete pvc -l app=tm 9 | 10 | .PHONY: create destroy 11 | -------------------------------------------------------------------------------- /tools/mintnet-kubernetes/examples/dummy/Makefile: -------------------------------------------------------------------------------- 1 | create: 2 | @echo "==> Creating deployment" 3 | @kubectl create -f app.yaml 4 | @echo "==> Waiting 10s until it is probably ready" 5 | @sleep 10 6 | @echo "==> Creating monitor and transacter pods" 7 | @kubectl create -f tm-monitor-pod.yaml 8 | @kubectl create -f transacter-pod.yaml 9 | 10 | destroy: 11 | @echo "==> Destroying deployment" 12 | @kubectl delete -f transacter-pod.yaml 13 | @kubectl delete -f tm-monitor-pod.yaml 14 | @kubectl delete -f app.yaml 15 | @kubectl delete pvc -l app=tm 16 | 17 | .PHONY: create destroy 18 | -------------------------------------------------------------------------------- /tools/mintnet-kubernetes/examples/dummy/tm-monitor-pod.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | name: monitor 6 | spec: 7 | containers: 8 | - name: monitor 9 | image: tendermint/monitor 10 | args: ["-listen-addr=tcp://0.0.0.0:26670", "tm-0.dummy:26657,tm-1.dummy:26657,tm-2.dummy:26657,tm-3.dummy:26657"] 11 | ports: 12 | - containerPort: 26670 13 | name: rpc 14 | -------------------------------------------------------------------------------- /tools/mintnet-kubernetes/examples/dummy/transacter-pod.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | name: transacter 6 | spec: 7 | containers: 8 | - name: transacter 9 | image: tendermint/transacter 10 | command: 11 | - bash 12 | - "-c" 13 | - | 14 | set -ex 15 | while true 16 | do 17 | ./transact 100 "tm-0.dummy:26657" 18 | sleep 1 19 | done 20 | -------------------------------------------------------------------------------- /tools/proto/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM bufbuild/buf:latest as buf 2 | 3 | FROM golang:1.14-alpine3.11 as builder 4 | 5 | RUN apk add --update --no-cache build-base curl git upx && \ 6 | rm -rf /var/cache/apk/* 7 | 8 | ENV GOLANG_PROTOBUF_VERSION=1.3.1 \ 9 | GOGO_PROTOBUF_VERSION=1.3.2 10 | 11 | RUN GO111MODULE=on go get \ 12 | github.com/golang/protobuf/protoc-gen-go@v${GOLANG_PROTOBUF_VERSION} \ 13 | github.com/gogo/protobuf/protoc-gen-gogo@v${GOGO_PROTOBUF_VERSION} \ 14 | github.com/gogo/protobuf/protoc-gen-gogofaster@v${GOGO_PROTOBUF_VERSION} && \ 15 | mv /go/bin/protoc-gen-go* /usr/local/bin/ 16 | 17 | 18 | FROM alpine:edge 19 | 20 | WORKDIR /work 21 | 22 | RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories && \ 23 | apk add --update --no-cache clang && \ 24 | rm -rf /var/cache/apk/* 25 | 26 | COPY --from=builder /usr/local/bin /usr/local/bin 27 | COPY --from=buf /usr/local/bin /usr/local/bin 28 | -------------------------------------------------------------------------------- /tools/tm-signer-harness/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TENDERMINT_VERSION=latest 2 | FROM tendermint/tendermint:${TENDERMINT_VERSION} 3 | 4 | COPY tm-signer-harness /usr/bin/tm-signer-harness 5 | -------------------------------------------------------------------------------- /tools/tm-signer-harness/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build install docker-image 2 | 3 | TENDERMINT_VERSION?=latest 4 | BUILD_TAGS?='tendermint' 5 | VERSION := $(shell git describe --always) 6 | BUILD_FLAGS = -ldflags "-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(VERSION) 7 | 8 | .DEFAULT_GOAL := build 9 | 10 | build: 11 | CGO_ENABLED=0 go build $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o ../../build/tm-signer-harness main.go 12 | 13 | install: 14 | CGO_ENABLED=0 go install $(BUILD_FLAGS) -tags $(BUILD_TAGS) . 15 | 16 | docker-image: 17 | GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o tm-signer-harness main.go 18 | docker build \ 19 | --build-arg TENDERMINT_VERSION=$(TENDERMINT_VERSION) \ 20 | -t tendermint/tm-signer-harness:$(TENDERMINT_VERSION) . 21 | rm -rf tm-signer-harness 22 | -------------------------------------------------------------------------------- /tools/tm-signer-harness/README.md: -------------------------------------------------------------------------------- 1 | # tm-signer-harness 2 | 3 | See the [`tm-signer-harness` 4 | documentation](https://tendermint.com/docs/tools/remote-signer-validation.html) 5 | for more details. 6 | -------------------------------------------------------------------------------- /tools/tm-signer-harness/internal/utils.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "os/user" 5 | "path/filepath" 6 | "strings" 7 | ) 8 | 9 | // ExpandPath will check if the given path begins with a "~" symbol, and if so, 10 | // will expand it to become the user's home directory. If it fails to expand the 11 | // path it will automatically return the original path itself. 12 | func ExpandPath(path string) string { 13 | usr, err := user.Current() 14 | if err != nil { 15 | return path 16 | } 17 | 18 | if path == "~" { 19 | return usr.HomeDir 20 | } else if strings.HasPrefix(path, "~/") { 21 | return filepath.Join(usr.HomeDir, path[2:]) 22 | } 23 | 24 | return path 25 | } 26 | -------------------------------------------------------------------------------- /tools/tools.go: -------------------------------------------------------------------------------- 1 | //go:build tools 2 | 3 | // This file uses the recommended method for tracking developer tools in a go module. 4 | // 5 | // https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module 6 | 7 | package tools 8 | 9 | import ( 10 | _ "github.com/bufbuild/buf/cmd/buf" 11 | _ "github.com/golangci/golangci-lint/cmd/golangci-lint" 12 | _ "github.com/vektra/mockery/v2" 13 | ) 14 | -------------------------------------------------------------------------------- /types/encoding_helper.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | gogotypes "github.com/gogo/protobuf/types" 5 | 6 | "github.com/tendermint/tendermint/libs/bytes" 7 | ) 8 | 9 | // cdcEncode returns nil if the input is nil, otherwise returns 10 | // proto.Marshal(<type>Value{Value: item}) 11 | func cdcEncode(item interface{}) []byte { 12 | if item != nil && !isTypedNil(item) && !isEmpty(item) { 13 | switch item := item.(type) { 14 | case string: 15 | i := gogotypes.StringValue{ 16 | Value: item, 17 | } 18 | bz, err := i.Marshal() 19 | if err != nil { 20 | return nil 21 | } 22 | return bz 23 | case int64: 24 | i := gogotypes.Int64Value{ 25 | Value: item, 26 | } 27 | bz, err := i.Marshal() 28 | if err != nil { 29 | return nil 30 | } 31 | return bz 32 | case bytes.HexBytes: 33 | i := gogotypes.BytesValue{ 34 | Value: item, 35 | } 36 | bz, err := i.Marshal() 37 | if err != nil { 38 | return nil 39 | } 40 | return bz 41 | default: 42 | return nil 43 | } 44 | } 45 | 46 | return nil 47 | } 48 | -------------------------------------------------------------------------------- /types/events_test.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/assert" 8 | ) 9 | 10 | func TestQueryTxFor(t *testing.T) { 11 | tx := Tx("foo") 12 | assert.Equal(t, 13 | fmt.Sprintf("tm.event='Tx' AND tx.hash='%X'", tx.Hash()), 14 | EventQueryTxFor(tx).String(), 15 | ) 16 | } 17 | 18 | func TestQueryForEvent(t *testing.T) { 19 | assert.Equal(t, 20 | "tm.event='NewBlock'", 21 | QueryForEvent(EventNewBlock).String(), 22 | ) 23 | assert.Equal(t, 24 | "tm.event='NewEvidence'", 25 | QueryForEvent(EventNewEvidence).String(), 26 | ) 27 | } 28 | -------------------------------------------------------------------------------- /types/keys.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // UNSTABLE 4 | var ( 5 | PeerStateKey = "ConsensusReactor.peerState" 6 | ) 7 | -------------------------------------------------------------------------------- /types/signable.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/tendermint/tendermint/crypto/ed25519" 5 | tmmath "github.com/tendermint/tendermint/libs/math" 6 | ) 7 | 8 | var ( 9 | // MaxSignatureSize is a maximum allowed signature size for the Proposal 10 | // and Vote. 11 | // XXX: secp256k1 does not have Size nor MaxSize defined. 12 | MaxSignatureSize = tmmath.MaxInt(ed25519.SignatureSize, 64) 13 | ) 14 | 15 | // Signable is an interface for all signable things. 16 | // It typically removes signatures before serializing. 17 | // SignBytes returns the bytes to be signed 18 | // NOTE: chainIDs are part of the SignBytes but not 19 | // necessarily the object themselves. 20 | // NOTE: Expected to panic if there is an error marshaling. 21 | type Signable interface { 22 | SignBytes(chainID string) []byte 23 | } 24 | -------------------------------------------------------------------------------- /types/signed_msg_type.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import tmproto "github.com/tendermint/tendermint/proto/tendermint/types" 4 | 5 | // IsVoteTypeValid returns true if t is a valid vote type. 6 | func IsVoteTypeValid(t tmproto.SignedMsgType) bool { 7 | switch t { 8 | case tmproto.PrevoteType, tmproto.PrecommitType: 9 | return true 10 | default: 11 | return false 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /types/utils.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import "reflect" 4 | 5 | // Go lacks a simple and safe way to see if something is a typed nil. 6 | // See: 7 | // - https://dave.cheney.net/2017/08/09/typed-nils-in-go-2 8 | // - https://groups.google.com/forum/#!topic/golang-nuts/wnH302gBa4I/discussion 9 | // - https://github.com/golang/go/issues/21538 10 | func isTypedNil(o interface{}) bool { 11 | rv := reflect.ValueOf(o) 12 | switch rv.Kind() { 13 | case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.Slice: 14 | return rv.IsNil() 15 | default: 16 | return false 17 | } 18 | } 19 | 20 | // Returns true if it has zero length. 21 | func isEmpty(o interface{}) bool { 22 | rv := reflect.ValueOf(o) 23 | switch rv.Kind() { 24 | case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice, reflect.String: 25 | return rv.Len() == 0 26 | default: 27 | return false 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /version/version.go: -------------------------------------------------------------------------------- 1 | package version 2 | 3 | var TMCoreSemVer = TMVersionDefault 4 | 5 | const ( 6 | // TMVersionDefault is the used as the fallback version of Tendermint Core 7 | // when not using git describe. It is formatted with semantic versioning. 8 | TMVersionDefault = "0.34.24" 9 | // ABCISemVer is the semantic version of the ABCI library 10 | ABCISemVer = "0.17.0" 11 | 12 | ABCIVersion = ABCISemVer 13 | ) 14 | 15 | var ( 16 | // P2PProtocol versions all p2p behaviour and msgs. 17 | // This includes proposer selection. 18 | P2PProtocol uint64 = 8 19 | 20 | // BlockProtocol versions all block data structures and processing. 21 | // This includes validity of blocks and state updates. 22 | BlockProtocol uint64 = 11 23 | ) 24 | --------------------------------------------------------------------------------