Skip to content

Commit d9d4673

Browse files
committed
Revise Fundamentals
1 parent 6874659 commit d9d4673

File tree

9 files changed

+224
-87
lines changed

9 files changed

+224
-87
lines changed

docs/fundamentals/accounts.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ tags:
1111

1212
In Parallelchain Mainnet, accounts are divided into two types:
1313

14-
- __Externally Owned Accounts (EOA)__: The address of an EOA is the public key of the keypair that is compatible with `ed25519_dalek`.
15-
- __Contract Accounts__: A contract account is created from contract deployment. The address is the hash of the concatenation of a contract's bytecode and the nonce of the EOA that deploys the contract.
14+
- __Externally Owned Accounts (EOA)__: The address of an EOA is the public key of the keypair that is compatible with [ed25519-dalek](https://github.com/dalek-cryptography/curve25519-dalek/).
15+
- __Contract Accounts__: A contract account is created from contract deployment. The address is the [SHA256](https://en.wikipedia.org/wiki/SHA-2) hash of the concatenation of a contract's bytecode and the nonce of the **EOA** that deploys the contract.
1616

1717
Elements inside an account include:
1818

@@ -25,10 +25,33 @@ The followings are elements that only apply to Contract Accounts:
2525
- **CBI Version**: The version of the Contract Binary Interface.
2626
- **Storage Hash**: The 32-byte SHA256 root hash of its Storage Trie. This is empty for an External.
2727

28+
## How Account Works
29+
30+
You can create **EOA** account by **ed25519-dalek** key generation algorithm. The account is composed of a 32-byte public key and a 32-byte private key. This public key is the **Address** which can be known to others. While your private key, which is used for signing [transactions](transactions.md), **MUST** be kept in secret.
31+
32+
Address is usually displayed in [Base64url](https://datatracker.ietf.org/doc/html/rfc4648#section-5) format in ParallelChain Mainnet ecosystem. Here is an example:
33+
34+
```text
35+
Tc0bU2oS0A0_GrjPKsDLSyVa3gc7PvzwWIAGRk-_SmA
36+
```
37+
38+
If you want to transfer [XPLL](../introduction.md#what-is-xpll) to Alice's account, first you need to know her address. Then, you create a transaction with Alice's address as [recipient](transactions.md#account-commands), and sign it by using your private key. The **Balance** of your and Alice's account will be updated when this signed transaction is made to blockchain successfully. The **Nonce** of your account will be increased by 1.
39+
40+
On the other hand, a **Contract Account** is not made up of cryptographic keys. Its address is a 32-byte hash. It is not able to sign a transaction. But similar to **EOA**, it has its own balance, and can receive XPLL from other accounts. See [Smart Contract](../for_developers/smart_contracts/introduction.md) for details.
41+
2842
!!! Note
29-
These accounts cannot be distinguished from each other just by looking at the address format.
43+
The type of account cannot be distinguished from each other just by looking at the address format.
44+
45+
See also:
46+
47+
- [Create Account by CLI](../for_users/pchain_client_cli/manage_account.md)
48+
- [Create Account by Web Wallet](../for_users/web_wallet/create_account.md)
49+
- [Create Account by Xperience Browser Extension](../for_users/xperience_browser_extension/create_account.md)
50+
51+
52+
## Network Account
3053

31-
A **Network Account** is a single identified network-wide account that maintains the state of ParallelChain Mainnet. This account is not associated with Ed25519 material. The network-significant data that the Network Account stores are composed of various fields:
54+
A **Network Account** is a single identified network-wide account that maintains the [state](nodes.md#world-state) of ParallelChain Mainnet. The purpose of this state is to implement the [staking](staking.md) related protocol. This account is not associated with Ed25519 material. The network-significant data that the Network Account stores are composed of various fields:
3255

3356
- **Previous Validator Set**: The set of pools that form the validator set in the previous epoch. The stake in this validator set is locked until the next epoch.
3457
- **Current Validator Set**: The set of pools that form the validator set in the current epoch.

docs/fundamentals/blocks.md

Lines changed: 101 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ tags:
55

66
# Blocks
77

8-
**Block** is a data structure that describes and authorizes the execution of a batch of transactions (state transitions) on the blockchain.
8+
**Block** is a fundamental data structure in a blockchain. It describes execution of a batch of [transactions](transactions.md). Blocks are "chained" by attaching a cryptographic hash of an earlier block. The hash is the proof of the data integrity of the earlier blocks because if their content have been changed, the hash will not be the same. This is how blockchain provides data immutability.
99

10-
Elements inside a block include:
10+
Summary of the elements inside a block:
1111

1212
- `Hash` - the unique identifier for the block
1313
- `Height` - a number that represents the position of the block on the blockchain
@@ -16,23 +16,116 @@ Elements inside a block include:
1616
- `Chain ID` - a number that identifies a particular Parallelchain Mainnet-based blockchain
1717
- `Proposer` - the public address of the block producer
1818
- `Timestamp` - the time the block was created, measured in seconds since 1970-01-01
19-
- `Base Fee Per Gas` - the minimum number of grays that a transaction must pay for every gas used to be included in the block
19+
- [Base Fee Per Gas](nodes.md#base-fee-per-gas-in-parallelchain-mainnet) - the minimum number of grays that a transaction must pay for every gas used to be included in the block
2020
- `Gas Used` - the amount of [gas](gas.md) used in a block, which is the total sum of the gas used in executing the included transactions
2121
- `Transactions Hash` - the root hash of the Merkle Tree that contains the transactions included in the block
2222
- `Receipt Hash` - the root hash of the Merkle Tree that contains the execution results of the transactions included in the block
2323
- `State Hash` - the root hash of the Merkle Tree that represents the current world state
2424
- `Log Bloom` - a 256-byte block-level [Bloom Filter](https://en.wikipedia.org/wiki/Bloom_filter) that combines all the Bloom Filters of each Log topic from the block's receipts
25-
- `Transactions` - the [transactions](transactions.md) that are included in the block
26-
- `Receipts` - the execution results of the transactions that are included in the block
25+
- [Transactions](transactions.md) - the transactions that are included in the block
26+
- [Receipts](transactions.md#receipt-and-logs) - the execution results of the transactions that are included in the block
2727

28-
A block is a fundamental data structure in a blockchain system that serves as a container for a batch of transactions. It plays a critical role in maintaining the integrity and immutability of the blockchain.
28+
## Inside a Block
2929

3030
Each block contains a unique identifier known as the `block hash`, which is calculated based on the contents of the block. The block hash acts as a fingerprint for the block, making it tamper-evident. Any change to the block's contents would alter its hash, making it easily detectable by network participants.
3131

3232
The block header contains important metadata about the block, including the block's `height`, `timestamp`, and the `address of the block producer`, among others. It also includes Merkle Patricia Tree root hashes for transactions, receipts, and the current state of the blockchain.
3333

34-
Transactions contained within the block are executed by the blockchain system, with the results recorded in `receipts`. These receipts contain information about the execution status of each transaction and are stored in a Merkle Patricia Tree, with the root hash included in the block header.
34+
Transactions contained within the block are executed by the blockchain system, with the results recorded in receipts. These receipts contain information about the execution status of each transaction and are stored in a Merkle Patricia Tree, with the root hash included in the block header.
3535

3636
In addition to transactions and receipts, the block also contains a Bloom filter, which is a probabilistic data structure used to efficiently query logs associated with the transactions contained in the block.
3737

38-
Overall, block is an essential component of a blockchain system, providing a secure and reliable means of recording and validating transactions while ensuring the immutability and integrity of the blockchain.
38+
Example of a block queried by [ParallelChain Client CLI](../for_users/pchain_client_cli/introduction.md):
39+
40+
```json
41+
{
42+
"header": {
43+
"chain_id": 10000,
44+
"block_hash": "Yn0SAN6KDA3v2uDjN_j1P_tFCCqgqCbak1g7zvHwr9Q",
45+
"height": 2844080,
46+
"justify": {
47+
"chain_id": 10000,
48+
"view": 2844930,
49+
"block": "zT3iUT2sCmD80ztBDScBlAvUXhbzba7RTLtSiBLsvRg",
50+
"phase": "Generic",
51+
"signatures": {
52+
"signatures": [
53+
"hin8bfLnbuuUBRVB7GbClI0g1Ad0rfM_oDfvYILhwKPG_eqqZEDVyNj1c1VZeeRuUW94pqEQzAqbz4zQuTz0Dg",
54+
"5usLkVtsEsFCIHQOKi8X_LjvMxzBd4xxJJz7QSbl1pGLimFUkpV5MCBi1SGRY9jVHCArxu6v3B_jn3xCZfhrCg",
55+
null,
56+
null,
57+
"XqLSsQP6YkvtbBpPo7NX4o2Q7GvjAU-5dHfKPiDrdIBZPzTric_LvqJCgZLemUmzKkELkUl9BCBtFLth61qhAg",
58+
null,
59+
null,
60+
null,
61+
"PWhCgGM_SQpEf3NTZIdEIHecaFEd9MHptZqUyM4l7J4oR5aMrxkPYLRQ89msWfRtCF6fSvYVLZhTR-FjcIJqBg",
62+
"lLnEWWKxoToD-URLN7PDWFBQTyC1waS9KHBAskgdXdn_bZIyr3XYoqxIbTcHW6f0m6qozQGkZTXQukGbi08fCA"
63+
]
64+
}
65+
},
66+
"data_hash": "Tr4Z99mUiaHGVuzW5eyZ73bKqEXUcYPV1C5RkUVCP2U",
67+
"timestamp": 1711515120,
68+
"base_fee": 8,
69+
"txs_hash": "wDUDiSjWumCmyEu_Fz0H8zqs3jSlpCMxN2NnST7fieM",
70+
"state_hash": "rU3ilPOG1Lr-4fYtGTHpSXsMvZM8v0l5JX3PgK-wauc",
71+
"receipts_hash": "uXRT1micHUt7orVPifaFg5BvOQJLd9K4mNAFo0zW0x4",
72+
"proposer": "TY0vjFcDm681NupNBVSU9DKNunP6JlwNNhc7lDJ2uU0"
73+
},
74+
"transactions": [
75+
{
76+
"commands": [
77+
{
78+
"Transfer": {
79+
"recipient": "kxrCl32WEzr7gr4Awb3jAMQtoh5zY8grabqlu-x42jY",
80+
"amount": 2000000000
81+
}
82+
}
83+
],
84+
"signer": "qPReY5x_DPKAx1v30UrU1x1RI61Wd2OxeZo2eSWcjMU",
85+
"priority_fee_per_gas": 0,
86+
"gas_limit": 67500000,
87+
"max_base_fee_per_gas": 8,
88+
"nonce": 428,
89+
"hash": "dOrjtT7o5Y97mlLJFaCvdNUq6UgVQItVYGXHPoDw5n4",
90+
"signature": "RLM3k5VDDzBqkQ7ios4TMP9LwL50n8hNQ7OjH-wcTE0Ts6F3uWDaA5J52sCyYr3aGGGElXKiIatqH15qVwMUAA"
91+
}
92+
],
93+
"receipts": [
94+
[
95+
{
96+
"status_code": "Success",
97+
"gas_used": 32820,
98+
"return_values": "",
99+
"logs": []
100+
}
101+
]
102+
]
103+
}
104+
```
105+
106+
## How Block Works
107+
108+
Blocks are produced by validator [Nodes](nodes.md). To produce a block, the node executes transactions and creates receipts as a result of execution. The transactions and receipts become the content of a block, and the node will then compute the metadata such as `block height`, `timestamp`, hashes, etc. in the block header.
109+
110+
When a block is created by a node, the validator nodes will validate it and then agree on the block content through a [consensus mechanism](consensus_mechanism.md). An agreed block is said to be **committed**. If the block is invalid, it will not be part of the blockchain. Nodes will keep producing new blocks, and this process repeats within a time interval (i.e. block time). As a result, the blockchain grows with more and more blocks.
111+
112+
## Epoch Block
113+
114+
**Epoch Block** is a special block created by executing a transaction with [Next Epoch Command](transactions.md#protocol-commands). This special block signifies the last block in an **Epoch**.
115+
116+
Epoch is a protocol-defined period for measuring the performance of operators on the blockchain network.
117+
118+
The primary purpose of epochs in a blockchain is to facilitate various network functionalities and maintain consensus among network participants by defining a common reference point, which could be utilized to validate transactions. During one epoch, there would be block creation and block addition to the blockchain.
119+
120+
In the ParallelChain Mainnet ecosystem, an `epoch` is defined by a predetermined block height or the number of blocks added to the blockchain, which is 8640. When a specific block height is reached or another 8640 blocks are added to the blockchain, the blockchain network would move from the current epoch to the next. The epoch transition could trigger critical events:
121+
122+
- Reward stakes in Current Validator Set
123+
- *Increase deposits* of owner and operator
124+
- *Update stakes* if auto-stake-rewards is enabled
125+
126+
- Replacing Previous Validator Set with Current Validator Set
127+
- Replacing Current Validator Set with Next Validator Set
128+
- Returning Next Validator Set for the next leader selection
129+
130+
Epoch transition ensures that only one set of validators is active on the blockchain network at any given time, which makes the information on the blockchain tamper-proof.
131+

docs/fundamentals/consensus_mechanism.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ HotStuff guarantees that committed Blocks are *immutable*. That is, they can nev
1818

1919
![A graphic depicting a Tree (DAG) of Blocks. Blocks are coloured depending on how many confirmations they have.](../img/BlockTree%20Structure%20Diagram.png)
2020

21-
A Block becomes *committed* the instant its third confirmation is written into the BlockTree. Confirmation for a Block `A` is another Block `B` such that there is a path between `B` to `A`.
21+
A Block becomes **committed** the instant its third confirmation is written into the BlockTree. Confirmation for a Block `A` is another Block `B` such that there is a path between `B` to `A`.
2222

2323
The choice of third confirmation to define commitment--as opposed to first or second--is not arbitrary. HotStuff's safety and liveness properties hinge upon this condition. You can read this [paper](https://github.com/parallelchain-io/hotstuff_rs/blob/master/readme_assets/HotStuff%20paper.pdf) to learn more about it. To summarize:
2424

docs/fundamentals/epoch.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

docs/fundamentals/gas.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ tags:
1111

1212
There are different categories of gas cost in the ParallelChain Mainnet ecosystem:
1313

14-
- WASM opcode execution inside a contract call
14+
- WASM opcode execution inside a contract [call](transactions.md#account-commands)
1515
- Reading and writing WASM memory from host functions inside a contract call
1616
- Transaction-related data storage
17-
- World state storage and access
17+
- [World state](nodes.md#world-state) storage and access
1818
- Cryptographic operations
1919

2020
Details about gas can be found in [ParallelChain Mainnet Protocol](https://github.com/parallelchain-io/parallelchain-protocol/blob/master/Gas.md).

docs/fundamentals/networks.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ tags:
1414

1515
**ParallelChain Mainnet** is a high-performance blockchain designed for enterprise-level use cases. It provides a platform for developers to build decentralised applications (dApps) with its efficient smart contract execution engine.
1616

17-
It is designed to balance high performance and genuine decentralization. It is protected by the ParallelBFT consensus protocol, which adopts a sophisticated class-based node system to ensure fast and accountable consensus.
17+
It is designed to balance high performance and genuine decentralization. It is protected by the a Byzantine Fault Tolerant (BFT) consensus protocol, which adopts a sophisticated class-based node system to ensure fast and accountable consensus.
1818

1919
For more information about the consensus protocol, please read the section [Consensus Mechanism](./consensus_mechanism.md).
2020

2121
## ParallelChain Testnet
2222

2323
To ensure the new features in ParallelChain Mainnet have what it takes to survive decentralised deployment, they must first be battle-tested. This is where ParallelChain Testnet comes into play by allowing developers, or simply users, to develop and run smart contracts or transactions on ParallelChain and experiment with the blockchain, at no cost.
2424

25-
The current testnet iteration delivers on Byzantine Fault Tolerant (BFT) consensus, the cornerstone of security in ParallelChain's proof-of-stake network. Besides this, Testnet 4 delivers big leaps in the contract SDK and developer experience, as well as a web Wallet.
2625
Both Mainnet and Testnet are accessible through [Explorer](#parallelchain-explorer). But only onTestnet, a service called [Faucet Service](#faucet-service) provides free tokens to users.
2726

2827
## Accessing the Networks
@@ -50,13 +49,13 @@ What you can do:
5049

5150
### Xperience Browser Extension
5251

53-
**Xperience Browser Extension** is a browser extension that allows you to integrate your [dApp](../../for_developers/xperience_browser_provider_apis/introduction) with ParallelChain Wallet.
52+
**Xperience Browser Extension** is a browser extension that allows you to integrate your [dApp](../for_developers/xperience_browser_provider_apis/introduction.md) with ParallelChain Wallet.
5453

5554
This enables your dapp to interact with your dapp users' XPLL accounts, to:
5655

5756
- Send [transactions](transactions.md)
5857
- [Stake](staking.md) XPLL
59-
- Trigger confirmation for [smart contract](../../for_developers/smart_contracts/introduction) calls
58+
- Trigger confirmation for [smart contract](../for_developers/smart_contracts/introduction.md) calls
6059

6160
**The browser extension is available on the [Chrome Web Store](https://chromewebstore.google.com/detail/xperience-browser-extensi/gpfllmjckejjhmmdmgbgmclmhopekjpf) now.**
6261

0 commit comments

Comments
 (0)