Skip to content
This repository was archived by the owner on Jan 2, 2023. It is now read-only.
This repository was archived by the owner on Jan 2, 2023. It is now read-only.

Improve nonce handling in StfEnclaveSigner #121

@ziming-zung

Description

@ziming-zung

Currently, indirect_call is initiated by enclave_account in indirect_call_executor, and the nonce of the account is read from storage. When a block has only one indirect_call, the nonce handing is no problem(read from stroage), but if there are multiple indirect_call in a block, a too low priority error will occur. Because the nonce will not increase before the indirect_call is executed.

This requires us to have a method to adjust the value of nonce. The solution can be:

  • We can read the number of pending_trusted_calls initiated by enclave_account from top_pool (here I will call it pending_tx), current_nonce plus pending_tx should be the value we need. Here are some code for reference

Sign call:

fn sign_call_with_self(
&self,
trusted_call: &TrustedCall,
shard: &ShardIdentifier,
) -> Result<TrustedCallSigned> {
let mr_enclave = self.ocall_api.get_mrenclave_of_self()?;
let enclave_account_nonce = self.get_enclave_account_nonce(shard)?;
let enclave_call_signing_key = self.get_enclave_call_signing_key()?;
Ok(trusted_call.sign(
&KeyPair::Ed25519(enclave_call_signing_key),
enclave_account_nonce.into(),
&mr_enclave.m,
shard,
))
}

Adjust nonce:
https://github.com/paritytech/substrate/blob/ac176294e647f0eabd0970537567bf37ded00360/utils/frame/rpc/system/src/lib.rs#L180-L211

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions