docs(dapi): document architecture and implementation
Issue being fixed or feature implemented
We need to share knoweldge about DAPI internal implementation.
What was done?
- Described DAPI archtecture and internal behaviour
How Has This Been Tested?
None
Breaking Changes
None
Checklist:
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have added or updated relevant unit/integration/functional/e2e tests
- [x] I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
- [x] I have made corresponding changes to the documentation if needed
For repository code-owners and collaborators only
- [x] I have assigned this pull request to a milestone
Summary by CodeRabbit
- Documentation
- Added comprehensive new documentation for DAPI, including architecture, endpoint overviews, and detailed API references for core, platform, stream, and JSON-RPC endpoints.
- Introduced new endpoint documentation covering transaction broadcasting, blockchain status, masternode list streaming, consensus parameters, and more.
- Removed outdated and redundant documentation files, configuration references, and OpenAPI definitions.
- Refactor
- Reformatted and reorganized code for improved readability without altering functionality.
- Chores
- Updated internal constants and arrays to reflect recent changes in supported messages and method identifiers.
[!CAUTION]
Review failed
The head commit changed during the review from d2a530b6b516fa5c98d427ffa682f4c91f14c11c to f1872483e66bb7ae11752a3217f6fccc0de657a8.
Walkthrough
This set of changes primarily restructures and expands the documentation for the DAPI (Dash API) package. It introduces detailed new markdown documentation files covering DAPI's architecture, endpoint overviews, and in-depth descriptions of core, platform, stream, and JSON-RPC endpoints. Several older documentation files, including configuration guides and API references, are removed or replaced. Minor source code changes include a reduction in the size of versioned gRPC message arrays in a Rust build script, reordering of method ID constants in a Java gRPC client, and a duplicate trait implementation in a Rust service. No core logic or exported code interfaces are modified.
Changes
| File(s) | Change Summary |
|---|---|
packages/dapi/doc/architecture.md, packages/dapi/doc/index.md, packages/dapi/doc/endpoints/index.md, packages/dapi/doc/endpoints/core/*.md, packages/dapi/doc/endpoints/platform/*.md, packages/dapi/doc/endpoints/streams/*.md, packages/dapi/doc/endpoints/json-rpc/*.md |
Added comprehensive new documentation files describing DAPI architecture, endpoint overviews, and detailed API endpoint behavior for core, platform, stream, and JSON-RPC interfaces. |
packages/dapi/README.md |
Simplified the README by removing detailed instructions and usage examples, leaving a concise overview and documentation links. |
packages/dapi/doc/CONFIGURATION.md, packages/dapi/doc/README.md, packages/dapi/doc/REFERENCE.md, packages/dapi/doc/swaggerDef.js, packages/dapi/doc/dependencies_configs/dash.conf |
Removed legacy documentation and configuration files, including configuration guides, API references, and OpenAPI definitions. |
packages/dapi/doc/endpoints/core/broadcastTransaction.md, packages/dapi/doc/endpoints/core/getBestBlockHeight.md, packages/dapi/doc/endpoints/core/getBlockchainStatus.md, packages/dapi/doc/endpoints/core/getTransaction.md, packages/dapi/doc/endpoints/core/subscribeToMasternodeList.md |
Added new documentation for individual core endpoints, detailing parameters, responses, internal logic, and error handling. |
packages/dapi/doc/endpoints/platform/broadcastStateTransition.md, packages/dapi/doc/endpoints/platform/getConsensusParams.md, packages/dapi/doc/endpoints/platform/getStatus.md, packages/dapi/doc/endpoints/platform/waitForStateTransitionResult.md |
Added new documentation for platform endpoints, including request/response formats, implementation notes, and code flows. |
packages/dapi/doc/endpoints/streams/subscribeToBlockHeadersWithChainLocks.md, packages/dapi/doc/endpoints/streams/subscribeToTransactionsWithProofs.md |
Added new documentation for stream endpoints, describing streaming mechanisms, data formats, and lifecycle management. |
packages/dapi/doc/endpoints/json-rpc/getBestBlockHash.md, packages/dapi/doc/endpoints/json-rpc/getBlockHash.md |
Added new documentation for JSON-RPC endpoints, including request/response formats and internal implementation details. |
packages/dapi-grpc/build.rs |
Reduced the size of the VERSIONED_REQUESTS and VERSIONED_RESPONSES arrays by one element each. |
packages/dapi-grpc/clients/platform/v0/java/org/dash/platform/dapi/v0/PlatformGrpc.java |
Adjusted and reordered method ID constants for platform gRPC methods; updated integer assignments for new and existing methods. |
packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs |
Reformatted function signatures and reorganized import statements; no logic changes. |
packages/rs-drive-abci/src/query/service.rs |
Added a duplicate implementation of the DriveInternal trait for QueryService with identical method logic. |
Sequence Diagram(s)
sequenceDiagram
participant Client
participant DAPI gRPC/JSON-RPC Server
participant Dash Core Node
participant Drive
participant Tenderdash
%% Example: Core endpoint (getBestBlockHeight)
Client->>DAPI gRPC/JSON-RPC Server: Request getBestBlockHeight
alt Cache valid
DAPI gRPC/JSON-RPC Server-->>Client: Return cached block height
else Cache invalid
DAPI gRPC/JSON-RPC Server->>Dash Core Node: getBlockCount RPC
Dash Core Node-->>DAPI gRPC/JSON-RPC Server: Block height
DAPI gRPC/JSON-RPC Server-->>Client: Return block height
end
%% Example: Platform endpoint (broadcastStateTransition)
Client->>DAPI gRPC Server: broadcastStateTransition(stateTransition)
DAPI gRPC Server->>Tenderdash: broadcast_tx(stateTransition)
alt Success
DAPI gRPC Server-->>Client: Success (empty response)
else Error
Tenderdash-->>DAPI gRPC Server: Error details
DAPI gRPC Server-->>Client: Error mapped to gRPC code
end
%% Example: Stream endpoint (subscribeToTransactionsWithProofs)
Client->>DAPI gRPC Server: subscribeToTransactionsWithProofs(bloomFilter)
DAPI gRPC Server->>Dash Core Node: Subscribe to ZMQ events
Dash Core Node-->>DAPI gRPC Server: New block/transaction events
DAPI gRPC Server-->>Client: Stream matching transactions/proofs
Possibly related PRs
- dashpay/platform#2544: Modifies the same versioned request/response arrays in
configure_platform, but by adding message types—effectively the inverse of this PR's removals. - dashpay/platform#2431: Adds new platform RPC methods and updates method ID constants, directly relating to the method ID adjustments in the Java gRPC client and the versioned message arrays.
Poem
In the warren of docs, a rabbit hops, Tidying up the files, old guides it stops. New trails are mapped, with endpoints so clear, From platform to core, all details appear. With arrays trimmed and constants realigned, This bunny leaves no carrot behind. 🥕✨
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.