def _make_frontier_receipt(vm_state, transaction, computation): # Reusable for other forks logs = [ Log(address, topics, data) for address, topics, data in computation.get_log_entries() ] gas_remaining = computation.get_gas_remaining() gas_refund = computation.get_gas_refund() tx_gas_used = ( transaction.gas - gas_remaining ) - min( gas_refund, (transaction.gas - gas_remaining) // 2, ) gas_used = vm_state.block_header.gas_used + tx_gas_used receipt = Receipt( state_root=vm_state.block_header.state_root, gas_used=gas_used, logs=logs, ) return receipt
def make_receipt(self, transaction, computation): old_receipt = super(ByzantiumBlock, self).make_receipt(transaction, computation) receipt = Receipt( state_root=b'' if computation.is_error else b'\x01', gas_used=old_receipt.gas_used, logs=old_receipt.logs, ) return receipt
def make_receipt(self, transaction, computation): old_receipt = _make_frontier_receipt(self, transaction, computation) if computation.is_error: state_root = EIP658_TRANSACTION_STATUS_CODE_FAILURE else: state_root = EIP658_TRANSACTION_STATUS_CODE_SUCCESS receipt = Receipt( state_root=state_root, gas_used=old_receipt.gas_used, logs=old_receipt.logs, ) return receipt
def add_transaction(self, transaction, computation): logs = [ Log(address, topics, data) for address, topics, data in computation.get_log_entries() ] if computation.error: tx_gas_used = transaction.gas else: gas_remaining = computation.get_gas_remaining() gas_refund = computation.get_gas_refund() tx_gas_used = ( transaction.gas - gas_remaining ) - min( gas_refund, (transaction.gas - gas_remaining) // 2, ) gas_used = self.header.gas_used + tx_gas_used receipt = Receipt( state_root=computation.state_db.root_hash, gas_used=gas_used, logs=logs, ) transaction_idx = len(self.transactions) index_key = rlp.encode(transaction_idx, sedes=rlp.sedes.big_endian_int) self.transactions.append(transaction) self.transaction_db[index_key] = rlp.encode(transaction) self.receipt_db[index_key] = rlp.encode(receipt) self.bloom_filter |= receipt.bloom self.header.transaction_root = self.transaction_db.root_hash self.header.state_root = computation.state_db.root_hash self.header.receipt_root = self.receipt_db.root_hash self.header.bloom = int(self.bloom_filter) self.header.gas_used = gas_used return self
def make_receipt(self, transaction, computation): logs = [ Log(address, topics, data) for address, topics, data in computation.get_log_entries() ] gas_remaining = computation.get_gas_remaining() gas_refund = computation.get_gas_refund() tx_gas_used = (transaction.gas - gas_remaining) - min( gas_refund, (transaction.gas - gas_remaining) // 2, ) gas_used = self.header.gas_used + tx_gas_used receipt = Receipt( state_root=self.header.state_root, gas_used=gas_used, logs=logs, ) return receipt