diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 74940a5a754..00000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,26 +0,0 @@ -version: 2 -jobs: - build: - branches: - only: - - master - - develop - - addinCircleCI - - docker: - - image: circleci/openjdk:8-jdk-browsers - working_directory: ~/java-tron - steps: - - checkout - - run: - name: multi_os_result - command: echo "curl http://60.205.215.34/multi_os_result" -# -# - run: -# name: Daily Build Report -# command: curl http://47.95.206.44:50080/Daily_Build_Task_Report -# -# - run: -# name: Download Links -# command: sh DownloadLinks.sh - diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 6d82a3ae6a9..00000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,13 +0,0 @@ - - -### 1. What did you do? - - - -### 2. What did you expect to see? - - - -### 3. What did you see instead? - - diff --git a/.github/ISSUE_TEMPLATE/ask-a-question.md b/.github/ISSUE_TEMPLATE/ask-a-question.md new file mode 100644 index 00000000000..e503998b477 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/ask-a-question.md @@ -0,0 +1,10 @@ +--- +name: Ask a question +about: Something is unclear +title: '' +labels: 'type:docs' +assignees: '' + +--- +This should only be used in very rare cases e.g. if you are not 100% sure if something is a bug or asking a question that leads to improving the documentation. For general questions please use [Discord](https://discord.gg/cGKSsRVCGm) or [Telegram](https://t.me/TronOfficialDevelopersGroupEn). + diff --git a/.github/ISSUE_TEMPLATE/report-a-bug.md b/.github/ISSUE_TEMPLATE/report-a-bug.md new file mode 100644 index 00000000000..a0d68121565 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/report-a-bug.md @@ -0,0 +1,50 @@ +--- +name: Report a bug +about: Create a report to help us improve +title: '' +labels: 'type:bug' +assignees: '' + +--- + + + + + +#### Software Versions + + + + +#### Expected behaviour + + + +#### Actual behaviour + + + +#### Frequency + + +#### Steps to reproduce the behaviour + +1. [Step 1] +2. [Step 2] +3. [Step ...] + +#### Backtrace + +```` +[backtrace] +```` + +When submitting logs: please submit them as text and not screenshots. diff --git a/.github/ISSUE_TEMPLATE/request-a-feature.md b/.github/ISSUE_TEMPLATE/request-a-feature.md new file mode 100644 index 00000000000..261f1088ded --- /dev/null +++ b/.github/ISSUE_TEMPLATE/request-a-feature.md @@ -0,0 +1,28 @@ +--- +name: Request a feature +about: Suggest an idea for this project +title: '' +labels: 'type:feature' +assignees: '' + +--- +# Background + +# Rationale + +Why should this feature exist? + +What are the use-cases? + +# Specification + +# Test Specification + +# Scope Of Impact + + +# Implementation + +Do you have ideas regarding the implementation of this feature? + +Are you willing to implement this feature? diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000000..4ab98d5cf3c --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,64 @@ +name: "CodeQL" + +on: + push: + branches: [ 'develop', 'master', 'release_**' ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ 'develop' ] + schedule: + - cron: '6 10 * * 0' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'java' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" diff --git a/.gitignore b/.gitignore index b980800f353..3917bb44679 100644 --- a/.gitignore +++ b/.gitignore @@ -31,7 +31,6 @@ shareddata.* # protobuf generated classes src/main/gen - src/main/java/org/tron/core/bftconsensus src/test/java/org/tron/consensus2 src/main/java/META-INF/ @@ -55,3 +54,6 @@ Wallet # vm_trace /vm_trace/ + +/framework/propPath +.cache diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7a3b00d2ece..00000000000 --- a/.travis.yml +++ /dev/null @@ -1,45 +0,0 @@ -sudo: required -dist: trusty -language: java -dist: trusty -jdk: oraclejdk8 -addons: - ssh_known_hosts: - - 47.93.42.145:22008 - - 47.93.42.145:22008 - - 47.93.42.145:22008 - - 47.93.18.60:22008 - - 47.93.18.60:22008 - - 47.93.18.60:22008 - sonarcloud: - organization: tron-zhaohong - token: - secure: "KXWEeQ1elAoQ0XfR54TQWfhrIdDP0+2CYPv2X9aWpU/YDl7hqZBAjcCOAUGvlbyM54jtG6YMaWwG48jlrOwwl5l/VjWSnUXF+7ixQy5ki0Ci9s7Y1pTQwV9SpL8TLIK2TYqabN8Mw+FJULASXLjYr9GerbbcUbCPTmcL6mQKw6ivxxpNPmz4eNoKAEuOzruO9fTXGAV3yr8Nn85c+mVxV8EUhkR17zpE9O8fvzOtSnYArWNOSCgDBn0EG45UNNPF2vn44s1c3h3gX1m3WK6PeCXPgy3hPqRn3wTG+xglnbqthGpo2wt1rJ83af+BwdYwvPEcUq84yLgXcE/aMkTKcVAfPWBP/6vblaoI90jxCeFji+MdMimKZAqIXt7oLqDZVmIq65de5YC5s7QTSbzJNY/tsAu3dqzSfbUJY6CRNFDcoenVpvgQkqb37TkDah4mJM8EUjbu2A9Q2HSFbyCVsQJtdasuu9cBOf6azK3U0XgFNBc0y2aziZrTnX30q7bi+5L/mbTnRdXrDqBOqyPeGtT77UZfcajHHmEWU/e6gYWiA/c+K25n13DD53Au6gpnnQ6ALeUl/1gDwz3fPBebJ5bVWrkIcLj7bbysjzfOvQmDS6G13RNz58Hm0/B7bVtZTr1E1q6Z1zEJwbuJYEJASNcezAfK5x/hIfZTGNqT3M8=" -cache: - directories: - - '$HOME/.sonar/cache' -matrix: - include: - - name: build - script: - - sh tron.sh - - "./gradlew build" - - "./gradlew jacocoTestReport" - - - - name: stest - script: - - sh tron.sh - - bash deploy.sh - - -after_success: - - "bash <(curl -s https://codecov.io/bash)" - -skip_build: - - README.md: - - LICENSE - - - - diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e4f431da551..d8dc83ad51b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,83 +1,245 @@ # Contributing to java-tron -java-tron is an open source project. +java-tron is an open-source project which needs the support of open-source contributors. -It is the work of contributors. We appreciate your help! +Below are the instructions. We understand that there is much left to be desired, and if you see any room for improvement, please let us know. Thank you. -Here are instructions to get you started. They are not perfect, so -please let us know if anything feels wrong or incomplete. +Here are some guidelines to get started quickly and easily: +- [Reporting An Issue](#Reporting-An-Issue) +- [Working on java-tron](#Working-on-java-tron) + - [Key Branches](#Key-Branches) + - [Submitting Code](#Submitting-Code) +- [Code Review Guidelines](#Code-Review-Guidelines) + - [Terminology](#Terminology) + - [The Process](#The-Process) + - [Code Style](#Code-Style) + - [Commit Messages](#Commit-Messages) + - [Branch Naming Conventions](#Branch-Naming-Conventions) + - [Pull Request Guidelines](#Pull-Request-Guidelines) + - [Special Situations And How To Deal With Them](#Special-Situations-And-How-To-Deal-With-Them) +- [Conduct](#Conduct) -## Contribution guidelines -First of all, java-tron follows GitFlow, the branches description in the java-tron project are listed as follow: -- ``master`` branch: -This branch contains the latest code released to the production environment. It can only be merged, and can not be modified directly in this branch. +### Reporting An Issue -- ``develop`` branch: -This branch is the main development branch. It contains the complete code that is going to release. It can only be merged, and can not be modified directly in this branch. +If you're about to raise an issue because you think you've found a problem or bug with java-tron, please respect the following restrictions: -- ``feature`` branch: -This branch is used to develop new features. It is created based on ``develop`` branch. Once the development is finished, it should be merged into ``develop`` branch, and then delete the branch. +- Please search for existing issues. Help us keep duplicate issues to a minimum by checking to see if someone has already reported your problem or requested your idea. -- ``release`` branch: -This is the branch that is going to be released. It is created based on ``develop`` branch. In this branch, small fix and modification of final version of metadata is allowed. When the code is released, this branch should be merged into ``master`` branch (tag needed) and ``develop`` branch. The final test before release uses this branch. +- Use the Issue Report Template below. + ``` + 1.What did you do? -- ``hotfix`` branch: -This branch is used to fix a bug when an online bug is found. It is created based on ``master`` branch. When bug fix is done, it should be merged into ``master`` branch(as a new release) and ``develop`` and then delete the branch. branch. + 2.What did you expect to see? -### Pull requests + 3.What did you see instead? + ``` -If you'd like to contribute to java-tron, you should follow the steps below: -- **Fork** a repository from **tronprotocol/java-tron** allows you to freely experiment with changes without affecting the original project -- **Fix** some code and **Commit** your modified code. -- **Send** a Pull Request(PR)for the maintainers to review and merge into the main code base. - *notice*:When you create a new PR,please choose the **tronprotocol/java-tron** as the base repository and choose **your fork/java-tron** as the head repository. - And you must choose **develop** as the base repository branch, which means we will merge the PR into our **develop** branch when reviewed and approved. - Additionally, if you are writing a new feature, please ensure you add appropriate test cases under ``/src/test``. -After the PR is checked by our Sonar check procedure and Travis CI continuous-integration check procedure automaticly, -we maintainers will review the code changed and give some advices for modifying if necessary.Once approved, -we will close the PR and merge into the protocol/java-tron's develop branch. +## Working on java-tron +Thank you for considering to help out with the source code! We welcome contributions from anyone on the internet, and are grateful for even the smallest of fixes! -We are always happy to receive pull requests, and do our best to -review them as fast as possible. Not sure if that typo is worth a pull -request? Do it! We would appreciate it. +If you’d like to contribute to java-tron, for small fixes, we recommend that you send a pull request (PR) for the maintainers to review and merge into the main code base, make sure the PR contains a detailed description. For more complex changes, you need to submit an issue to the TIP repository to detail your motive and implementation plan, etc. For how to submit a TIP issue, please refer to [TIP Specification](https://github.com/tronprotocol/tips#to-submit-a-tip). -If your pull request is not accepted on the first try, don't be -discouraged as it can be a possible oversight. Please explain your code as -detailed as possible to make it easier for us to understand. -Please make sure your contributions adhere to our coding guidelines: +As the author of TIP issue, you are expected to encourage developers to discuss this issue, flesh out your issue by collecting their feedback, and eventually put your issue into practice. -- Code must be documented adhering to the [Google Style](https://google.github.io/styleguide/javaguide.html) -- Code must pass Sonar detection. -- Pull requests need to be based on and opened against the develop branch. -- Commit messages should be started with verb, and the first letter should be a lowercase.The length of commit message -must be limited in 50 words. -### Create issues -Any significant improvement should be documented as [a GitHub -issue](https://github.com/tronprotocol/java-tron/issues) before anyone -starts working on it. +### Key Branches +java-tron only has `master`, `develop`, `release-*`, `feature-*`, and `hotfix-*` branches, which are described below: -When filing an issue, make sure to answer these three questions: +- ``develop`` branch + The `develop` branch only accept merge request from other forked branches or`release_*` branches. It is not allowed to directly push changes to the `develop` branch. A `release_*` branch has to be pulled from the develop branch when a new build is to be released. -- What did you do? -- What did you expect to see? -- What did you see instead? +- ``master`` branch + `release_*` branches and `hotfix/*` branches should only be merged into the `master` branch when a new build is released. -### Please check existing issues and docs first! +- ``release`` branch + `release_*` is a branch pulled from the `develop` branch for release. It should be merged into `master` after a regression test and will be permanently kept in the repository. If a bug is identified in a `release_*` branch, its fixes should be directly merged into the branch. After passing the regression test, the `release_*` branch should be merged back into the `develop` branch. Essentially, a `release_*` branch serves as a snapshot for each release. -Please take a moment to check that your bug report or improvement proposal -doesn't already exist. If it does, please add a quick "+1" or "I have this problem too". -This will help prioritize the most common problems and requests. +- ``feature`` branch + `feature/*` is an important feature branch pulled from the `develop` branch. After the `feature/*` branch is code-complete, it should be merged back to the `develop` branch. The `feature/*` branch is maintainable. -## Community Developers Incentives Programme +- ``hotfix`` branch + It is pulled from the `master` branch and should be merged back into the master branch and the `develop` branch. Only pull requests of the fork repository (pull requests for bug fixes) should be merged into the `hotfix/` branch. `hotfix/` branches are used only for fixing bugs found after release. -Bonus point applies in TRON incentives programme. Developers can earn points by contributing to TRON. -You can find your points ranking at [Tronscan](https://tronscan.org/#/developersreward). +### Submitting Code -The Top 5 scored developers (for every month, quarter and year) can win a cash reward. +If you want to contribute codes to java-tron, please follow the following steps: -For more details, please visit [Incentives Policy](https://tronprotocol.github.io/documentation-en/developers/incentives/). +* Fork code repository + Fork a new repository from tronprotocol/java-tron to your personal code repository + +* Edit the code in the fork repository + ``` + git clone https://github.com/yourname/java-tron.git + + git remote add upstream https://github.com/tronprotocol/java-tron.git ("upstream" refers to upstream projects repositories, namely tronprotocol's repositories, and can be named as you like it. We usually call it "upstream" for convenience) + ``` + Before developing new features, please synchronize your fork repository with the upstream repository. + ``` + git fetch upstream + git checkout develop + git merge upstream/develop --no-ff (Add --no-ff to turn off the default fast merge mode) + ``` + + Pull a new branch from the develop branch of your repository for local development. Please refer to [Branch Naming Conventions](#Branch-Naming-Conventions), + ``` + git checkout -b feature/branch_name develop + ``` + + Write and commit the new code when it is completed. Please refer to [Commit Messages](#Commit-Messages) + ``` + git add . + git commit -m 'commit message' + ``` + Commit the new branch to your personal remote repository + ``` + git push origin feature/branch_name + ``` + +* Push code + + Submit a pull request (PR) from your repository to `tronprotocol/java-tron`. + Please be sure to click on the link in the red box shown below. Select the base branch for tronprotocol and the compare branch for your personal fork repository. + ![image](https://raw.githubusercontent.com/tronprotocol/documentation-en/master/images/javatron_pr.png) + + + +## Code Review Guidelines +The only way to get code into java-tron is to send a pull request. Those pull requests need to be reviewed by someone. The following guide explains our expectations around PRs for both authors and reviewers. + +### Terminology +- The author of a pull request is the entity who wrote the diff and submitted it to GitHub. +- The team consists of people with commit rights on the java-tron repository. +- The reviewer is the person assigned to review the diff. The reviewer must be a team member. +- The code owner is the person responsible for the subsystem being modified by the PR. + +### The Process +The first decision to make for any PR is whether it’s worth including at all. This decision lies primarily with the code owner, but may be negotiated with team members. + +To make the decision we must understand what the PR is about. If there isn’t enough description content or the diff is too large, request an explanation. Anyone can do this part. + +We expect that reviewers check the style and functionality of the PR, providing comments to the author using the GitHub review system. Reviewers should follow up with the PR until it is in good shape, then approve the PR. Approved PRs can be merged by any code owner. + +When communicating with authors, be polite and respectful. + +### Code Style +We would like all developers to follow a standard development flow and coding style. Therefore, we suggest the following: +1. Review the code with coding style checkers. +2. Review the code before submission. +3. Run standardized tests. + +`Sonar`-scanner and `Travis CI` continuous integration scanner will be automatically triggered when a pull request has been submitted. When a PR passes all the checks, the **java-tron** maintainers will then review the PR and offer feedback and modifications when necessary. Once adopted, the PR will be closed and merged into the `develop` branch. + +We are glad to receive your pull requests and will try our best to review them as soon as we can. Any pull request is welcome, even if it is for a typo. + +Please kindly address the issue you find. We would appreciate your contribution. + +Please do not be discouraged if your pull request is not accepted, as it may be an oversight. Please explain your code as detailed as possible to make it easier to understand. + +Please make sure your submission meets the following code style: + +- The code must conform to [Google Code Style](https://google.github.io/styleguide/javaguide.html). +- The code must have passed the Sonar scanner test. +- The code has to be pulled from the `develop` branch. +- The commit message should start with a verb, whose initial should not be capitalized. +- The commit message should be less than 50 characters in length. + + + +### Commit Messages + +Commit messages should follow the rule below, we provide a template corresponding instructions. + +Template: +``` +(): + + + +