|
| 1 | +# Contributing to java-tron |
| 2 | + |
| 3 | +Thank you for considering contributing to java-tron! We welcome contributions from anyone and are grateful for even the smallest fixes. |
| 4 | + |
| 5 | +java-tron is an open-source project that thrives on community support. This guide will help you contribute effectively. If you have suggestions for improving this guide, please let us know. |
| 6 | + |
| 7 | +## Table of Contents |
| 8 | + |
| 9 | +- [Reporting An Issue](#reporting-an-issue) |
| 10 | +- [Working on java-tron](#working-on-java-tron) |
| 11 | + - [Contribution Types](#contribution-types) |
| 12 | + - [Key Branches](#key-branches) |
| 13 | + - [Submitting Code](#submitting-code) |
| 14 | +- [Code Review Guidelines](#code-review-guidelines) |
| 15 | + - [Terminology](#terminology) |
| 16 | + - [The Process](#the-process) |
| 17 | + - [Code Style](#code-style) |
| 18 | + - [Commit Messages](#commit-messages) |
| 19 | + - [Branch Naming Conventions](#branch-naming-conventions) |
| 20 | + - [Pull Request Guidelines](#pull-request-guidelines) |
| 21 | + - [Special Situations](#special-situations-and-how-to-deal-with-them) |
| 22 | +- [Code of Conduct](#code-of-conduct) |
| 23 | + |
| 24 | +## Reporting An Issue |
| 25 | + |
| 26 | +Before raising an issue, please follow these guidelines: |
| 27 | + |
| 28 | +- **Search for existing issues** - Help us avoid duplicates by checking if someone has already reported your problem or requested your feature. |
| 29 | + |
| 30 | +- **Use the Issue Report Template** - Provide clear information using this format: |
| 31 | + ``` |
| 32 | + 1. What did you do? |
| 33 | +
|
| 34 | + 2. What did you expect to see? |
| 35 | +
|
| 36 | + 3. What did you see instead? |
| 37 | + ``` |
| 38 | +
|
| 39 | +## Working on java-tron |
| 40 | +
|
| 41 | +### Contribution Types |
| 42 | +
|
| 43 | +**For small fixes:** |
| 44 | +- Submit a pull request (PR) directly with a detailed description |
| 45 | +- Maintainers will review and merge into the main codebase |
| 46 | +
|
| 47 | +**For complex changes:** |
| 48 | +- Submit a TIP (TRON Improvement Proposal) issue first |
| 49 | +- Detail your motivation and implementation plan |
| 50 | +- Refer to the [TIP Specification](https://github.com/tronprotocol/tips#to-submit-a-tip) for submission guidelines |
| 51 | +
|
| 52 | +### Key Branches |
| 53 | +
|
| 54 | +java-tron uses the following branch structure: |
| 55 | +
|
| 56 | +- **`develop` branch** |
| 57 | + - Accepts merge requests from forked branches or `release_*` branches only |
| 58 | + - Direct pushes are not allowed |
| 59 | + - Source branch for creating new `release_*` branches |
| 60 | +
|
| 61 | +- **`master` branch** |
| 62 | + - Receives merges from `release_*` and `hotfix/*` branches only |
| 63 | + - Updated only when a new build is released |
| 64 | + - Represents the production-ready state |
| 65 | +
|
| 66 | +- **`release_*` branch** |
| 67 | + - Created from `develop` for each release |
| 68 | + - Merged into `master` after passing regression tests |
| 69 | + - Permanently kept in the repository as a release snapshot |
| 70 | + - Bug fixes can be applied directly to this branch |
| 71 | + - After regression tests, merged back into `develop` |
| 72 | +
|
| 73 | +- **`feature/*` branch** |
| 74 | + - Created from `develop` for new feature development |
| 75 | + - Merged back to `develop` when code-complete |
| 76 | + - Maintained throughout the feature development lifecycle |
| 77 | +
|
| 78 | +- **`hotfix/*` branch** |
| 79 | + - Created from `master` for urgent production bug fixes |
| 80 | + - Merged back into both `master` and `develop` branches |
| 81 | + - Used exclusively for fixing critical bugs found after release |
| 82 | + - Only accepts pull requests for bug fixes from forked repositories |
| 83 | +
|
| 84 | +### Submitting Code |
| 85 | +
|
| 86 | +Follow these steps to contribute code to java-tron: |
| 87 | +
|
| 88 | +**1. Fork the repository** |
| 89 | + - Fork tronprotocol/java-tron to your personal GitHub account |
| 90 | +
|
| 91 | +**2. Clone and configure your fork** |
| 92 | + ```bash |
| 93 | + git clone https://github.com/yourname/java-tron.git |
| 94 | + git remote add upstream https://github.com/tronprotocol/java-tron.git |
| 95 | + ``` |
| 96 | +
|
| 97 | +**3. Synchronize with upstream** |
| 98 | + Before developing, sync your fork with the upstream repository: |
| 99 | + ```bash |
| 100 | + git fetch upstream |
| 101 | + git checkout develop |
| 102 | + git merge upstream/develop --no-ff # Disable fast-forward merge |
| 103 | + ``` |
| 104 | +
|
| 105 | +**4. Create a feature branch** |
| 106 | + Create a new branch from `develop` (see [Branch Naming Conventions](#branch-naming-conventions)): |
| 107 | + ```bash |
| 108 | + git checkout -b feature/branch_name develop |
| 109 | + ``` |
| 110 | +
|
| 111 | +**5. Develop and commit** |
| 112 | + Write your code and commit changes (see [Commit Messages](#commit-messages)): |
| 113 | + ```bash |
| 114 | + git add . |
| 115 | + git commit -m 'commit message' |
| 116 | + ``` |
| 117 | +
|
| 118 | +**6. Push to your fork** |
| 119 | + ```bash |
| 120 | + git push origin feature/branch_name |
| 121 | + ``` |
| 122 | +
|
| 123 | +**7. Create a pull request** |
| 124 | + - Submit a PR from your fork to `tronprotocol/java-tron` |
| 125 | + - Select the appropriate base branch (usually `develop`) |
| 126 | + - Select your feature branch as the compare branch |
| 127 | + -  |
| 128 | +
|
| 129 | +## Code Review Guidelines |
| 130 | +
|
| 131 | +All code changes must go through the pull request review process. This section outlines expectations for both PR authors and reviewers. |
| 132 | +
|
| 133 | +### Terminology |
| 134 | +
|
| 135 | +- **Author**: The entity who wrote the diff and submitted it to GitHub |
| 136 | +- **Team**: People with commit rights on the java-tron repository |
| 137 | +- **Reviewer**: The person assigned to review the diff (must be a team member) |
| 138 | +- **Code owner**: The person responsible for the subsystem being modified |
| 139 | +
|
| 140 | +### The Process |
| 141 | +
|
| 142 | +**Initial Assessment:** |
| 143 | +- Code owners evaluate PR inclusion based on adequate descriptions and reasonable diff sizes |
| 144 | +- Anyone can request clarification when needed |
| 145 | +
|
| 146 | +**Review Responsibilities:** |
| 147 | +- Reviewers verify code style and functionality |
| 148 | +- Provide constructive feedback through GitHub's review system |
| 149 | +- Maintain professional communication throughout the process |
| 150 | +- Follow up until quality standards are met |
| 151 | +- Approve when ready for merge |
| 152 | +
|
| 153 | +**Merging:** |
| 154 | +- Code owners merge approved PRs |
| 155 | +
|
| 156 | +### Code Style |
| 157 | +
|
| 158 | +**Before Submitting:** |
| 159 | +1. Use coding style checkers to review your code |
| 160 | +2. Perform a self-review before submission |
| 161 | +3. Run all standardized tests |
| 162 | +
|
| 163 | +**Automated Checks:** |
| 164 | +- Sonar scanner and Travis CI run automatically on all PRs |
| 165 | +- PRs must pass all checks before maintainer review |
| 166 | +
|
| 167 | +**Review Process:** |
| 168 | +- Maintainers provide feedback and request modifications as needed |
| 169 | +- Approved PRs are merged into the `develop` branch |
| 170 | +- All contributions are welcome, including typo fixes |
| 171 | +
|
| 172 | +**If Your PR is Not Accepted:** |
| 173 | +- Don't be discouraged - it may be an oversight |
| 174 | +- Provide detailed explanations to help reviewers understand your changes |
| 175 | +- Address feedback constructively |
| 176 | +
|
| 177 | +**Code Style Requirements:** |
| 178 | +- Code must conform to [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html) |
| 179 | +- Code must pass Sonar scanner tests |
| 180 | +- Branches must be created from `develop` |
| 181 | +- Commit messages must start with a lowercase verb |
| 182 | +- Commit subject lines must be 50 characters or less |
| 183 | +
|
| 184 | +### Commit Messages |
| 185 | +
|
| 186 | +Follow this template for all commit messages: |
| 187 | +
|
| 188 | +``` |
| 189 | +<commit type>(<scope>): <subject> |
| 190 | +<BLANK LINE> |
| 191 | +<body> |
| 192 | +<BLANK LINE> |
| 193 | +<footer> |
| 194 | +``` |
| 195 | +
|
| 196 | +**Header Format:** |
| 197 | +A single line containing the commit type, optional scope, and subject. |
| 198 | +
|
| 199 | +**Commit Types:** |
| 200 | +* feat (new feature) |
| 201 | +* fix (bug fix) |
| 202 | +* docs (changes to documentation) |
| 203 | +* style (formatting, missing semi colons, etc. no code change) |
| 204 | +* refactor (refactoring production code) |
| 205 | +* test (adding or refactoring tests. no production code change) |
| 206 | +* chore (updating grunt tasks etc. no production code change) |
| 207 | +
|
| 208 | +**Scope:** |
| 209 | +Specifies the area of change (e.g., `protobuf`, `api`, `test`, `docs`, `build`, `db`, `net`). Use `*` if no specific scope applies. |
| 210 | +
|
| 211 | +**Subject Guidelines:** |
| 212 | +1. Limit to 50 characters |
| 213 | +2. Use imperative, present tense (e.g., "change" not "changed" or "changes") |
| 214 | +3. Start with a lowercase letter |
| 215 | +4. Do not end with a period |
| 216 | +5. Avoid meaningless commits (use `git rebase` to clean up) |
| 217 | +
|
| 218 | +**Body:** |
| 219 | +- Use imperative, present tense |
| 220 | +- Explain the motivation for the change |
| 221 | +- Contrast with previous behavior |
| 222 | +
|
| 223 | +**Footer:** |
| 224 | +Reference related issues using the `Closes` keyword: |
| 225 | +- Single issue: `Closes #1234` |
| 226 | +- Multiple issues: `Closes #123, #245, #992` |
| 227 | +
|
| 228 | +**Example:** |
| 229 | +``` |
| 230 | +feat(block): optimize the block-producing logic |
| 231 | + |
| 232 | +1. increase the priority that block producing thread acquires synchronization lock |
| 233 | +2. add the interruption exception handling in block-producing thread |
| 234 | + |
| 235 | +Closes #1234 |
| 236 | +``` |
| 237 | +
|
| 238 | +### Branch Naming Conventions |
| 239 | +
|
| 240 | +1. **Main branches:** Always use `master` and `develop` |
| 241 | +2. **Release branches:** Use version numbers assigned by project lead (e.g., `Odyssey-v3.1.3`, `3.1.3`) |
| 242 | +3. **Hotfix branches:** Use `hotfix/` prefix with brief description, words separated by underscores (e.g., `hotfix/typo`, `hotfix/null_point_exception`) |
| 243 | +4. **Feature branches:** Use `feature/` prefix with brief description, words separated by underscores (e.g., `feature/new_resource_model`) |
| 244 | +
|
| 245 | +### Pull Request Guidelines |
| 246 | +
|
| 247 | +1. **One PR per issue** - Keep changes focused |
| 248 | +2. **Avoid massive PRs** - Break large changes into smaller, reviewable pieces |
| 249 | +3. **Clear title** - Summarize the purpose concisely |
| 250 | +4. **Detailed description** - Help reviewers understand your changes |
| 251 | +5. **Specify feedback needs** - Indicate what kind of review you need |
| 252 | +6. **Title formatting:** |
| 253 | + - Start with a lowercase letter |
| 254 | + - Do not end with a period |
| 255 | +
|
| 256 | +### Special Situations And How To Deal With Them |
| 257 | +
|
| 258 | +**Author doesn't follow up:** |
| 259 | +- Ping them after a few days |
| 260 | +- If no response, close the PR or complete the work yourself |
| 261 | +
|
| 262 | +**Author includes refactoring with bug fix:** |
| 263 | +- Small refactorings are acceptable |
| 264 | +- For large refactorings, request a separate PR or independent commit |
| 265 | +- Ask if the diff is difficult to review |
| 266 | +
|
| 267 | +**Author rejects feedback:** |
| 268 | +- Reviewers have authority to reject changes for technical reasons |
| 269 | +- Seek a second opinion from the team if unsure |
| 270 | +- Close the PR if no consensus can be reached |
| 271 | +
|
| 272 | +## Code of Conduct |
| 273 | +
|
| 274 | +We are committed to providing a welcoming and inclusive environment for all contributors. |
| 275 | +
|
| 276 | +**Positive Behaviors:** |
| 277 | +- Use welcoming and inclusive language |
| 278 | +- Respect differing viewpoints and experiences |
| 279 | +- Accept constructive criticism gracefully |
| 280 | +- Focus on what's best for the community |
| 281 | +- Show empathy towards other community members |
| 282 | +
|
| 283 | +**Unacceptable Behaviors:** |
| 284 | +- Sexualized language, imagery, or unwelcome advances |
| 285 | +- Trolling, insulting comments, or personal/political attacks |
| 286 | +- Public or private harassment |
| 287 | +- Publishing others' private information without permission |
| 288 | +- Other conduct inappropriate in a professional setting |
0 commit comments