-
Notifications
You must be signed in to change notification settings - Fork 1.7k
docs: add AGENTS.md and reorganize project documentation #6871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Sunny6889
wants to merge
12
commits into
tronprotocol:develop
Choose a base branch
from
Little-Peony:fix_readme
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
773ab21
docs(readme): add Documentation section linking guides and protocol doc
Little-Peony 1a3bafc
docs(config): add super-representative private-key security notes
Little-Peony cbf9eae
docs: move protocol document into docs/ with a shorter name
Little-Peony 0ca2740
docs: move metrics changelog into docs/ and link from README
Little-Peony c020830
docs: mark outdated protobuf protocol copies as superseded
Little-Peony f2fb426
chore(ci): remove unused CodeClimate and Sonar configs
Little-Peony acac4d5
delete .dockerignore
Little-Peony f966422
modify chinese
Little-Peony 8ead205
docs: drop stale Sonar references and fix metrics changelog link
Little-Peony 565ae0f
chore: remove unused Sonar entries from verification-metadata
Little-Peony 84c44b6
docs: add AGENTS.md for AI assistants and contributors
Little-Peony 0ca52e5
docs: correct AGENTS.md platform and build details
Little-Peony File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| # AGENTS.md | ||
|
|
||
| Guidance for AI coding assistants and new contributors working on java-tron: how to build, test, and navigate the codebase, plus the high-frequency constraints to respect. For running a node, see the [README](./README.md) and [`docs/`](./docs). | ||
|
|
||
| ## Working principles | ||
|
|
||
| - Keep changes minimal and focused: only touch code related to the task. Do not refactor unrelated code, rename for style, or bundle unrelated fixes into one commit/PR. | ||
| - Do not add, remove, or upgrade dependencies unless the task requires it — dependency changes in a consensus node are high-risk and need separate review. | ||
|
|
||
| ## Build & Test | ||
|
|
||
| Supported platforms: **Linux** and **macOS** only. JDK requirement is by CPU architecture: **JDK 8** on x86_64, **JDK 17** on ARM64/aarch64 (e.g. Apple Silicon Macs, or Linux aarch64 servers such as AWS Graviton). The build fails fast if the JDK major version does not match the architecture. | ||
|
|
||
| ```bash | ||
| ./gradlew clean build -x test # build without tests | ||
| ./gradlew build # build with tests | ||
| ./gradlew test # run all tests | ||
| ./gradlew :framework:test # test one module | ||
| ./gradlew test --tests "org.tron.core.db.TronDatabaseTest" # one class | ||
| ./gradlew test --tests "org.tron.core.db.TronDatabaseTest.testX" # one method | ||
| ./gradlew :framework:testWithRocksDb # RocksDB tests (x86 only) | ||
| ./gradlew lint # Checkstyle (framework main only) | ||
| ./gradlew checkstyleMain checkstyleTest # Checkstyle main + test (as CI runs) | ||
| ./gradlew jacocoTestReport # coverage report | ||
| ``` | ||
|
|
||
| - Main entry point: `org.tron.program.FullNode`. | ||
| - Tests run in parallel locally, serially in CI (detected via the `CI` env var); the test-retry plugin retries up to 5 times. | ||
| - On ARM64/aarch64, only the RocksDB storage engine is supported; the build forces RocksDB and skips the LevelDB tests. | ||
| - Protobuf / gRPC Java stubs are generated at build time from the `.proto` files under `protocol/src/main/protos/` (subdirectories `core/`, `api/`; via the `com.google.protobuf` Gradle plugin) and are git-ignored — rebuild after changing a `.proto`; never hand-edit or commit generated sources. | ||
|
|
||
| **Before pushing:** | ||
| - `./gradlew checkstyleMain checkstyleTest` and `./gradlew test` must pass. | ||
| - Do not commit build artifacts or byproducts — `*.jar`, `build/`, logs, or database files. | ||
|
|
||
| ## Module Layout | ||
|
|
||
| | Module | Responsibility | | ||
| |--------|----------------| | ||
| | `framework` | Main entry (`org.tron.program.FullNode`); wires all modules; largest test suite | | ||
| | `protocol` | Protobuf / gRPC definitions | | ||
| | `chainbase` | Blockchain storage abstraction (LevelDB / RocksDB); snapshot & rollback | | ||
| | `consensus` | Pluggable DPoS consensus engine | | ||
| | `actuator` | Transaction execution; one Actuator class per transaction type | | ||
| | `crypto` | Cryptographic primitives (depends only on `common`) | | ||
| | `common` | Shared utilities | | ||
| | `platform` | Architecture-specific implementations selected at build time (separate `x86` / `arm` / `common` source sets): math wrappers, LevelDB/RocksDB order-price comparators — relevant to cross-JVM determinism | | ||
| | `plugins` | Standalone tools (`Toolkit.jar`, `ArchiveManifest.jar`) | | ||
|
|
||
| **Module dependency direction is one-way — do not introduce reverse dependencies:** | ||
|
|
||
| ```text | ||
| framework → chainbase → common → protocol | ||
| actuator → chainbase | ||
| consensus → chainbase / common (only via ConsensusDelegate; never call Manager directly) | ||
| crypto → common | ||
| ``` | ||
|
|
||
| `platform` is a leaf module (no project dependencies of its own) that `common`, `framework`, and `plugins` depend on for architecture-specific code. | ||
|
|
||
| ## Hard Constraints | ||
|
|
||
| **Cross-JVM determinism** (consensus, state transition, block ordering): | ||
| - Never use `float` / `double`. | ||
| - Never depend on `HashMap` iteration order for a business decision. | ||
| - Use the DPoS slot time for produced-block timestamps, not `System.currentTimeMillis()`. | ||
|
|
||
| **DB / Store:** | ||
| - All writes must happen inside a `Session` / `Dialog` — no bare `put()`. | ||
| - A new store must extend `TronStoreWithRevoking<T>` and register with the `RevokingDatabase`. | ||
| - Multi-store updates must roll back fully on exception. | ||
|
|
||
| **Actuator:** | ||
| - Register new actuators in `ActuatorFactory`. | ||
| - Charge fees before `execute()`. | ||
| - `validate()` must not mutate state. | ||
|
|
||
| **Protobuf:** | ||
| - Fields may only be added — never removed or renumbered. | ||
| - Message field numbers start at `1`; the first enum value must be `0`. | ||
|
|
||
| **API / Threads:** | ||
| - New HTTP servlets must go through `HttpApiAccessFilter` and use `Wallet` (never inject `Manager` directly). | ||
| - New gRPC methods must join the `LiteFnQueryGrpcInterceptor` chain. | ||
| - No bare `new Thread()` — use a named Executor, shut down via `shutdown()` → `awaitTermination()` → `shutdownNow()`. | ||
|
|
||
| ## Authoritative Documentation | ||
|
|
||
| - **Build / run / node operation:** [README](./README.md) | ||
| - **Configuration:** [`docs/configuration.md`](./docs/configuration.md), [`docs/configuration-conventions.md`](./docs/configuration-conventions.md) | ||
| - **Protobuf protocol:** [`docs/protobuf-protocol-document.md`](./docs/protobuf-protocol-document.md) is the maintained reference (the copies under `protocol/src/main/protos/` are outdated). | ||
| - **Extending / deployment:** the [`docs/`](./docs) directory (customized actuator, modular deployment). | ||
| - **Contributing:** [CONTRIBUTING.md](./CONTRIBUTING.md) (workflow, coding style, commit/PR conventions). | ||
| - **Security policy:** [SECURITY.md](./SECURITY.md) (supported versions, vulnerability disclosure). | ||
|
|
||
| ## Commit Convention | ||
|
|
||
| `type(scope): description` (Conventional Commits), 10–72 chars, no trailing period. | ||
|
|
||
| - **type:** `feat` `fix` `refactor` `docs` `style` `test` `chore` `ci` `perf` `build` `revert` | ||
| - **scope:** `framework` `chainbase` `actuator` `consensus` `common` `crypto` `plugins` `protocol` `net` `db` `vm` `tvm` `api` `jsonrpc` `rpc` `http` `event` `config` `block` `proposal` `trie` `log` `metrics` `test` `docker` `version` | ||
| - **PR title:** same `type(scope): description` convention; fill in `.github/PULL_REQUEST_TEMPLATE.md`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,3 @@ | ||
| plugins { | ||
| id "org.sonarqube" version "2.6" | ||
| } | ||
|
|
||
| apply plugin: 'application' | ||
| apply plugin: 'checkstyle' | ||
|
|
||
|
|
||
2 changes: 2 additions & 0 deletions
2
protocol/src/main/protos/Chinese version of TRON Protocol document.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
protocol/src/main/protos/English version of TRON Protocol document.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.