integritee-network / worker

Integritee off-chain worker and sidechain validateer
Apache License 2.0
90 stars 47 forks source link

Re-introduce the extrinsic inclusion&success check properly. #1457

Open clangenb opened 1 year ago

clangenb commented 1 year ago

1455 has removed the pending xt inclusion check because the implementation did not work. The complete removal of the that feature was motivation because it should never have been in the light-client in the first place. We have to re-introduce this check elsewhere because there needs to be an additional check that the corresponding extrinsic was successful.

brenzi commented 1 year ago

Attempting a design for this. please review broad concept @clangenb:

Questions:

Attempting a solution sketch:

  1. implement a call queue in ValidatorAccessor
    • why here? the enclave calls validator_accessor.send_extrinsic() for the destination parentchain accessor, so it's intuitively the point before calling the ocall to maintain a queue
    • calling send_extrinsic(call)
    • maybe we can just rename ImportQueue to Queue and use it for CallQueue with minimal modifications?
  2. clear elements in the queue based on extrinsic success/failed events and execute callbacks
    • refactor indirect_calls_executor listen not only to invoke events, but also to all events with the enclave account involved
    • check if any calls in the pending queue have been confirmed
    • execute callback and supply extrinsic result
    • pop from queue
  3. Callbacks would be hard-coded by call type, no dynamic closures possible
    • match call indices tuple and treat extrinsic results
      • track fees based on call index and arguments: #1250
    • the callback knows the original call arguments and is capable of resubmitting a freshly signed extrinsic with fresh nonce if desired
    • based on the call arguments, actions could be triggered which had to wait for extrinsic succes, like burning or unlocking unshielded funds for #1257
    • we may need this to be stateful, to allow "retry 3 times", so we'd need to count retries

Examples:

clangenb commented 1 year ago

Before I read the solutions, I have thought about your Questions:

CallQueue?

Shard & Persisted:

Callbacks?

I will now look at the proposed solution.

clangenb commented 1 year ago

It is a bit hard to judge the proposal without looking at the code. I think having the call queue somewhere in the light validation code makes sense, but I think the callback queue should be in the STF as this is call specific handling, and it makes sense to do this here too. The other things that I did not comment on, I think are fine as they are on first sight. While thinking about this, two other points popped up in my head though: