-
Notifications
You must be signed in to change notification settings - Fork 0
goshard: add qkc types design doc #155
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
blockchaindevsh
wants to merge
3
commits into
main
Choose a base branch
from
qkc-3-types-design-doc
base: main
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.
+83
−0
Open
Changes from all commits
Commits
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 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,83 @@ | ||
| # qkc-3-types design doc | ||
|
|
||
| ## Goal | ||
|
|
||
| Add QuarkChain's basic type layer under `qkc/types`: hash/RLP helpers, token balances, logs, receipts, transactions, and root/minor blocks. | ||
|
|
||
| This series only adds standalone QKC types and byte-compatible encoding/hash behavior. It does not wire these types into `core/state`, `core/types`, EVM execution, block import, or P2P/RPC. | ||
|
|
||
| ## Scope | ||
|
|
||
| In scope: standalone QKC wire/type definitions for hashes, token balances, logs, receipts, transactions, and root/minor blocks. The transaction PR adds transaction encoding, hashing, signing, and sender recovery as type-level behavior only. | ||
|
|
||
| Out of scope: using these types in execution, state transition, account storage, block import, P2P/RPC, snapshot/pathdb/history, or MNT account integration. | ||
|
|
||
| ## Boundary | ||
|
|
||
| `qkc/types` may depend on geth's general utilities such as `common`, `crypto`, `rlp`, `trie`, and isolated base types. Geth core packages should not depend on `qkc/types` in this series. | ||
|
|
||
| This keeps the dependency direction clear: | ||
|
|
||
| ```text | ||
| qkc/types -> geth utilities | ||
| geth core/state/vm -> no qkc/types dependency in this series | ||
| ``` | ||
|
|
||
| If later PRs need QKC data in geth core, they should add explicit adapters or a QKC-specific integration layer instead of directly mixing package responsibilities. | ||
|
|
||
| ## TokenBalances note | ||
|
|
||
| MNT PRs also define `TokenBalances`, but that type is for account/state-account encoding. The `qkc/types` version is used by QKC block/header wire types, especially `CoinbaseAmount`. | ||
|
|
||
| They should not be blindly merged by making `qkc/types` depend on `core/types`. The balance representation should still align with modern geth/MNT (`uint256.Int` internally), while `qkc/serialize` boundaries can convert to the historical wire bytes. If we want one canonical type later, it should move to a neutral QKC package first, then both users can depend on it. | ||
|
|
||
| ## PR split | ||
|
|
||
| All PRs are stacked; each one is based on the previous one. | ||
| Each PR should be reviewable on its own: why it is needed and what later PR depends on it. | ||
|
|
||
| 1. `qkc-3-types-01-hash-utils` | ||
| - Title: `qkc/types: add hash and rlp helpers` | ||
| - Why needed: later receipts, transactions, and blocks all need pyquarkchain-compatible hash/RLP helpers before their golden-vector tests can be meaningful. | ||
| - Adds: `DeriveSha`, `CalculateMerkleRoot`, `serHash`, and QKC `Uint32` RLP. | ||
|
|
||
| 2. `qkc-3-types-02-token-balances` | ||
| - Title: `qkc/types: add token balances` | ||
| - Why needed: QKC block/header wire types reference token balance bytes, especially `CoinbaseAmount`, but this PR does not model account-state storage. | ||
| - Adds: QKC token balance container and encoding for block/header usage. | ||
|
|
||
| 3. `qkc-3-types-03-logs-receipts` | ||
| - Title: `qkc/types: add logs and receipts` | ||
| - Why needed: minor blocks need receipt/log wire encoding, receipt roots, and header bloom values before block types can be verified. | ||
| - Adds: QKC logs, receipts, bloom integration, and receipt storage/wire encoding. | ||
|
|
||
| 4. `qkc-3-types-04-transactions` | ||
| - Title: `qkc/types: add transactions and signing` | ||
| - Why needed: minor blocks contain QKC transactions, and block hash/root tests need transaction encoding, hashing, signing, and sender recovery to match pyquarkchain. | ||
| - Adds: EVM transactions, cross-shard transactions, signing, and ABI helpers. | ||
|
|
||
| 5. `qkc-3-types-05-blocks` | ||
| - Title: `qkc/types: add root and minor blocks` | ||
| - Why needed: this is the first PR that composes the earlier standalone types into QKC root/minor block headers and block bodies. | ||
| - Adds: root/minor block headers, metadata, blocks, copy/hash helpers. | ||
|
|
||
| ## Testing | ||
|
|
||
| Use pyquarkchain-generated golden vectors for consensus-critical bytes and hashes whenever possible. Do not only recompute expected values with the same Go helpers under test. | ||
|
|
||
| Coverage should include: | ||
|
|
||
| - hash helpers, `Uint32`, `DeriveSha`, `CalculateMerkleRoot` | ||
| - token balance encoding and round trips | ||
| - log/receipt RLP, storage encoding, bloom, status handling | ||
| - transaction RLP, serialize, hash, signing/sender recovery | ||
| - root/minor block serialization, hash, seal hash, copy behavior | ||
| - invalid inputs: bad RLP prefix/length, invalid receipt status, invalid signature, nil/empty cases | ||
|
|
||
| Deferred to later integration PRs: | ||
|
|
||
| - state/account trie root | ||
| - receipt root from real execution receipts | ||
| - MNT account encoding with snapshot/pathdb/history | ||
| - block import and state transition | ||
| - P2P/RPC wire integration | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m a little unclear about the scope of this PR series. As I understand it, the current scope covers only blocks, not transactions, and also excludes the features listed under
Deferred to later integration PRs, such asMNT account encoding with snapshot/pathdb/historyandP2P/RPC wire integration. Is that correct?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scope includes standalone transaction types as well, not only blocks.
The transaction PR defines transaction data structures and their type-level behavior only: encoding, hashing, signing, and sender recovery. It does not wire transactions into txpool, execution, state transition, block import, P2P, or RPC.
I updated the doc with an explicit
Scopesection to make this clearer.