Create a prototype for a super simple haf that manages forks just using nested transactions
Today, I was thinking about if we could create a super simple version of HAF, that might be more suitable for a blockchain with OBI support, and this is what I came up with as an idea:
During live sync, each block would start a new nested transaction and all "reversible" apps would be run in the same transaction that adds the block data. Simplest mechanism would just be to fill a table with calls to all the app "process_block" procedures that should be run by the transaction.
Whenever blocks are orphaned, the nested transactions (and hence the state of all reversible apps) would be rolled back to remove the impacts of all orphaned blocks on the reversible apps. One issue I need to lookup is if nested transactions allow committing the impacts of the earlier parts of the nested transaction (i.e. can we commit the early parts of the transaction).
Irreversible apps could continue to run in separate threads/transactions as they would only be working on committed blocks and don't need rollbacks.
This super simple methodology for now assumes reversible apps would be replayed at the same time as HAF itself is replayed, but it isn't strictly necessary. Transaction nesting would only need to start once the last irreversible block was reached.