Skip to content

Commit

Permalink
Worked on reviewed contents and added missing examples and content
Browse files Browse the repository at this point in the history
  • Loading branch information
rutvikghaskata18 committed Jul 1, 2024
1 parent aa38db0 commit 6399cdc
Show file tree
Hide file tree
Showing 11 changed files with 509 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Contracts using ACS0 need to implement these methods:
|--------------|--------------|----------------------------------|
| `address` | `aelf.address` | Contract code byte array. |
| `old_author` | `aelf.address` | Contract code category (0: C#). |
| `CrossChainCreateToken` | `aelf.address` | Indicates if the contract is the system contract. |

#### acs0.CodeCheckRequired

Expand Down Expand Up @@ -114,25 +115,20 @@ Contracts using ACS0 need to implement these methods:
| `is_system_contract`| `bool` | Is it a system contract? |
| `version` | `int32` | Contract version. |
| `contract_version` | `string` | Contract version. |
| `contract_type` | `string` | Contract type. |
| `deployed_by` | `aelf.Address` | Deployer address. |
| `deployed_on` | `google.protobuf.Timestamp` | Deployment time. |
| `is_user_contract` | `bool` | Indicates if the contract is the user contract. |

#### acs0.ContractProposed

| Field | Type | Description |
|---------------------|--------------|----------------------------------|
| `proposed_contract_input_hash` | `aelf.Hash` | The id of the proposed contract.|

#### acs0.ContractUpdateInput

| Field | Type | Description |
|---------------------|--------------|----------------------------------|
| `address` | `aelf.Address` | Contract address. |
| `code` | `bytes` | Contract code byte array. |
| `category` | `sint32` | Contract code category (0: C#). |
| `is_system_contract`| `bool` | Is it a system contract? |
| `is_user_contract` | `bool` | Is it a user contract? |

#### acs0.ReleaseContractInput

| Field | Type | Description |
|-------------|------------|--------------------------------|
| `proposal_id` | `aelf.Hash` | Proposal ID to be released. |

#### acs0.SetContractAuthorInput

Expand All @@ -141,21 +137,43 @@ Contracts using ACS0 need to implement these methods:
| `address` | `aelf.Address` | Contract address. |
| `author` | `aelf.Address` | New author address. |

#### acs0.ReleaseContractInput

| Field | Type | Description |
|-------------|------------|--------------------------------|
| `proposal_id` | `aelf.Hash` | Proposal ID to be released. |
| `proposed_contract_input_hash` | `aelf.Hash` | The id of the proposed contract. |

#### acs0.SystemContractDeploymentInput

| Field | Type | Description |
|-----------------|--------------|----------------------------------|
| `category` | `sint32` | Contract code category (0: C#). |
| `code` | `bytes` | Contract code byte array. |
| `name` | `aelf.Hash` | Contract name (must be unique). |
| `transaction_method_call_list` | `aelf.Hash` | SystemContractDeploymentInput.SystemTransactionMethodCallList |

#### acs0.SystemContractDeploymentInput.SystemTransactionMethodCall

| Field | Type | Description |
|------------------------|--------------|----------------------------------|
| `method_name` | `string` | The method name of system transaction. |
| `params` | `aelf.Address` | The params of system transaction method.|


#### acs0.SystemContractDeploymentInput.SystemTransactionMethodCallList

| Field | Type | Description |
|------------------------|--------------|----------------------------------|
| `value` | `SystemContractDeploymentInput.SystemTransactionMethodCall` | The list of system transactions.|


#### acs0.ValidateSystemContractAddressInput

| Field | Type | Description |
|------------------------|--------------|----------------------------------|
| `system_contract_hash_name` | `aelf.Hash` | Contract name hash. |
| `address` | `aelf.Address` | Contract address. |

#### aelf.Address

| Field | Type | Description |
Expand Down
136 changes: 136 additions & 0 deletions docs/learn/acs-introduction/acs3-contract-proposal-standard/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,142 @@ ACS3 is used when a method needs multiple approvals. Implement these methods for
| proposer | aelf.Address | Proposer address | |
| organization_address| aelf.Address | Organization address | |

#### acs3.Address
| Field | Type | Description | Label |
| ------------------- | ------------- | ------------------------ | ----- |
| value | bytes | | |

#### acs3.BinaryMerkleTree
| Field | Type | Description | Label |
| ------------------- | ------------- | ------------------------ | ----- |
| nodes | Hash | The leaf nodes. | |
| root | Hash | The root node hash. | |
| leaf_count | int32 | The count of leaf node. | |

#### acs3.Hash
| Field | Type | Description | Label |
| ------------------- | ------------- | ------------------------ | ----- |
| value | bytes | | |

#### acs3.LogEvent
| Field | Type | Description | Label |
| ------------------- | ------------- | ------------------------ | ----- |
| address | Address | The contract address. | |
| name | string | The name of the log event.| |
| indexed | bytes | The indexed data, used to calculate bloom. | repeated |
| non_indexed | bytes | The non indexed data. | |

#### acs3.MerklePath
| Field | Type | Description | Label |
| ------------------- | ------------- | ------------------------ | ----- |
| merkle_path_nodes | MerklePathNode| The merkle path nodes. |repeated|

#### acs3.MerklePathNode
| Field | Type | Description | Label |
| ------------------- | ------------- | ------------------------ | ----- |
| hash | Hash | The node hash. | |
| is_left_child_node | bool | Whether it is a left child node.| |

#### acs3.SInt32Value
| Field | Type | Description | Label |
| ------------------- | ------------- | ------------------------ | ----- |
| value | sint32 | | |

#### acs3.SInt64Value
| Field | Type | Description | Label |
| ------------------- | ------------- | ------------------------ | ----- |
| value | sint64 | | |

#### acs3.ScopedStatePath
| Field | Type | Description | Label |
| ------------------- | ------------- | ------------------------ | ----- |
| address | Address | The scope address, which will be the contract address. | |
| path | StatePath | The path of contract state. | |

#### acs3.SmartContractRegistration
| Field | Type | Description | Label |
| ------------------- | ------------- | ------------------------ | ----- |
| category | sint32 | The category of contract code(0: C#). | |
| code | bytes | The byte array of the contract code. | |
| code_hash | Hash | The hash of the contract code. | |
| is_system_contract | bool | Whether it is a system contract. | |
| version | int32 | The version of the current contract. | |

#### acs3.StatePath
| Field | Type | Description | Label |
| ------------------- | ------------- | ------------------------ | ----- |
| parts | string | The partial path of the state path.|repeated|


#### acs3.Transaction

| Field | Type | Description |
| ------------------- | ------------- | ------------------------ |
| from | Address | The address of the sender of the transaction. |
| to | Address | The address of the contract when calling a contract. |
| ref_block_number | int64 | The height of the referenced block hash. |
| ref_block_prefix | bytes | The first four bytes of the referenced block hash. |
| method_name | string | The name of a method in the smart contract at the To address. |
| params | bytes | The parameters to pass to the smart contract method. |
| signature | bytes | When signing a transaction it’s actually a subset of the fields: from/to and the target method as well as the parameter that were given. It also contains the reference block number and prefix. |


#### acs3.TransactionExecutingStateSet

| Field | Type | Description | Label |
| ------------------- | ------------- | ------------------------ | -------- |
| writes | TransactionExecutingStateSet.WritesEntry | The changed states. | repeated |
| reads | TransactionExecutingStateSet.ReadsEntry | The read states. | repeated |
| deletes | TransactionExecutingStateSet.DeletesEntry| The deleted states. | repeated |


#### acs3.TransactionExecutingStateSet.DeletesEntry

| Field | Type | Description |
| ------------------- | ------------- | ------------------------ |
| key | string | |
| value | bool | |


#### acs3.TransactionExecutingStateSet.ReadsEntry

| Field | Type | Description |
| ------------------- | ------------- | ------------------------ |
| key | string | |
| value | bool | |

#### acs3.TransactionExecutingStateSet.WritesEntry

| Field | Type | Description |
| ------------------- | ------------- | ------------------------ |
| key | string | |
| value | bool | |

#### acs3.TransactionResult

| Field | Type | Description | Label |
| ------------------- | ------------- | ------------------------ | ------- |
| transaction_id | Hash | The transaction id. | |
| status | TransactionResultStatus | The transaction result status.| |
| logs | LogEvent | The log events. |repeated |
| bloom | bytes | Bloom filter for transaction logs. A transaction log event can be defined in the contract and stored in the bloom filter after the transaction is executed. Through this filter, we can quickly search for and determine whether a log exists in the transaction result.| |
| return_value | bytes | The return value of the transaction execution.| |
| block_number | int64 | The height of the block hat packages the transaction.| |
| block_hash | Hash | The hash of the block hat packages the transaction.| |
| error | string | Failed execution error message.| |

#### acs3.TransactionResultStatus

| Field | Number | Description |
| ------------------- | ------ | ------------------------ |
| NOT_EXISTED | 0 | The execution result of the transaction does not exist.|
| PENDING | 1 | The transaction is in the transaction pool waiting to be packaged.|
| FAILED | 2 | Transaction execution failed. |
| MINED | 3 | The transaction was successfully executed and successfully packaged into a block.|
| CONFLICT | 4 | When executed in parallel, there are conflicts with other transactions.|
| PENDING_VALIDATION | 5 | The transaction is waiting for validation.|
| NODE_VALIDATION_FAILED | 6 | Transaction validation failed.|

## Implementation

Assume there's only one organization in a contract, so no need to define the Organization type. Voters must use a token to vote. We'll focus on the core methods: CreateProposal, Approve, Reject, Abstain, and Release.
Expand Down
30 changes: 30 additions & 0 deletions docs/learn/consensus/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ In aelf, the consensus protocol has two parts: election and scheduling. Election
## Core Data Center
Core Data Centers, also known as Miners or Block Producers, act like parliament members in the aelf blockchain. aelf has 2N+1 Core Data Centers, starting with 8 and increasing by 1 each year. These nodes enforce aelf’s consensus rules, relay transactions, confirm transactions, package blocks, and transfer data. They also act as miners for some Side Chains and are elected by ELF token holders.

![image](../../../static/img/consensus-1.png)

In the AElf system, nodes enforce all consensus rules. These delegated mining nodes handle transaction relay, confirmation, block packaging, and data transfer. AElf uses a multi-Side Chain architecture, so Core Data Centers act as miners for some Side Chains. Each week, 2N+1 nodes are arranged in a randomized order.

All Core Data Centers are elected by ELF token holders. Voters can lock their ELF tokens to vote for a specific Validate Data Center, boosting its chances in the election process.

## Validate Data Center
Anyone can join the election by locking ELF tokens. The top (2N+1)*5 nodes become Validate Data Centers, with N starting at 8 and increasing by 1 each year.

Expand All @@ -24,6 +30,30 @@ aelf operates in units called "rounds." In each round, one Core Data Center prod

![Round](/img/consensus-2.webp)

In each round, one Core Data Center node produces one block, and one node gets an extra transaction at the end of the round.

Each mining node has three main properties during a specific round 𝑡:

#### 1. Private Key (in_node(t)):

- This value is inputted and kept private by the mining node during round 𝑡.
- It becomes public after all blocks in round 𝑡 are generated.


#### 2. Public Key (out_node(t)):

- This is the hash of the private key (in_node(t)).
- Every node in the AElf network can look up this value at any time.


#### 3. Signature (sig_node(t)):

- This value is generated by the mining node in the first round.
- In subsequent rounds, it is calculated after the previous round is completed.
- It acts as the node's signature for the round and is always publicly accessible, like the out_node(t).



### Main Processes

#### Pre-Verification
Expand Down
Loading

0 comments on commit 6399cdc

Please sign in to comment.