Leg cramps at night are quite common and medical professionals aren't quite sure what causes them for some people. I've had them my whole adult life and have heard every theory in the book from a variety of medical professionals - too much walking, not enough walking, too much potassium, not enough potassium, too many carbs, not enough carbs, too much stress, too high shoes, too warm a bed, blah blah blah.
It will have occurred when you pointed your toes upon waking, I have no doubt. If you wake in the middle of the night try and get into the habit of NOT doing this. This is what brings on the awful pain. If it's too late, I find thumping on the calf muscle with a fist tends to help! For me I've learned to stop pointing my toes at all when I wake up, but it has taken me quite a long time!
It could be a coincidence that you've had these now, or it could not be - frankly I'd be shocked if you ever got a conducive answer from a doctor!