litentry / tee-worker

Based on the integritee-network/worker framework
Apache License 2.0
4 stars 2 forks source link

Read/write storage in `stf_task_thread` #110

Closed ziming-zung closed 2 years ago

ziming-zung commented 2 years ago

We have a dedicated thread stf_task_thread used for the sync handling of stf-tasks.

We need to find a way to read/write the sp-io storage in it.

The implementation of reading could be:

let mut stf_state: StfState = state_handler.load(&default_shard_identifier).unwrap();
stf_state.execute_with(||{
    let key = storage_double_map_key(
        "IdentityManagement",
        "ChallengeCodes",
        &self.verification_request.target,
        &StorageHasher::Blake2_128Concat,
        &self.verification_request.identity,
        &StorageHasher::Blake2_128Concat,
    );
       log::warn!("storage--key: {:?}", key);  
       let code: Option<u32> = ita_stf::helpers::get_storage_by_key_hash(key);
       log::warn!("code: {:?}", code);
});

What about the writing? We need to consider apply_update Can we call pallet storage getter/setter instead? Like ita_sgx_runtime::IdentityManagement::challenge_codes(...)

Kailai-Wang commented 2 years ago

I take it

Kailai-Wang commented 2 years ago

I read the code in more detail and wrote this doc: https://www.notion.so/web3builders/Sidechain-block-importer-and-block-production-28292233b4c74f4ab8110a0014f8d9df