I am currently an undergraduate heading into my senior year. I've taken some theory/math classes (algorithms, and set theory/topology) in the past year and am taking quite a few more this year (more algorithms, abstract algebra, graph theory). My theory classes were the first classes in college I truly enjoyed. I definitely have an interest/passion for more theoretical and mathematical areas of computer science. I am pretty set on going to grad school/getting a PhD and if had the option, I would want to do research in an algorithms/theory group. However, I am wondering how can I assess if I have what it takes to succeed. Success in the case equates to getting a PhD --not necessarily at the most prestigious university -- but just making my contribution (as tiny as it may be) to the field. The reason I am asking this is because I am not some whiz kid who aces their classes with no sweat. I don't struggle by any means, but considering that algorithms/theory is a very intellectually challenging field, do you think hard work and passion for a subject can allow me to achieve my goal? Essentially, I don't want to put limitations on myself and regret not pursuing something I truly enjoy. However, at the same time, I want to be realistic with myself. Would love to hear your thoughts/experiences with this subject matter.
If TCS is something you enjoy, and you want to pursue a PhD, I wouldn't let the fear of failure stop you. You can also mitigate some of the risk by enrolling in a program that awards you a Master's after a year or two -- that way, if you realize research isn't for you, you won't come out "empty-handed". And if you don't succeed in landing a research job afterwards, as long as you enjoy grad school, it's not a big sunk cost.
To answer your question about "having what it takes" more directly -- I think you need to both have talent and put in the hard work to succeed. My feeling is that most people who fail to get a PhD, however, fail not because they were not talented enough, but because they weren't disciplined enough.