Skip to content

Commit 54116f4

Browse files
feat(docs): add readmes (#814)
1 parent 983e359 commit 54116f4

File tree

15 files changed

+425
-404
lines changed

15 files changed

+425
-404
lines changed
Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
# TFChain Pallet Burning
1+
# Burning Module
22

3-
Pallet for burning functionality.
3+
Pallet for burning tokens. Anyone can freely burn tokens, but the tokens are lost forever.
44

5-
## Building
5+
## Interface
66

7-
`cargo build`
7+
Dispatchable functions of this pallet.
88

9-
## Testing
10-
11-
`cargo test`
12-
13-
## Spec
14-
15-
[spec](./spec.md)
16-
17-
## Flow Diagram
18-
19-
[flow](./flow.md)
9+
- `burn_tft` - Burn a given amount of TFT.

substrate-node/pallets/pallet-dao/README.md

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,55 @@
1-
# TFChain Pallet DAO
1+
# DAO Module
22

3-
Pallet for DAO proposals and voting.
3+
Pallet for a DAO (decentralised autonomous organisation) proposals and voting. This pallet is tightly coupled with a configured [collective](https://github.com/paritytech/substrate/tree/master/frame/collective) and with [Tfgrid module](../pallet-tfgrid/readme.md).
44

5-
## Proposals
5+
## Overview
6+
7+
The DAO module provides functions for:
8+
9+
- Creating Proposals
10+
- Voting on Proposals
11+
- Closing Proposals
12+
- Vetoing Proposals (X amount of veto votes will close and dissaprove a proposal)
13+
14+
## Terminology
15+
16+
- Council member: a member of the [collective](https://github.com/paritytech/substrate/tree/master/frame/collective)
17+
- Proposal: A proposal is a request to execute an extrinsic on chain. A proposal can be created by a [council member](../../../docs/misc/minimal_DAO.md). This proposal has a threshold, a link to a forum post, a duration specified in amount of blocks, a description and an extrinsic to execute.
18+
- Vote: farmer can vote for a proposal. A vote has a weight based on the farmers stake in the network. One vote by default is 1 weight. If the farmer has nodes, the weight of the vote is calulcated as following: Sum of all nodes of the farmer: (node CU * 2 + node SU)
19+
- Veto: council members can veto a proposal, a proposal is vetod when majority of council members vote to veto a proposal. A veto closes and dissaproves a proposal.
20+
21+
## Implementations
22+
23+
This pallet implements a trait `ChangeNode`. Specifically it implements:
24+
25+
- `node_changed`: registers or updates a node's voting weight in storage
26+
- `node_deleted`: deleted a node's voting weight
27+
28+
This trait's functions can be called by other modules to trigger changes in the voting weights of nodes.
29+
30+
### Addendum on Proposals
631

732
Proposals can be created by members of the council. A proposal can include the following properties:
833

934
- Extrinsic to execute (pricing change, connection price change, runtime upgrade, ..)
1035
- Description of the proposals
1136
- Link to a webpage / github markdown / wiki file, ...
1237
- Threshold: amount of farmers that need to vote to have a valid proposal
38+
- Duration: specified in amount of blocks
1339

1440
When a "generic" proposal needs to be executed, the extrinsic `system.setRemark` needs to be selected. The remark itself is up to the council member to choose.
1541
This is because a proposal needs to have an extrinsic attached.
16-
A proposal duration is set by the config trait `MotionDuration` on this pallet, this value needs to be expressed in number of blocks.
42+
A proposal default duration is set by the config trait `MotionDuration` on this pallet, this value needs to be expressed in number of blocks.
1743

18-
A proposal can be closed either when threshold of votes is met or proposal duration ended.
19-
Only a council member can close a proposal.
44+
A proposal can be closed either when threshold of votes is met or proposal duration ended. Only a council member can close a proposal.
2045
Based on the voting result the proposal can be either approved(executed) or dissaproved.
2146

22-
## Voting
23-
24-
Any farmer on chain can vote for proposals. Votes are weighted based on the farmers stake in the network. One vote by default is 1 weight.
25-
26-
If the farmers has nodes, the weight of the vote is calulcated as following:
27-
28-
- Sum of all nodes of the farmer: (node CU * 2 + node SU)
29-
30-
## Building
47+
## Interface
3148

32-
`cargo build`
49+
Dispatchable functions of this pallet.
3350

34-
## Testing
51+
- `propose` - Create a proposal
52+
- `vote` - Vote for a proposal
53+
- `veto` - Veto a proposal
54+
- `close` - Close a proposal
3555

36-
`cargo test`
Lines changed: 105 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,105 @@
1-
# Threefold key-value store
2-
This is a key-value store which can be used by users as a database on the blockchain
3-
the user can simply set,get and remove values
1+
# Threefold Key-value Store Pallet
2+
3+
The Key-value Store Pallet is a module that enables storing key-value pairs on the blockchain, where the key is a unique identifier and the value is the data payload.
4+
5+
Some use cases for this module are storing user profiles, preferences, or settings; storing metadata or configuration data for other modules or dapps; storing encrypted or hashed data for privacy or security purposes. The Key-value Store Pallet provides a simple and efficient way to store and access arbitrary data on the blockchain, without relying on any intermediaries or centralized servers.
6+
7+
## Overview
8+
9+
The Key-value Store Pallet provides [dictionary-like data storage](https://paritytech.github.io/substrate/master/frame_support/storage/trait.StorageDoubleMap.html#) and functions for:
10+
- Storing key-value pairs.
11+
- Retrieving the value associated with the specified key.
12+
- Removing a value associated with the specified key.
13+
14+
The key value store uses under hood a map with two keys
15+
16+
*(Key1, Key2) -> Value*
17+
18+
**Key1** is provided by the runtime set to the account that signed the extrinsic. **Key2** and **Value** are user provided
19+
20+
You can think of the key1 as namespace that make it easier to come up with unique names which distinguished from other accounts' names.
21+
22+
The key value store pallet impose restrictions on the size of the keys and values. see [Assumptions](#assumptions) section.
23+
24+
## Terminology
25+
- Key-value store: A key-value store, or key-value database is a simple database that uses an associative array (think of a map or dictionary) as the fundamental data model where each key is associated with one and only one value in a collection. This relationship is referred to as a key-value pair.
26+
27+
## Implementations
28+
NA
29+
30+
## Interface
31+
### Dispatchable Functions
32+
- `set(key: Vec<u8>, value: Vec<u8>)` store value for a pair of keys (key1, key2) in the store. The first key is automatically set to the account ID of the signer of the transaction, while the second key is given by the user. This way, you can assign ownership of a key to the account that created it, and also use freely any name for a key that might be already taken by someone else. If the key pair already exists in the store, the value is overwritten with the new one. Emits `EntrySet` event.
33+
34+
- `delete(key: Vec<u8>)` remove a value stored under a pair of keys (key1, key2) from the store. The first key is automatically set to the account ID of the sender of the transaction, while the second key is given by the user. so by design, only the owner of a key pair can delete it from the store. Emits `EntryTaken` event.
35+
36+
37+
### Events
38+
- `EntrySet(T::AccountId, Vec<u8>, Vec<u8>)` The value for the specified key has been stored/updated.
39+
- `EntryGot(T::AccountId, Vec<u8>, Vec<u8>)` The value for the specified key has been queried. (This Event Defined But Not Used By the runtime)
40+
- `EntryTaken(T::AccountId, Vec<u8>, Vec<u8>)` The value stored under the specified key has been removed.
41+
42+
All events included account id, the user key name and the value.
43+
44+
### Errors
45+
- `NoValueStored` The double key (Account ID, Provided Key) is not in the `StorageDoubleMap`
46+
- `KeyIsTooLarge` The key length exceed the maximum length. see [Assumptions](#assumptions) section.
47+
- `ValueIsTooLarge` The key length exceed the maximum length. see [Assumptions](#assumptions) section.
48+
49+
## Config
50+
```rust
51+
pub trait Config: Config {
52+
type RuntimeEvent: From<Event<Self>> + IsType<<Self as Config>::RuntimeEvent>;
53+
type WeightInfo: WeightInfo;
54+
}
55+
```
56+
57+
The main purpose of this trait is to act as an interface between this pallet and the runtime in which it is embedded in. A type, function, or constant in this trait is essentially left to be configured by the runtime that includes this pallet.
58+
59+
Consequently, a runtime that wants to include this pallet must implement this trait.
60+
61+
### Required Associated Types
62+
```rust
63+
type RuntimeEvent: From<Event<Self>> + IsType<<Self as Config>::RuntimeEvent>
64+
```
65+
66+
The overarching event type.
67+
68+
```rust
69+
type WeightInfo: WeightInfo
70+
```
71+
72+
Weight information for extrinsics in this pallet.
73+
74+
## Usage
75+
The following example shows how to use the key value store pallet in your runtime:
76+
```rust
77+
// Import the key value store pallet
78+
pub use pallet_kvstore;
79+
80+
// Add it to your runtime configuration
81+
construct_runtime!(
82+
pub enum Runtime where
83+
Block = Block,
84+
NodeBlock = opaque::Block,
85+
UncheckedExtrinsic = UncheckedExtrinsic
86+
{
87+
// ...
88+
KeyValueStore: pallet_kvstore::{Pallet, Call, Storage, Event<T>},
89+
}
90+
);
91+
92+
// Implement the config trait for the key value store pallet
93+
impl pallet_kvstore::Config for Runtime {
94+
type RuntimeEvent = RuntimeEvent;
95+
type WeightInfo = pallet_kvstore::weights::SubstrateWeight<Runtime>;
96+
}
97+
```
98+
## Genesis config
99+
NA
100+
101+
## Assumptions
102+
- The key length must not exceed 512 bytes.
103+
- The value length must not exceed 2048 bytes.
104+
- The user is responsible for ensuring the uniqueness of the key within their account, otherwise the previous value associated with the key will be replaced or updated.
105+
- The stored information is publicly accessible and queryable. This means that anyone can see your data without your permission. The user must not store any sensitive information unencrypted, such as personal details, passwords, credit card numbers, or confidential information. Doing so can have serious consequences. Please use encryption tools to protect your sensitive data before storing it on this store.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Runtime upgrade module
2+
3+
A wrapper pallet for [frame-system](https://github.com/paritytech/substrate/tree/master/frame/system) specifically the `set_code` action. This action replaces the runtime code with the new code.
4+
5+
## Config
6+
7+
- `SetCodeOrigin` - The origin that can call the `set_code` action
8+
9+
## Interface
10+
11+
Dispatchable functions of this pallet.
12+
13+
- `set_code` - Set the runtime code (Can only by signed by a configurable Origin in the Config)
Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,55 @@
1-
# TFChain Pallet Smart Contract
2-
3-
Pallet for smart contract functionality.
4-
5-
## Building
6-
7-
`cargo build`
8-
9-
## Testing
10-
11-
`cargo test`
12-
13-
## Spec
14-
15-
[spec](./spec.md)
16-
17-
## Flow Diagram
18-
19-
[flow](./flow.md)
1+
# Smart Contract Module
2+
3+
A pallet for Threefold "smart contracts". A smart contract is an agreement between a user and a [ZOS](https://github.com/threefoldtech/zos) node that is enforced by the blockchain. The smart contract module is responsible for the creation, billing and deletion of smart contracts.
4+
5+
This module is tightly coupled with the [Tfgrid module](../pallet-tfgrid/readme.md) and the [Tft Price Module](../pallet-tft-price/readme.md).
6+
7+
## Overview
8+
9+
The smart contract module provides functions for:
10+
11+
- Creating / Updating / Canceling a smart contract
12+
- Reporting resource usage for a smart contract
13+
- Creating / Approving solution providers
14+
- Creating / Updating / Canceling a Service Contract
15+
- Setting an extra price for a dedicated ZOS node
16+
- Billing all sorts of contracts based on a pricing policy defined in the [Tfgrid module](../pallet-tfgrid/readme.md) and a TFT price fetched in the [Tft Price Module](../pallet-tft-price/readme.md)..
17+
18+
The billing is triggered by an offchain worker that runs after a block is created. This offchain worker relies on the `aura` key in the keystore to sign the transaction triggers the billing. This means that only valid block creators can sign this transaction. Given this configuration this pallet will only work in an Aura / Grandpa based chains.
19+
20+
For a more in depth view of this module, see [spec](./spec.md).
21+
22+
## Terminology
23+
24+
- [ZOS](https://github.com/threefoldtech/zos): a Zero-OS node that is running on a physical machine.
25+
- Smart Contract: an agreement between a user and a ZOS node that is enforced by the blockchain. This can be any of:
26+
- `NodeContract`: An agreement between a user and a ZOS node for the usage of resources on that node.
27+
- `NameContract`: An agreement between a user and a ZOS node for the usage of a dns name on that node using a gateway.
28+
- `RentContract`: An agreement between a user and a ZOS node for the usage of the entire node.
29+
- `ServiceContract`: An agreement between a user and an external service provider for the usage of a service.
30+
- Solution provider: a provider of a solution, see [solution provider](./solution_provider.md)
31+
32+
## Interface
33+
34+
Dispatchable functions of this pallet.
35+
36+
- `create_node_contract` - Create a node contract
37+
- `update_node_contract` - Update a node contract
38+
- `create_name_contract` - Create a name contract
39+
- `create_rent_contract` - Create a rent contract
40+
- `cancel_contract`: Cancel a contract (any of the smart contract type)
41+
- `add_nru_reports`: Reports network resource usage from ZOS to the chain
42+
- `report_contract_resources`: Reports a `NodeContract` used resources (nru, cru, mru, sru, ipu) to the chain.
43+
- `create_solution_provider`: Create a solution provider
44+
- `approve_solution_provider`: Approve a solution provider, the origin for this call is a configurable origin.
45+
- `bill_contract_for_block`: Triggers the billing of a contract on this block.
46+
- `service_contract_create`: Create a service contract
47+
- `service_contract_set_metadata`: Set metadata for a service contract
48+
- `service_contract_set_fees`: Set fees for a service contract
49+
- `service_contract_approve`: Approve a service contract
50+
- `service_contract_reject`: Reject a service contract
51+
- `service_contract_cancel`: Cancel a service contract
52+
- `service_contract_bill`: Bill a service contract
53+
- `change_billing_frequency`: Change the billing frequency of all contracts, the origin for this call is a configurable origin.
54+
- `attach_solution_provider_id`: Attach a solution provider id to a contract
55+
- `set_dedicated_node_extra_fee`: Set an extra fee for a dedicated node

0 commit comments

Comments
 (0)