Move make_receipt to BaseTransactionExecutor
What is wrong?
#383 was recently merged, bringing a generic transaction executor to be used as mixin in different VM state classes, thereby allowing us to achieve better code reuse across forks.
A good candidate that can benefit from a similar refactoring is the BaseVMState.make_receipt method. This method is currently called inside BaseVMState.add_transaction(transaction, computation, block), though receipt generation has nothing to do with adding the transaction to a block. A better place to make the call is in BaseTransactionExecutor.execute_transaction. It therefore also makes logical sense to move BaseVMState.make_receipt to the BaseTransactionExecutor class, which has all the necessary information for receipt generation, i.e. vm state (via self), computation, and transaction.
How can it be fixed
- Add
make_receiptas anabstractmethodtoevm.vm_state.BaseTransactionExecutor. - Move the call to
self.make_receiptin theevm.vm_state.BaseVMState.add_transaction, toevm.vm_state.BaseTransactionExecutor.execute_transaction. - Implement
make_receiptinevm.vm.forks.frontier.vm_state.FrontierTransactionExecutor. - Use proper inheritance in other forks, notably in
ByzantiumVMState.
So would execute_transaction now return a 2-tuple of computation, receipt?
So would execute_transaction now return a 2-tuple of computation, receipt?
I think this should be the preferred way of doing it. Alternately, we can call the add_receipt method in execute_transaction and modify this line to be: block.bloom_filter |= self.receipts[-1].bloom.
I'm inclined to instead modify add_transaction to take the extra receipt parameter (along with having execute_transaction return the receipt.