I get cramps at night after some extra harder or longer ride. It would be like me that I don't drink enough while on the bike, or maybe even after the ride.
I cure it by getting up into upright walking position, if I manage it. Then the cramps go away and I carefully wander about for a bit, then carefully lie back down and can finish my sleep then.
All that drinking this or eating that, I think the trick here is that you walked, managed to walk to get it LOL It was that walking in upright position cured it, not the stuff you ingested.
I suspect the increased blood pressure in your lower limbs as you stand up does the trick. Also my new bike has the provision for two bottles, that might also help.