├── .circleci └── config.yml ├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.md │ └── feature-request.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── rust.yml ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Cargo.toml ├── LICENSE ├── Makefile ├── README.md ├── build.rs ├── examples ├── counter_app.rs └── empty_app.rs ├── protobuf ├── abci.proto ├── abci │ └── types │ │ └── types.proto ├── crypto │ └── merkle │ │ └── merkle.proto ├── github.com │ └── tendermint │ │ └── tendermint │ │ └── abci │ │ └── types │ │ └── types.proto ├── google │ └── protobuf │ │ ├── descriptor.proto │ │ ├── duration.proto │ │ └── timestamp.proto ├── libs │ └── kv │ │ └── types.proto └── third_party │ └── proto │ └── gogoproto │ └── gogo.proto ├── src ├── codec.rs ├── lib.rs ├── messages │ ├── abci.rs │ ├── merkle.rs │ ├── mod.rs │ └── types.rs └── server.rs └── version.txt /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | jobs: 4 | build: 5 | docker: 6 | - image: circleci/rust:latest 7 | steps: 8 | - checkout 9 | - restore_cache: 10 | key: project-cache 11 | - run: 12 | name: Publish Crate 13 | command: | 14 | if [ $CIRCLE_BRANCH == master ]; then cargo login $CARGO_TOKEN && cargo package --allow-dirty && cargo publish --allow-dirty; fi 15 | - save_cache: 16 | key: project-cache 17 | paths: 18 | - "~/.cargo" 19 | - "./target" 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a report to help us squash bugs! 4 | 5 | --- 6 | 7 | 12 | 13 | ## Summary of Bug 14 | 15 | 16 | 17 | ## Version 18 | 19 | 20 | 21 | ## Steps to Reproduce 22 | 23 | 24 | 25 | ____ 26 | 27 | #### For Admin Use 28 | 29 | - [ ] Not duplicate issue 30 | - [ ] Appropriate labels applied 31 | - [ ] Appropriate contributors tagged 32 | - [ ] Contributor assigned/self-assigned -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Create a proposal to request a feature 4 | 5 | --- 6 | 7 | 13 | 14 | ## Summary 15 | 16 | 17 | 18 | ## Problem Definition 19 | 20 | 24 | 25 | ## Proposal 26 | 27 | 28 | 29 | ____ 30 | 31 | #### For Admin Use 32 | 33 | - [ ] Not duplicate issue 34 | - [ ] Appropriate labels applied 35 | - [ ] Appropriate contributors tagged 36 | - [ ] Contributor assigned/self-assigned -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | - Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/tendermint/rust-abci/blob/develop/CONTRIBUTING.md)) 8 | 9 | - [ ] Linked to github-issue with discussion and accepted design OR link to spec that describes this work. 10 | - [ ] Wrote tests 11 | - [ ] Updated relevant documentation (`docs/`) 12 | - [ ] Added a relevant changelog entry: `clog add [section] [stanza] [message]` 13 | - [ ] Reviewed `Files changed` in the github PR explorer 14 | - [ ] Bump Tendermint & ABCI version in README.md if version was updated 15 | 16 | 17 | ______ 18 | 19 | For Admin Use: 20 | - Added appropriate labels to PR (ex. wip, ready-for-review, docs) 21 | - Reviewers Assigned 22 | - Squashed all commits, uses message "Merge pull request #XYZ: [title]" ([coding standards](https://github.com/tendermint/coding/blob/master/README.md#merging-a-pr)) 23 | -------------------------------------------------------------------------------- /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | name: Rust 2 | on: [pull_request] 3 | jobs: 4 | cleanup-runs: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - uses: rokroskar/workflow-run-cleanup-action@master 8 | env: 9 | GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" 10 | if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" 11 | 12 | fmt: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v2 16 | - uses: actions-rs/toolchain@v1 17 | with: 18 | toolchain: stable 19 | override: true 20 | - uses: actions-rs/cargo@v1 21 | with: 22 | command: fmt 23 | args: --all -- --check 24 | 25 | clippy_check: 26 | runs-on: ubuntu-latest 27 | steps: 28 | - uses: actions/checkout@v2 29 | - uses: actions-rs/toolchain@v1 30 | with: 31 | toolchain: stable 32 | components: clippy 33 | override: true 34 | - uses: actions-rs/clippy-check@v1 35 | with: 36 | token: ${{ secrets.GITHUB_TOKEN }} 37 | args: --all-features 38 | 39 | test-stable: 40 | runs-on: ubuntu-latest 41 | steps: 42 | - uses: actions/checkout@v2 43 | - uses: actions-rs/toolchain@v1 44 | with: 45 | toolchain: stable 46 | override: true 47 | - uses: actions-rs/cargo@v1 48 | with: 49 | command: build 50 | args: --workspace --all-targets 51 | - uses: actions-rs/cargo@v1 52 | with: 53 | command: test 54 | args: --all-features --no-fail-fast 55 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /target/ 3 | **/*.rs.bk 4 | Cargo.lock 5 | /.idea/ 6 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG 2 | 3 | _July 24, 2020_ 4 | 5 | ## v0.7.2 6 | 7 | ### IMPROVEMENTS: 8 | 9 | - [\#138](https://github.com/tendermint/rust-abci/pull/138): dependencies upgrades (protobuf to 2.16.2, tokio to 0.2, bytes to 0.5) 10 | 11 | _June 30, 2020_ 12 | 13 | ## v0.7.1 14 | 15 | ### IMPROVEMENTS: 16 | 17 | - [\#131](https://github.com/tendermint/rust-abci/pull/131): Tendermint 0.33.4+ ABCI compatibility and upgraded protobuf to 2.15.1 18 | 19 | _March 3, 2020_ 20 | 21 | ## v0.7.0 22 | 23 | ### BREAKING CHANGES: 24 | 25 | - [\#116](https://github.com/tendermint/rust-abci/pull/116): Tendermint 0.33.\*'s ABCI compatibility 26 | 27 | 28 | _January 2, 2020_ 29 | 30 | Special thanks to external contributors on this release: @devashishdxt 31 | 32 | ## v0.6.5 33 | 34 | ### IMPROVEMENTS: 35 | 36 | - [\#110](https://github.com/tendermint/rust-abci/pull/110): Upgrade protobuf to 2.10.0 37 | 38 | _November 18, 2019_ 39 | 40 | Special thanks to external contributors on this release: @yihuang 41 | 42 | ## v0.6.4 43 | 44 | ### IMPROVEMENTS: 45 | 46 | - [\#100](https://github.com/tendermint/rust-abci/pull/100): worker panic propagated to the abci process 47 | 48 | _November 11, 2019_ 49 | 50 | ## v0.6.3 51 | 52 | ### IMPROVEMENTS: 53 | 54 | - [\#97](https://github.com/tendermint/rust-abci/pull/97): futures version bumped to 0.3 55 | - [\#94](https://github.com/tendermint/rust-abci/pull/94): Reduce number of tokio dependencies 56 | 57 | _September 25, 2019_ 58 | 59 | ## v0.6.2 60 | 61 | - [\#97](https://github.com/tendermint/rust-abci/pull/97): futures version bumped to 0.3 62 | - [\#94](https://github.com/tendermint/rust-abci/pull/94): Reduce number of tokio dependencies 63 | 64 | _September 25, 2019_ 65 | 66 | ## v0.6.2 67 | 68 | ### BUG FIXES: 69 | 70 | - [\#89](https://github.com/tendermint/rust-abci/pull/89): Version of protobuf specified to the latest one (2.8.1) 71 | 72 | _August 23, 2019_ 73 | 74 | Special thanks to external contributors on this release: @amanusk, @marbar3778 75 | 76 | ## v0.6.1 77 | 78 | ### IMPROVEMENTS: 79 | 80 | - [\#84](https://github.com/tendermint/rust-abci/pull/84): Fix warning for dynamic trait objects 81 | 82 | - [\#80](https://github.com/tendermint/rust-abci/pull/80): Reduce amount of logs under `info` 83 | 84 | ### BUG FIXES: 85 | 86 | _July 1, 2019_ 87 | 88 | Special thanks to external contributors on this release: @liamsi 89 | 90 | ## v0.6.0 91 | 92 | ### BREAKING CHANGES: 93 | 94 | - [\#79](https://github.com/tendermint/rust-abci/pull/79): Tendermint 0.32.\*'s ABCI compatibility 95 | 96 | ### FEATURES: 97 | 98 | ### IMPROVEMENTS: 99 | 100 | ### BUG FIXES: 101 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # The Tendermint Code of Conduct 2 | This code of conduct applies to all projects run by the Tendermint/COSMOS team and hence to rust-abci. 3 | 4 | 5 | ---- 6 | 7 | 8 | # Conduct 9 | ## Contact: ismail@tendermint.com or marko@tendermint.com 10 | 11 | * We are committed to providing a friendly, safe and welcoming environment for all, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, nationality, or other similar characteristic. 12 | 13 | * On Slack, please avoid using overtly sexual nicknames or other nicknames that might detract from a friendly, safe and welcoming environment for all. 14 | 15 | * Please be kind and courteous. There’s no need to be mean or rude. 16 | 17 | * Respect that people have differences of opinion and that every design or implementation choice carries a trade-off and numerous costs. There is seldom a right answer. 18 | 19 | * Please keep unstructured critique to a minimum. If you have solid ideas you want to experiment with, make a fork and see how it works. 20 | 21 | * We will exclude you from interaction if you insult, demean or harass anyone. That is not welcome behaviour. We interpret the term “harassment” as including the definition in the [Citizen Code of Conduct](http://citizencodeofconduct.org/); if you have any lack of clarity about what might be included in that concept, please read their definition. In particular, we don’t tolerate behavior that excludes people in socially marginalized groups. 22 | 23 | * Private harassment is also unacceptable. No matter who you are, if you feel you have been or are being harassed or made uncomfortable by a community member, please contact one of the channel admins or the person mentioned above immediately. Whether you’re a regular contributor or a newcomer, we care about making this community a safe place for you and we’ve got your back. 24 | 25 | * Likewise any spamming, trolling, flaming, baiting or other attention-stealing behaviour is not welcome. 26 | 27 | 28 | ---- 29 | 30 | 31 | # Moderation 32 | These are the policies for upholding our community’s standards of conduct. If you feel that a thread needs moderation, please contact the above mentioned person. 33 | 34 | 1. Remarks that violate the Tendermint/COSMOS standards of conduct, including hateful, hurtful, oppressive, or exclusionary remarks, are not allowed. (Cursing is allowed, but never targeting another user, and never in a hateful manner.) 35 | 36 | 2. Remarks that moderators find inappropriate, whether listed in the code of conduct or not, are also not allowed. 37 | 38 | 3. Moderators will first respond to such remarks with a warning. 39 | 40 | 4. If the warning is unheeded, the user will be “kicked,” i.e., kicked out of the communication channel to cool off. 41 | 42 | 5. If the user comes back and continues to make trouble, they will be banned, i.e., indefinitely excluded. 43 | 44 | 6. Moderators may choose at their discretion to un-ban the user if it was a first offense and they offer the offended party a genuine apology. 45 | 46 | 7. If a moderator bans someone and you think it was unjustified, please take it up with that moderator, or with a different moderator, in private. Complaints about bans in-channel are not allowed. 47 | 48 | 8. Moderators are held to a higher standard than other community members. If a moderator creates an inappropriate situation, they should expect less leeway than others. 49 | 50 | In the Tendermint/COSMOS community we strive to go the extra step to look out for each other. Don’t just aim to be technically unimpeachable, try to be your best self. In particular, avoid flirting with offensive or sensitive issues, particularly if they’re off-topic; this all too often leads to unnecessary fights, hurt feelings, and damaged trust; worse, it can drive people away from the community entirely. 51 | 52 | And if someone takes issue with something you said or did, resist the urge to be defensive. Just stop doing what it was they complained about and apologize. Even if you feel you were misinterpreted or unfairly accused, chances are good there was something you could’ve communicated better — remember that it’s your responsibility to make your fellow Cosmonauts comfortable. Everyone wants to get along and we are all here first and foremost because we want to talk about cool technology. You will find that people will be eager to assume good intent and forgive as long as you earn their trust. 53 | 54 | The enforcement policies listed above apply to all official Tendermint/COSMOS venues.For other projects adopting the Tendermint/COSMOS Code of Conduct, please contact the maintainers of those projects for enforcement. If you wish to use this code of conduct for your own project, consider explicitly mentioning your moderation policy or making a copy with your own moderation policy so as to avoid confusion. 55 | 56 | *Adapted from the [Node.js Policy on Trolling](http://blog.izs.me/post/30036893703/policy-on-trolling), the [Contributor Covenant v1.3.0](http://contributor-covenant.org/version/1/3/0/) and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html). 57 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to rust-ABCI 2 | 3 | Thank you for taking the time to contribute to our organization and this repository. 4 | 5 | Please follow standard github best practices: fork the repo, branch from the tip of develop, make some commits, and submit a pull request to develop. See the open (issues)[https://github.com/tendermint/rust-abci/issues] for things to contribute. 6 | 7 | ## Code of Conduct 8 | 9 | --- 10 | 11 | All contributors are expected to follow (Code of Conduct)[./CODE_OF_CONDUCT.md] 12 | 13 | ## Feature requests and bug reports 14 | 15 | --- 16 | 17 | Feature requests or bug reports can be posted as a (Github issue)[https://github.com/tendermint/rust-abci/issues/new]. In the issue, please follow the template and describe to the best of your ability what you did, what you expected and what happened instead. 18 | 19 | If you'd like to solve a issue, please comment that you would like to claim the issue. This makes sure that no one else will work on it. 20 | 21 | ## Forking 22 | 23 | --- 24 | 25 | Once you have a issue that you would to work on and commented on it to claim it: 26 | 27 | - Fork the repository to your Github account. 28 | - Clone your fork to your local machine 29 | - Create a local branch `git checkout -b `. 30 | - Commit & push your changes to your branch on github. 31 | - Make sure that you are working off the most recent version, if not, pull the develop branch and rebase your committed history. 32 | - Before opening a pull request read the [development section](#development) 33 | - Open a [Pull Request](#pull-requests) for others to review the branch. 34 | 35 | ## Pull Requests 36 | 37 | --- 38 | 39 | To accommodate review process we suggest that PRs are categorically broken up. Ideally each PR addresses only a single issue. Additionally, as much as possible code refactoring and cleanup should be submitted as a separate PRs from bugfixes/feature-additions. 40 | 41 | If you are working on a issue and plan on contributing, please submit your PR early and make sure its opened as a `Draft`, even if it's incomplete, this indicates to the community you're working on something and allows them to provide comments early in the development process. When the code is complete it should be marked using Github's `Mark Ready` feature. This will let the maintainers know that there is a open PR for review. 42 | 43 | ## Development 44 | 45 | --- 46 | 47 | The code should follow [Rust Style Guide](https://github.com/rust-lang/rfcs/tree/master/style-guide). Much of the code style is captured by `rustfmt`. 48 | 49 | Before opening a Pull Request please run the checks below: 50 | 51 | - Install rustfmt: `rustup component add rustfmt` 52 | - Install clippy: `rustup component add clippy` 53 | 54 | ### Testing 55 | 56 | Run the test suite with 57 | 58 | `cargo test --all-features` 59 | 60 | ### Format checking (rustfmt) 61 | 62 | Make sure your code is well-formatted by running 63 | 64 | `cargo fmt` 65 | 66 | ### Lint (clippy) 67 | 68 | Lint your code (i.e. check it for common issues) with: 69 | 70 | `cargo clippy` 71 | 72 | ## Changelog 73 | 74 | Every fix, improvement, feature, or breaking change should be made in a 75 | pull-request that includes an update to the `CHANGELOG.md` file. 76 | 77 | Changelog entries should be formatted as follows: 78 | 79 | ``` 80 | - \#xxx Some description about the change (@contributor) 81 | ``` 82 | 83 | Here, `xxx` is the pull-request number, and `contributor` 84 | is the author/s of the change. 85 | 86 | It's also acceptable for `xxx` to refer to the relevent issue number, but pull-request 87 | numbers are preferred. 88 | Note this means pull-requests should be opened first so the changelog can then 89 | be updated with the pull-request's number. 90 | There is no need to include the full link, as this will be added 91 | automatically during release. But please include the backslash and pound, eg. `\#2313`. 92 | 93 | Changelog entries should be numerically according to the pull-request number. 94 | 95 | Changes with multiple classifications should be doubly included (eg. a bug fix 96 | that is also a breaking change should be recorded under both). 97 | 98 | ## License 99 | 100 | Copyright © 2018-2019 Tendermint 101 | 102 | Licensed under the Apache License, Version 2.0 (the "License"); 103 | you may not use this file except in compliance with the License. 104 | You may obtain a copy of the License at 105 | 106 | https://www.apache.org/licenses/LICENSE-2.0 107 | 108 | Unless required by applicable law or agreed to in writing, software 109 | distributed under the License is distributed on an "AS IS" BASIS, 110 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 111 | See the License for the specific language governing permissions and 112 | limitations under the License. 113 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "abci" 3 | version = "0.7.2" 4 | authors = ["Adrian Brink ", "Jackson Lewis ", "Dave Bryson", "Tomas Tauber"] 5 | edition = "2018" 6 | license = "MIT/Apache-2.0" 7 | description = "Tendermint ABCI server for Rust" 8 | homepage = "https://tendermint.com/docs/spec/abci/" 9 | repository = "https://github.com/tendermint/rust-abci" 10 | keywords = ["abci", "tendermint", "blockchain", "rust"] 11 | readme = "README.md" 12 | include = ["src/**/*", "Cargo.toml"] 13 | 14 | [dependencies] 15 | bytes = "0.5" 16 | protobuf = "= 2.16.2" 17 | byteorder = "1.3.4" 18 | integer-encoding = "1.1.5" 19 | log = "0.4.8" 20 | env_logger = "0.8.2" 21 | tokio = { version = "0.2", features = ["tcp", "rt-core", "io-driver", "sync"] } 22 | tokio-util = { version = "0.3.1", features = ["codec"] } 23 | futures = "0.3" 24 | 25 | [build-dependencies] 26 | protobuf-codegen-pure = "= 2.16.2" 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2017 Adrian Brink 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Origin 2 | version_branch = v0.33.6 3 | tendermint = https://raw.githubusercontent.com/tendermint/tendermint/$(version_branch) 4 | 5 | # Outputs 6 | tmkv = protobuf/libs/kv/types.proto 7 | tmmerkle = protobuf/crypto/merkle/merkle.proto 8 | tmabci = protobuf/abci/types/types.proto 9 | third_party = third_party/proto/gogoproto/gogo.proto 10 | 11 | # You *only* need to run this to rebuild protobufs from the tendermint source 12 | update-proto: 13 | curl $(tendermint)/abci/types/types.proto > $(tmabci) 14 | curl $(tendermint)/libs/kv/types.proto > $(tmkv) 15 | curl $(tendermint)/crypto/merkle/merkle.proto > $(tmmerkle) 16 | sed 's@package types;@package abci;@' $(tmabci) > protobuf/abci.proto 17 | curl $(tendermint)/version/version.go | grep -F -eTMCoreSem -eABCISemVer > version.txt 18 | curl $(tendermint)/$(third_party) > protobuf/$(third_party) 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🚨 DEPRECATED 🚨 2 | 3 | This repo has been deprecated. Development work continues as the "abci" crate of [informalsystems/tendermint-rs](https://github.com/informalsystems/tendermint-rs/tree/master/abci). Please reference that repository in the future. 4 | 5 | ------- 6 | 7 | # Rust ABCI 8 | 9 | Tendermint ABCI server, written in the Rust programming language. 10 | 11 | [![Current Version](https://meritbadge.herokuapp.com/abci)](https://crates.io/crates/abci) 12 | [![](https://tokei.rs/b1/github/tendermint/rust-abci)](https://github.com/tendermint/rust-abci) 13 | [![CircleCI](https://circleci.com/gh/tendermint/rust-abci/tree/master.svg?style=shield)](https://circleci.com/gh/tendermint/rust-abci/tree/master) 14 | 15 | This library implements the [ABCI 16 | protocol](https://tendermint.com/docs/spec/abci/) and can be used to write ABCI 17 | applications for [Tendermint](https://github.com/tendermint/tendermint/). 18 | 19 | ## Supported Version 20 | 21 | - Tendermint 0.33.6 22 | - ABCI 0.16.2 23 | 24 | ## Installation 25 | 26 | ### Dependencies 27 | 28 | Make sure that you have Rust and Cargo installed. The easiest way is to follow the instructions on [rustup](https://rustup.rs/). 29 | 30 | To test the examples, please clone this repository. 31 | 32 | ``` 33 | git clone https://github.com/tendermint/rust-abci.git 34 | ``` 35 | 36 | The `empty_app` example, found under the `examples` folder, is a good demonstration/bare minimum foundation for a Rust ABCI app. 37 | 38 | To use this library to build your own ABCI apps in Rust you have to include the following in your `Cargo.toml` file. 39 | 40 | ```toml 41 | [dependencies] 42 | abci = "0.7.2" 43 | ``` 44 | 45 | ### Development 46 | 47 | This crate already contains the compiled ABCI protobuf messages. If you want to update protobuf messages to a newer version of Tendermint. Run `make update-proto` 48 | 49 | ## Running the examples 50 | 51 | ### Tendermint 52 | 53 | To run either of the example apps you have to have Tendermint installed and initialised (Remember to run `tendermint init`!). Please install it according to these [instructions](https://docs.tendermint.com/master/introduction/install.html). After initializing and configuring the node, Tendermint can be run with: 54 | 55 | ``` 56 | tendermint node 57 | ``` 58 | 59 | After the node is online, you can run the `empty_app` example using `cargo run --example empty_app`. 60 | 61 | To run the `counter_app` run `cargo run --example counter_app` and send transaction to Tendermint via: 62 | 63 | ``` 64 | curl localhost:26657/broadcast_tx_commit?tx=0x01 65 | curl localhost:26657/broadcast_tx_commit?tx=0x02 66 | ``` 67 | 68 | For a real life example of an ABCI application you can checkout [Cosmos SDK](https://github.com/cosmos/cosmos-sdk) or [Ethermint](https://github.com/cosmos/ethermint). 69 | 70 | #### Tendermint Compatibility Table 71 | 72 | | Tendermint | Rust-abci | 73 | | ---------- | :-------: | 74 | | 0.33.6 | 0.7.2 | 75 | | 0.33.5 | 0.7.1 | 76 | | 0.33.1 | 0.7.0 | 77 | | 0.32.9 | 0.6.5 | 78 | | 0.31.7 | 0.5.4 | 79 | 80 | ## Documentation 81 | 82 | Coming soon! 83 | 84 | ## Join the Community 85 | 86 | Find us through a variety of channels [here](https://cosmos.network/community). 87 | 88 | ### Code of Conduct 89 | 90 | Please read, understand and adhere to our [code of conduct](./CODE_OF_CONDUCT.md). 91 | 92 | ## Credits 93 | 94 | - [Jackson Lewis](https://github.com/InquisitivePenguin) 95 | - [Dave Bryson](https://github.com/davebryson) 96 | 97 | Original `rust-tsp` made by [Adrian Brink](https://github.com/adrianbrink). 98 | -------------------------------------------------------------------------------- /build.rs: -------------------------------------------------------------------------------- 1 | extern crate protobuf_codegen_pure; 2 | 3 | fn main() { 4 | protobuf_codegen_pure::Codegen::new() 5 | .out_dir("src/messages") 6 | .inputs(&[ 7 | "protobuf/abci.proto", 8 | "protobuf/libs/kv/types.proto", 9 | "protobuf/crypto/merkle/merkle.proto", 10 | ]) 11 | .include("protobuf") 12 | .run() 13 | .expect("protoc"); 14 | } 15 | -------------------------------------------------------------------------------- /examples/counter_app.rs: -------------------------------------------------------------------------------- 1 | extern crate abci; 2 | extern crate byteorder; 3 | extern crate env_logger; 4 | 5 | use abci::*; 6 | use byteorder::{BigEndian, ByteOrder}; 7 | use env_logger::Env; 8 | 9 | // Simple counter application. Its only state is a u64 count 10 | // We use BigEndian to serialize the data across transactions calls 11 | struct CounterApp { 12 | count: u64, 13 | } 14 | 15 | impl CounterApp { 16 | fn new() -> CounterApp { 17 | CounterApp { count: 0 } 18 | } 19 | } 20 | 21 | // Convert incoming tx data to the proper BigEndian size. txs.len() > 8 will return 0 22 | fn convert_tx(tx: &[u8]) -> u64 { 23 | if tx.len() < 8 { 24 | let pad = 8 - tx.len(); 25 | let mut x = vec![0; pad]; 26 | x.extend_from_slice(tx); 27 | return BigEndian::read_u64(x.as_slice()); 28 | } 29 | BigEndian::read_u64(tx) 30 | } 31 | 32 | impl abci::Application for CounterApp { 33 | // Validate transactions. Rule: Transactions must be incremental: 1,2,3,4... 34 | fn check_tx(&mut self, req: &RequestCheckTx) -> ResponseCheckTx { 35 | // Get the Tx [u8] and convert to u64 36 | let c = convert_tx(req.get_tx()); 37 | let mut resp = ResponseCheckTx::new(); 38 | 39 | // Validation logic 40 | if c != self.count + 1 { 41 | resp.set_code(1); 42 | resp.set_log(String::from("Count must be incremental!")); 43 | return resp; 44 | } 45 | 46 | // Update state to keep state correct for next check_tx call 47 | self.count = c; 48 | resp 49 | } 50 | 51 | fn deliver_tx(&mut self, req: &RequestDeliverTx) -> ResponseDeliverTx { 52 | // Get the Tx [u8] 53 | let c = convert_tx(req.get_tx()); 54 | // Update state 55 | self.count = c; 56 | // Return default code 0 == bueno 57 | ResponseDeliverTx::new() 58 | } 59 | 60 | fn commit(&mut self, _req: &RequestCommit) -> ResponseCommit { 61 | // Create the response 62 | let mut resp = ResponseCommit::new(); 63 | // Convert count to bits 64 | let mut buf = [0; 8]; 65 | BigEndian::write_u64(&mut buf, self.count); 66 | // Set data so last state is included in the block 67 | resp.set_data(buf.to_vec()); 68 | resp 69 | } 70 | } 71 | 72 | fn main() { 73 | // Run on localhost using default Tendermint port 74 | env_logger::from_env(Env::default().default_filter_or("info")).init(); 75 | abci::run_local(CounterApp::new()); 76 | } 77 | -------------------------------------------------------------------------------- /examples/empty_app.rs: -------------------------------------------------------------------------------- 1 | extern crate abci; 2 | extern crate env_logger; 3 | 4 | use env_logger::Env; 5 | 6 | // Simple example that responds with defaults to Tendermint 7 | struct EmptyApp; 8 | 9 | // Implement the Application and use default responses 10 | impl abci::Application for EmptyApp {} 11 | 12 | fn main() { 13 | // Use default local addr and Tendermint ABCI port 14 | let addr = "127.0.0.1:26658".parse().unwrap(); 15 | // Fire it up! 16 | env_logger::from_env(Env::default().default_filter_or("info")).init(); 17 | abci::run(addr, EmptyApp); 18 | } 19 | -------------------------------------------------------------------------------- /protobuf/abci.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package tendermint.abci.types; 3 | option go_package = "github.com/tendermint/tendermint/abci/types"; 4 | 5 | // For more information on gogo.proto, see: 6 | // https://github.com/gogo/protobuf/blob/master/extensions.md 7 | import "third_party/proto/gogoproto/gogo.proto"; 8 | import "crypto/merkle/merkle.proto"; 9 | import "libs/kv/types.proto"; 10 | import "google/protobuf/timestamp.proto"; 11 | import "google/protobuf/duration.proto"; 12 | 13 | // This file is copied from http://github.com/tendermint/abci 14 | // NOTE: When using custom types, mind the warnings. 15 | // https://github.com/gogo/protobuf/blob/master/custom_types.md#warnings-and-issues 16 | 17 | option (gogoproto.marshaler_all) = true; 18 | option (gogoproto.unmarshaler_all) = true; 19 | option (gogoproto.sizer_all) = true; 20 | option (gogoproto.goproto_registration) = true; 21 | // Generate tests 22 | option (gogoproto.populate_all) = true; 23 | option (gogoproto.equal_all) = true; 24 | option (gogoproto.testgen_all) = true; 25 | 26 | //---------------------------------------- 27 | // Request types 28 | 29 | message Request { 30 | oneof value { 31 | RequestEcho echo = 2; 32 | RequestFlush flush = 3; 33 | RequestInfo info = 4; 34 | RequestSetOption set_option = 5; 35 | RequestInitChain init_chain = 6; 36 | RequestQuery query = 7; 37 | RequestBeginBlock begin_block = 8; 38 | RequestCheckTx check_tx = 9; 39 | RequestDeliverTx deliver_tx = 19; 40 | RequestEndBlock end_block = 11; 41 | RequestCommit commit = 12; 42 | } 43 | } 44 | 45 | message RequestEcho { 46 | string message = 1; 47 | } 48 | 49 | message RequestFlush {} 50 | 51 | message RequestInfo { 52 | string version = 1; 53 | uint64 block_version = 2; 54 | uint64 p2p_version = 3; 55 | } 56 | 57 | // nondeterministic 58 | message RequestSetOption { 59 | string key = 1; 60 | string value = 2; 61 | } 62 | 63 | message RequestInitChain { 64 | google.protobuf.Timestamp time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; 65 | string chain_id = 2; 66 | ConsensusParams consensus_params = 3; 67 | repeated ValidatorUpdate validators = 4 [(gogoproto.nullable) = false]; 68 | bytes app_state_bytes = 5; 69 | } 70 | 71 | message RequestQuery { 72 | bytes data = 1; 73 | string path = 2; 74 | int64 height = 3; 75 | bool prove = 4; 76 | } 77 | 78 | message RequestBeginBlock { 79 | bytes hash = 1; 80 | Header header = 2 [(gogoproto.nullable) = false]; 81 | LastCommitInfo last_commit_info = 3 [(gogoproto.nullable) = false]; 82 | repeated Evidence byzantine_validators = 4 [(gogoproto.nullable) = false]; 83 | } 84 | 85 | enum CheckTxType { 86 | New = 0; 87 | Recheck = 1; 88 | } 89 | 90 | message RequestCheckTx { 91 | bytes tx = 1; 92 | CheckTxType type = 2; 93 | } 94 | 95 | message RequestDeliverTx { 96 | bytes tx = 1; 97 | } 98 | 99 | message RequestEndBlock { 100 | int64 height = 1; 101 | } 102 | 103 | message RequestCommit {} 104 | 105 | //---------------------------------------- 106 | // Response types 107 | 108 | message Response { 109 | oneof value { 110 | ResponseException exception = 1; 111 | ResponseEcho echo = 2; 112 | ResponseFlush flush = 3; 113 | ResponseInfo info = 4; 114 | ResponseSetOption set_option = 5; 115 | ResponseInitChain init_chain = 6; 116 | ResponseQuery query = 7; 117 | ResponseBeginBlock begin_block = 8; 118 | ResponseCheckTx check_tx = 9; 119 | ResponseDeliverTx deliver_tx = 10; 120 | ResponseEndBlock end_block = 11; 121 | ResponseCommit commit = 12; 122 | } 123 | } 124 | 125 | // nondeterministic 126 | message ResponseException { 127 | string error = 1; 128 | } 129 | 130 | message ResponseEcho { 131 | string message = 1; 132 | } 133 | 134 | message ResponseFlush {} 135 | 136 | message ResponseInfo { 137 | string data = 1; 138 | 139 | string version = 2; 140 | uint64 app_version = 3; 141 | 142 | int64 last_block_height = 4; 143 | bytes last_block_app_hash = 5; 144 | } 145 | 146 | // nondeterministic 147 | message ResponseSetOption { 148 | uint32 code = 1; 149 | // bytes data = 2; 150 | string log = 3; 151 | string info = 4; 152 | } 153 | 154 | message ResponseInitChain { 155 | ConsensusParams consensus_params = 1; 156 | repeated ValidatorUpdate validators = 2 [(gogoproto.nullable) = false]; 157 | } 158 | 159 | message ResponseQuery { 160 | uint32 code = 1; 161 | // bytes data = 2; // use "value" instead. 162 | string log = 3; // nondeterministic 163 | string info = 4; // nondeterministic 164 | int64 index = 5; 165 | bytes key = 6; 166 | bytes value = 7; 167 | tendermint.crypto.merkle.Proof proof = 8; 168 | int64 height = 9; 169 | string codespace = 10; 170 | } 171 | 172 | message ResponseBeginBlock { 173 | repeated Event events = 1 174 | [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; 175 | } 176 | 177 | message ResponseCheckTx { 178 | uint32 code = 1; 179 | bytes data = 2; 180 | string log = 3; // nondeterministic 181 | string info = 4; // nondeterministic 182 | int64 gas_wanted = 5; 183 | int64 gas_used = 6; 184 | repeated Event events = 7 185 | [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; 186 | string codespace = 8; 187 | } 188 | 189 | message ResponseDeliverTx { 190 | uint32 code = 1; 191 | bytes data = 2; 192 | string log = 3; // nondeterministic 193 | string info = 4; // nondeterministic 194 | int64 gas_wanted = 5; 195 | int64 gas_used = 6; 196 | repeated Event events = 7 197 | [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; 198 | string codespace = 8; 199 | } 200 | 201 | message ResponseEndBlock { 202 | repeated ValidatorUpdate validator_updates = 1 [(gogoproto.nullable) = false]; 203 | ConsensusParams consensus_param_updates = 2; 204 | repeated Event events = 3 205 | [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; 206 | } 207 | 208 | message ResponseCommit { 209 | // reserve 1 210 | bytes data = 2; 211 | int64 retain_height = 3; 212 | } 213 | 214 | //---------------------------------------- 215 | // Misc. 216 | 217 | // ConsensusParams contains all consensus-relevant parameters 218 | // that can be adjusted by the abci app 219 | message ConsensusParams { 220 | BlockParams block = 1; 221 | EvidenceParams evidence = 2; 222 | ValidatorParams validator = 3; 223 | } 224 | 225 | // BlockParams contains limits on the block size. 226 | message BlockParams { 227 | // Note: must be greater than 0 228 | int64 max_bytes = 1; 229 | // Note: must be greater or equal to -1 230 | int64 max_gas = 2; 231 | } 232 | 233 | message EvidenceParams { 234 | // Note: must be greater than 0 235 | int64 max_age_num_blocks = 1; 236 | google.protobuf.Duration max_age_duration = 2 237 | [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; 238 | } 239 | 240 | // ValidatorParams contains limits on validators. 241 | message ValidatorParams { 242 | repeated string pub_key_types = 1; 243 | } 244 | 245 | message LastCommitInfo { 246 | int32 round = 1; 247 | repeated VoteInfo votes = 2 [(gogoproto.nullable) = false]; 248 | } 249 | 250 | message Event { 251 | string type = 1; 252 | repeated tendermint.libs.kv.Pair attributes = 2 253 | [(gogoproto.nullable) = false, (gogoproto.jsontag) = "attributes,omitempty"]; 254 | } 255 | 256 | //---------------------------------------- 257 | // Blockchain Types 258 | 259 | message Header { 260 | // basic block info 261 | Version version = 1 [(gogoproto.nullable) = false]; 262 | string chain_id = 2 [(gogoproto.customname) = "ChainID"]; 263 | int64 height = 3; 264 | google.protobuf.Timestamp time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; 265 | 266 | // prev block info 267 | BlockID last_block_id = 5 [(gogoproto.nullable) = false]; 268 | 269 | // hashes of block data 270 | bytes last_commit_hash = 6; // commit from validators from the last block 271 | bytes data_hash = 7; // transactions 272 | 273 | // hashes from the app output from the prev block 274 | bytes validators_hash = 8; // validators for the current block 275 | bytes next_validators_hash = 9; // validators for the next block 276 | bytes consensus_hash = 10; // consensus params for current block 277 | bytes app_hash = 11; // state after txs from the previous block 278 | bytes last_results_hash = 12; // root hash of all results from the txs from the previous block 279 | 280 | // consensus info 281 | bytes evidence_hash = 13; // evidence included in the block 282 | bytes proposer_address = 14; // original proposer of the block 283 | } 284 | 285 | message Version { 286 | uint64 Block = 1; 287 | uint64 App = 2; 288 | } 289 | 290 | message BlockID { 291 | bytes hash = 1; 292 | PartSetHeader parts_header = 2 [(gogoproto.nullable) = false]; 293 | } 294 | 295 | message PartSetHeader { 296 | int32 total = 1; 297 | bytes hash = 2; 298 | } 299 | 300 | // Validator 301 | message Validator { 302 | bytes address = 1; 303 | // PubKey pub_key = 2 [(gogoproto.nullable)=false]; 304 | int64 power = 3; 305 | } 306 | 307 | // ValidatorUpdate 308 | message ValidatorUpdate { 309 | PubKey pub_key = 1 [(gogoproto.nullable) = false]; 310 | int64 power = 2; 311 | } 312 | 313 | // VoteInfo 314 | message VoteInfo { 315 | Validator validator = 1 [(gogoproto.nullable) = false]; 316 | bool signed_last_block = 2; 317 | } 318 | 319 | message PubKey { 320 | string type = 1; 321 | bytes data = 2; 322 | } 323 | 324 | message Evidence { 325 | string type = 1; 326 | Validator validator = 2 [(gogoproto.nullable) = false]; 327 | int64 height = 3; 328 | google.protobuf.Timestamp time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; 329 | int64 total_voting_power = 5; 330 | } 331 | 332 | //---------------------------------------- 333 | // Service Definition 334 | 335 | service ABCIApplication { 336 | rpc Echo(RequestEcho) returns (ResponseEcho); 337 | rpc Flush(RequestFlush) returns (ResponseFlush); 338 | rpc Info(RequestInfo) returns (ResponseInfo); 339 | rpc SetOption(RequestSetOption) returns (ResponseSetOption); 340 | rpc DeliverTx(RequestDeliverTx) returns (ResponseDeliverTx); 341 | rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx); 342 | rpc Query(RequestQuery) returns (ResponseQuery); 343 | rpc Commit(RequestCommit) returns (ResponseCommit); 344 | rpc InitChain(RequestInitChain) returns (ResponseInitChain); 345 | rpc BeginBlock(RequestBeginBlock) returns (ResponseBeginBlock); 346 | rpc EndBlock(RequestEndBlock) returns (ResponseEndBlock); 347 | } 348 | -------------------------------------------------------------------------------- /protobuf/abci/types/types.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package tendermint.abci.types; 3 | option go_package = "github.com/tendermint/tendermint/abci/types"; 4 | 5 | // For more information on gogo.proto, see: 6 | // https://github.com/gogo/protobuf/blob/master/extensions.md 7 | import "third_party/proto/gogoproto/gogo.proto"; 8 | import "crypto/merkle/merkle.proto"; 9 | import "libs/kv/types.proto"; 10 | import "google/protobuf/timestamp.proto"; 11 | import "google/protobuf/duration.proto"; 12 | 13 | // This file is copied from http://github.com/tendermint/abci 14 | // NOTE: When using custom types, mind the warnings. 15 | // https://github.com/gogo/protobuf/blob/master/custom_types.md#warnings-and-issues 16 | 17 | option (gogoproto.marshaler_all) = true; 18 | option (gogoproto.unmarshaler_all) = true; 19 | option (gogoproto.sizer_all) = true; 20 | option (gogoproto.goproto_registration) = true; 21 | // Generate tests 22 | option (gogoproto.populate_all) = true; 23 | option (gogoproto.equal_all) = true; 24 | option (gogoproto.testgen_all) = true; 25 | 26 | //---------------------------------------- 27 | // Request types 28 | 29 | message Request { 30 | oneof value { 31 | RequestEcho echo = 2; 32 | RequestFlush flush = 3; 33 | RequestInfo info = 4; 34 | RequestSetOption set_option = 5; 35 | RequestInitChain init_chain = 6; 36 | RequestQuery query = 7; 37 | RequestBeginBlock begin_block = 8; 38 | RequestCheckTx check_tx = 9; 39 | RequestDeliverTx deliver_tx = 19; 40 | RequestEndBlock end_block = 11; 41 | RequestCommit commit = 12; 42 | } 43 | } 44 | 45 | message RequestEcho { 46 | string message = 1; 47 | } 48 | 49 | message RequestFlush {} 50 | 51 | message RequestInfo { 52 | string version = 1; 53 | uint64 block_version = 2; 54 | uint64 p2p_version = 3; 55 | } 56 | 57 | // nondeterministic 58 | message RequestSetOption { 59 | string key = 1; 60 | string value = 2; 61 | } 62 | 63 | message RequestInitChain { 64 | google.protobuf.Timestamp time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; 65 | string chain_id = 2; 66 | ConsensusParams consensus_params = 3; 67 | repeated ValidatorUpdate validators = 4 [(gogoproto.nullable) = false]; 68 | bytes app_state_bytes = 5; 69 | } 70 | 71 | message RequestQuery { 72 | bytes data = 1; 73 | string path = 2; 74 | int64 height = 3; 75 | bool prove = 4; 76 | } 77 | 78 | message RequestBeginBlock { 79 | bytes hash = 1; 80 | Header header = 2 [(gogoproto.nullable) = false]; 81 | LastCommitInfo last_commit_info = 3 [(gogoproto.nullable) = false]; 82 | repeated Evidence byzantine_validators = 4 [(gogoproto.nullable) = false]; 83 | } 84 | 85 | enum CheckTxType { 86 | New = 0; 87 | Recheck = 1; 88 | } 89 | 90 | message RequestCheckTx { 91 | bytes tx = 1; 92 | CheckTxType type = 2; 93 | } 94 | 95 | message RequestDeliverTx { 96 | bytes tx = 1; 97 | } 98 | 99 | message RequestEndBlock { 100 | int64 height = 1; 101 | } 102 | 103 | message RequestCommit {} 104 | 105 | //---------------------------------------- 106 | // Response types 107 | 108 | message Response { 109 | oneof value { 110 | ResponseException exception = 1; 111 | ResponseEcho echo = 2; 112 | ResponseFlush flush = 3; 113 | ResponseInfo info = 4; 114 | ResponseSetOption set_option = 5; 115 | ResponseInitChain init_chain = 6; 116 | ResponseQuery query = 7; 117 | ResponseBeginBlock begin_block = 8; 118 | ResponseCheckTx check_tx = 9; 119 | ResponseDeliverTx deliver_tx = 10; 120 | ResponseEndBlock end_block = 11; 121 | ResponseCommit commit = 12; 122 | } 123 | } 124 | 125 | // nondeterministic 126 | message ResponseException { 127 | string error = 1; 128 | } 129 | 130 | message ResponseEcho { 131 | string message = 1; 132 | } 133 | 134 | message ResponseFlush {} 135 | 136 | message ResponseInfo { 137 | string data = 1; 138 | 139 | string version = 2; 140 | uint64 app_version = 3; 141 | 142 | int64 last_block_height = 4; 143 | bytes last_block_app_hash = 5; 144 | } 145 | 146 | // nondeterministic 147 | message ResponseSetOption { 148 | uint32 code = 1; 149 | // bytes data = 2; 150 | string log = 3; 151 | string info = 4; 152 | } 153 | 154 | message ResponseInitChain { 155 | ConsensusParams consensus_params = 1; 156 | repeated ValidatorUpdate validators = 2 [(gogoproto.nullable) = false]; 157 | } 158 | 159 | message ResponseQuery { 160 | uint32 code = 1; 161 | // bytes data = 2; // use "value" instead. 162 | string log = 3; // nondeterministic 163 | string info = 4; // nondeterministic 164 | int64 index = 5; 165 | bytes key = 6; 166 | bytes value = 7; 167 | tendermint.crypto.merkle.Proof proof = 8; 168 | int64 height = 9; 169 | string codespace = 10; 170 | } 171 | 172 | message ResponseBeginBlock { 173 | repeated Event events = 1 174 | [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; 175 | } 176 | 177 | message ResponseCheckTx { 178 | uint32 code = 1; 179 | bytes data = 2; 180 | string log = 3; // nondeterministic 181 | string info = 4; // nondeterministic 182 | int64 gas_wanted = 5; 183 | int64 gas_used = 6; 184 | repeated Event events = 7 185 | [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; 186 | string codespace = 8; 187 | } 188 | 189 | message ResponseDeliverTx { 190 | uint32 code = 1; 191 | bytes data = 2; 192 | string log = 3; // nondeterministic 193 | string info = 4; // nondeterministic 194 | int64 gas_wanted = 5; 195 | int64 gas_used = 6; 196 | repeated Event events = 7 197 | [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; 198 | string codespace = 8; 199 | } 200 | 201 | message ResponseEndBlock { 202 | repeated ValidatorUpdate validator_updates = 1 [(gogoproto.nullable) = false]; 203 | ConsensusParams consensus_param_updates = 2; 204 | repeated Event events = 3 205 | [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; 206 | } 207 | 208 | message ResponseCommit { 209 | // reserve 1 210 | bytes data = 2; 211 | int64 retain_height = 3; 212 | } 213 | 214 | //---------------------------------------- 215 | // Misc. 216 | 217 | // ConsensusParams contains all consensus-relevant parameters 218 | // that can be adjusted by the abci app 219 | message ConsensusParams { 220 | BlockParams block = 1; 221 | EvidenceParams evidence = 2; 222 | ValidatorParams validator = 3; 223 | } 224 | 225 | // BlockParams contains limits on the block size. 226 | message BlockParams { 227 | // Note: must be greater than 0 228 | int64 max_bytes = 1; 229 | // Note: must be greater or equal to -1 230 | int64 max_gas = 2; 231 | } 232 | 233 | message EvidenceParams { 234 | // Note: must be greater than 0 235 | int64 max_age_num_blocks = 1; 236 | google.protobuf.Duration max_age_duration = 2 237 | [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; 238 | } 239 | 240 | // ValidatorParams contains limits on validators. 241 | message ValidatorParams { 242 | repeated string pub_key_types = 1; 243 | } 244 | 245 | message LastCommitInfo { 246 | int32 round = 1; 247 | repeated VoteInfo votes = 2 [(gogoproto.nullable) = false]; 248 | } 249 | 250 | message Event { 251 | string type = 1; 252 | repeated tendermint.libs.kv.Pair attributes = 2 253 | [(gogoproto.nullable) = false, (gogoproto.jsontag) = "attributes,omitempty"]; 254 | } 255 | 256 | //---------------------------------------- 257 | // Blockchain Types 258 | 259 | message Header { 260 | // basic block info 261 | Version version = 1 [(gogoproto.nullable) = false]; 262 | string chain_id = 2 [(gogoproto.customname) = "ChainID"]; 263 | int64 height = 3; 264 | google.protobuf.Timestamp time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; 265 | 266 | // prev block info 267 | BlockID last_block_id = 5 [(gogoproto.nullable) = false]; 268 | 269 | // hashes of block data 270 | bytes last_commit_hash = 6; // commit from validators from the last block 271 | bytes data_hash = 7; // transactions 272 | 273 | // hashes from the app output from the prev block 274 | bytes validators_hash = 8; // validators for the current block 275 | bytes next_validators_hash = 9; // validators for the next block 276 | bytes consensus_hash = 10; // consensus params for current block 277 | bytes app_hash = 11; // state after txs from the previous block 278 | bytes last_results_hash = 12; // root hash of all results from the txs from the previous block 279 | 280 | // consensus info 281 | bytes evidence_hash = 13; // evidence included in the block 282 | bytes proposer_address = 14; // original proposer of the block 283 | } 284 | 285 | message Version { 286 | uint64 Block = 1; 287 | uint64 App = 2; 288 | } 289 | 290 | message BlockID { 291 | bytes hash = 1; 292 | PartSetHeader parts_header = 2 [(gogoproto.nullable) = false]; 293 | } 294 | 295 | message PartSetHeader { 296 | int32 total = 1; 297 | bytes hash = 2; 298 | } 299 | 300 | // Validator 301 | message Validator { 302 | bytes address = 1; 303 | // PubKey pub_key = 2 [(gogoproto.nullable)=false]; 304 | int64 power = 3; 305 | } 306 | 307 | // ValidatorUpdate 308 | message ValidatorUpdate { 309 | PubKey pub_key = 1 [(gogoproto.nullable) = false]; 310 | int64 power = 2; 311 | } 312 | 313 | // VoteInfo 314 | message VoteInfo { 315 | Validator validator = 1 [(gogoproto.nullable) = false]; 316 | bool signed_last_block = 2; 317 | } 318 | 319 | message PubKey { 320 | string type = 1; 321 | bytes data = 2; 322 | } 323 | 324 | message Evidence { 325 | string type = 1; 326 | Validator validator = 2 [(gogoproto.nullable) = false]; 327 | int64 height = 3; 328 | google.protobuf.Timestamp time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; 329 | int64 total_voting_power = 5; 330 | } 331 | 332 | //---------------------------------------- 333 | // Service Definition 334 | 335 | service ABCIApplication { 336 | rpc Echo(RequestEcho) returns (ResponseEcho); 337 | rpc Flush(RequestFlush) returns (ResponseFlush); 338 | rpc Info(RequestInfo) returns (ResponseInfo); 339 | rpc SetOption(RequestSetOption) returns (ResponseSetOption); 340 | rpc DeliverTx(RequestDeliverTx) returns (ResponseDeliverTx); 341 | rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx); 342 | rpc Query(RequestQuery) returns (ResponseQuery); 343 | rpc Commit(RequestCommit) returns (ResponseCommit); 344 | rpc InitChain(RequestInitChain) returns (ResponseInitChain); 345 | rpc BeginBlock(RequestBeginBlock) returns (ResponseBeginBlock); 346 | rpc EndBlock(RequestEndBlock) returns (ResponseEndBlock); 347 | } 348 | -------------------------------------------------------------------------------- /protobuf/crypto/merkle/merkle.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package tendermint.crypto.merkle; 3 | option go_package = "github.com/tendermint/tendermint/crypto/merkle"; 4 | 5 | // For more information on gogo.proto, see: 6 | // https://github.com/gogo/protobuf/blob/master/extensions.md 7 | import "third_party/proto/gogoproto/gogo.proto"; 8 | 9 | option (gogoproto.marshaler_all) = true; 10 | option (gogoproto.unmarshaler_all) = true; 11 | option (gogoproto.sizer_all) = true; 12 | 13 | option (gogoproto.populate_all) = true; 14 | option (gogoproto.equal_all) = true; 15 | 16 | //---------------------------------------- 17 | // Message types 18 | 19 | // ProofOp defines an operation used for calculating Merkle root 20 | // The data could be arbitrary format, providing nessecary data 21 | // for example neighbouring node hash 22 | message ProofOp { 23 | string type = 1; 24 | bytes key = 2; 25 | bytes data = 3; 26 | } 27 | 28 | // Proof is Merkle proof defined by the list of ProofOps 29 | message Proof { 30 | repeated ProofOp ops = 1 [(gogoproto.nullable) = false]; 31 | } 32 | -------------------------------------------------------------------------------- /protobuf/github.com/tendermint/tendermint/abci/types/types.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package types; 3 | 4 | // For more information on gogo.proto, see: 5 | // https://github.com/gogo/protobuf/blob/master/extensions.md 6 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 7 | import "github.com/tendermint/tendermint/crypto/merkle/merkle.proto"; 8 | import "github.com/tendermint/tendermint/libs/common/types.proto"; 9 | import "google/protobuf/timestamp.proto"; 10 | 11 | // This file is copied from http://github.com/tendermint/abci 12 | // NOTE: When using custom types, mind the warnings. 13 | // https://github.com/gogo/protobuf/blob/master/custom_types.md#warnings-and-issues 14 | 15 | option (gogoproto.marshaler_all) = true; 16 | option (gogoproto.unmarshaler_all) = true; 17 | option (gogoproto.sizer_all) = true; 18 | option (gogoproto.goproto_registration) = true; 19 | // Generate tests 20 | option (gogoproto.populate_all) = true; 21 | option (gogoproto.equal_all) = true; 22 | option (gogoproto.testgen_all) = true; 23 | 24 | //---------------------------------------- 25 | // Request types 26 | 27 | message Request { 28 | oneof value { 29 | RequestEcho echo = 2; 30 | RequestFlush flush = 3; 31 | RequestInfo info = 4; 32 | RequestSetOption set_option = 5; 33 | RequestInitChain init_chain = 6; 34 | RequestQuery query = 7; 35 | RequestBeginBlock begin_block = 8; 36 | RequestCheckTx check_tx = 9; 37 | RequestDeliverTx deliver_tx = 19; 38 | RequestEndBlock end_block = 11; 39 | RequestCommit commit = 12; 40 | } 41 | } 42 | 43 | message RequestEcho { 44 | string message = 1; 45 | } 46 | 47 | message RequestFlush { 48 | } 49 | 50 | message RequestInfo { 51 | string version = 1; 52 | uint64 block_version = 2; 53 | uint64 p2p_version = 3; 54 | } 55 | 56 | // nondeterministic 57 | message RequestSetOption { 58 | string key = 1; 59 | string value = 2; 60 | } 61 | 62 | message RequestInitChain { 63 | google.protobuf.Timestamp time = 1 [(gogoproto.nullable)=false, (gogoproto.stdtime)=true]; 64 | string chain_id = 2; 65 | ConsensusParams consensus_params = 3; 66 | repeated ValidatorUpdate validators = 4 [(gogoproto.nullable)=false]; 67 | bytes app_state_bytes = 5; 68 | } 69 | 70 | message RequestQuery { 71 | bytes data = 1; 72 | string path = 2; 73 | int64 height = 3; 74 | bool prove = 4; 75 | } 76 | 77 | message RequestBeginBlock { 78 | bytes hash = 1; 79 | Header header = 2 [(gogoproto.nullable)=false]; 80 | LastCommitInfo last_commit_info = 3 [(gogoproto.nullable)=false]; 81 | repeated Evidence byzantine_validators = 4 [(gogoproto.nullable)=false]; 82 | } 83 | 84 | enum CheckTxType { 85 | New = 0; 86 | Recheck = 1; 87 | } 88 | 89 | message RequestCheckTx { 90 | bytes tx = 1; 91 | CheckTxType type = 2; 92 | } 93 | 94 | message RequestDeliverTx { 95 | bytes tx = 1; 96 | } 97 | 98 | message RequestEndBlock { 99 | int64 height = 1; 100 | } 101 | 102 | message RequestCommit { 103 | } 104 | 105 | //---------------------------------------- 106 | // Response types 107 | 108 | message Response { 109 | oneof value { 110 | ResponseException exception = 1; 111 | ResponseEcho echo = 2; 112 | ResponseFlush flush = 3; 113 | ResponseInfo info = 4; 114 | ResponseSetOption set_option = 5; 115 | ResponseInitChain init_chain = 6; 116 | ResponseQuery query = 7; 117 | ResponseBeginBlock begin_block = 8; 118 | ResponseCheckTx check_tx = 9; 119 | ResponseDeliverTx deliver_tx = 10; 120 | ResponseEndBlock end_block = 11; 121 | ResponseCommit commit = 12; 122 | } 123 | } 124 | 125 | // nondeterministic 126 | message ResponseException { 127 | string error = 1; 128 | } 129 | 130 | message ResponseEcho { 131 | string message = 1; 132 | } 133 | 134 | message ResponseFlush { 135 | } 136 | 137 | message ResponseInfo { 138 | string data = 1; 139 | 140 | string version = 2; 141 | uint64 app_version = 3; 142 | 143 | int64 last_block_height = 4; 144 | bytes last_block_app_hash = 5; 145 | } 146 | 147 | // nondeterministic 148 | message ResponseSetOption { 149 | uint32 code = 1; 150 | // bytes data = 2; 151 | string log = 3; 152 | string info = 4; 153 | } 154 | 155 | message ResponseInitChain { 156 | ConsensusParams consensus_params = 1; 157 | repeated ValidatorUpdate validators = 2 [(gogoproto.nullable)=false]; 158 | } 159 | 160 | message ResponseQuery { 161 | uint32 code = 1; 162 | // bytes data = 2; // use "value" instead. 163 | string log = 3; // nondeterministic 164 | string info = 4; // nondeterministic 165 | int64 index = 5; 166 | bytes key = 6; 167 | bytes value = 7; 168 | merkle.Proof proof = 8; 169 | int64 height = 9; 170 | string codespace = 10; 171 | } 172 | 173 | message ResponseBeginBlock { 174 | repeated Event events = 1 [(gogoproto.nullable)=false, (gogoproto.jsontag)="events,omitempty"]; 175 | } 176 | 177 | message ResponseCheckTx { 178 | uint32 code = 1; 179 | bytes data = 2; 180 | string log = 3; // nondeterministic 181 | string info = 4; // nondeterministic 182 | int64 gas_wanted = 5; 183 | int64 gas_used = 6; 184 | repeated Event events = 7 [(gogoproto.nullable)=false, (gogoproto.jsontag)="events,omitempty"]; 185 | string codespace = 8; 186 | } 187 | 188 | message ResponseDeliverTx { 189 | uint32 code = 1; 190 | bytes data = 2; 191 | string log = 3; // nondeterministic 192 | string info = 4; // nondeterministic 193 | int64 gas_wanted = 5; 194 | int64 gas_used = 6; 195 | repeated Event events = 7 [(gogoproto.nullable)=false, (gogoproto.jsontag)="events,omitempty"]; 196 | string codespace = 8; 197 | } 198 | 199 | message ResponseEndBlock { 200 | repeated ValidatorUpdate validator_updates = 1 [(gogoproto.nullable)=false]; 201 | ConsensusParams consensus_param_updates = 2; 202 | repeated Event events = 3 [(gogoproto.nullable)=false, (gogoproto.jsontag)="events,omitempty"]; 203 | } 204 | 205 | message ResponseCommit { 206 | // reserve 1 207 | bytes data = 2; 208 | } 209 | 210 | //---------------------------------------- 211 | // Misc. 212 | 213 | // ConsensusParams contains all consensus-relevant parameters 214 | // that can be adjusted by the abci app 215 | message ConsensusParams { 216 | BlockParams block = 1; 217 | EvidenceParams evidence = 2; 218 | ValidatorParams validator = 3; 219 | } 220 | 221 | // BlockParams contains limits on the block size. 222 | message BlockParams { 223 | // Note: must be greater than 0 224 | int64 max_bytes = 1; 225 | // Note: must be greater or equal to -1 226 | int64 max_gas = 2; 227 | } 228 | 229 | // EvidenceParams contains limits on the evidence. 230 | message EvidenceParams { 231 | // Note: must be greater than 0 232 | int64 max_age = 1; 233 | } 234 | 235 | // ValidatorParams contains limits on validators. 236 | message ValidatorParams { 237 | repeated string pub_key_types = 1; 238 | } 239 | 240 | message LastCommitInfo { 241 | int32 round = 1; 242 | repeated VoteInfo votes = 2 [(gogoproto.nullable)=false]; 243 | } 244 | 245 | message Event { 246 | string type = 1; 247 | repeated common.KVPair attributes = 2 [(gogoproto.nullable)=false, (gogoproto.jsontag)="attributes,omitempty"]; 248 | } 249 | 250 | //---------------------------------------- 251 | // Blockchain Types 252 | 253 | message Header { 254 | // basic block info 255 | Version version = 1 [(gogoproto.nullable)=false]; 256 | string chain_id = 2 [(gogoproto.customname)="ChainID"]; 257 | int64 height = 3; 258 | google.protobuf.Timestamp time = 4 [(gogoproto.nullable)=false, (gogoproto.stdtime)=true]; 259 | int64 num_txs = 5; 260 | int64 total_txs = 6; 261 | 262 | // prev block info 263 | BlockID last_block_id = 7 [(gogoproto.nullable)=false]; 264 | 265 | // hashes of block data 266 | bytes last_commit_hash = 8; // commit from validators from the last block 267 | bytes data_hash = 9; // transactions 268 | 269 | // hashes from the app output from the prev block 270 | bytes validators_hash = 10; // validators for the current block 271 | bytes next_validators_hash = 11; // validators for the next block 272 | bytes consensus_hash = 12; // consensus params for current block 273 | bytes app_hash = 13; // state after txs from the previous block 274 | bytes last_results_hash = 14;// root hash of all results from the txs from the previous block 275 | 276 | // consensus info 277 | bytes evidence_hash = 15; // evidence included in the block 278 | bytes proposer_address = 16; // original proposer of the block 279 | } 280 | 281 | message Version { 282 | uint64 Block = 1; 283 | uint64 App = 2; 284 | } 285 | 286 | 287 | message BlockID { 288 | bytes hash = 1; 289 | PartSetHeader parts_header = 2 [(gogoproto.nullable)=false]; 290 | } 291 | 292 | message PartSetHeader { 293 | int32 total = 1; 294 | bytes hash = 2; 295 | } 296 | 297 | // Validator 298 | message Validator { 299 | bytes address = 1; 300 | //PubKey pub_key = 2 [(gogoproto.nullable)=false]; 301 | int64 power = 3; 302 | } 303 | 304 | // ValidatorUpdate 305 | message ValidatorUpdate { 306 | PubKey pub_key = 1 [(gogoproto.nullable)=false]; 307 | int64 power = 2; 308 | } 309 | 310 | // VoteInfo 311 | message VoteInfo { 312 | Validator validator = 1 [(gogoproto.nullable)=false]; 313 | bool signed_last_block = 2; 314 | } 315 | 316 | message PubKey { 317 | string type = 1; 318 | bytes data = 2; 319 | } 320 | 321 | message Evidence { 322 | string type = 1; 323 | Validator validator = 2 [(gogoproto.nullable)=false]; 324 | int64 height = 3; 325 | google.protobuf.Timestamp time = 4 [(gogoproto.nullable)=false, (gogoproto.stdtime)=true]; 326 | int64 total_voting_power = 5; 327 | } 328 | 329 | //---------------------------------------- 330 | // Service Definition 331 | 332 | service ABCIApplication { 333 | rpc Echo(RequestEcho) returns (ResponseEcho) ; 334 | rpc Flush(RequestFlush) returns (ResponseFlush); 335 | rpc Info(RequestInfo) returns (ResponseInfo); 336 | rpc SetOption(RequestSetOption) returns (ResponseSetOption); 337 | rpc DeliverTx(RequestDeliverTx) returns (ResponseDeliverTx); 338 | rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx); 339 | rpc Query(RequestQuery) returns (ResponseQuery); 340 | rpc Commit(RequestCommit) returns (ResponseCommit); 341 | rpc InitChain(RequestInitChain) returns (ResponseInitChain); 342 | rpc BeginBlock(RequestBeginBlock) returns (ResponseBeginBlock); 343 | rpc EndBlock(RequestEndBlock) returns (ResponseEndBlock); 344 | } 345 | -------------------------------------------------------------------------------- /protobuf/google/protobuf/descriptor.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: kenton@google.com (Kenton Varda) 32 | // Based on original Protocol Buffers design by 33 | // Sanjay Ghemawat, Jeff Dean, and others. 34 | // 35 | // The messages in this file describe the definitions found in .proto files. 36 | // A valid .proto file can be translated directly to a FileDescriptorProto 37 | // without any other information (e.g. without reading its imports). 38 | 39 | 40 | syntax = "proto2"; 41 | 42 | package google.protobuf; 43 | option go_package = "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor"; 44 | option java_package = "com.google.protobuf"; 45 | option java_outer_classname = "DescriptorProtos"; 46 | option csharp_namespace = "Google.Protobuf.Reflection"; 47 | option objc_class_prefix = "GPB"; 48 | option cc_enable_arenas = true; 49 | 50 | // descriptor.proto must be optimized for speed because reflection-based 51 | // algorithms don't work during bootstrapping. 52 | option optimize_for = SPEED; 53 | 54 | // The protocol compiler can output a FileDescriptorSet containing the .proto 55 | // files it parses. 56 | message FileDescriptorSet { 57 | repeated FileDescriptorProto file = 1; 58 | } 59 | 60 | // Describes a complete .proto file. 61 | message FileDescriptorProto { 62 | optional string name = 1; // file name, relative to root of source tree 63 | optional string package = 2; // e.g. "foo", "foo.bar", etc. 64 | 65 | // Names of files imported by this file. 66 | repeated string dependency = 3; 67 | // Indexes of the public imported files in the dependency list above. 68 | repeated int32 public_dependency = 10; 69 | // Indexes of the weak imported files in the dependency list. 70 | // For Google-internal migration only. Do not use. 71 | repeated int32 weak_dependency = 11; 72 | 73 | // All top-level definitions in this file. 74 | repeated DescriptorProto message_type = 4; 75 | repeated EnumDescriptorProto enum_type = 5; 76 | repeated ServiceDescriptorProto service = 6; 77 | repeated FieldDescriptorProto extension = 7; 78 | 79 | optional FileOptions options = 8; 80 | 81 | // This field contains optional information about the original source code. 82 | // You may safely remove this entire field without harming runtime 83 | // functionality of the descriptors -- the information is needed only by 84 | // development tools. 85 | optional SourceCodeInfo source_code_info = 9; 86 | 87 | // The syntax of the proto file. 88 | // The supported values are "proto2" and "proto3". 89 | optional string syntax = 12; 90 | } 91 | 92 | // Describes a message type. 93 | message DescriptorProto { 94 | optional string name = 1; 95 | 96 | repeated FieldDescriptorProto field = 2; 97 | repeated FieldDescriptorProto extension = 6; 98 | 99 | repeated DescriptorProto nested_type = 3; 100 | repeated EnumDescriptorProto enum_type = 4; 101 | 102 | message ExtensionRange { 103 | optional int32 start = 1; 104 | optional int32 end = 2; 105 | 106 | optional ExtensionRangeOptions options = 3; 107 | } 108 | repeated ExtensionRange extension_range = 5; 109 | 110 | repeated OneofDescriptorProto oneof_decl = 8; 111 | 112 | optional MessageOptions options = 7; 113 | 114 | // Range of reserved tag numbers. Reserved tag numbers may not be used by 115 | // fields or extension ranges in the same message. Reserved ranges may 116 | // not overlap. 117 | message ReservedRange { 118 | optional int32 start = 1; // Inclusive. 119 | optional int32 end = 2; // Exclusive. 120 | } 121 | repeated ReservedRange reserved_range = 9; 122 | // Reserved field names, which may not be used by fields in the same message. 123 | // A given name may only be reserved once. 124 | repeated string reserved_name = 10; 125 | } 126 | 127 | message ExtensionRangeOptions { 128 | // The parser stores options it doesn't recognize here. See above. 129 | repeated UninterpretedOption uninterpreted_option = 999; 130 | 131 | // Clients can define custom options in extensions of this message. See above. 132 | extensions 1000 to max; 133 | } 134 | 135 | // Describes a field within a message. 136 | message FieldDescriptorProto { 137 | enum Type { 138 | // 0 is reserved for errors. 139 | // Order is weird for historical reasons. 140 | TYPE_DOUBLE = 1; 141 | TYPE_FLOAT = 2; 142 | // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if 143 | // negative values are likely. 144 | TYPE_INT64 = 3; 145 | TYPE_UINT64 = 4; 146 | // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if 147 | // negative values are likely. 148 | TYPE_INT32 = 5; 149 | TYPE_FIXED64 = 6; 150 | TYPE_FIXED32 = 7; 151 | TYPE_BOOL = 8; 152 | TYPE_STRING = 9; 153 | // Tag-delimited aggregate. 154 | // Group type is deprecated and not supported in proto3. However, Proto3 155 | // implementations should still be able to parse the group wire format and 156 | // treat group fields as unknown fields. 157 | TYPE_GROUP = 10; 158 | TYPE_MESSAGE = 11; // Length-delimited aggregate. 159 | 160 | // New in version 2. 161 | TYPE_BYTES = 12; 162 | TYPE_UINT32 = 13; 163 | TYPE_ENUM = 14; 164 | TYPE_SFIXED32 = 15; 165 | TYPE_SFIXED64 = 16; 166 | TYPE_SINT32 = 17; // Uses ZigZag encoding. 167 | TYPE_SINT64 = 18; // Uses ZigZag encoding. 168 | }; 169 | 170 | enum Label { 171 | // 0 is reserved for errors 172 | LABEL_OPTIONAL = 1; 173 | LABEL_REQUIRED = 2; 174 | LABEL_REPEATED = 3; 175 | }; 176 | 177 | optional string name = 1; 178 | optional int32 number = 3; 179 | optional Label label = 4; 180 | 181 | // If type_name is set, this need not be set. If both this and type_name 182 | // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. 183 | optional Type type = 5; 184 | 185 | // For message and enum types, this is the name of the type. If the name 186 | // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping 187 | // rules are used to find the type (i.e. first the nested types within this 188 | // message are searched, then within the parent, on up to the root 189 | // namespace). 190 | optional string type_name = 6; 191 | 192 | // For extensions, this is the name of the type being extended. It is 193 | // resolved in the same manner as type_name. 194 | optional string extendee = 2; 195 | 196 | // For numeric types, contains the original text representation of the value. 197 | // For booleans, "true" or "false". 198 | // For strings, contains the default text contents (not escaped in any way). 199 | // For bytes, contains the C escaped value. All bytes >= 128 are escaped. 200 | // TODO(kenton): Base-64 encode? 201 | optional string default_value = 7; 202 | 203 | // If set, gives the index of a oneof in the containing type's oneof_decl 204 | // list. This field is a member of that oneof. 205 | optional int32 oneof_index = 9; 206 | 207 | // JSON name of this field. The value is set by protocol compiler. If the 208 | // user has set a "json_name" option on this field, that option's value 209 | // will be used. Otherwise, it's deduced from the field's name by converting 210 | // it to camelCase. 211 | optional string json_name = 10; 212 | 213 | optional FieldOptions options = 8; 214 | } 215 | 216 | // Describes a oneof. 217 | message OneofDescriptorProto { 218 | optional string name = 1; 219 | optional OneofOptions options = 2; 220 | } 221 | 222 | // Describes an enum type. 223 | message EnumDescriptorProto { 224 | optional string name = 1; 225 | 226 | repeated EnumValueDescriptorProto value = 2; 227 | 228 | optional EnumOptions options = 3; 229 | 230 | // Range of reserved numeric values. Reserved values may not be used by 231 | // entries in the same enum. Reserved ranges may not overlap. 232 | // 233 | // Note that this is distinct from DescriptorProto.ReservedRange in that it 234 | // is inclusive such that it can appropriately represent the entire int32 235 | // domain. 236 | message EnumReservedRange { 237 | optional int32 start = 1; // Inclusive. 238 | optional int32 end = 2; // Inclusive. 239 | } 240 | 241 | // Range of reserved numeric values. Reserved numeric values may not be used 242 | // by enum values in the same enum declaration. Reserved ranges may not 243 | // overlap. 244 | repeated EnumReservedRange reserved_range = 4; 245 | 246 | // Reserved enum value names, which may not be reused. A given name may only 247 | // be reserved once. 248 | repeated string reserved_name = 5; 249 | } 250 | 251 | // Describes a value within an enum. 252 | message EnumValueDescriptorProto { 253 | optional string name = 1; 254 | optional int32 number = 2; 255 | 256 | optional EnumValueOptions options = 3; 257 | } 258 | 259 | // Describes a service. 260 | message ServiceDescriptorProto { 261 | optional string name = 1; 262 | repeated MethodDescriptorProto method = 2; 263 | 264 | optional ServiceOptions options = 3; 265 | } 266 | 267 | // Describes a method of a service. 268 | message MethodDescriptorProto { 269 | optional string name = 1; 270 | 271 | // Input and output type names. These are resolved in the same way as 272 | // FieldDescriptorProto.type_name, but must refer to a message type. 273 | optional string input_type = 2; 274 | optional string output_type = 3; 275 | 276 | optional MethodOptions options = 4; 277 | 278 | // Identifies if client streams multiple client messages 279 | optional bool client_streaming = 5 [default=false]; 280 | // Identifies if server streams multiple server messages 281 | optional bool server_streaming = 6 [default=false]; 282 | } 283 | 284 | 285 | // =================================================================== 286 | // Options 287 | 288 | // Each of the definitions above may have "options" attached. These are 289 | // just annotations which may cause code to be generated slightly differently 290 | // or may contain hints for code that manipulates protocol messages. 291 | // 292 | // Clients may define custom options as extensions of the *Options messages. 293 | // These extensions may not yet be known at parsing time, so the parser cannot 294 | // store the values in them. Instead it stores them in a field in the *Options 295 | // message called uninterpreted_option. This field must have the same name 296 | // across all *Options messages. We then use this field to populate the 297 | // extensions when we build a descriptor, at which point all protos have been 298 | // parsed and so all extensions are known. 299 | // 300 | // Extension numbers for custom options may be chosen as follows: 301 | // * For options which will only be used within a single application or 302 | // organization, or for experimental options, use field numbers 50000 303 | // through 99999. It is up to you to ensure that you do not use the 304 | // same number for multiple options. 305 | // * For options which will be published and used publicly by multiple 306 | // independent entities, e-mail protobuf-global-extension-registry@google.com 307 | // to reserve extension numbers. Simply provide your project name (e.g. 308 | // Objective-C plugin) and your project website (if available) -- there's no 309 | // need to explain how you intend to use them. Usually you only need one 310 | // extension number. You can declare multiple options with only one extension 311 | // number by putting them in a sub-message. See the Custom Options section of 312 | // the docs for examples: 313 | // https://developers.google.com/protocol-buffers/docs/proto#options 314 | // If this turns out to be popular, a web service will be set up 315 | // to automatically assign option numbers. 316 | 317 | 318 | message FileOptions { 319 | 320 | // Sets the Java package where classes generated from this .proto will be 321 | // placed. By default, the proto package is used, but this is often 322 | // inappropriate because proto packages do not normally start with backwards 323 | // domain names. 324 | optional string java_package = 1; 325 | 326 | 327 | // If set, all the classes from the .proto file are wrapped in a single 328 | // outer class with the given name. This applies to both Proto1 329 | // (equivalent to the old "--one_java_file" option) and Proto2 (where 330 | // a .proto always translates to a single class, but you may want to 331 | // explicitly choose the class name). 332 | optional string java_outer_classname = 8; 333 | 334 | // If set true, then the Java code generator will generate a separate .java 335 | // file for each top-level message, enum, and service defined in the .proto 336 | // file. Thus, these types will *not* be nested inside the outer class 337 | // named by java_outer_classname. However, the outer class will still be 338 | // generated to contain the file's getDescriptor() method as well as any 339 | // top-level extensions defined in the file. 340 | optional bool java_multiple_files = 10 [default=false]; 341 | 342 | // This option does nothing. 343 | optional bool java_generate_equals_and_hash = 20 [deprecated=true]; 344 | 345 | // If set true, then the Java2 code generator will generate code that 346 | // throws an exception whenever an attempt is made to assign a non-UTF-8 347 | // byte sequence to a string field. 348 | // Message reflection will do the same. 349 | // However, an extension field still accepts non-UTF-8 byte sequences. 350 | // This option has no effect on when used with the lite runtime. 351 | optional bool java_string_check_utf8 = 27 [default=false]; 352 | 353 | 354 | // Generated classes can be optimized for speed or code size. 355 | enum OptimizeMode { 356 | SPEED = 1; // Generate complete code for parsing, serialization, 357 | // etc. 358 | CODE_SIZE = 2; // Use ReflectionOps to implement these methods. 359 | LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime. 360 | } 361 | optional OptimizeMode optimize_for = 9 [default=SPEED]; 362 | 363 | // Sets the Go package where structs generated from this .proto will be 364 | // placed. If omitted, the Go package will be derived from the following: 365 | // - The basename of the package import path, if provided. 366 | // - Otherwise, the package statement in the .proto file, if present. 367 | // - Otherwise, the basename of the .proto file, without extension. 368 | optional string go_package = 11; 369 | 370 | 371 | 372 | // Should generic services be generated in each language? "Generic" services 373 | // are not specific to any particular RPC system. They are generated by the 374 | // main code generators in each language (without additional plugins). 375 | // Generic services were the only kind of service generation supported by 376 | // early versions of google.protobuf. 377 | // 378 | // Generic services are now considered deprecated in favor of using plugins 379 | // that generate code specific to your particular RPC system. Therefore, 380 | // these default to false. Old code which depends on generic services should 381 | // explicitly set them to true. 382 | optional bool cc_generic_services = 16 [default=false]; 383 | optional bool java_generic_services = 17 [default=false]; 384 | optional bool py_generic_services = 18 [default=false]; 385 | optional bool php_generic_services = 42 [default=false]; 386 | 387 | // Is this file deprecated? 388 | // Depending on the target platform, this can emit Deprecated annotations 389 | // for everything in the file, or it will be completely ignored; in the very 390 | // least, this is a formalization for deprecating files. 391 | optional bool deprecated = 23 [default=false]; 392 | 393 | // Enables the use of arenas for the proto messages in this file. This applies 394 | // only to generated classes for C++. 395 | optional bool cc_enable_arenas = 31 [default=false]; 396 | 397 | 398 | // Sets the objective c class prefix which is prepended to all objective c 399 | // generated classes from this .proto. There is no default. 400 | optional string objc_class_prefix = 36; 401 | 402 | // Namespace for generated classes; defaults to the package. 403 | optional string csharp_namespace = 37; 404 | 405 | // By default Swift generators will take the proto package and CamelCase it 406 | // replacing '.' with underscore and use that to prefix the types/symbols 407 | // defined. When this options is provided, they will use this value instead 408 | // to prefix the types/symbols defined. 409 | optional string swift_prefix = 39; 410 | 411 | // Sets the php class prefix which is prepended to all php generated classes 412 | // from this .proto. Default is empty. 413 | optional string php_class_prefix = 40; 414 | 415 | // Use this option to change the namespace of php generated classes. Default 416 | // is empty. When this option is empty, the package name will be used for 417 | // determining the namespace. 418 | optional string php_namespace = 41; 419 | 420 | 421 | // Use this option to change the namespace of php generated metadata classes. 422 | // Default is empty. When this option is empty, the proto file name will be used 423 | // for determining the namespace. 424 | optional string php_metadata_namespace = 44; 425 | 426 | // Use this option to change the package of ruby generated classes. Default 427 | // is empty. When this option is not set, the package name will be used for 428 | // determining the ruby package. 429 | optional string ruby_package = 45; 430 | 431 | // The parser stores options it doesn't recognize here. 432 | // See the documentation for the "Options" section above. 433 | repeated UninterpretedOption uninterpreted_option = 999; 434 | 435 | // Clients can define custom options in extensions of this message. 436 | // See the documentation for the "Options" section above. 437 | extensions 1000 to max; 438 | 439 | reserved 38; 440 | } 441 | 442 | message MessageOptions { 443 | // Set true to use the old proto1 MessageSet wire format for extensions. 444 | // This is provided for backwards-compatibility with the MessageSet wire 445 | // format. You should not use this for any other reason: It's less 446 | // efficient, has fewer features, and is more complicated. 447 | // 448 | // The message must be defined exactly as follows: 449 | // message Foo { 450 | // option message_set_wire_format = true; 451 | // extensions 4 to max; 452 | // } 453 | // Note that the message cannot have any defined fields; MessageSets only 454 | // have extensions. 455 | // 456 | // All extensions of your type must be singular messages; e.g. they cannot 457 | // be int32s, enums, or repeated messages. 458 | // 459 | // Because this is an option, the above two restrictions are not enforced by 460 | // the protocol compiler. 461 | optional bool message_set_wire_format = 1 [default=false]; 462 | 463 | // Disables the generation of the standard "descriptor()" accessor, which can 464 | // conflict with a field of the same name. This is meant to make migration 465 | // from proto1 easier; new code should avoid fields named "descriptor". 466 | optional bool no_standard_descriptor_accessor = 2 [default=false]; 467 | 468 | // Is this message deprecated? 469 | // Depending on the target platform, this can emit Deprecated annotations 470 | // for the message, or it will be completely ignored; in the very least, 471 | // this is a formalization for deprecating messages. 472 | optional bool deprecated = 3 [default=false]; 473 | 474 | // Whether the message is an automatically generated map entry type for the 475 | // maps field. 476 | // 477 | // For maps fields: 478 | // map map_field = 1; 479 | // The parsed descriptor looks like: 480 | // message MapFieldEntry { 481 | // option map_entry = true; 482 | // optional KeyType key = 1; 483 | // optional ValueType value = 2; 484 | // } 485 | // repeated MapFieldEntry map_field = 1; 486 | // 487 | // Implementations may choose not to generate the map_entry=true message, but 488 | // use a native map in the target language to hold the keys and values. 489 | // The reflection APIs in such implementions still need to work as 490 | // if the field is a repeated message field. 491 | // 492 | // NOTE: Do not set the option in .proto files. Always use the maps syntax 493 | // instead. The option should only be implicitly set by the proto compiler 494 | // parser. 495 | optional bool map_entry = 7; 496 | 497 | reserved 8; // javalite_serializable 498 | reserved 9; // javanano_as_lite 499 | 500 | // The parser stores options it doesn't recognize here. See above. 501 | repeated UninterpretedOption uninterpreted_option = 999; 502 | 503 | // Clients can define custom options in extensions of this message. See above. 504 | extensions 1000 to max; 505 | } 506 | 507 | message FieldOptions { 508 | // The ctype option instructs the C++ code generator to use a different 509 | // representation of the field than it normally would. See the specific 510 | // options below. This option is not yet implemented in the open source 511 | // release -- sorry, we'll try to include it in a future version! 512 | optional CType ctype = 1 [default = STRING]; 513 | enum CType { 514 | // Default mode. 515 | STRING = 0; 516 | 517 | CORD = 1; 518 | 519 | STRING_PIECE = 2; 520 | } 521 | // The packed option can be enabled for repeated primitive fields to enable 522 | // a more efficient representation on the wire. Rather than repeatedly 523 | // writing the tag and type for each element, the entire array is encoded as 524 | // a single length-delimited blob. In proto3, only explicit setting it to 525 | // false will avoid using packed encoding. 526 | optional bool packed = 2; 527 | 528 | // The jstype option determines the JavaScript type used for values of the 529 | // field. The option is permitted only for 64 bit integral and fixed types 530 | // (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING 531 | // is represented as JavaScript string, which avoids loss of precision that 532 | // can happen when a large value is converted to a floating point JavaScript. 533 | // Specifying JS_NUMBER for the jstype causes the generated JavaScript code to 534 | // use the JavaScript "number" type. The behavior of the default option 535 | // JS_NORMAL is implementation dependent. 536 | // 537 | // This option is an enum to permit additional types to be added, e.g. 538 | // goog.math.Integer. 539 | optional JSType jstype = 6 [default = JS_NORMAL]; 540 | enum JSType { 541 | // Use the default type. 542 | JS_NORMAL = 0; 543 | 544 | // Use JavaScript strings. 545 | JS_STRING = 1; 546 | 547 | // Use JavaScript numbers. 548 | JS_NUMBER = 2; 549 | } 550 | 551 | // Should this field be parsed lazily? Lazy applies only to message-type 552 | // fields. It means that when the outer message is initially parsed, the 553 | // inner message's contents will not be parsed but instead stored in encoded 554 | // form. The inner message will actually be parsed when it is first accessed. 555 | // 556 | // This is only a hint. Implementations are free to choose whether to use 557 | // eager or lazy parsing regardless of the value of this option. However, 558 | // setting this option true suggests that the protocol author believes that 559 | // using lazy parsing on this field is worth the additional bookkeeping 560 | // overhead typically needed to implement it. 561 | // 562 | // This option does not affect the public interface of any generated code; 563 | // all method signatures remain the same. Furthermore, thread-safety of the 564 | // interface is not affected by this option; const methods remain safe to 565 | // call from multiple threads concurrently, while non-const methods continue 566 | // to require exclusive access. 567 | // 568 | // 569 | // Note that implementations may choose not to check required fields within 570 | // a lazy sub-message. That is, calling IsInitialized() on the outer message 571 | // may return true even if the inner message has missing required fields. 572 | // This is necessary because otherwise the inner message would have to be 573 | // parsed in order to perform the check, defeating the purpose of lazy 574 | // parsing. An implementation which chooses not to check required fields 575 | // must be consistent about it. That is, for any particular sub-message, the 576 | // implementation must either *always* check its required fields, or *never* 577 | // check its required fields, regardless of whether or not the message has 578 | // been parsed. 579 | optional bool lazy = 5 [default=false]; 580 | 581 | // Is this field deprecated? 582 | // Depending on the target platform, this can emit Deprecated annotations 583 | // for accessors, or it will be completely ignored; in the very least, this 584 | // is a formalization for deprecating fields. 585 | optional bool deprecated = 3 [default=false]; 586 | 587 | // For Google-internal migration only. Do not use. 588 | optional bool weak = 10 [default=false]; 589 | 590 | 591 | // The parser stores options it doesn't recognize here. See above. 592 | repeated UninterpretedOption uninterpreted_option = 999; 593 | 594 | // Clients can define custom options in extensions of this message. See above. 595 | extensions 1000 to max; 596 | 597 | reserved 4; // removed jtype 598 | } 599 | 600 | message OneofOptions { 601 | // The parser stores options it doesn't recognize here. See above. 602 | repeated UninterpretedOption uninterpreted_option = 999; 603 | 604 | // Clients can define custom options in extensions of this message. See above. 605 | extensions 1000 to max; 606 | } 607 | 608 | message EnumOptions { 609 | 610 | // Set this option to true to allow mapping different tag names to the same 611 | // value. 612 | optional bool allow_alias = 2; 613 | 614 | // Is this enum deprecated? 615 | // Depending on the target platform, this can emit Deprecated annotations 616 | // for the enum, or it will be completely ignored; in the very least, this 617 | // is a formalization for deprecating enums. 618 | optional bool deprecated = 3 [default=false]; 619 | 620 | reserved 5; // javanano_as_lite 621 | 622 | // The parser stores options it doesn't recognize here. See above. 623 | repeated UninterpretedOption uninterpreted_option = 999; 624 | 625 | // Clients can define custom options in extensions of this message. See above. 626 | extensions 1000 to max; 627 | } 628 | 629 | message EnumValueOptions { 630 | // Is this enum value deprecated? 631 | // Depending on the target platform, this can emit Deprecated annotations 632 | // for the enum value, or it will be completely ignored; in the very least, 633 | // this is a formalization for deprecating enum values. 634 | optional bool deprecated = 1 [default=false]; 635 | 636 | // The parser stores options it doesn't recognize here. See above. 637 | repeated UninterpretedOption uninterpreted_option = 999; 638 | 639 | // Clients can define custom options in extensions of this message. See above. 640 | extensions 1000 to max; 641 | } 642 | 643 | message ServiceOptions { 644 | 645 | // Note: Field numbers 1 through 32 are reserved for Google's internal RPC 646 | // framework. We apologize for hoarding these numbers to ourselves, but 647 | // we were already using them long before we decided to release Protocol 648 | // Buffers. 649 | 650 | // Is this service deprecated? 651 | // Depending on the target platform, this can emit Deprecated annotations 652 | // for the service, or it will be completely ignored; in the very least, 653 | // this is a formalization for deprecating services. 654 | optional bool deprecated = 33 [default=false]; 655 | 656 | // The parser stores options it doesn't recognize here. See above. 657 | repeated UninterpretedOption uninterpreted_option = 999; 658 | 659 | // Clients can define custom options in extensions of this message. See above. 660 | extensions 1000 to max; 661 | } 662 | 663 | message MethodOptions { 664 | 665 | // Note: Field numbers 1 through 32 are reserved for Google's internal RPC 666 | // framework. We apologize for hoarding these numbers to ourselves, but 667 | // we were already using them long before we decided to release Protocol 668 | // Buffers. 669 | 670 | // Is this method deprecated? 671 | // Depending on the target platform, this can emit Deprecated annotations 672 | // for the method, or it will be completely ignored; in the very least, 673 | // this is a formalization for deprecating methods. 674 | optional bool deprecated = 33 [default=false]; 675 | 676 | // Is this method side-effect-free (or safe in HTTP parlance), or idempotent, 677 | // or neither? HTTP based RPC implementation may choose GET verb for safe 678 | // methods, and PUT verb for idempotent methods instead of the default POST. 679 | enum IdempotencyLevel { 680 | IDEMPOTENCY_UNKNOWN = 0; 681 | NO_SIDE_EFFECTS = 1; // implies idempotent 682 | IDEMPOTENT = 2; // idempotent, but may have side effects 683 | } 684 | optional IdempotencyLevel idempotency_level = 685 | 34 [default=IDEMPOTENCY_UNKNOWN]; 686 | 687 | // The parser stores options it doesn't recognize here. See above. 688 | repeated UninterpretedOption uninterpreted_option = 999; 689 | 690 | // Clients can define custom options in extensions of this message. See above. 691 | extensions 1000 to max; 692 | } 693 | 694 | 695 | // A message representing a option the parser does not recognize. This only 696 | // appears in options protos created by the compiler::Parser class. 697 | // DescriptorPool resolves these when building Descriptor objects. Therefore, 698 | // options protos in descriptor objects (e.g. returned by Descriptor::options(), 699 | // or produced by Descriptor::CopyTo()) will never have UninterpretedOptions 700 | // in them. 701 | message UninterpretedOption { 702 | // The name of the uninterpreted option. Each string represents a segment in 703 | // a dot-separated name. is_extension is true iff a segment represents an 704 | // extension (denoted with parentheses in options specs in .proto files). 705 | // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents 706 | // "foo.(bar.baz).qux". 707 | message NamePart { 708 | required string name_part = 1; 709 | required bool is_extension = 2; 710 | } 711 | repeated NamePart name = 2; 712 | 713 | // The value of the uninterpreted option, in whatever type the tokenizer 714 | // identified it as during parsing. Exactly one of these should be set. 715 | optional string identifier_value = 3; 716 | optional uint64 positive_int_value = 4; 717 | optional int64 negative_int_value = 5; 718 | optional double double_value = 6; 719 | optional bytes string_value = 7; 720 | optional string aggregate_value = 8; 721 | } 722 | 723 | // =================================================================== 724 | // Optional source code info 725 | 726 | // Encapsulates information about the original source file from which a 727 | // FileDescriptorProto was generated. 728 | message SourceCodeInfo { 729 | // A Location identifies a piece of source code in a .proto file which 730 | // corresponds to a particular definition. This information is intended 731 | // to be useful to IDEs, code indexers, documentation generators, and similar 732 | // tools. 733 | // 734 | // For example, say we have a file like: 735 | // message Foo { 736 | // optional string foo = 1; 737 | // } 738 | // Let's look at just the field definition: 739 | // optional string foo = 1; 740 | // ^ ^^ ^^ ^ ^^^ 741 | // a bc de f ghi 742 | // We have the following locations: 743 | // span path represents 744 | // [a,i) [ 4, 0, 2, 0 ] The whole field definition. 745 | // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). 746 | // [c,d) [ 4, 0, 2, 0, 5 ] The type (string). 747 | // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). 748 | // [g,h) [ 4, 0, 2, 0, 3 ] The number (1). 749 | // 750 | // Notes: 751 | // - A location may refer to a repeated field itself (i.e. not to any 752 | // particular index within it). This is used whenever a set of elements are 753 | // logically enclosed in a single code segment. For example, an entire 754 | // extend block (possibly containing multiple extension definitions) will 755 | // have an outer location whose path refers to the "extensions" repeated 756 | // field without an index. 757 | // - Multiple locations may have the same path. This happens when a single 758 | // logical declaration is spread out across multiple places. The most 759 | // obvious example is the "extend" block again -- there may be multiple 760 | // extend blocks in the same scope, each of which will have the same path. 761 | // - A location's span is not always a subset of its parent's span. For 762 | // example, the "extendee" of an extension declaration appears at the 763 | // beginning of the "extend" block and is shared by all extensions within 764 | // the block. 765 | // - Just because a location's span is a subset of some other location's span 766 | // does not mean that it is a descendent. For example, a "group" defines 767 | // both a type and a field in a single declaration. Thus, the locations 768 | // corresponding to the type and field and their components will overlap. 769 | // - Code which tries to interpret locations should probably be designed to 770 | // ignore those that it doesn't understand, as more types of locations could 771 | // be recorded in the future. 772 | repeated Location location = 1; 773 | message Location { 774 | // Identifies which part of the FileDescriptorProto was defined at this 775 | // location. 776 | // 777 | // Each element is a field number or an index. They form a path from 778 | // the root FileDescriptorProto to the place where the definition. For 779 | // example, this path: 780 | // [ 4, 3, 2, 7, 1 ] 781 | // refers to: 782 | // file.message_type(3) // 4, 3 783 | // .field(7) // 2, 7 784 | // .name() // 1 785 | // This is because FileDescriptorProto.message_type has field number 4: 786 | // repeated DescriptorProto message_type = 4; 787 | // and DescriptorProto.field has field number 2: 788 | // repeated FieldDescriptorProto field = 2; 789 | // and FieldDescriptorProto.name has field number 1: 790 | // optional string name = 1; 791 | // 792 | // Thus, the above path gives the location of a field name. If we removed 793 | // the last element: 794 | // [ 4, 3, 2, 7 ] 795 | // this path refers to the whole field declaration (from the beginning 796 | // of the label to the terminating semicolon). 797 | repeated int32 path = 1 [packed=true]; 798 | 799 | // Always has exactly three or four elements: start line, start column, 800 | // end line (optional, otherwise assumed same as start line), end column. 801 | // These are packed into a single field for efficiency. Note that line 802 | // and column numbers are zero-based -- typically you will want to add 803 | // 1 to each before displaying to a user. 804 | repeated int32 span = 2 [packed=true]; 805 | 806 | // If this SourceCodeInfo represents a complete declaration, these are any 807 | // comments appearing before and after the declaration which appear to be 808 | // attached to the declaration. 809 | // 810 | // A series of line comments appearing on consecutive lines, with no other 811 | // tokens appearing on those lines, will be treated as a single comment. 812 | // 813 | // leading_detached_comments will keep paragraphs of comments that appear 814 | // before (but not connected to) the current element. Each paragraph, 815 | // separated by empty lines, will be one comment element in the repeated 816 | // field. 817 | // 818 | // Only the comment content is provided; comment markers (e.g. //) are 819 | // stripped out. For block comments, leading whitespace and an asterisk 820 | // will be stripped from the beginning of each line other than the first. 821 | // Newlines are included in the output. 822 | // 823 | // Examples: 824 | // 825 | // optional int32 foo = 1; // Comment attached to foo. 826 | // // Comment attached to bar. 827 | // optional int32 bar = 2; 828 | // 829 | // optional string baz = 3; 830 | // // Comment attached to baz. 831 | // // Another line attached to baz. 832 | // 833 | // // Comment attached to qux. 834 | // // 835 | // // Another line attached to qux. 836 | // optional double qux = 4; 837 | // 838 | // // Detached comment for corge. This is not leading or trailing comments 839 | // // to qux or corge because there are blank lines separating it from 840 | // // both. 841 | // 842 | // // Detached comment for corge paragraph 2. 843 | // 844 | // optional string corge = 5; 845 | // /* Block comment attached 846 | // * to corge. Leading asterisks 847 | // * will be removed. */ 848 | // /* Block comment attached to 849 | // * grault. */ 850 | // optional int32 grault = 6; 851 | // 852 | // // ignored detached comments. 853 | optional string leading_comments = 3; 854 | optional string trailing_comments = 4; 855 | repeated string leading_detached_comments = 6; 856 | } 857 | } 858 | 859 | // Describes the relationship between generated code and its original source 860 | // file. A GeneratedCodeInfo message is associated with only one generated 861 | // source file, but may contain references to different source .proto files. 862 | message GeneratedCodeInfo { 863 | // An Annotation connects some span of text in generated code to an element 864 | // of its generating .proto file. 865 | repeated Annotation annotation = 1; 866 | message Annotation { 867 | // Identifies the element in the original source .proto file. This field 868 | // is formatted the same as SourceCodeInfo.Location.path. 869 | repeated int32 path = 1 [packed=true]; 870 | 871 | // Identifies the filesystem path to the original source .proto. 872 | optional string source_file = 2; 873 | 874 | // Identifies the starting offset in bytes in the generated code 875 | // that relates to the identified object. 876 | optional int32 begin = 3; 877 | 878 | // Identifies the ending offset in bytes in the generated code that 879 | // relates to the identified offset. The end offset should be one past 880 | // the last relevant byte (so the length of the text = end - begin). 881 | optional int32 end = 4; 882 | } 883 | } 884 | -------------------------------------------------------------------------------- /protobuf/google/protobuf/duration.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option cc_enable_arenas = true; 37 | option go_package = "github.com/golang/protobuf/ptypes/duration"; 38 | option java_package = "com.google.protobuf"; 39 | option java_outer_classname = "DurationProto"; 40 | option java_multiple_files = true; 41 | option objc_class_prefix = "GPB"; 42 | 43 | // A Duration represents a signed, fixed-length span of time represented 44 | // as a count of seconds and fractions of seconds at nanosecond 45 | // resolution. It is independent of any calendar and concepts like "day" 46 | // or "month". It is related to Timestamp in that the difference between 47 | // two Timestamp values is a Duration and it can be added or subtracted 48 | // from a Timestamp. Range is approximately +-10,000 years. 49 | // 50 | // # Examples 51 | // 52 | // Example 1: Compute Duration from two Timestamps in pseudo code. 53 | // 54 | // Timestamp start = ...; 55 | // Timestamp end = ...; 56 | // Duration duration = ...; 57 | // 58 | // duration.seconds = end.seconds - start.seconds; 59 | // duration.nanos = end.nanos - start.nanos; 60 | // 61 | // if (duration.seconds < 0 && duration.nanos > 0) { 62 | // duration.seconds += 1; 63 | // duration.nanos -= 1000000000; 64 | // } else if (duration.seconds > 0 && duration.nanos < 0) { 65 | // duration.seconds -= 1; 66 | // duration.nanos += 1000000000; 67 | // } 68 | // 69 | // Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. 70 | // 71 | // Timestamp start = ...; 72 | // Duration duration = ...; 73 | // Timestamp end = ...; 74 | // 75 | // end.seconds = start.seconds + duration.seconds; 76 | // end.nanos = start.nanos + duration.nanos; 77 | // 78 | // if (end.nanos < 0) { 79 | // end.seconds -= 1; 80 | // end.nanos += 1000000000; 81 | // } else if (end.nanos >= 1000000000) { 82 | // end.seconds += 1; 83 | // end.nanos -= 1000000000; 84 | // } 85 | // 86 | // Example 3: Compute Duration from datetime.timedelta in Python. 87 | // 88 | // td = datetime.timedelta(days=3, minutes=10) 89 | // duration = Duration() 90 | // duration.FromTimedelta(td) 91 | // 92 | // # JSON Mapping 93 | // 94 | // In JSON format, the Duration type is encoded as a string rather than an 95 | // object, where the string ends in the suffix "s" (indicating seconds) and 96 | // is preceded by the number of seconds, with nanoseconds expressed as 97 | // fractional seconds. For example, 3 seconds with 0 nanoseconds should be 98 | // encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should 99 | // be expressed in JSON format as "3.000000001s", and 3 seconds and 1 100 | // microsecond should be expressed in JSON format as "3.000001s". 101 | // 102 | // 103 | message Duration { 104 | // Signed seconds of the span of time. Must be from -315,576,000,000 105 | // to +315,576,000,000 inclusive. Note: these bounds are computed from: 106 | // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years 107 | int64 seconds = 1; 108 | 109 | // Signed fractions of a second at nanosecond resolution of the span 110 | // of time. Durations less than one second are represented with a 0 111 | // `seconds` field and a positive or negative `nanos` field. For durations 112 | // of one second or more, a non-zero value for the `nanos` field must be 113 | // of the same sign as the `seconds` field. Must be from -999,999,999 114 | // to +999,999,999 inclusive. 115 | int32 nanos = 2; 116 | } -------------------------------------------------------------------------------- /protobuf/google/protobuf/timestamp.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option cc_enable_arenas = true; 37 | option go_package = "github.com/golang/protobuf/ptypes/timestamp"; 38 | option java_package = "com.google.protobuf"; 39 | option java_outer_classname = "TimestampProto"; 40 | option java_multiple_files = true; 41 | option objc_class_prefix = "GPB"; 42 | 43 | // A Timestamp represents a point in time independent of any time zone or local 44 | // calendar, encoded as a count of seconds and fractions of seconds at 45 | // nanosecond resolution. The count is relative to an epoch at UTC midnight on 46 | // January 1, 1970, in the proleptic Gregorian calendar which extends the 47 | // Gregorian calendar backwards to year one. 48 | // 49 | // All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap 50 | // second table is needed for interpretation, using a [24-hour linear 51 | // smear](https://developers.google.com/time/smear). 52 | // 53 | // The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By 54 | // restricting to that range, we ensure that we can convert to and from [RFC 55 | // 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. 56 | // 57 | // # Examples 58 | // 59 | // Example 1: Compute Timestamp from POSIX `time()`. 60 | // 61 | // Timestamp timestamp; 62 | // timestamp.set_seconds(time(NULL)); 63 | // timestamp.set_nanos(0); 64 | // 65 | // Example 2: Compute Timestamp from POSIX `gettimeofday()`. 66 | // 67 | // struct timeval tv; 68 | // gettimeofday(&tv, NULL); 69 | // 70 | // Timestamp timestamp; 71 | // timestamp.set_seconds(tv.tv_sec); 72 | // timestamp.set_nanos(tv.tv_usec * 1000); 73 | // 74 | // Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. 75 | // 76 | // FILETIME ft; 77 | // GetSystemTimeAsFileTime(&ft); 78 | // UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; 79 | // 80 | // // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z 81 | // // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. 82 | // Timestamp timestamp; 83 | // timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); 84 | // timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); 85 | // 86 | // Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. 87 | // 88 | // long millis = System.currentTimeMillis(); 89 | // 90 | // Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) 91 | // .setNanos((int) ((millis % 1000) * 1000000)).build(); 92 | // 93 | // 94 | // Example 5: Compute Timestamp from current time in Python. 95 | // 96 | // timestamp = Timestamp() 97 | // timestamp.GetCurrentTime() 98 | // 99 | // # JSON Mapping 100 | // 101 | // In JSON format, the Timestamp type is encoded as a string in the 102 | // [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the 103 | // format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" 104 | // where {year} is always expressed using four digits while {month}, {day}, 105 | // {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional 106 | // seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), 107 | // are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone 108 | // is required. A proto3 JSON serializer should always use UTC (as indicated by 109 | // "Z") when printing the Timestamp type and a proto3 JSON parser should be 110 | // able to accept both UTC and other timezones (as indicated by an offset). 111 | // 112 | // For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past 113 | // 01:30 UTC on January 15, 2017. 114 | // 115 | // In JavaScript, one can convert a Date object to this format using the 116 | // standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString] 117 | // method. In Python, a standard `datetime.datetime` object can be converted 118 | // to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) 119 | // with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one 120 | // can use the Joda Time's [`ISODateTimeFormat.dateTime()`]( 121 | // http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D 122 | // ) to obtain a formatter capable of generating timestamps in this format. 123 | // 124 | // 125 | message Timestamp { 126 | 127 | // Represents seconds of UTC time since Unix epoch 128 | // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 129 | // 9999-12-31T23:59:59Z inclusive. 130 | int64 seconds = 1; 131 | 132 | // Non-negative fractions of a second at nanosecond resolution. Negative 133 | // second values with fractions must still have non-negative nanos values 134 | // that count forward in time. Must be from 0 to 999,999,999 135 | // inclusive. 136 | int32 nanos = 2; 137 | } 138 | -------------------------------------------------------------------------------- /protobuf/libs/kv/types.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package tendermint.libs.kv; 3 | option go_package = "github.com/tendermint/tendermint/libs/kv"; 4 | 5 | import "third_party/proto/gogoproto/gogo.proto"; 6 | 7 | option (gogoproto.marshaler_all) = true; 8 | option (gogoproto.unmarshaler_all) = true; 9 | option (gogoproto.sizer_all) = true; 10 | option (gogoproto.goproto_registration) = true; 11 | // Generate tests 12 | option (gogoproto.populate_all) = true; 13 | option (gogoproto.equal_all) = true; 14 | option (gogoproto.testgen_all) = true; 15 | 16 | //---------------------------------------- 17 | // Abstract types 18 | 19 | message Pair { 20 | bytes key = 1; 21 | bytes value = 2; 22 | } 23 | -------------------------------------------------------------------------------- /protobuf/third_party/proto/gogoproto/gogo.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copied from https://github.com/gogo/protobuf/blob/master/gogoproto/gogo.proto 4 | // 5 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 6 | // http://github.com/gogo/protobuf 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto2"; 32 | package gogoproto; 33 | 34 | import "google/protobuf/descriptor.proto"; 35 | 36 | option java_package = "com.google.protobuf"; 37 | option java_outer_classname = "GoGoProtos"; 38 | option go_package = "github.com/gogo/protobuf/gogoproto"; 39 | 40 | extend google.protobuf.EnumOptions { 41 | optional bool goproto_enum_prefix = 62001; 42 | optional bool goproto_enum_stringer = 62021; 43 | optional bool enum_stringer = 62022; 44 | optional string enum_customname = 62023; 45 | optional bool enumdecl = 62024; 46 | } 47 | 48 | extend google.protobuf.EnumValueOptions { 49 | optional string enumvalue_customname = 66001; 50 | } 51 | 52 | extend google.protobuf.FileOptions { 53 | optional bool goproto_getters_all = 63001; 54 | optional bool goproto_enum_prefix_all = 63002; 55 | optional bool goproto_stringer_all = 63003; 56 | optional bool verbose_equal_all = 63004; 57 | optional bool face_all = 63005; 58 | optional bool gostring_all = 63006; 59 | optional bool populate_all = 63007; 60 | optional bool stringer_all = 63008; 61 | optional bool onlyone_all = 63009; 62 | 63 | optional bool equal_all = 63013; 64 | optional bool description_all = 63014; 65 | optional bool testgen_all = 63015; 66 | optional bool benchgen_all = 63016; 67 | optional bool marshaler_all = 63017; 68 | optional bool unmarshaler_all = 63018; 69 | optional bool stable_marshaler_all = 63019; 70 | 71 | optional bool sizer_all = 63020; 72 | 73 | optional bool goproto_enum_stringer_all = 63021; 74 | optional bool enum_stringer_all = 63022; 75 | 76 | optional bool unsafe_marshaler_all = 63023; 77 | optional bool unsafe_unmarshaler_all = 63024; 78 | 79 | optional bool goproto_extensions_map_all = 63025; 80 | optional bool goproto_unrecognized_all = 63026; 81 | optional bool gogoproto_import = 63027; 82 | optional bool protosizer_all = 63028; 83 | optional bool compare_all = 63029; 84 | optional bool typedecl_all = 63030; 85 | optional bool enumdecl_all = 63031; 86 | 87 | optional bool goproto_registration = 63032; 88 | optional bool messagename_all = 63033; 89 | 90 | optional bool goproto_sizecache_all = 63034; 91 | optional bool goproto_unkeyed_all = 63035; 92 | } 93 | 94 | extend google.protobuf.MessageOptions { 95 | optional bool goproto_getters = 64001; 96 | optional bool goproto_stringer = 64003; 97 | optional bool verbose_equal = 64004; 98 | optional bool face = 64005; 99 | optional bool gostring = 64006; 100 | optional bool populate = 64007; 101 | optional bool stringer = 67008; 102 | optional bool onlyone = 64009; 103 | 104 | optional bool equal = 64013; 105 | optional bool description = 64014; 106 | optional bool testgen = 64015; 107 | optional bool benchgen = 64016; 108 | optional bool marshaler = 64017; 109 | optional bool unmarshaler = 64018; 110 | optional bool stable_marshaler = 64019; 111 | 112 | optional bool sizer = 64020; 113 | 114 | optional bool unsafe_marshaler = 64023; 115 | optional bool unsafe_unmarshaler = 64024; 116 | 117 | optional bool goproto_extensions_map = 64025; 118 | optional bool goproto_unrecognized = 64026; 119 | 120 | optional bool protosizer = 64028; 121 | optional bool compare = 64029; 122 | 123 | optional bool typedecl = 64030; 124 | 125 | optional bool messagename = 64033; 126 | 127 | optional bool goproto_sizecache = 64034; 128 | optional bool goproto_unkeyed = 64035; 129 | } 130 | 131 | extend google.protobuf.FieldOptions { 132 | optional bool nullable = 65001; 133 | optional bool embed = 65002; 134 | optional string customtype = 65003; 135 | optional string customname = 65004; 136 | optional string jsontag = 65005; 137 | optional string moretags = 65006; 138 | optional string casttype = 65007; 139 | optional string castkey = 65008; 140 | optional string castvalue = 65009; 141 | 142 | optional bool stdtime = 65010; 143 | optional bool stdduration = 65011; 144 | optional bool wktpointer = 65012; 145 | 146 | optional string castrepeated = 65013; 147 | } -------------------------------------------------------------------------------- /src/codec.rs: -------------------------------------------------------------------------------- 1 | use bytes::{buf::BufMutExt, BufMut, BytesMut}; 2 | use integer_encoding::VarInt; 3 | use protobuf::{Message, ProtobufError}; 4 | use tokio_util::codec::{Decoder, Encoder}; 5 | 6 | use crate::messages::abci::*; 7 | 8 | #[derive(Debug)] 9 | pub struct ABCICodec; 10 | 11 | impl ABCICodec { 12 | pub fn new() -> ABCICodec { 13 | ABCICodec 14 | } 15 | } 16 | 17 | impl Decoder for ABCICodec { 18 | type Item = Request; 19 | type Error = ProtobufError; 20 | 21 | fn decode(&mut self, buf: &mut BytesMut) -> Result, ProtobufError> { 22 | let length = buf.len(); 23 | if length == 0 { 24 | return Ok(None); 25 | } 26 | let varint: (i64, usize) = i64::decode_var(&buf[..]); 27 | if varint.0 as usize + varint.1 > length { 28 | return Ok(None); 29 | } 30 | let request = protobuf::parse_from_bytes(&buf[varint.1..(varint.0 as usize + varint.1)])?; 31 | let _ = buf.split_to(varint.0 as usize + varint.1); 32 | Ok(Some(request)) 33 | } 34 | } 35 | 36 | impl Encoder for ABCICodec { 37 | type Error = ProtobufError; 38 | 39 | fn encode(&mut self, msg: Response, buf: &mut BytesMut) -> Result<(), ProtobufError> { 40 | let msg_len = msg.compute_size(); 41 | let varint = i64::encode_var_vec(i64::from(msg_len)); 42 | 43 | let remaining = buf.remaining_mut(); 44 | let needed = msg_len as usize + varint.len(); 45 | if remaining < needed { 46 | buf.reserve(needed); 47 | } 48 | 49 | buf.put(varint.as_ref()); 50 | msg.write_to_writer(&mut buf.writer())?; 51 | trace!("Encode response! {:?}", &buf[..]); 52 | Ok(()) 53 | } 54 | } 55 | 56 | #[cfg(test)] 57 | mod tests { 58 | use super::*; 59 | use std::error::Error; 60 | 61 | fn setup_echo_request_buf() -> Result> { 62 | let mut buf = BytesMut::new(); 63 | 64 | let mut r = Request::new(); 65 | let mut echo = RequestEcho::new(); 66 | echo.set_message(String::from("Helloworld")); 67 | r.set_echo(echo); 68 | 69 | let msg_len = r.compute_size(); 70 | let varint = i64::encode_var_vec(msg_len as i64); 71 | buf.put(varint.as_ref()); 72 | r.write_to_writer(&mut (&mut buf).writer())?; 73 | 74 | trace!("Encode response! {:?}", &buf[..]); 75 | 76 | Ok(buf) 77 | } 78 | 79 | fn setup_echo_large_request_buf() -> Result> { 80 | let mut buf = BytesMut::new(); 81 | 82 | let mut r = Request::new(); 83 | let mut echo = RequestEcho::new(); 84 | let st = (0..2 * 4096).map(|_| "X").collect::(); 85 | echo.set_message(st); 86 | r.set_echo(echo); 87 | 88 | let msg_len = r.compute_size(); 89 | let varint = i64::encode_var_vec(msg_len as i64); 90 | 91 | let remaining = buf.remaining_mut(); 92 | let needed = msg_len as usize + varint.len(); 93 | if remaining < needed { 94 | buf.reserve(needed); 95 | } 96 | 97 | buf.put(varint.as_ref()); 98 | r.write_to_writer(&mut (&mut buf).writer())?; 99 | 100 | trace!("Encode response! {:?}", &buf[..]); 101 | 102 | Ok(buf) 103 | } 104 | 105 | #[test] 106 | fn should_decode() { 107 | let mut codec = ABCICodec::new(); 108 | let mut buf = setup_echo_request_buf().unwrap(); 109 | let r = codec.decode(&mut buf); 110 | assert!(r.is_ok()); 111 | let v1 = r.ok(); 112 | assert!(v1.is_some()); 113 | let v2 = v1.unwrap(); 114 | assert!(v2.is_some()); 115 | let v3 = v2.unwrap(); 116 | assert!(v3.has_echo()); 117 | assert_eq!(v3.get_echo().get_message(), "Helloworld"); 118 | } 119 | 120 | #[test] 121 | fn should_decode_large_request() { 122 | let mut codec = ABCICodec::new(); 123 | let mut buf = setup_echo_large_request_buf().unwrap(); 124 | let r = codec.decode(&mut buf); 125 | assert!(r.is_ok()); 126 | let v1 = r.ok(); 127 | assert!(v1.is_some()); 128 | let v2 = v1.unwrap(); 129 | assert!(v2.is_some()); 130 | let v3 = v2.unwrap(); 131 | assert!(v3.has_echo()); 132 | } 133 | 134 | #[test] 135 | fn should_encode() { 136 | let mut codec = ABCICodec::new(); 137 | 138 | let mut r = Response::new(); 139 | let mut echo = ResponseEcho::new(); 140 | echo.set_message(String::from("Helloworld")); 141 | r.set_echo(echo); 142 | 143 | let buf = &mut BytesMut::new(); 144 | 145 | let v = codec.encode(r, buf); 146 | assert!(v.is_ok()); 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # Tendermint ABCI library for Rust 2 | //! 3 | //! This library provides an application Trait and TCP server for implementing Tendemint ABCI 4 | //! application in Rust. The Application Trait provides default implementations for each callback 5 | //! to simplify development. 6 | //! 7 | //! ## Example 8 | //! 9 | //! Here's a simple example that communicates with Tendermint. Defaults callbacks are handled by 10 | //! the Trait. The app doesn't do any actual processing on a transaction. 11 | //! 12 | //! ```rust,no_run 13 | //! struct EmptyApp; 14 | //! 15 | //! impl abci::Application for EmptyApp {} 16 | //! 17 | //! fn run_empty_app() { 18 | //! abci::run_local(EmptyApp); 19 | //! } 20 | //!``` 21 | //! 22 | extern crate byteorder; 23 | extern crate bytes; 24 | extern crate env_logger; 25 | extern crate futures; 26 | extern crate integer_encoding; 27 | #[macro_use] 28 | extern crate log; 29 | extern crate core; 30 | extern crate protobuf; 31 | extern crate tokio; 32 | 33 | use std::net::SocketAddr; 34 | 35 | pub use crate::messages::abci::*; 36 | pub use crate::messages::merkle::*; 37 | pub use crate::messages::types::*; 38 | use crate::server::serve; 39 | 40 | mod codec; 41 | mod messages; 42 | mod server; 43 | 44 | /// Main Trait for an ABCI application. Provides generic responses for all callbacks 45 | /// Override desired callbacks as needed. Tendermint makes 3 TCP connections to the 46 | /// application and does so in a synchonized manner. 47 | pub trait Application { 48 | /// Query Connection: Called on startup from Tendermint. The application should normally 49 | /// return the last know state so Tendermint can determine if it needs to replay blocks 50 | /// to the application. 51 | fn info(&mut self, _req: &RequestInfo) -> ResponseInfo { 52 | ResponseInfo::new() 53 | } 54 | 55 | /// Query Connection: Set options on the application (rarely used) 56 | fn set_option(&mut self, _req: &RequestSetOption) -> ResponseSetOption { 57 | ResponseSetOption::new() 58 | } 59 | 60 | /// Query Connection: Query your application. This usually resolves through a merkle tree holding 61 | /// the state of the app. 62 | fn query(&mut self, _req: &RequestQuery) -> ResponseQuery { 63 | ResponseQuery::new() 64 | } 65 | 66 | /// Mempool Connection: Used to validate incoming transactions. If the application reponds 67 | /// with a non-zero value, the transaction is added to Tendermint's mempool for processing 68 | /// on the deliver_tx call below. 69 | fn check_tx(&mut self, _req: &RequestCheckTx) -> ResponseCheckTx { 70 | ResponseCheckTx::new() 71 | } 72 | 73 | /// Consensus Connection: Called once on startup. Usually used to establish initial (genesis) 74 | /// state. 75 | fn init_chain(&mut self, _req: &RequestInitChain) -> ResponseInitChain { 76 | ResponseInitChain::new() 77 | } 78 | 79 | /// Consensus Connection: Called at the start of processing a block of transactions 80 | /// The flow is: 81 | /// begin_block() 82 | /// deliver_tx() for each transaction in the block 83 | /// end_block() 84 | /// commit() 85 | fn begin_block(&mut self, _req: &RequestBeginBlock) -> ResponseBeginBlock { 86 | ResponseBeginBlock::new() 87 | } 88 | 89 | /// Consensus Connection: Actually processing the transaction, performing some form of a 90 | /// state transistion. 91 | fn deliver_tx(&mut self, _p: &RequestDeliverTx) -> ResponseDeliverTx { 92 | ResponseDeliverTx::new() 93 | } 94 | 95 | /// Consensus Connection: Called at the end of the block. Often used to update the validator set. 96 | fn end_block(&mut self, _req: &RequestEndBlock) -> ResponseEndBlock { 97 | ResponseEndBlock::new() 98 | } 99 | 100 | /// Consensus Connection: Commit the block with the latest state from the application. 101 | fn commit(&mut self, _req: &RequestCommit) -> ResponseCommit { 102 | ResponseCommit::new() 103 | } 104 | } 105 | 106 | /// Setup the app and start the server using localhost and default tendermint port 26658 107 | pub fn run_local(app: A) 108 | where 109 | A: Application + 'static + Send + Sync, 110 | { 111 | let addr = "127.0.0.1:26658".parse().unwrap(); 112 | run(addr, app); 113 | } 114 | 115 | /// Setup the application and start the server. Use this fn when setting different ip:port. 116 | pub fn run(listen_addr: SocketAddr, app: A) 117 | where 118 | A: Application + 'static + Send + Sync, 119 | { 120 | serve(app, listen_addr).unwrap(); 121 | } 122 | -------------------------------------------------------------------------------- /src/messages/merkle.rs: -------------------------------------------------------------------------------- 1 | // This file is generated by rust-protobuf 2.16.2. Do not edit 2 | // @generated 3 | 4 | // https://github.com/rust-lang/rust-clippy/issues/702 5 | #![allow(unknown_lints)] 6 | #![allow(clippy::all)] 7 | 8 | #![allow(unused_attributes)] 9 | #![rustfmt::skip] 10 | 11 | #![allow(box_pointers)] 12 | #![allow(dead_code)] 13 | #![allow(missing_docs)] 14 | #![allow(non_camel_case_types)] 15 | #![allow(non_snake_case)] 16 | #![allow(non_upper_case_globals)] 17 | #![allow(trivial_casts)] 18 | #![allow(unused_imports)] 19 | #![allow(unused_results)] 20 | //! Generated file from `crypto/merkle/merkle.proto` 21 | 22 | /// Generated files are compatible only with the same version 23 | /// of protobuf runtime. 24 | // const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_16_2; 25 | 26 | #[derive(PartialEq, Clone, Default)] 27 | pub struct ProofOp { 28 | // message fields 29 | pub field_type: ::std::string::String, 30 | pub key: ::std::vec::Vec, 31 | pub data: ::std::vec::Vec, 32 | // special fields 33 | pub unknown_fields: ::protobuf::UnknownFields, 34 | pub cached_size: ::protobuf::CachedSize, 35 | } 36 | 37 | impl<'a> ::std::default::Default for &'a ProofOp { 38 | fn default() -> &'a ProofOp { 39 | ::default_instance() 40 | } 41 | } 42 | 43 | impl ProofOp { 44 | pub fn new() -> ProofOp { 45 | ::std::default::Default::default() 46 | } 47 | 48 | // string type = 1; 49 | 50 | pub fn get_field_type(&self) -> &str { 51 | &self.field_type 52 | } 53 | pub fn clear_field_type(&mut self) { 54 | self.field_type.clear(); 55 | } 56 | 57 | // Param is passed by value, moved 58 | pub fn set_field_type(&mut self, v: ::std::string::String) { 59 | self.field_type = v; 60 | } 61 | 62 | // Mutable pointer to the field. 63 | // If field is not initialized, it is initialized with default value first. 64 | pub fn mut_field_type(&mut self) -> &mut ::std::string::String { 65 | &mut self.field_type 66 | } 67 | 68 | // Take field 69 | pub fn take_field_type(&mut self) -> ::std::string::String { 70 | ::std::mem::replace(&mut self.field_type, ::std::string::String::new()) 71 | } 72 | 73 | // bytes key = 2; 74 | 75 | pub fn get_key(&self) -> &[u8] { 76 | &self.key 77 | } 78 | pub fn clear_key(&mut self) { 79 | self.key.clear(); 80 | } 81 | 82 | // Param is passed by value, moved 83 | pub fn set_key(&mut self, v: ::std::vec::Vec) { 84 | self.key = v; 85 | } 86 | 87 | // Mutable pointer to the field. 88 | // If field is not initialized, it is initialized with default value first. 89 | pub fn mut_key(&mut self) -> &mut ::std::vec::Vec { 90 | &mut self.key 91 | } 92 | 93 | // Take field 94 | pub fn take_key(&mut self) -> ::std::vec::Vec { 95 | ::std::mem::replace(&mut self.key, ::std::vec::Vec::new()) 96 | } 97 | 98 | // bytes data = 3; 99 | 100 | pub fn get_data(&self) -> &[u8] { 101 | &self.data 102 | } 103 | pub fn clear_data(&mut self) { 104 | self.data.clear(); 105 | } 106 | 107 | // Param is passed by value, moved 108 | pub fn set_data(&mut self, v: ::std::vec::Vec) { 109 | self.data = v; 110 | } 111 | 112 | // Mutable pointer to the field. 113 | // If field is not initialized, it is initialized with default value first. 114 | pub fn mut_data(&mut self) -> &mut ::std::vec::Vec { 115 | &mut self.data 116 | } 117 | 118 | // Take field 119 | pub fn take_data(&mut self) -> ::std::vec::Vec { 120 | ::std::mem::replace(&mut self.data, ::std::vec::Vec::new()) 121 | } 122 | } 123 | 124 | impl ::protobuf::Message for ProofOp { 125 | fn is_initialized(&self) -> bool { 126 | true 127 | } 128 | 129 | fn merge_from( 130 | &mut self, 131 | is: &mut ::protobuf::CodedInputStream<'_>, 132 | ) -> ::protobuf::ProtobufResult<()> { 133 | while !is.eof()? { 134 | let (field_number, wire_type) = is.read_tag_unpack()?; 135 | match field_number { 136 | 1 => { 137 | ::protobuf::rt::read_singular_proto3_string_into( 138 | wire_type, 139 | is, 140 | &mut self.field_type, 141 | )?; 142 | } 143 | 2 => { 144 | ::protobuf::rt::read_singular_proto3_bytes_into(wire_type, is, &mut self.key)?; 145 | } 146 | 3 => { 147 | ::protobuf::rt::read_singular_proto3_bytes_into(wire_type, is, &mut self.data)?; 148 | } 149 | _ => { 150 | ::protobuf::rt::read_unknown_or_skip_group( 151 | field_number, 152 | wire_type, 153 | is, 154 | self.mut_unknown_fields(), 155 | )?; 156 | } 157 | }; 158 | } 159 | ::std::result::Result::Ok(()) 160 | } 161 | 162 | // Compute sizes of nested messages 163 | #[allow(unused_variables)] 164 | fn compute_size(&self) -> u32 { 165 | let mut my_size = 0; 166 | if !self.field_type.is_empty() { 167 | my_size += ::protobuf::rt::string_size(1, &self.field_type); 168 | } 169 | if !self.key.is_empty() { 170 | my_size += ::protobuf::rt::bytes_size(2, &self.key); 171 | } 172 | if !self.data.is_empty() { 173 | my_size += ::protobuf::rt::bytes_size(3, &self.data); 174 | } 175 | my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); 176 | self.cached_size.set(my_size); 177 | my_size 178 | } 179 | 180 | fn write_to_with_cached_sizes( 181 | &self, 182 | os: &mut ::protobuf::CodedOutputStream<'_>, 183 | ) -> ::protobuf::ProtobufResult<()> { 184 | if !self.field_type.is_empty() { 185 | os.write_string(1, &self.field_type)?; 186 | } 187 | if !self.key.is_empty() { 188 | os.write_bytes(2, &self.key)?; 189 | } 190 | if !self.data.is_empty() { 191 | os.write_bytes(3, &self.data)?; 192 | } 193 | os.write_unknown_fields(self.get_unknown_fields())?; 194 | ::std::result::Result::Ok(()) 195 | } 196 | 197 | fn get_cached_size(&self) -> u32 { 198 | self.cached_size.get() 199 | } 200 | 201 | fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { 202 | &self.unknown_fields 203 | } 204 | 205 | fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { 206 | &mut self.unknown_fields 207 | } 208 | 209 | fn as_any(&self) -> &dyn (::std::any::Any) { 210 | self as &dyn (::std::any::Any) 211 | } 212 | fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { 213 | self as &mut dyn (::std::any::Any) 214 | } 215 | fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { 216 | self 217 | } 218 | 219 | fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { 220 | Self::descriptor_static() 221 | } 222 | 223 | fn new() -> ProofOp { 224 | ProofOp::new() 225 | } 226 | 227 | fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { 228 | static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = 229 | ::protobuf::rt::LazyV2::INIT; 230 | descriptor.get(|| { 231 | let mut fields = ::std::vec::Vec::new(); 232 | fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::< 233 | _, 234 | ::protobuf::types::ProtobufTypeString, 235 | >( 236 | "type", 237 | |m: &ProofOp| &m.field_type, 238 | |m: &mut ProofOp| &mut m.field_type, 239 | )); 240 | fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::< 241 | _, 242 | ::protobuf::types::ProtobufTypeBytes, 243 | >( 244 | "key", |m: &ProofOp| &m.key, |m: &mut ProofOp| &mut m.key 245 | )); 246 | fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::< 247 | _, 248 | ::protobuf::types::ProtobufTypeBytes, 249 | >( 250 | "data", 251 | |m: &ProofOp| &m.data, 252 | |m: &mut ProofOp| &mut m.data, 253 | )); 254 | ::protobuf::reflect::MessageDescriptor::new_pb_name::( 255 | "ProofOp", 256 | fields, 257 | file_descriptor_proto(), 258 | ) 259 | }) 260 | } 261 | 262 | fn default_instance() -> &'static ProofOp { 263 | static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; 264 | instance.get(ProofOp::new) 265 | } 266 | } 267 | 268 | impl ::protobuf::Clear for ProofOp { 269 | fn clear(&mut self) { 270 | self.field_type.clear(); 271 | self.key.clear(); 272 | self.data.clear(); 273 | self.unknown_fields.clear(); 274 | } 275 | } 276 | 277 | impl ::std::fmt::Debug for ProofOp { 278 | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 279 | ::protobuf::text_format::fmt(self, f) 280 | } 281 | } 282 | 283 | impl ::protobuf::reflect::ProtobufValue for ProofOp { 284 | fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { 285 | ::protobuf::reflect::ReflectValueRef::Message(self) 286 | } 287 | } 288 | 289 | #[derive(PartialEq, Clone, Default)] 290 | pub struct Proof { 291 | // message fields 292 | pub ops: ::protobuf::RepeatedField, 293 | // special fields 294 | pub unknown_fields: ::protobuf::UnknownFields, 295 | pub cached_size: ::protobuf::CachedSize, 296 | } 297 | 298 | impl<'a> ::std::default::Default for &'a Proof { 299 | fn default() -> &'a Proof { 300 | ::default_instance() 301 | } 302 | } 303 | 304 | impl Proof { 305 | pub fn new() -> Proof { 306 | ::std::default::Default::default() 307 | } 308 | 309 | // repeated .tendermint.crypto.merkle.ProofOp ops = 1; 310 | 311 | pub fn get_ops(&self) -> &[ProofOp] { 312 | &self.ops 313 | } 314 | pub fn clear_ops(&mut self) { 315 | self.ops.clear(); 316 | } 317 | 318 | // Param is passed by value, moved 319 | pub fn set_ops(&mut self, v: ::protobuf::RepeatedField) { 320 | self.ops = v; 321 | } 322 | 323 | // Mutable pointer to the field. 324 | pub fn mut_ops(&mut self) -> &mut ::protobuf::RepeatedField { 325 | &mut self.ops 326 | } 327 | 328 | // Take field 329 | pub fn take_ops(&mut self) -> ::protobuf::RepeatedField { 330 | ::std::mem::replace(&mut self.ops, ::protobuf::RepeatedField::new()) 331 | } 332 | } 333 | 334 | impl ::protobuf::Message for Proof { 335 | fn is_initialized(&self) -> bool { 336 | for v in &self.ops { 337 | if !v.is_initialized() { 338 | return false; 339 | } 340 | } 341 | true 342 | } 343 | 344 | fn merge_from( 345 | &mut self, 346 | is: &mut ::protobuf::CodedInputStream<'_>, 347 | ) -> ::protobuf::ProtobufResult<()> { 348 | while !is.eof()? { 349 | let (field_number, wire_type) = is.read_tag_unpack()?; 350 | match field_number { 351 | 1 => { 352 | ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.ops)?; 353 | } 354 | _ => { 355 | ::protobuf::rt::read_unknown_or_skip_group( 356 | field_number, 357 | wire_type, 358 | is, 359 | self.mut_unknown_fields(), 360 | )?; 361 | } 362 | }; 363 | } 364 | ::std::result::Result::Ok(()) 365 | } 366 | 367 | // Compute sizes of nested messages 368 | #[allow(unused_variables)] 369 | fn compute_size(&self) -> u32 { 370 | let mut my_size = 0; 371 | for value in &self.ops { 372 | let len = value.compute_size(); 373 | my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; 374 | } 375 | my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); 376 | self.cached_size.set(my_size); 377 | my_size 378 | } 379 | 380 | fn write_to_with_cached_sizes( 381 | &self, 382 | os: &mut ::protobuf::CodedOutputStream<'_>, 383 | ) -> ::protobuf::ProtobufResult<()> { 384 | for v in &self.ops { 385 | os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; 386 | os.write_raw_varint32(v.get_cached_size())?; 387 | v.write_to_with_cached_sizes(os)?; 388 | } 389 | os.write_unknown_fields(self.get_unknown_fields())?; 390 | ::std::result::Result::Ok(()) 391 | } 392 | 393 | fn get_cached_size(&self) -> u32 { 394 | self.cached_size.get() 395 | } 396 | 397 | fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { 398 | &self.unknown_fields 399 | } 400 | 401 | fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { 402 | &mut self.unknown_fields 403 | } 404 | 405 | fn as_any(&self) -> &dyn (::std::any::Any) { 406 | self as &dyn (::std::any::Any) 407 | } 408 | fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { 409 | self as &mut dyn (::std::any::Any) 410 | } 411 | fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { 412 | self 413 | } 414 | 415 | fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { 416 | Self::descriptor_static() 417 | } 418 | 419 | fn new() -> Proof { 420 | Proof::new() 421 | } 422 | 423 | fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { 424 | static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = 425 | ::protobuf::rt::LazyV2::INIT; 426 | descriptor.get(|| { 427 | let mut fields = ::std::vec::Vec::new(); 428 | fields.push( 429 | ::protobuf::reflect::accessor::make_repeated_field_accessor::< 430 | _, 431 | ::protobuf::types::ProtobufTypeMessage, 432 | >("ops", |m: &Proof| &m.ops, |m: &mut Proof| &mut m.ops), 433 | ); 434 | ::protobuf::reflect::MessageDescriptor::new_pb_name::( 435 | "Proof", 436 | fields, 437 | file_descriptor_proto(), 438 | ) 439 | }) 440 | } 441 | 442 | fn default_instance() -> &'static Proof { 443 | static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; 444 | instance.get(Proof::new) 445 | } 446 | } 447 | 448 | impl ::protobuf::Clear for Proof { 449 | fn clear(&mut self) { 450 | self.ops.clear(); 451 | self.unknown_fields.clear(); 452 | } 453 | } 454 | 455 | impl ::std::fmt::Debug for Proof { 456 | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 457 | ::protobuf::text_format::fmt(self, f) 458 | } 459 | } 460 | 461 | impl ::protobuf::reflect::ProtobufValue for Proof { 462 | fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { 463 | ::protobuf::reflect::ReflectValueRef::Message(self) 464 | } 465 | } 466 | 467 | static file_descriptor_proto_data: &'static [u8] = b"\ 468 | \n\x1acrypto/merkle/merkle.proto\x12\x18tendermint.crypto.merkle\":\n\ 469 | \x07ProofOp\x12\x0e\n\x04type\x18\x01\x20\x01(\tB\0\x12\r\n\x03key\x18\ 470 | \x02\x20\x01(\x0cB\0\x12\x0e\n\x04data\x18\x03\x20\x01(\x0cB\0:\0\"?\n\ 471 | \x05Proof\x124\n\x03ops\x18\x01\x20\x03(\x0b2!.tendermint.crypto.merkle.\ 472 | ProofOpB\x04\xc8\xde\x1f\0:\0B\x14\xc8\xe2\x1e\x01\xe0\xe2\x1e\x01\xf8\ 473 | \xe1\x1e\x01\xa8\xe2\x1e\x01\xd0\xe2\x1e\x01b\x06proto3\ 474 | "; 475 | 476 | static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2< 477 | ::protobuf::descriptor::FileDescriptorProto, 478 | > = ::protobuf::rt::LazyV2::INIT; 479 | 480 | fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { 481 | ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() 482 | } 483 | 484 | pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { 485 | file_descriptor_proto_lazy.get(|| parse_descriptor_proto()) 486 | } 487 | -------------------------------------------------------------------------------- /src/messages/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod abci; // Core types 2 | pub mod merkle; 3 | pub mod types; // Common (KV Pairs) 4 | -------------------------------------------------------------------------------- /src/messages/types.rs: -------------------------------------------------------------------------------- 1 | // This file is generated by rust-protobuf 2.16.2. Do not edit 2 | // @generated 3 | 4 | // https://github.com/rust-lang/rust-clippy/issues/702 5 | #![allow(unknown_lints)] 6 | #![allow(clippy::all)] 7 | 8 | #![allow(unused_attributes)] 9 | #![rustfmt::skip] 10 | 11 | #![allow(box_pointers)] 12 | #![allow(dead_code)] 13 | #![allow(missing_docs)] 14 | #![allow(non_camel_case_types)] 15 | #![allow(non_snake_case)] 16 | #![allow(non_upper_case_globals)] 17 | #![allow(trivial_casts)] 18 | #![allow(unused_imports)] 19 | #![allow(unused_results)] 20 | //! Generated file from `libs/kv/types.proto` 21 | 22 | /// Generated files are compatible only with the same version 23 | /// of protobuf runtime. 24 | // const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_16_2; 25 | 26 | #[derive(PartialEq, Clone, Default)] 27 | pub struct Pair { 28 | // message fields 29 | pub key: ::std::vec::Vec, 30 | pub value: ::std::vec::Vec, 31 | // special fields 32 | pub unknown_fields: ::protobuf::UnknownFields, 33 | pub cached_size: ::protobuf::CachedSize, 34 | } 35 | 36 | impl<'a> ::std::default::Default for &'a Pair { 37 | fn default() -> &'a Pair { 38 | ::default_instance() 39 | } 40 | } 41 | 42 | impl Pair { 43 | pub fn new() -> Pair { 44 | ::std::default::Default::default() 45 | } 46 | 47 | // bytes key = 1; 48 | 49 | pub fn get_key(&self) -> &[u8] { 50 | &self.key 51 | } 52 | pub fn clear_key(&mut self) { 53 | self.key.clear(); 54 | } 55 | 56 | // Param is passed by value, moved 57 | pub fn set_key(&mut self, v: ::std::vec::Vec) { 58 | self.key = v; 59 | } 60 | 61 | // Mutable pointer to the field. 62 | // If field is not initialized, it is initialized with default value first. 63 | pub fn mut_key(&mut self) -> &mut ::std::vec::Vec { 64 | &mut self.key 65 | } 66 | 67 | // Take field 68 | pub fn take_key(&mut self) -> ::std::vec::Vec { 69 | ::std::mem::replace(&mut self.key, ::std::vec::Vec::new()) 70 | } 71 | 72 | // bytes value = 2; 73 | 74 | pub fn get_value(&self) -> &[u8] { 75 | &self.value 76 | } 77 | pub fn clear_value(&mut self) { 78 | self.value.clear(); 79 | } 80 | 81 | // Param is passed by value, moved 82 | pub fn set_value(&mut self, v: ::std::vec::Vec) { 83 | self.value = v; 84 | } 85 | 86 | // Mutable pointer to the field. 87 | // If field is not initialized, it is initialized with default value first. 88 | pub fn mut_value(&mut self) -> &mut ::std::vec::Vec { 89 | &mut self.value 90 | } 91 | 92 | // Take field 93 | pub fn take_value(&mut self) -> ::std::vec::Vec { 94 | ::std::mem::replace(&mut self.value, ::std::vec::Vec::new()) 95 | } 96 | } 97 | 98 | impl ::protobuf::Message for Pair { 99 | fn is_initialized(&self) -> bool { 100 | true 101 | } 102 | 103 | fn merge_from( 104 | &mut self, 105 | is: &mut ::protobuf::CodedInputStream<'_>, 106 | ) -> ::protobuf::ProtobufResult<()> { 107 | while !is.eof()? { 108 | let (field_number, wire_type) = is.read_tag_unpack()?; 109 | match field_number { 110 | 1 => { 111 | ::protobuf::rt::read_singular_proto3_bytes_into(wire_type, is, &mut self.key)?; 112 | } 113 | 2 => { 114 | ::protobuf::rt::read_singular_proto3_bytes_into( 115 | wire_type, 116 | is, 117 | &mut self.value, 118 | )?; 119 | } 120 | _ => { 121 | ::protobuf::rt::read_unknown_or_skip_group( 122 | field_number, 123 | wire_type, 124 | is, 125 | self.mut_unknown_fields(), 126 | )?; 127 | } 128 | }; 129 | } 130 | ::std::result::Result::Ok(()) 131 | } 132 | 133 | // Compute sizes of nested messages 134 | #[allow(unused_variables)] 135 | fn compute_size(&self) -> u32 { 136 | let mut my_size = 0; 137 | if !self.key.is_empty() { 138 | my_size += ::protobuf::rt::bytes_size(1, &self.key); 139 | } 140 | if !self.value.is_empty() { 141 | my_size += ::protobuf::rt::bytes_size(2, &self.value); 142 | } 143 | my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); 144 | self.cached_size.set(my_size); 145 | my_size 146 | } 147 | 148 | fn write_to_with_cached_sizes( 149 | &self, 150 | os: &mut ::protobuf::CodedOutputStream<'_>, 151 | ) -> ::protobuf::ProtobufResult<()> { 152 | if !self.key.is_empty() { 153 | os.write_bytes(1, &self.key)?; 154 | } 155 | if !self.value.is_empty() { 156 | os.write_bytes(2, &self.value)?; 157 | } 158 | os.write_unknown_fields(self.get_unknown_fields())?; 159 | ::std::result::Result::Ok(()) 160 | } 161 | 162 | fn get_cached_size(&self) -> u32 { 163 | self.cached_size.get() 164 | } 165 | 166 | fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { 167 | &self.unknown_fields 168 | } 169 | 170 | fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { 171 | &mut self.unknown_fields 172 | } 173 | 174 | fn as_any(&self) -> &dyn (::std::any::Any) { 175 | self as &dyn (::std::any::Any) 176 | } 177 | fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { 178 | self as &mut dyn (::std::any::Any) 179 | } 180 | fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { 181 | self 182 | } 183 | 184 | fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { 185 | Self::descriptor_static() 186 | } 187 | 188 | fn new() -> Pair { 189 | Pair::new() 190 | } 191 | 192 | fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { 193 | static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = 194 | ::protobuf::rt::LazyV2::INIT; 195 | descriptor.get(|| { 196 | let mut fields = ::std::vec::Vec::new(); 197 | fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::< 198 | _, 199 | ::protobuf::types::ProtobufTypeBytes, 200 | >( 201 | "key", |m: &Pair| &m.key, |m: &mut Pair| &mut m.key 202 | )); 203 | fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::< 204 | _, 205 | ::protobuf::types::ProtobufTypeBytes, 206 | >( 207 | "value", |m: &Pair| &m.value, |m: &mut Pair| &mut m.value 208 | )); 209 | ::protobuf::reflect::MessageDescriptor::new_pb_name::( 210 | "Pair", 211 | fields, 212 | file_descriptor_proto(), 213 | ) 214 | }) 215 | } 216 | 217 | fn default_instance() -> &'static Pair { 218 | static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; 219 | instance.get(Pair::new) 220 | } 221 | } 222 | 223 | impl ::protobuf::Clear for Pair { 224 | fn clear(&mut self) { 225 | self.key.clear(); 226 | self.value.clear(); 227 | self.unknown_fields.clear(); 228 | } 229 | } 230 | 231 | impl ::std::fmt::Debug for Pair { 232 | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 233 | ::protobuf::text_format::fmt(self, f) 234 | } 235 | } 236 | 237 | impl ::protobuf::reflect::ProtobufValue for Pair { 238 | fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { 239 | ::protobuf::reflect::ReflectValueRef::Message(self) 240 | } 241 | } 242 | 243 | static file_descriptor_proto_data: &'static [u8] = b"\ 244 | \n\x13libs/kv/types.proto\x12\x12tendermint.libs.kv\"(\n\x04Pair\x12\r\n\ 245 | \x03key\x18\x01\x20\x01(\x0cB\0\x12\x0f\n\x05value\x18\x02\x20\x01(\x0cB\ 246 | \0:\0B\x1c\xd0\xe2\x1e\x01\xc8\xe2\x1e\x01\xc0\xe3\x1e\x01\xa8\xe2\x1e\ 247 | \x01\xb8\xe2\x1e\x01\xf8\xe1\x1e\x01\xe0\xe2\x1e\x01b\x06proto3\ 248 | "; 249 | 250 | static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2< 251 | ::protobuf::descriptor::FileDescriptorProto, 252 | > = ::protobuf::rt::LazyV2::INIT; 253 | 254 | fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { 255 | ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() 256 | } 257 | 258 | pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { 259 | file_descriptor_proto_lazy.get(|| parse_descriptor_proto()) 260 | } 261 | -------------------------------------------------------------------------------- /src/server.rs: -------------------------------------------------------------------------------- 1 | use std::net::SocketAddr; 2 | use std::ops::DerefMut; 3 | use std::sync::Arc; 4 | 5 | use env_logger::Env; 6 | use futures::sink::SinkExt; 7 | use futures::stream::StreamExt; 8 | use tokio::net::TcpListener; 9 | use tokio::runtime; 10 | use tokio::sync::Mutex; 11 | use tokio_util::codec::Decoder; 12 | 13 | use crate::codec::ABCICodec; 14 | use crate::messages::abci::*; 15 | use crate::Application; 16 | 17 | async fn serve_async(app: A, addr: SocketAddr) 18 | where 19 | A: Application + 'static + Send + Sync, 20 | { 21 | let app = Arc::new(Mutex::new(app)); 22 | let mut listener = TcpListener::bind(&addr).await.unwrap(); 23 | while let Some(Ok(socket)) = listener.next().await { 24 | let app_instance = app.clone(); 25 | tokio::spawn(async move { 26 | info!("Got connection! {:?}", socket); 27 | let framed = ABCICodec::new().framed(socket); 28 | let (mut writer, mut reader) = framed.split(); 29 | let mut mrequest = reader.next().await; 30 | while let Some(Ok(ref request)) = mrequest { 31 | debug!("Got Request! {:?}", request); 32 | let response = respond(&app_instance, request).await; 33 | debug!("Return Response! {:?}", response); 34 | writer.send(response).await.expect("sending back response"); 35 | mrequest = reader.next().await; 36 | } 37 | match mrequest { 38 | None => { 39 | panic!("connection dropped"); 40 | } 41 | Some(Err(e)) => { 42 | panic!("decoding error: {:?}", e); 43 | } 44 | _ => { 45 | unreachable!(); 46 | } 47 | } 48 | }); 49 | } 50 | } 51 | 52 | /// Creates the TCP server and listens for connections from Tendermint 53 | pub fn serve(app: A, addr: SocketAddr) -> std::io::Result<()> 54 | where 55 | A: Application + 'static + Send + Sync, 56 | { 57 | env_logger::from_env(Env::default().default_filter_or("info")) 58 | .try_init() 59 | .ok(); 60 | 61 | let mut rt = runtime::Builder::new() 62 | .basic_scheduler() 63 | .enable_io() 64 | .build() 65 | .unwrap(); 66 | let default_hook = std::panic::take_hook(); 67 | std::panic::set_hook(Box::new(move |info| { 68 | default_hook(info); 69 | std::process::exit(1); 70 | })); 71 | rt.block_on(serve_async(app, addr)); 72 | Ok(()) 73 | } 74 | 75 | async fn respond(app: &Arc>, request: &Request) -> Response 76 | where 77 | A: Application + 'static + Send + Sync, 78 | { 79 | let mut guard = app.lock().await; 80 | let app = guard.deref_mut(); 81 | 82 | let mut response = Response::new(); 83 | 84 | match request.value { 85 | // Info 86 | Some(Request_oneof_value::info(ref r)) => response.set_info(app.info(r)), 87 | // Init chain 88 | Some(Request_oneof_value::init_chain(ref r)) => response.set_init_chain(app.init_chain(r)), 89 | // Set option 90 | Some(Request_oneof_value::set_option(ref r)) => response.set_set_option(app.set_option(r)), 91 | // Query 92 | Some(Request_oneof_value::query(ref r)) => response.set_query(app.query(r)), 93 | // Check tx 94 | Some(Request_oneof_value::check_tx(ref r)) => response.set_check_tx(app.check_tx(r)), 95 | // Begin block 96 | Some(Request_oneof_value::begin_block(ref r)) => { 97 | response.set_begin_block(app.begin_block(r)) 98 | } 99 | // Deliver Tx 100 | Some(Request_oneof_value::deliver_tx(ref r)) => response.set_deliver_tx(app.deliver_tx(r)), 101 | // End block 102 | Some(Request_oneof_value::end_block(ref r)) => response.set_end_block(app.end_block(r)), 103 | // Commit 104 | Some(Request_oneof_value::commit(ref r)) => response.set_commit(app.commit(r)), 105 | // Flush 106 | Some(Request_oneof_value::flush(_)) => response.set_flush(ResponseFlush::new()), 107 | // Echo 108 | Some(Request_oneof_value::echo(ref r)) => { 109 | let echo_msg = r.get_message().to_string(); 110 | let mut echo = ResponseEcho::new(); 111 | echo.set_message(echo_msg); 112 | response.set_echo(echo); 113 | } 114 | _ => { 115 | let mut re = ResponseException::new(); 116 | re.set_error(String::from("Unrecognized request")); 117 | response.set_exception(re) 118 | } 119 | } 120 | response 121 | } 122 | -------------------------------------------------------------------------------- /version.txt: -------------------------------------------------------------------------------- 1 | Version = TMCoreSemVer 2 | // TMCoreSemVer is the current version of Tendermint Core. 3 | TMCoreSemVer = "0.33.6" 4 | // ABCISemVer is the semantic version of the ABCI library 5 | ABCISemVer = "0.16.2" 6 | ABCIVersion = ABCISemVer 7 | --------------------------------------------------------------------------------