code: def get_canonical_transaction(self, transaction_hash: Hash32) -> BaseTransaction:
          
          (block_num, index) = self.chaindb.get_transaction_index(transaction_hash)
          VM_class = self.get_vm_class_for_block_number(block_num)
  
          transaction = self.chaindb.get_transaction_by_index(
              block_num,
              index,
              VM_class.get_transaction_class(),
          )
  
          if transaction.hash == transaction_hash:
              return transaction
          else:
              raise TransactionNotFound("Found transaction {} instead of {} in block {} at {}".format(
                  encode_hex(transaction.hash),
                  encode_hex(transaction_hash),
                  block_num,
                  index,
              ))
docs: Returns the requested transaction as specified by the transaction hash
          from the canonical chain.
  
          Raises TransactionNotFound if no transaction with the specified hash is
          found in the main chain.