thehubbleproject / contracts

Smart contracts for OPRHub protocol ✌🏻
12 stars 10 forks source link

Use processBatch more effectively #69

Closed vaibhavchellani closed 3 years ago

vaibhavchellani commented 4 years ago

Right now we aren't using processBatch anywhere on the node, I am struggling to think of any compelling place to use it. This issue is to discuss its usage.

vaibhavchellani commented 4 years ago

We aren't using it on the node atm because I will have to create witnesses for all transactions before calling this function, one benefit of using processBatch once and not processTx on every transaction would be reduced network calls.

barryWhiteHat commented 4 years ago

We could use it as a final check to make sure the blcok created is correct.

Will we use processBatch when syncing ?

vaibhavchellani commented 4 years ago

We could use processBatch while syncing, but we will have to create witnesses for all txs before that.

The process would look something like this:

  1. Get submitBatch calldata
  2. Loop through txs
  3. Create MP for from account, apply tx on fromAccount
  4. Create MP for to account, apply tx on toAccount
  5. Do this for all txs
  6. Call processBatch with all the witnesses to validate batch

If we use processTx the process would look something like:

  1. Get submitBatch calldata
  2. Loop through txs
  3. Create MP for from account, apply tx on fromAccount
  4. Create MP for to account, apply tx on toAccount
  5. Call processTx with all the witnesses to validate tx
  6. Post doing this for all txs, match final state root.
ChihChengLiang commented 3 years ago

Let's bring the discussion to the node side. https://github.com/thehubbleproject/hubble-commander/issues/55