├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.md │ ├── feature-request.md │ ├── technical-debt.md │ └── update-dependencies.md ├── pull_request_template.md └── workflows │ └── doc.yaml ├── .gitignore ├── AUTHORS ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── cartesi-machine-checkin.proto ├── cartesi-machine.proto ├── ipfs.proto ├── logger.proto ├── machine-manager.proto ├── p2p.proto ├── server-manager.proto ├── state-fold-server.proto ├── stateserver.proto └── versioning.proto /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Template for reporting bugs 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | | WARNING: Please, read carefully before submitting an issue | 11 | |------------------------------------------------------------| 12 | 13 | Do not use issues to seek technical support. 14 | If you need support read the [documentation](https://docs.cartesi.io/) first. 15 | If you still have unanswered questions or need further discussion, join the [Cartesi Discord server](https://discord.gg/cartesi) and use the `#cartesi-machine` channel. 16 | 17 | Before submitting a new issue, please make sure that: 18 | - You are sure the issue manifests itself on the latest release (i.e., in the main branch); 19 | - You have verified that a similar issue has not already been reported; 20 | - You have verified, with your best effort, that your code or use case is not itself at fault. 21 | 22 | ## Context 23 | 24 | What is the bug that you are experiencing? 25 | Why is this bug relevant? 26 | 27 | (Please try to be clear and concise.) 28 | 29 | ## Expected behavior 30 | 31 | What was expected? 32 | 33 | ## Actual behavior 34 | 35 | What happened instead? 36 | 37 | ## Steps to reproduce 38 | 39 | Please describe a minimal set of steps to reproduce the bug. 40 | Try to keep it as simple as possible, focusing exclusively on the bug. 41 | Your description should include the artifacts used and their versions. 42 | Provide the exact commands needed to reproduce the bug, if possible in the form of a script that can be run on other machines. 43 | 44 | ## Environment 45 | 46 | Please describe the environment where the bug happens. 47 | 48 | Include the following (when applicable and/or relevant): 49 | - Emulator version; 50 | - Host operating system (e.g. Ubuntu 22.04, MacOS 13, Cartesi Playground v0.6.0); 51 | - Host architecture (e.g. x86\_64, arm64); 52 | - Docker version (e.g. Docker Desktop 4.19.0); 53 | - Compiler version (e.g. GCC 12.3, Clang 15.0.7). 54 | 55 | ## Possible solutions 56 | 57 | *This section is optional.* 58 | 59 | Is there any workaround for the issue? (This may help others experiencing the same issue.) 60 | 61 | Can you offer any hint on how to solve the issue? 62 | What parts of the code will be affected? 63 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Template for requesting new features 4 | title: '' 5 | labels: feature 6 | assignees: '' 7 | 8 | --- 9 | 10 | | WARNING: Please, read carefully before submitting an issue | 11 | |------------------------------------------------------------| 12 | 13 | Do not use issues to seek technical support. 14 | If you need support read the [documentation](https://docs.cartesi.io/) first. 15 | If you still have unanswered questions or need further discussion, join the [Cartesi Discord server](https://discord.gg/cartesi) and use the `#cartesi-machine` channel. 16 | 17 | Before submitting a new issue, please make sure that: 18 | - You are sure the issue manifests itself on the latest release (i.e., in the main branch); 19 | - You have verified that a similar issue has not already been reported; 20 | - You have verified, with your best effort, that your code or use case is not itself at fault. 21 | 22 | ## Context 23 | 24 | What problem are you trying to solve? 25 | Why is this feature relevant? 26 | 27 | (Please try to be clear and concise.) 28 | 29 | ## Possible solutions 30 | 31 | *This section is optional.* 32 | 33 | What are the possible solutions? 34 | If there are multiple alternatives, what are the benefits and drawbacks of each one? 35 | 36 | ## Subtasks 37 | 38 | *This section is optional.* 39 | 40 | - [ ] If there is a solution, what are the subtasks for completing this issue? 41 | 42 | ## Definition of Done 43 | 44 | *This section is optional.* 45 | 46 | - [ ] If there is a solution, what are the final deliverables? 47 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/technical-debt.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Technical Debt 3 | about: Template for proposing solutions to technical debts 4 | title: '' 5 | labels: refactor 6 | assignees: '' 7 | 8 | --- 9 | 10 | | WARNING: Please, read carefully before submitting an issue | 11 | |------------------------------------------------------------| 12 | 13 | ## Context 14 | 15 | What problem are you trying to solve? 16 | Why is this problem relevant? 17 | How does this problem affect the feature roadmap? 18 | Is it a blocker to implement a new future? 19 | What parts of the architecture and code are affected? 20 | 21 | ## Possible solutions 22 | 23 | What are the possible solutions? 24 | If there are multiple alternatives, what are the benefits and drawbacks of each one? 25 | 26 | ## Subtasks 27 | 28 | *This section is optional.* 29 | 30 | - [ ] What are the subtasks for completing this issue? 31 | 32 | ## Definition of Done 33 | 34 | *This section is optional.* 35 | 36 | - [ ] What are the final deliverables? 37 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/update-dependencies.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Update Dependencies 3 | about: Template for updating dependencies 4 | title: '' 5 | labels: chore 6 | assignees: '' 7 | 8 | --- 9 | 10 | | WARNING: Please, read carefully before submitting an issue | 11 | |------------------------------------------------------------| 12 | 13 | ## Context 14 | 15 | Does the dependency have a bug fix? 16 | Does it provide additional features or optimizations? 17 | 18 | ## Subtasks 19 | 20 | - [ ] Verify that the new version is available on all supported platforms. 21 | - [ ] Update build scripts and Dockerfiles 22 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | | WARNING: Please, read carefully before submitting a pull request | 2 | |------------------------------------------------------------------| 3 | 4 | Although this software is open source and we welcome contributions, 5 | we believe these contributions should be preceded by an open discussion. 6 | Open discussions tend to result in better solutions to any given problem, 7 | and help maintain and improve the quality of the software. 8 | If you would like to see a bug fixed or a new feature implemented, 9 | please open an issue for the discussion rather than directly opening 10 | a pull request. 11 | 12 | If you would like to contribute please read [CONTRIBUTING.md](../blob/main/CONTRIBUTING.md). 13 | 14 | When you finally create a pull request, please follow these guidelines: 15 | 16 | - Make sure the description clearly describes the problem, its solution, and references the associated issue; 17 | - Do not create large pull requests (involving many different changes) because these are difficult to review. Instead, break large changes into smaller ones and create independent pull requests for each one; 18 | - Use different pull requests for different issues. Each pull request should address a single issue; 19 | - When fixing a bug or adding a new feature, make sure to add tests that cover your changes. This will ensure the changes will continue to work in the future; 20 | - Verify that changes do not break the tests; 21 | - Follow the same coding style rules as the rest of the code base; 22 | - Pull requests for stylistic changes (or even simple typos or grammatical errors) may be rejected. Pull requests should always address worthy issues. 23 | -------------------------------------------------------------------------------- /.github/workflows/doc.yaml: -------------------------------------------------------------------------------- 1 | name: Documentation 2 | on: 3 | push: 4 | branches: 5 | - master 6 | tags: 7 | - v* 8 | jobs: 9 | build: 10 | runs-on: ubuntu-18.04 11 | steps: 12 | - uses: actions/checkout@v2 13 | 14 | # run protoc-gen-doc 15 | - name: Generate Documentation 16 | run: make doc 17 | 18 | # save artifact for publishing 19 | - name: Save Artifact 20 | uses: actions/upload-artifact@v1 21 | with: 22 | name: doc 23 | path: doc/ 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /doc -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Alex Mikhalevich 2 | Augusto Teixeira 3 | Carlo Fragni 4 | Carsten Munk 5 | Colin Steil 6 | Danilo Tuler 7 | Diego Nehab 8 | Eduardo Barthel 9 | Erick de Moura 10 | Felipe Argento 11 | Gabriel Coutinho 12 | Gabriel de Quadros Ligneul 13 | Marcos Pernambuco Motta 14 | Stephen Chen 15 | Victor Fusco 16 | Victor Yves 17 | Yelyzaveta Dymchenko 18 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | ## [Unreleased] 8 | 9 | ## [0.16.0] - 2024-02-07 10 | ### Added 11 | - Added interpreter break reason in run response 12 | 13 | ## [0.15.0] - 2023-12-06 14 | ### Added 15 | - Added memory range introspection on cartesi-machine 16 | - Added init and entrypoint fields to machine DTB on cartesi-machine 17 | 18 | ### Changed 19 | - Replaced proof with sibling_hashes on cartesi-machine 20 | - Refactored uarch reset on cartesi-machine 21 | - Removed DumpPmas on cartesi-machine 22 | - Renamed ROM to DTB on cartesi-machine 23 | 24 | ## [0.14.0] - 2023-08-02 25 | ### Added 26 | - Added new reject reason for larger payloads on the server-manager 27 | 28 | ### Changed 29 | - Updated license/copyright notice in all source code 30 | 31 | ### Fixed 32 | - Fixed typos on the server-manager documentation 33 | 34 | ## [0.13.0] - 2023-07-13 35 | ### Changed 36 | - Renamed fields in output validity proof in server-manager interface 37 | - Adjusted server manager documentation 38 | 39 | ### Fixed 40 | - Fixed build of machine-manager with uarch 41 | 42 | ## [0.12.0] - 2023-04-28 43 | ### Changed 44 | - Changed processed input count in finish epoch request 45 | 46 | ## [0.11.0] - 2023-04-18 47 | ### Added 48 | - Added new proof structure to finish epoch 49 | - Added DeleteEpoch method to server manager 50 | - Added SessionReplaceMemoryRange method on machine-manager 51 | - Added ResetUarchState on Cartesi Machine 52 | - Added GetUarchXAddress on Cartesi Machine 53 | - Added Uarch halt flag on Cartesi Machine 54 | 55 | ### Changed 56 | - Replaced epoch input index with global input index 57 | - Moved hashes from get epoch status to finish epoch 58 | - Renamed voucher.address to voucher.destination 59 | - Renamed machine Step to StepUarch on Cartesi Machine 60 | - Renamed machine UarchRun to RunUarch on Cartesi Machine 61 | - Removed Uarch ROM on Cartesi Machine 62 | 63 | ### Removed 64 | - Removed keccak fields from vouchers and notices 65 | 66 | ## [0.10.0] - 2023-02-16 67 | ### Changed 68 | - Removed brkflag CSR 69 | - Replaced minstret by icycleinstret CSR 70 | 71 | ## [0.9.0] - 2022-11-17 72 | ### Added 73 | - Added microarchitecture configs 74 | - Added TLB configs 75 | - Added read/write virtual memory methods 76 | - Added new CSRs related to the RISC-V specification 77 | 78 | ### Changed 79 | - Removed DHD device 80 | 81 | ## [Previous Versions] 82 | - [0.8.0] 83 | - [0.7.0] 84 | - [0.6.0] 85 | - [0.5.0] 86 | - [0.4.0] 87 | - [0.3.0] 88 | - [0.2.0] 89 | - [0.1.3] 90 | - [0.1.2] 91 | - [0.1.1] 92 | 93 | [Unreleased]: https://github.com/cartesi/grpc-interfaces/compare/v0.16.0...HEAD 94 | [0.16.0]: https://github.com/cartesi/grpc-interfaces/releases/tag/v0.16.0 95 | [0.15.0]: https://github.com/cartesi/grpc-interfaces/releases/tag/v0.15.0 96 | [0.14.0]: https://github.com/cartesi/grpc-interfaces/releases/tag/v0.14.0 97 | [0.13.0]: https://github.com/cartesi/grpc-interfaces/releases/tag/v0.13.0 98 | [0.12.0]: https://github.com/cartesi/grpc-interfaces/releases/tag/v0.12.0 99 | [0.11.0]: https://github.com/cartesi/grpc-interfaces/releases/tag/v0.11.0 100 | [0.10.0]: https://github.com/cartesi/grpc-interfaces/releases/tag/v0.10.0 101 | [0.9.0]: https://github.com/cartesi/grpc-interfaces/releases/tag/v0.9.0 102 | [0.8.0]: https://github.com/cartesi/grpc-interfaces/releases/tag/v0.8.0 103 | [0.7.0]: https://github.com/cartesi/grpc-interfaces/releases/tag/v0.7.0 104 | [0.6.0]: https://github.com/cartesi/grpc-interfaces/releases/tag/v0.6.0 105 | [0.5.0]: https://github.com/cartesi/grpc-interfaces/releases/tag/v0.5.0 106 | [0.4.0]: https://github.com/cartesi/grpc-interfaces/releases/tag/v0.4.0 107 | [0.3.0]: https://github.com/cartesi/grpc-interfaces/releases/tag/v0.3.0 108 | [0.2.0]: https://github.com/cartesi/grpc-interfaces/releases/tag/v0.2.0 109 | [0.1.3]: https://github.com/cartesi/grpc-interfaces/releases/tag/v0.1.3 110 | [0.1.2]: https://github.com/cartesi/grpc-interfaces/releases/tag/v0.1.2 111 | [0.1.1]: https://github.com/cartesi/grpc-interfaces/releases/tag/v0.1.1 112 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at info@cartesi.io. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Cartesi 2 | 3 | Thank you for your interest in Cartesi! We highly appreciate even the smallest of fixes or additions to our project. 4 | 5 | Make sure to review our [Contributing License Agreement](https://forms.gle/k3E9ZNkZY6Vy3mkK9), 6 | sign and send it to info@cartesi.io with the title of "CLA Signed" before taking part in the project. We are happy to automate 7 | this for you via DocuSign upon request in the Google Form as well. 8 | 9 | ## Basic Contributing Guidelines 10 | 11 | We use the same guidelines for contributing code to any of our repositories, any developers wanting to contribute to Cartesi must create pull requests. This process is described in the [GitHub documentation](https://help.github.com/en/articles/creating-a-pull-request). Each pull request should be started against the master branch in the respective Cartesi repository. After a pull request is submitted the Cartesi team will review the submission and give feedback via the comments section of the pull request. After the submission is reviewed and approved, it will be merged into the master branch of the source. 12 | 13 | Please note the below! We appreciate everyone following the guidelines. 14 | 15 | * No --force pushes or modifying the Git history in any way; 16 | * Use non-master branches, using a short meaningful description, with words separated by dash (e.g. 'fix-this-bug'); 17 | * All modifications must be made in a pull-request to solicit feedback from other contributors. 18 | 19 | ## Get in Touch 20 | 21 | When contributing in a deeper manner to this repository, please first discuss the change you wish to make via our 22 | [Discord channel here](https://discord.gg/Pt2NrnS), or contact us at info@cartesi.io email before working on the change. 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Build settings 2 | DOCDIR := $(abspath doc) 3 | 4 | all: doc 5 | 6 | clean: 7 | rm -rf $(DOCDIR) 8 | 9 | doc: 10 | docker run --rm -v `pwd`/doc:/out -v `pwd`:/protos pseudomuto/protoc-gen-doc 11 | 12 | .PHONY: all doc clean 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cartesi gRPC Interfaces 2 | 3 | The Cartesi gRPC Interfaces repository contains all gRPC and Protobuf definitions used in the gRPC interfaces of the Cartesi Project modules. Currently these comprehend: 4 | 5 | - [cartesi-machine.proto](cartesi-machine.proto): contains the services exported by the cartesi machine that are consumed by the machine manager and also the definition of the lowest level messages used in multiple interfaces 6 | - [machine-manager.proto](machine-manager.proto): services and higher level message types used to interact with the machine manager sessions 7 | - [rollup-machine-manager.proto](rollup-machine-manager.proto): services and higher level message types used to interact with the rollup machine manager sessions 8 | - [logger.proto](logger.proto): services and higher level message types used to interact with the logger-managed files 9 | 10 | ## Getting Started 11 | 12 | This repository is not intended for standalone usage. Every repository that makes use of a gRPC interface, either serving or consuming a certain API, includes this repository as submodule and builds the language specific auto-generated code that implements the desired services and messages. Specifics on those can be checked in the individual repositories that include this as a submodule. 13 | 14 | ## Contributing 15 | 16 | Thank you for your interest in Cartesi! Head over to our [Contributing Guidelines](CONTRIBUTING.md) for instructions on how to sign our Contributors Agreement and get started with Cartesi! 17 | 18 | Please note we have a [Code of Conduct](CODE_OF_CONDUCT.md), please follow it in all your interactions with the project. 19 | 20 | ## Authors 21 | 22 | * *Diego Nehab* 23 | * *Carlo Fragni* 24 | * *Augusto Teixeira* 25 | 26 | ## License 27 | 28 | The grpc-interfaces repository and all contributions are licensed under [APACHE 2.0](https://www.apache.org/licenses/LICENSE-2.0). Please review our [LICENSE](LICENSE) file. 29 | 30 | ## Acknowledgments 31 | 32 | - Original work 33 | -------------------------------------------------------------------------------- /cartesi-machine-checkin.proto: -------------------------------------------------------------------------------- 1 | // Copyright Cartesi and individual authors (see AUTHORS) 2 | // SPDX-License-Identifier: Apache-2.0 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | syntax = "proto3"; 18 | 19 | import "cartesi-machine.proto"; 20 | 21 | package CartesiMachine; 22 | 23 | service MachineCheckIn { 24 | rpc CheckIn (CheckInRequest) returns (CartesiMachine.Void) {} 25 | } 26 | 27 | message CheckInRequest { 28 | string session_id = 1; 29 | string address = 2; 30 | } 31 | -------------------------------------------------------------------------------- /cartesi-machine.proto: -------------------------------------------------------------------------------- 1 | // Copyright Cartesi and individual authors (see AUTHORS) 2 | // SPDX-License-Identifier: Apache-2.0 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | syntax = "proto3"; 18 | 19 | import "versioning.proto"; 20 | 21 | package CartesiMachine; 22 | 23 | //Service definiton section 24 | 25 | service Machine { 26 | rpc GetVersion(Void) returns (Versioning.GetVersionResponse) {} 27 | rpc SetCheckInTarget(SetCheckInTargetRequest) returns (Void) {} 28 | rpc Machine(MachineRequest) returns (Void) {} 29 | rpc Run(RunRequest) returns (RunResponse) {} 30 | rpc RunUarch(RunUarchRequest) returns (RunUarchResponse) {} 31 | rpc ResetUarch(Void) returns (Void) {} 32 | rpc LogUarchReset(LogUarchResetRequest) returns (LogUarchResetResponse) {} 33 | rpc Store(StoreRequest) returns (Void) {} 34 | rpc Destroy(Void) returns (Void) {} 35 | rpc Snapshot(Void) returns (Void) {} 36 | rpc Rollback(Void) returns (Void) {} 37 | rpc Shutdown(Void) returns (Void) {} 38 | rpc LogUarchStep(LogUarchStepRequest) returns (LogUarchStepResponse) {} 39 | rpc ReadMemory(ReadMemoryRequest) returns (ReadMemoryResponse) {} 40 | rpc WriteMemory(WriteMemoryRequest) returns (Void) {} 41 | rpc ReadVirtualMemory(ReadMemoryRequest) returns (ReadMemoryResponse) {} 42 | rpc WriteVirtualMemory(WriteMemoryRequest) returns (Void) {} 43 | rpc ReadWord(ReadWordRequest) returns (ReadWordResponse) {} 44 | rpc GetRootHash(Void) returns (GetRootHashResponse) {} 45 | rpc GetProof(GetProofRequest) returns (GetProofResponse) {} 46 | rpc ReplaceMemoryRange (ReplaceMemoryRangeRequest) returns (Void) {} 47 | rpc GetXAddress(GetXAddressRequest) returns (GetXAddressResponse) {} 48 | rpc GetUarchXAddress(GetUarchXAddressRequest) returns (GetUarchXAddressResponse) {} 49 | rpc ReadX(ReadXRequest) returns (ReadXResponse) {} 50 | rpc WriteX(WriteXRequest) returns (Void) {} 51 | rpc GetFAddress(GetFAddressRequest) returns (GetFAddressResponse) {} 52 | rpc ReadF(ReadFRequest) returns (ReadFResponse) {} 53 | rpc WriteF(WriteFRequest) returns (Void) {} 54 | rpc ReadUarchX(ReadUarchXRequest) returns (ReadUarchXResponse) {} 55 | rpc WriteUarchX(WriteUarchXRequest) returns (Void) {} 56 | rpc ResetIflagsY(Void) returns (Void) {} 57 | rpc GetCsrAddress(GetCsrAddressRequest) returns (GetCsrAddressResponse) {} 58 | rpc ReadCsr(ReadCsrRequest) returns (ReadCsrResponse) {} 59 | rpc WriteCsr(WriteCsrRequest) returns (Void) {} 60 | rpc GetInitialConfig(Void) returns (GetInitialConfigResponse) {} 61 | rpc VerifyMerkleTree(Void) returns (VerifyMerkleTreeResponse) {} 62 | rpc VerifyDirtyPageMaps(Void) returns (VerifyDirtyPageMapsResponse) {} 63 | rpc GetDefaultConfig(Void) returns (GetDefaultConfigResponse) {} 64 | rpc GetMemoryRanges(Void) returns (GetMemoryRangesResponse) {} 65 | rpc VerifyUarchStepLog(VerifyUarchStepLogRequest) returns (Void) {} 66 | rpc VerifyUarchStepStateTransition(VerifyUarchStepStateTransitionRequest) returns (Void) {} 67 | rpc VerifyUarchResetLog(VerifyUarchResetLogRequest) returns (Void) {} 68 | rpc VerifyUarchResetStateTransition(VerifyUarchResetStateTransitionRequest) returns (Void) {} 69 | } 70 | 71 | //Messages definition section 72 | 73 | message Void { } 74 | 75 | message SetCheckInTargetRequest { 76 | string session_id = 1; 77 | string address = 2; 78 | } 79 | 80 | message Hash { 81 | bytes data = 1; 82 | } 83 | 84 | message ProcessorConfig { 85 | optional uint64 x1 = 1; 86 | optional uint64 x2 = 2; 87 | optional uint64 x3 = 3; 88 | optional uint64 x4 = 4; 89 | optional uint64 x5 = 5; 90 | optional uint64 x6 = 6; 91 | optional uint64 x7 = 7; 92 | optional uint64 x8 = 8; 93 | optional uint64 x9 = 9; 94 | optional uint64 x10 = 10; 95 | optional uint64 x11 = 11; 96 | optional uint64 x12 = 12; 97 | optional uint64 x13 = 13; 98 | optional uint64 x14 = 14; 99 | optional uint64 x15 = 15; 100 | optional uint64 x16 = 16; 101 | optional uint64 x17 = 17; 102 | optional uint64 x18 = 18; 103 | optional uint64 x19 = 19; 104 | optional uint64 x20 = 20; 105 | optional uint64 x21 = 21; 106 | optional uint64 x22 = 22; 107 | optional uint64 x23 = 23; 108 | optional uint64 x24 = 24; 109 | optional uint64 x25 = 25; 110 | optional uint64 x26 = 26; 111 | optional uint64 x27 = 27; 112 | optional uint64 x28 = 28; 113 | optional uint64 x29 = 29; 114 | optional uint64 x30 = 30; 115 | optional uint64 x31 = 31; 116 | optional uint64 f0 = 32; 117 | optional uint64 f1 = 33; 118 | optional uint64 f2 = 34; 119 | optional uint64 f3 = 35; 120 | optional uint64 f4 = 36; 121 | optional uint64 f5 = 37; 122 | optional uint64 f6 = 38; 123 | optional uint64 f7 = 39; 124 | optional uint64 f8 = 40; 125 | optional uint64 f9 = 41; 126 | optional uint64 f10 = 42; 127 | optional uint64 f11 = 43; 128 | optional uint64 f12 = 44; 129 | optional uint64 f13 = 45; 130 | optional uint64 f14 = 46; 131 | optional uint64 f15 = 47; 132 | optional uint64 f16 = 48; 133 | optional uint64 f17 = 49; 134 | optional uint64 f18 = 50; 135 | optional uint64 f19 = 51; 136 | optional uint64 f20 = 52; 137 | optional uint64 f21 = 53; 138 | optional uint64 f22 = 54; 139 | optional uint64 f23 = 55; 140 | optional uint64 f24 = 56; 141 | optional uint64 f25 = 57; 142 | optional uint64 f26 = 58; 143 | optional uint64 f27 = 59; 144 | optional uint64 f28 = 60; 145 | optional uint64 f29 = 61; 146 | optional uint64 f30 = 62; 147 | optional uint64 f31 = 63; 148 | optional uint64 pc = 64; 149 | optional uint64 fcsr = 65; 150 | optional uint64 mvendorid = 66; 151 | optional uint64 marchid = 67; 152 | optional uint64 mimpid = 68; 153 | optional uint64 mcycle = 69; 154 | optional uint64 icycleinstret = 70; 155 | optional uint64 mstatus = 71; 156 | optional uint64 mtvec = 72; 157 | optional uint64 mscratch = 73; 158 | optional uint64 mepc = 74; 159 | optional uint64 mcause = 75; 160 | optional uint64 mtval = 76; 161 | optional uint64 misa = 77; 162 | optional uint64 mie = 78; 163 | optional uint64 mip = 79; 164 | optional uint64 medeleg = 80; 165 | optional uint64 mideleg = 81; 166 | optional uint64 mcounteren = 82; 167 | optional uint64 menvcfg = 83; 168 | optional uint64 stvec = 84; 169 | optional uint64 sscratch = 85; 170 | optional uint64 sepc = 86; 171 | optional uint64 scause = 87; 172 | optional uint64 stval = 88; 173 | optional uint64 satp = 89; 174 | optional uint64 scounteren = 90; 175 | optional uint64 senvcfg = 91; 176 | optional uint64 ilrsc = 92; 177 | optional uint64 iflags = 93; 178 | } 179 | 180 | message DTBConfig { 181 | string bootargs = 1; 182 | string image_filename = 2; 183 | string init = 3; 184 | string entrypoint = 4; 185 | } 186 | 187 | message RAMConfig { 188 | uint64 length = 1; 189 | string image_filename = 2; 190 | } 191 | 192 | message MemoryRangeConfig { 193 | uint64 start = 1; 194 | uint64 length = 2; 195 | string image_filename = 3; 196 | bool shared = 4; 197 | } 198 | 199 | message TLBConfig { 200 | string image_filename = 1; 201 | } 202 | 203 | message CLINTConfig { 204 | optional uint64 mtimecmp = 1; 205 | } 206 | 207 | message HTIFConfig { 208 | optional uint64 fromhost = 1; 209 | optional uint64 tohost = 2; 210 | bool console_getchar = 3; 211 | bool yield_manual = 4; 212 | bool yield_automatic = 5; 213 | } 214 | 215 | message RollupConfig { 216 | MemoryRangeConfig rx_buffer = 1; 217 | MemoryRangeConfig tx_buffer = 2; 218 | MemoryRangeConfig input_metadata = 3; 219 | MemoryRangeConfig voucher_hashes = 4; 220 | MemoryRangeConfig notice_hashes = 5; 221 | } 222 | 223 | message UarchRAMConfig { 224 | string image_filename = 1; 225 | } 226 | 227 | message UarchProcessorConfig { 228 | optional uint64 x1 = 1; 229 | optional uint64 x2 = 2; 230 | optional uint64 x3 = 3; 231 | optional uint64 x4 = 4; 232 | optional uint64 x5 = 5; 233 | optional uint64 x6 = 6; 234 | optional uint64 x7 = 7; 235 | optional uint64 x8 = 8; 236 | optional uint64 x9 = 9; 237 | optional uint64 x10 = 10; 238 | optional uint64 x11 = 11; 239 | optional uint64 x12 = 12; 240 | optional uint64 x13 = 13; 241 | optional uint64 x14 = 14; 242 | optional uint64 x15 = 15; 243 | optional uint64 x16 = 16; 244 | optional uint64 x17 = 17; 245 | optional uint64 x18 = 18; 246 | optional uint64 x19 = 19; 247 | optional uint64 x20 = 20; 248 | optional uint64 x21 = 21; 249 | optional uint64 x22 = 22; 250 | optional uint64 x23 = 23; 251 | optional uint64 x24 = 24; 252 | optional uint64 x25 = 25; 253 | optional uint64 x26 = 26; 254 | optional uint64 x27 = 27; 255 | optional uint64 x28 = 28; 256 | optional uint64 x29 = 29; 257 | optional uint64 x30 = 30; 258 | optional uint64 x31 = 31; 259 | optional uint64 halt_flag = 32; 260 | optional uint64 pc = 33; 261 | optional uint64 cycle = 34; 262 | } 263 | 264 | message UarchConfig { 265 | UarchProcessorConfig processor = 1; 266 | UarchRAMConfig ram = 2; 267 | } 268 | 269 | message MachineConfig { 270 | ProcessorConfig processor = 1; 271 | DTBConfig dtb = 2; 272 | RAMConfig ram = 3; 273 | repeated MemoryRangeConfig flash_drive = 4; 274 | CLINTConfig clint = 5; 275 | HTIFConfig htif = 6; 276 | RollupConfig rollup = 7; 277 | UarchConfig uarch = 8; 278 | TLBConfig tlb = 9; 279 | } 280 | 281 | message ConcurrencyConfig { 282 | uint64 update_merkle_tree = 1; 283 | } 284 | 285 | message MachineRuntimeConfig { 286 | ConcurrencyConfig concurrency = 1; 287 | } 288 | 289 | message MerkleTreeProof { 290 | uint64 target_address = 1; 291 | uint64 log2_target_size = 2; 292 | Hash target_hash = 3; 293 | uint64 log2_root_size = 4; 294 | Hash root_hash = 5; 295 | repeated Hash sibling_hashes = 6; 296 | } 297 | 298 | enum AccessType { 299 | READ = 0; 300 | WRITE = 1; 301 | } 302 | 303 | message Access { 304 | AccessType type = 1; 305 | Hash read_hash = 2; 306 | optional bytes read = 3; 307 | optional Hash written_hash = 4; 308 | optional bytes written = 5; 309 | repeated Hash sibling_hashes = 6; 310 | uint64 address = 7; 311 | uint64 log2_size = 8; 312 | } 313 | 314 | message BracketNote { 315 | enum BracketNoteType { 316 | BEGIN = 0; 317 | END = 1; 318 | } 319 | BracketNoteType type = 1; 320 | uint64 where = 2; 321 | string text = 3; 322 | } 323 | 324 | message AccessLogType { 325 | bool proofs = 1; 326 | bool annotations = 2; 327 | bool large_data = 3; 328 | } 329 | 330 | message AccessLog { 331 | AccessLogType log_type = 1; 332 | repeated Access accesses = 2; 333 | repeated BracketNote brackets = 3; 334 | repeated string notes = 4; 335 | } 336 | 337 | message MachineRequest { 338 | oneof machine_oneof { 339 | MachineConfig config = 1; 340 | string directory = 2; 341 | } 342 | MachineRuntimeConfig runtime = 3; 343 | } 344 | 345 | message GetInitialConfigResponse { 346 | MachineConfig config = 1; 347 | } 348 | 349 | message GetDefaultConfigResponse { 350 | MachineConfig config = 1; 351 | } 352 | 353 | message VerifyUarchStepLogRequest { 354 | AccessLog log = 1; 355 | bool one_based = 2; 356 | MachineRuntimeConfig runtime = 3; 357 | } 358 | 359 | message VerifyUarchResetLogRequest { 360 | AccessLog log = 1; 361 | bool one_based = 2; 362 | MachineRuntimeConfig runtime = 3; 363 | } 364 | 365 | message VerifyUarchStepStateTransitionRequest { 366 | Hash root_hash_before = 1; 367 | AccessLog log = 2; 368 | Hash root_hash_after = 3; 369 | bool one_based = 4; 370 | MachineRuntimeConfig runtime = 5; 371 | } 372 | 373 | message VerifyUarchResetStateTransitionRequest { 374 | Hash root_hash_before = 1; 375 | AccessLog log = 2; 376 | Hash root_hash_after = 3; 377 | bool one_based = 4; 378 | MachineRuntimeConfig runtime = 5; 379 | } 380 | 381 | message VerifyMerkleTreeResponse { 382 | bool success = 1; 383 | } 384 | 385 | message VerifyDirtyPageMapsResponse { 386 | bool success = 1; 387 | } 388 | 389 | message RunRequest { 390 | uint64 limit = 1; 391 | } 392 | 393 | message RunResponse { 394 | uint64 mcycle = 1; 395 | uint64 tohost = 2; 396 | bool iflags_h = 3; 397 | bool iflags_y = 4; 398 | bool iflags_x = 5; 399 | enum InterpreterBreakReason { 400 | FAILED = 0; 401 | HALTED = 1; 402 | YIELDED_MANUALLY = 2; 403 | YIELDED_AUTOMATICALLY = 3; 404 | YIELDED_SOFTLY = 4; 405 | REACHED_TARGET_MCYCLE = 5; 406 | }; 407 | InterpreterBreakReason break_reason = 6; 408 | } 409 | 410 | message RunUarchRequest { 411 | uint64 limit = 1; 412 | } 413 | 414 | message RunUarchResponse { 415 | uint64 cycle = 1; 416 | uint64 pc = 2; 417 | uint64 halt_flag = 3; 418 | } 419 | 420 | message StoreRequest { 421 | string directory = 1; 422 | } 423 | 424 | message LogUarchStepRequest { 425 | AccessLogType log_type = 1; 426 | bool one_based = 2; 427 | } 428 | 429 | message LogUarchStepResponse { 430 | AccessLog log = 1; 431 | } 432 | 433 | message LogUarchResetRequest { 434 | AccessLogType log_type = 1; 435 | bool one_based = 2; 436 | } 437 | message LogUarchResetResponse { 438 | AccessLog log = 1; 439 | } 440 | 441 | 442 | message ReadWordRequest { 443 | uint64 address = 1; 444 | } 445 | 446 | message ReadWordResponse { 447 | bool success = 1; 448 | uint64 value = 2; 449 | } 450 | 451 | message ReadMemoryRequest { 452 | uint64 address = 1; 453 | uint64 length = 2; 454 | } 455 | 456 | message ReadMemoryResponse { 457 | bytes data = 1; 458 | } 459 | 460 | message WriteMemoryRequest { 461 | uint64 address = 1; 462 | bytes data = 2; 463 | } 464 | 465 | message GetRootHashResponse { 466 | Hash hash = 1; 467 | } 468 | 469 | message GetProofRequest { 470 | uint64 address = 1; 471 | uint64 log2_size = 2; 472 | } 473 | 474 | message GetProofResponse { 475 | MerkleTreeProof proof = 1; 476 | } 477 | 478 | message ReplaceMemoryRangeRequest { 479 | MemoryRangeConfig config = 1; 480 | } 481 | 482 | message GetXAddressRequest { 483 | uint32 index = 1; 484 | } 485 | 486 | message GetXAddressResponse { 487 | uint64 address = 1; 488 | } 489 | 490 | message GetUarchXAddressRequest { 491 | uint32 index = 1; 492 | } 493 | 494 | message GetUarchXAddressResponse { 495 | uint64 address = 1; 496 | } 497 | 498 | message ReadXRequest { 499 | uint32 index = 1; 500 | } 501 | 502 | message ReadXResponse { 503 | uint64 value = 1; 504 | } 505 | 506 | message WriteXRequest { 507 | uint32 index = 1; 508 | uint64 value = 2; 509 | } 510 | 511 | message GetFAddressRequest { 512 | uint32 index = 1; 513 | } 514 | 515 | message GetFAddressResponse { 516 | uint64 address = 1; 517 | } 518 | 519 | message ReadFRequest { 520 | uint32 index = 1; 521 | } 522 | 523 | message ReadFResponse { 524 | uint64 value = 1; 525 | } 526 | 527 | message WriteFRequest { 528 | uint32 index = 1; 529 | uint64 value = 2; 530 | } 531 | 532 | message ReadUarchXRequest { 533 | uint32 index = 1; 534 | } 535 | 536 | message ReadUarchXResponse { 537 | uint64 value = 1; 538 | } 539 | 540 | message WriteUarchXRequest { 541 | uint32 index = 1; 542 | uint64 value = 2; 543 | } 544 | 545 | enum Csr { 546 | PC = 0; 547 | FCSR = 1; 548 | MVENDORID = 2; 549 | MARCHID = 3; 550 | MIMPID = 4; 551 | MCYCLE = 5; 552 | ICYCLEINSTRET = 6; 553 | MSTATUS = 7; 554 | MTVEC = 8; 555 | MSCRATCH = 9; 556 | MEPC = 10; 557 | MCAUSE = 11; 558 | MTVAL = 12; 559 | MISA = 13; 560 | MIE = 14; 561 | MIP = 15; 562 | MEDELEG = 16; 563 | MIDELEG = 17; 564 | MCOUNTEREN = 18; 565 | MENVCFG = 19; 566 | STVEC = 20; 567 | SSCRATCH = 21; 568 | SEPC = 22; 569 | SCAUSE = 23; 570 | STVAL = 24; 571 | SATP = 25; 572 | SCOUNTEREN = 26; 573 | SENVCFG = 27; 574 | ILRSC = 28; 575 | IFLAGS = 29; 576 | CLINT_MTIMECMP = 30; 577 | HTIF_TOHOST = 31; 578 | HTIF_FROMHOST = 32; 579 | HTIF_IHALT = 33; 580 | HTIF_ICONSOLE = 34; 581 | HTIF_IYIELD = 35; 582 | UARCH_PC = 36; 583 | UARCH_CYCLE = 37; 584 | UARCH_HALT_FLAG = 38; 585 | } 586 | 587 | message GetCsrAddressRequest { 588 | Csr csr = 1; 589 | } 590 | 591 | message GetCsrAddressResponse { 592 | uint64 address = 1; 593 | } 594 | 595 | message ReadCsrRequest { 596 | Csr csr = 1; 597 | } 598 | 599 | message ReadCsrResponse { 600 | uint64 value = 1; 601 | } 602 | 603 | message WriteCsrRequest { 604 | Csr csr = 1; 605 | uint64 value = 2; 606 | } 607 | 608 | message MemoryRangeDescription { 609 | uint64 start = 1; 610 | uint64 length = 2; 611 | string description = 3; 612 | } 613 | 614 | message GetMemoryRangesResponse { 615 | repeated MemoryRangeDescription memory_range = 1; 616 | } 617 | -------------------------------------------------------------------------------- /ipfs.proto: -------------------------------------------------------------------------------- 1 | // Copyright Cartesi and individual authors (see AUTHORS) 2 | // SPDX-License-Identifier: Apache-2.0 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | syntax = "proto3"; 18 | option go_package = ".;ipfs"; 19 | 20 | package CartesiIpfs; 21 | 22 | service Ipfs { 23 | rpc GetFile (GetFileRequest) returns (GetFileResponse) {} 24 | rpc AddFile (AddFileRequest) returns (AddFileResponse) {} 25 | } 26 | 27 | message GetFileRequest { 28 | string ipfs_path = 1; 29 | uint32 log2_size = 2; 30 | string output_path = 3; 31 | uint64 timeout = 4; 32 | } 33 | 34 | message Progress { 35 | uint64 progress = 1; 36 | uint64 updated_at = 2; 37 | } 38 | 39 | message GetFileResult { 40 | string output_path = 1; 41 | Hash root_hash = 2; 42 | } 43 | 44 | message GetFileResponse { 45 | oneof get_oneof { 46 | Progress progress = 1; 47 | GetFileResult result = 2; 48 | } 49 | } 50 | 51 | message AddFileRequest { 52 | string file_path = 1; 53 | } 54 | 55 | message AddFileResult { 56 | string ipfs_path = 1; 57 | } 58 | 59 | message AddFileResponse { 60 | oneof add_oneof { 61 | Progress progress = 1; 62 | AddFileResult result = 2; 63 | } 64 | } 65 | 66 | message Hash { 67 | bytes data = 1; 68 | } 69 | -------------------------------------------------------------------------------- /logger.proto: -------------------------------------------------------------------------------- 1 | // Copyright Cartesi and individual authors (see AUTHORS) 2 | // SPDX-License-Identifier: Apache-2.0 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | syntax = "proto3"; 18 | 19 | package CartesiLogger; 20 | 21 | service Logger { 22 | rpc SubmitFile (SubmitFileRequest) returns (SubmitFileResponse) {} 23 | rpc DownloadFile (DownloadFileRequest) returns (DownloadFileResponse) {} 24 | } 25 | 26 | message DownloadFileRequest { 27 | string path = 1; 28 | Hash root = 2; 29 | uint64 page_log2_size = 3; 30 | uint64 tree_log2_size = 4; 31 | } 32 | 33 | message SubmitFileRequest { 34 | string path = 1; 35 | uint64 page_log2_size = 2; 36 | uint64 tree_log2_size = 3; 37 | } 38 | 39 | message DownloadFileResponse { 40 | string path = 1; 41 | uint32 status = 2; 42 | uint64 progress = 3; 43 | string description = 4; 44 | } 45 | 46 | message SubmitFileResponse { 47 | Hash root = 1; 48 | uint32 status = 2; 49 | uint64 progress = 3; 50 | string description = 4; 51 | } 52 | 53 | message Hash { 54 | bytes content = 1; 55 | } 56 | -------------------------------------------------------------------------------- /machine-manager.proto: -------------------------------------------------------------------------------- 1 | // Copyright Cartesi and individual authors (see AUTHORS) 2 | // SPDX-License-Identifier: Apache-2.0 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | syntax = "proto3"; 18 | 19 | import "cartesi-machine.proto"; 20 | 21 | package CartesiMachineManager; 22 | 23 | service MachineManager { 24 | rpc NewSession (NewSessionRequest) returns (CartesiMachine.Hash) {} 25 | rpc SessionRun (SessionRunRequest) returns (SessionRunResponse) {} 26 | rpc SessionStep (SessionStepRequest) returns (SessionStepResponse) {} 27 | rpc SessionStore (SessionStoreRequest) returns (CartesiMachine.Void) {} 28 | rpc SessionReadMemory (SessionReadMemoryRequest) returns (SessionReadMemoryResponse) {} 29 | rpc SessionWriteMemory (SessionWriteMemoryRequest) returns (CartesiMachine.Void) {} 30 | rpc SessionReplaceMemoryRange (SessionReplaceMemoryRangeRequest) returns (CartesiMachine.Void) {} 31 | rpc SessionGetProof (SessionGetProofRequest) returns (CartesiMachine.MerkleTreeProof) {} 32 | rpc EndSession (EndSessionRequest) returns (CartesiMachine.Void) {} 33 | } 34 | 35 | message NewSessionRequest { 36 | CartesiMachine.MachineRequest machine = 1; 37 | string session_id = 2; 38 | bool force = 3; 39 | } 40 | 41 | message SessionRunRequest { 42 | string session_id = 1; 43 | repeated uint64 final_cycles = 2; 44 | } 45 | 46 | message SessionRunProgress { 47 | uint64 progress = 1; 48 | uint64 application_progress = 2; 49 | uint64 updated_at = 3; 50 | uint64 cycle = 4; 51 | } 52 | 53 | message SessionRunResult { 54 | repeated CartesiMachine.RunResponse summaries = 1; 55 | repeated CartesiMachine.Hash hashes = 2; 56 | } 57 | 58 | message SessionRunResponse { 59 | oneof run_oneof { 60 | SessionRunProgress progress = 1; 61 | SessionRunResult result = 2; 62 | } 63 | } 64 | 65 | message SessionStepRequest { 66 | string session_id = 1; 67 | uint64 initial_cycle = 2; 68 | oneof step_params_oneof { 69 | CartesiMachine.StepUarchRequest step_params = 3; 70 | }; 71 | } 72 | 73 | message SessionStepResponse { 74 | CartesiMachine.AccessLog log = 1; 75 | } 76 | 77 | message SessionStoreRequest { 78 | string session_id = 1; 79 | CartesiMachine.StoreRequest store = 2; 80 | } 81 | 82 | message SessionReadMemoryRequest { 83 | string session_id = 1; 84 | uint64 cycle = 2; 85 | CartesiMachine.ReadMemoryRequest position = 3; 86 | } 87 | 88 | message SessionReadMemoryResponse { 89 | CartesiMachine.ReadMemoryResponse read_content = 1; 90 | } 91 | 92 | message SessionReplaceMemoryRangeRequest { 93 | string session_id = 1; 94 | uint64 cycle = 2; 95 | CartesiMachine.MemoryRangeConfig range = 3; 96 | } 97 | 98 | message SessionWriteMemoryRequest { 99 | string session_id = 1; 100 | uint64 cycle = 2; 101 | CartesiMachine.WriteMemoryRequest position = 3; 102 | } 103 | 104 | message SessionGetProofRequest { 105 | string session_id = 1; 106 | uint64 cycle = 2; 107 | CartesiMachine.GetProofRequest target = 3; 108 | } 109 | 110 | message EndSessionRequest { 111 | string session_id = 1; 112 | bool silent = 2; 113 | } 114 | -------------------------------------------------------------------------------- /p2p.proto: -------------------------------------------------------------------------------- 1 | // Copyright Cartesi and individual authors (see AUTHORS) 2 | // SPDX-License-Identifier: Apache-2.0 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | syntax = "proto3"; 18 | option go_package = ".;p2p"; 19 | 20 | package CartesiP2p; 21 | 22 | service P2p { 23 | rpc Subscribe (SubscribeRequest) returns (Void) {} 24 | rpc Poll (PollRequest) returns (PollResponse) {} 25 | rpc Publish (PublishRequest) returns (Void) {} 26 | rpc SetMessages (SetMessagesRequest) returns (Void) {} 27 | } 28 | 29 | message SubscribeRequest { 30 | string channel_name = 1; 31 | } 32 | 33 | message PollRequest { 34 | string channel_name = 1; 35 | int64 number = 2; 36 | } 37 | 38 | message PublishRequest { 39 | string channel_name = 1; 40 | bytes content = 2; 41 | } 42 | 43 | message SetMessagesRequest { 44 | string channel_name = 1; 45 | repeated string pending_messages_id = 2; 46 | repeated string stale_messages_id = 3; 47 | repeated string expired_messages_id = 4; 48 | } 49 | 50 | message PollResponse { 51 | string channel_name = 1; 52 | repeated Message messages = 2; 53 | } 54 | 55 | message Message { 56 | string id = 1; 57 | bytes content = 2; 58 | } 59 | 60 | message Void { } 61 | -------------------------------------------------------------------------------- /server-manager.proto: -------------------------------------------------------------------------------- 1 | // Copyright Cartesi and individual authors (see AUTHORS) 2 | // SPDX-License-Identifier: Apache-2.0 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | syntax = "proto3"; 18 | 19 | import "versioning.proto"; 20 | 21 | import "cartesi-machine.proto"; 22 | 23 | package CartesiServerManager; 24 | 25 | // The version implemented by an instance of the Cartesi Server Manager can be obtained with a call to GetVersion. 26 | // Each Cartesi Server Manager controls a variety of independent Sessions (see StartSession). 27 | // The current list of Sessions can be obtained with a call to GetStatus. 28 | // Each Session controls a single Cartesi Machine through a connection to a Cartesi Machine Server that the 29 | // Server Manager itself spawns for the session. 30 | // The Cartesi Machine is specified in the StartSession request, by directory. 31 | // Each Session is divided into Epochs. 32 | // The list of past Epochs (and the current Epoch) for a Session can be obtained with a call to GetSessionStatus. 33 | // Within each Epoch, the state of the associated machine is advanced by individual inputs (see AdvanceState). 34 | // The processing of each input, when successful, may produce several Vouchers (i.e., collateral effects 35 | // actionable in the blockchain) and a variety of Notices (which describe any relevant changes to the internal 36 | // state of applications running inside the Cartesi Machine). 37 | // The current Epoch can be closed (and the next Epoch started) with a call to FinishEpoch. 38 | // This is a synchronous call that can only be issued after all inputs in the active epoch have been processed. 39 | // The entire state of the machine can be stored on disk (and later recovered) when the Epoch is finished. 40 | // An input can be skipped for a variety of reasons (see CompletionStatus). 41 | // Whether successfully processed or skipped, the machine can produce a variety of Reports (i.e., diagnostics, logs, etc) 42 | // Input processing is asynchronous: the results of all processed inputs can be obtained with a call to GetEpochStatus. 43 | // A closed epoch can be deleted to free the Server Manager's memory with a call to DeleteEpoch. 44 | // Otherwise, information about an Epoch is retained until its Session is terminated (see EndSession). 45 | // (Note that machines stored on disk are always retained.) 46 | // When an input is skipped, for whatever reason, the state of the Cartesi Machine is reverted to what it was 47 | // before the input was given to the machine: i.e., from the perspective of the machine, it never happened. 48 | // Certain error conditions may cause a Session to become unusable. 49 | // An unusable Session is said to be "tainted". 50 | // All further operations in a tainted Session (other than EndSession) will fail. 51 | // The underlying reason can be obtained with a call to GetSessionStatus. 52 | // Between inputs, the state of the machine can be inspected with a query (see InspectState). 53 | // Processing of a query can produce a variety of Reports. 54 | // Processing of a query can be aborted for a variety of reasons (see CompletionStatus). 55 | // After the query is processed, the state of the Cartesi Machine is reverted to what it was before the query was given 56 | // to the machine: i.e., from the perspective of the machine, it never happened. 57 | // State inspection is synchronous: the query is processed as soon as the current input is done (if any) and all 58 | // produced Reports are immediately returned. 59 | // A Cartesi Machine used with the Cartesi Server Manager must define 5 memory ranges, in addition to however 60 | // many flash drives the application it runs might require. 61 | // Each memory range must have a power-of-two length and must start at a multiple of its size. 62 | // The first two are the rx buffer and tx buffer memory ranges. 63 | // The rx buffer is used by the Cartesi Server Manager to send the input and query payloads into the Cartesi 64 | // Machine. 65 | // The tx buffer is used by the Cartesi Machine to send Vouchers, Notices, and Reports to the Cartesi Server 66 | // Manager. 67 | // Each input to AdvanceState, in addition to the payload, requires some metadata. 68 | // This is sent into the Cartesi Machine through the input metadata memory range. 69 | // The last two remaining memory ranges are the voucher hashes and notice hashes memory ranges. 70 | // These contain an array of hashes, respectively of each voucher and notice produced while processing a given input. 71 | // Whenever an input is processed, the Cartesi Server Manager collects from the Cartesi Machine a Merkle proof 72 | // that the voucher hashes and notice hashes memory ranges are part of the Cartesi Machine State. 73 | // Likewise, each voucher and notice accompanies a proof that its hash is part of, respectively, the voucher hashes 74 | // memory range and notice hashes memory range. 75 | // Finally, the Cartesi Server Manager also maintains two additional Merkle trees, respectively containing as 76 | // leaves the Merkle tree root hash of the voucher hashes memory range and the notice hashes memory range. 77 | 78 | service ServerManager { 79 | rpc GetVersion(CartesiMachine.Void) returns (Versioning.GetVersionResponse) {} 80 | rpc StartSession (StartSessionRequest) returns (StartSessionResponse) {} 81 | rpc AdvanceState (AdvanceStateRequest) returns (CartesiMachine.Void) {} 82 | rpc GetStatus (CartesiMachine.Void) returns (GetStatusResponse) {} 83 | rpc GetSessionStatus (GetSessionStatusRequest) returns (GetSessionStatusResponse) {} 84 | rpc GetEpochStatus (GetEpochStatusRequest) returns (GetEpochStatusResponse) {} 85 | rpc InspectState (InspectStateRequest) returns (InspectStateResponse) {} 86 | rpc FinishEpoch (FinishEpochRequest) returns (FinishEpochResponse) {} 87 | rpc DeleteEpoch (DeleteEpochRequest) returns (CartesiMachine.Void) {} 88 | rpc EndSession (EndSessionRequest) returns (CartesiMachine.Void) {} 89 | } 90 | 91 | message StartSessionResponse { 92 | CartesiMachine.MachineConfig config = 1; // Configuration of instantiated machine 93 | } 94 | 95 | message GetStatusResponse { 96 | repeated string session_id = 1; // List of available sessions 97 | } 98 | 99 | // Deadlines for a variety of machine server tasks 100 | // (All deadlines are in milliseconds) 101 | message DeadlineConfig { 102 | uint64 checkin = 1; // Deadline for receiving check-in from spawned machine server 103 | uint64 advance_state = 2; // Deadline for advancing the state 104 | uint64 advance_state_increment = 3; // Deadline for each increment when advancing state 105 | uint64 inspect_state = 4; // Deadline for inspecting state 106 | uint64 inspect_state_increment = 5; // Deadline for each increment when inspecting state 107 | uint64 machine = 6; // Deadline for instantiating a machine 108 | uint64 store = 7; // Deadline for storing a machine 109 | uint64 fast = 8; // Deadline for quick machine server tasks 110 | } 111 | 112 | // Cycle limits for a variety of machine server tasks 113 | message CyclesConfig { 114 | uint64 max_advance_state = 1; // Maximum number of cycles that processing the input in an AdvanceState can take 115 | uint64 advance_state_increment = 2; // Number of cycles in each increment to processing an input 116 | uint64 max_inspect_state = 3; // Maximum number of cycles that processing the query in an InspectState can take 117 | uint64 inspect_state_increment = 4; // Number of cycles in each increment to process a query 118 | } 119 | 120 | message StartSessionRequest { 121 | string session_id = 1; // Id of session to start 122 | string machine_directory = 2; // Machine to instantiate for session 123 | uint64 active_epoch_index = 3; // Active epoch for the newly instantiated machine 124 | uint64 processed_input_count = 4; // Number of processed inputs since genesis 125 | CyclesConfig server_cycles = 5; // Cycle limit for server tasks 126 | DeadlineConfig server_deadline = 6; // Time limit for server tasks 127 | CartesiMachine.MachineRuntimeConfig runtime = 7; // Machine runtime parameters 128 | } 129 | 130 | // Information about why the session became invalid 131 | message TaintStatus { 132 | int32 error_code = 1; // Error code associated with tainting of session 133 | string error_message = 2; // Descriptive error message 134 | } 135 | 136 | message GetSessionStatusRequest { 137 | string session_id = 1; // Id of session to describe 138 | } 139 | 140 | message GetSessionStatusResponse { 141 | string session_id = 1; // Id of session being described 142 | uint64 active_epoch_index = 2; // Currently active epoch in session 143 | repeated uint64 epoch_index = 3; // List of epochs the session holds 144 | TaintStatus taint_status = 4; // If the session is tainted, an error code and message giving the cause 145 | } 146 | 147 | message EndSessionRequest { 148 | string session_id = 1; // Session to end. 149 | } 150 | 151 | message Address { 152 | bytes data = 1; // 20-byte address 153 | } 154 | 155 | message InputMetadata { 156 | Address msg_sender = 1; // 20-byte address of sender 157 | uint64 block_number = 2; // Block number when input was posted 158 | uint64 timestamp = 3; // Time stamp of the block (Unix?) 159 | uint64 epoch_index = 4; // Deprecated. Always receives 0 160 | uint64 input_index = 5; // Input index starting from genesis 161 | } 162 | 163 | message AdvanceStateRequest { 164 | string session_id = 1; 165 | uint64 active_epoch_index = 2; // To double-check whether the desired epoch is the active one 166 | uint64 current_input_index = 3; // To double-check whether the current input is the expected one 167 | InputMetadata input_metadata = 4; // Information sent via the input metadata memory range 168 | bytes input_payload = 5; // Payload sent via the rx buffer memory range 169 | } 170 | 171 | message GetEpochStatusRequest { 172 | string session_id = 1; // Session to which epoch belongs 173 | uint64 epoch_index = 2; // Index of epoch to describe. It may refer to an old epoch that is still cached by the session 174 | } 175 | 176 | // Reason why the input was skipped 177 | enum CompletionStatus { 178 | ACCEPTED = 0; 179 | REJECTED = 1; 180 | EXCEPTION = 2; 181 | MACHINE_HALTED = 3; 182 | CYCLE_LIMIT_EXCEEDED = 4; 183 | TIME_LIMIT_EXCEEDED = 5; 184 | PAYLOAD_LENGTH_LIMIT_EXCEEDED = 6; 185 | } 186 | 187 | message AcceptedData { 188 | repeated Voucher vouchers = 1; // List of vouchers produced when processing the input 189 | repeated Notice notices = 2; // List of notices produced when processing the input 190 | } 191 | 192 | message ProcessedInput { 193 | uint64 input_index = 1; // Index of input starting from genesis 194 | CompletionStatus status = 2; // Status of the processed input 195 | oneof ProcessedInputOneOf { 196 | AcceptedData accepted_data = 3; // Result of processed input when completed with success (ACCEPTED) 197 | bytes exception_data = 4; // Exception payload when there was an EXCEPTION 198 | } 199 | repeated Report reports = 5; // Reports produced during input or query processing 200 | } 201 | 202 | enum EpochState { 203 | ACTIVE = 0; // Epoch is still accepting inputs 204 | FINISHED = 1; // Epoch has been buried under the next active epoch but is perhaps still processing pending inputs 205 | } 206 | 207 | message GetEpochStatusResponse { 208 | string session_id = 1; // Session to which epoch belong 209 | uint64 epoch_index = 2; // Index of epoch being described 210 | EpochState state = 3; // State epoch is currently in 211 | repeated ProcessedInput processed_inputs = 4; // List of inputs already processed in this epoch 212 | uint64 pending_input_count = 5; // Number of inputs pending processing 213 | TaintStatus taint_status = 6; // If the session is tainted, an error code and message giving the cause 214 | } 215 | 216 | message Notice { 217 | bytes payload = 1; // Notice payload 218 | } 219 | 220 | message Voucher { 221 | Address destination = 1; // 20-byte address 222 | bytes payload = 2; // Voucher payload 223 | } 224 | 225 | message Report { 226 | bytes payload = 1; // Report payload 227 | } 228 | 229 | message InspectStateRequest { 230 | string session_id = 1; // Session to inspect 231 | bytes query_payload = 2; // Query payload 232 | } 233 | 234 | message InspectStateResponse { 235 | string session_id = 1; // Id of session being described 236 | uint64 active_epoch_index = 2; // Epoch that was inspected 237 | uint64 processed_input_count = 3; // Number of processed inputs since genesis 238 | CompletionStatus status = 4; // Whether inspection completed or not (and why not) 239 | optional bytes exception_data = 5; // Exception payload when finished with EXCEPTION 240 | repeated Report reports = 6; // Reports produced while processing the query 241 | } 242 | 243 | // Validity proof for an output 244 | message OutputValidityProof { 245 | uint64 input_index_within_epoch = 1; // Local input index within the context of the related epoch 246 | uint64 output_index_within_input = 2; // Output index within the context of the input that produced it 247 | CartesiMachine.Hash output_hashes_root_hash = 3; // Merkle root of all output hashes of the related input 248 | CartesiMachine.Hash vouchers_epoch_root_hash = 4; // Merkle root of all voucher hashes of the related epoch 249 | CartesiMachine.Hash notices_epoch_root_hash = 5; // Merkle root of all notice hashes of the related epoch 250 | CartesiMachine.Hash machine_state_hash = 6; // Hash of the machine state claimed for the related epoch 251 | repeated CartesiMachine.Hash output_hash_in_output_hashes_siblings = 7; // Proof that this output hash is in the output-hashes merkle tree. This array of siblings is bottom-up ordered (from the leaf to the root). 252 | repeated CartesiMachine.Hash output_hashes_in_epoch_siblings = 8; // Proof that this output-hashes root hash is in epoch's output merkle tree. This array of siblings is bottom-up ordered (from the leaf to the root). 253 | } 254 | 255 | enum OutputEnum { 256 | VOUCHER = 0; 257 | NOTICE = 1; 258 | } 259 | 260 | // Data that can be used as proof to validate notices and execute vouchers on the base layer blockchain 261 | message Proof { 262 | uint64 input_index = 1; // Index of input starting from genesis 263 | uint64 output_index = 2; // Index of output (voucher or notice) in the context of the input 264 | OutputEnum output_enum = 3; // Type of the output 265 | OutputValidityProof validity = 4; // Validity proof for an output 266 | bytes context = 5; // Data that allows the validity proof to be contextualized within submitted claims. Currently, the context is the epoch number as a ABI-encoded uint256. 267 | } 268 | 269 | message FinishEpochRequest { 270 | string session_id = 1; // Id of session containing epoch to finish 271 | uint64 active_epoch_index = 2; // To double-check epoch index is correct 272 | uint64 processed_input_count_within_epoch = 3; // To double-check all inputs sent have been processed in this epoch 273 | string storage_directory = 4; // Directory to store machine state (do not store if an empty string) 274 | } 275 | 276 | message FinishEpochResponse { 277 | CartesiMachine.Hash machine_hash = 1; // Machine hash in epoch 278 | CartesiMachine.Hash vouchers_epoch_root_hash = 2; // Root hash for Merkle tree of voucher hashes memory ranges 279 | CartesiMachine.Hash notices_epoch_root_hash = 3; // Root hash for Merkle tree of notice hashes memory ranges 280 | repeated Proof proofs = 4; // Proofs for the outputs 281 | } 282 | 283 | message DeleteEpochRequest { 284 | string session_id = 1; // Id of session containing epoch to delete 285 | uint64 epoch_index = 2; // Index of the epoch to delete 286 | } 287 | -------------------------------------------------------------------------------- /state-fold-server.proto: -------------------------------------------------------------------------------- 1 | // Copyright Cartesi and individual authors (see AUTHORS) 2 | // SPDX-License-Identifier: Apache-2.0 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | syntax = "proto3"; 18 | 19 | package StateFoldServer; 20 | 21 | service StateFold { 22 | rpc QueryBlock (QueryBlockRequest) returns (Block) {} 23 | rpc QueryBlocksSince (QueryBlocksSinceRequest) returns (BlocksSinceResponse) {} 24 | rpc SubscribeNewBlocks (SubscribeNewBlocksRequest) returns (stream BlockStreamResponse) {} 25 | 26 | rpc QueryState (QueryStateRequest) returns (BlockState) {} 27 | rpc QueryStatesSince (QueryStatesSinceRequest) returns (StatesSinceResponse) {} 28 | rpc SubscribeNewStates (SubscribeNewStatesRequest) returns (stream StateStreamResponse) {} 29 | } 30 | 31 | message InitialState { 32 | string json_data = 1; 33 | } 34 | 35 | message State { 36 | string json_data = 1; 37 | } 38 | 39 | message Hash { 40 | bytes data = 1; // bytes of size 32 41 | } 42 | 43 | message Bloom { 44 | bytes data = 1; // bytes of size 256 45 | } 46 | 47 | message Block { 48 | Hash hash = 1; 49 | uint64 number = 2; 50 | Hash parent_hash = 3; 51 | uint64 timestamp = 4; 52 | Bloom logs_bloom = 5; 53 | } 54 | 55 | message Blocks { 56 | repeated Block blocks = 1; 57 | } 58 | 59 | message QueryBlock { 60 | oneof id { 61 | uint64 depth = 1; 62 | Hash block_hash = 2; 63 | uint64 block_number = 3; 64 | } 65 | } 66 | 67 | message BlockState { 68 | Block block = 1; 69 | State state = 2; 70 | } 71 | 72 | message States { 73 | repeated BlockState states = 1; 74 | } 75 | 76 | message QueryBlockRequest { 77 | QueryBlock query_block = 1; // None means latest 78 | } 79 | 80 | message QueryBlocksSinceRequest { 81 | Hash previous_block = 1; 82 | uint64 depth = 2; 83 | } 84 | 85 | message BlocksSinceResponse { 86 | oneof response { 87 | Blocks new_blocks = 1; 88 | Blocks reorganized_blocks = 2; 89 | } 90 | } 91 | 92 | message SubscribeNewBlocksRequest { 93 | uint64 confirmations = 1; 94 | } 95 | 96 | message BlockStreamResponse { 97 | oneof response { 98 | Block new_block = 1; 99 | Blocks reorganized_blocks = 2; 100 | } 101 | } 102 | 103 | message QueryStateRequest { 104 | InitialState initial_state = 1; 105 | QueryBlock query_block = 2; // None means latest 106 | } 107 | 108 | message QueryStatesSinceRequest { 109 | InitialState initial_state = 1; 110 | Hash previous_block = 2; 111 | uint64 depth = 3; 112 | } 113 | 114 | message StatesSinceResponse { 115 | oneof response { 116 | States new_states = 1; 117 | States reorganized_states = 2; 118 | } 119 | } 120 | 121 | message SubscribeNewStatesRequest { 122 | InitialState initial_state = 1; 123 | uint64 confirmations = 2; 124 | } 125 | 126 | message StateStreamResponse { 127 | oneof response { 128 | BlockState new_state = 1; 129 | States reorganized_states = 2; 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /stateserver.proto: -------------------------------------------------------------------------------- 1 | // Copyright Cartesi and individual authors (see AUTHORS) 2 | // SPDX-License-Identifier: Apache-2.0 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | syntax = "proto3"; 18 | 19 | package StateServer; 20 | 21 | service DelegateManager { 22 | rpc GetState (GetStateRequest) returns (GetStateResponse) {} 23 | } 24 | 25 | message GetStateRequest { 26 | string json_initial_state = 1; 27 | } 28 | 29 | message GetStateAtDepthRequest { 30 | string json_initial_state = 1; 31 | int64 depth = 2; 32 | } 33 | 34 | message GetStateResponse { 35 | string json_state = 1; 36 | } 37 | -------------------------------------------------------------------------------- /versioning.proto: -------------------------------------------------------------------------------- 1 | // Copyright Cartesi and individual authors (see AUTHORS) 2 | // SPDX-License-Identifier: Apache-2.0 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | syntax = "proto3"; 18 | 19 | package Versioning; 20 | 21 | message SemanticVersion { 22 | uint32 major = 1; 23 | uint32 minor = 2; 24 | uint32 patch = 3; 25 | string pre_release = 4; 26 | string build = 5; 27 | } 28 | 29 | message GetVersionResponse { 30 | SemanticVersion version = 1; 31 | } 32 | --------------------------------------------------------------------------------