Skip to content

Commit

Permalink
0.7.5 pre (#269)
Browse files Browse the repository at this point in the history
* readme: update tee-worker readme

* fix: div zero bug

* feat: challenge starts in 3 days

* update cess-testnet chain spec
  • Loading branch information
ytqaljn authored Nov 30, 2023
1 parent 6ede050 commit 3db93d7
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 16 deletions.
8 changes: 8 additions & 0 deletions c-pallets/audit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,11 @@ pub mod pallet {
fn generate_challenge(now: BlockNumberOf<T>) -> Weight {
let mut weight: Weight = Weight::zero();

let one_day = T::OneDay::get();
if now < one_day.saturating_mul(3u32.saturated_into()) {
return weight;
}

weight = weight.saturating_add(T::DbWeight::get().reads(1));
let miner_list = match T::MinerControl::get_all_miner() {
Ok(miner_list) => miner_list,
Expand Down Expand Up @@ -1002,6 +1007,9 @@ pub mod pallet {
let one_hour = T::OneHours::get();
weight = weight.saturating_add(T::DbWeight::get().reads(1));
let tee_length = T::TeeWorkerHandler::get_controller_list().len();
if tee_length == 0 {
return weight;
}
let verify_life: u32 = (idle_space
.saturating_add(service_space)
.saturating_div(IDLE_VERIFY_RATE)
Expand Down
20 changes: 20 additions & 0 deletions c-pallets/cess-treasury/src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Cess Treasury Module

Manage meta information of cess-treasury.

## Terminology

## Extrinsic


## Interface

### TeeWorkerHandler


#### Usage


## Implementation Details

###
61 changes: 50 additions & 11 deletions c-pallets/tee-worker/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,61 @@
# File Map Module
# Tee Worker Module

Store scheduling related information
Manage meta information of tee-worker.

### Terminology
## Terminology

* **Ip:** Scheduled IP address.
* **EndPoint:** The ip+port of tee-worker, or the domain name of tee-worker. Selected independently by tee-workers.
* **StashAccount:** Staking account when bond a consensus node.
* **ControllerAccount:** The control account bound when registering the consensus node, used for work transaction signatures.
* **Podr2Pbk:** The only public key shared between tee-workers in the entire network.
* **SgxAttestationReport:** The SGX report certificate applied for tee-worker certification is provided by Inter.

## Extrinsic
* `register()` - The extrinsic used for tee-worker registration requires bond to become a consensus before registration. The report will be verified in Extrinsic to confirm that the registrant is a legitimate sgx.
* `update_whitelist()` - Used to support iterative updates of sgx. When the internal code of sgx is updated, the new identification code needs to be added to the whitelist.
* `exit()` - Tee worker exit function, when the last tee worker exits, the only public key in the entire network will be cleared. However, this function will not affect the unbundling of consensus stashes.
* `update_podr2_pk()` - Method to update root permissions of the only public key in the entire network.
* `force_register()` - Forced registration of tee workers through root privileges will ignore a series of qualification certifications such as verification reports. After mainnet login, this method will be removed

## Interface
### Trait
#### TeeWorkerHandler

### TeeWorkerHandler

A series of methods for finding consensus scheduling.
* `contains_scheduler` - Judge whether the controller account exists.
* `get_controller_acc` - Obtain controller account through stash account.
* `get_controller_list` - Get the list of controller accounts of currently registered tee workers.
* `get_first_controller` - Get the first consensus in the list.
### Dispatchable Functions
* `get_tee_publickey` - Get the network-wide unique public key of the tee worker to verify the signature of sgx.
* `punish_scheduler` - Punish tee workers and deduct credibility points.

#### Usage
in pallet::Config
```rust
pub trait Config:
frame_system::Config + sp_std::fmt::Debug
{
//...
type TeeWorkerHandler: TeeWorkerHandler<Self::AccountId>;
//...
}
```
in runtime.rs
```rust
impl pallet_audit::Config for Runtime {
//...
type TeeWorkerHandler = TeeWorker;
//...
}
```

## Implementation Details

### Verify SGX report
Use the `verify_miner_cert` method to verify sgx reports. The method uses the third-party library webpki internally to verify the sgx report. At the same time, it will also check whether the custom information of tee worker in the report is legal.

Custom information includes the following:
* `sign` - the certificate signature.
* `cert_der` - certificate.
* `report_json_raw` - the json format string of the report.
* `identity_hash` - some basic registration information of tee worker, which is composed of peer_id, podr2_pbk, end_point, and finally the hash value calculated by sha2_256 algorithm.

* `registration_scheduler` - The interface for scheduling registration has no special restrictions at present.
* `update_scheduler` - Consensus Method for Updating IP Endpoints.
* `init_public_key` - Initialize the public key related to the certificate.
8 changes: 5 additions & 3 deletions node/ccg/cess-testnet-spec-raw.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// `spec_version`, and `authoring_version` are the same between Wasm and native.
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
// the compatible custom types.
spec_version: 107,
spec_version: 100,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down Expand Up @@ -626,7 +626,7 @@ parameter_types! {
pub const ProposalBondMinimum: Balance = 1 * DOLLARS;
// For TESTING
pub const SpendPeriod: BlockNumber = 1 * MINUTES;
pub const Burn: Permill = Permill::from_percent(50);
pub const Burn: Permill = Permill::from_percent(0);
pub const TipCountdown: BlockNumber = 1 * DAYS;
pub const TipFindersFee: Percent = Percent::from_percent(20);
pub const TipReportDepositBase: Balance = 1 * DOLLARS;
Expand Down

0 comments on commit 3db93d7

Please sign in to comment.