Poke the eggplants with a fork several times to prevent them from bursting while blackening.
Blacken the eggplants by holding them over a medium gas flame or heating them under a broiler on a rimmed baking sheet. Keep turning until blackened on all sides and soft. Under a low broiler, this should take 40-60 minutes, turning the eggplants every 15-20 minutes. Let cool.
Once cool, peel off the charred skin and discard. Roughly chop the eggplant flesh.
Combine the onion, garlic, ginger, and chili in a small blender or food processor. Pulse until chopped together but not a paste. Alternatively, chop very finely with a knife and mix together.
In a deep frying pan, heat the oil over medium heat. Add the onion mixture and cook until browned.
Add all the spices, including the salt and pepper. Stir for another minute.
Add the chopped tomato and simmer until liquid is reduced, about 10-20 minutes.
Add the eggplant to the pan and mash everything together with a wooden spoon. Continue simmering for 10-20 minutes, until the eggplants are soft and the spices are well distributed.
For a chunky dip, stir in the chopped cilantro leaves, if using, and serve.
For a smooth dip (my preference), blend everything together in a blender until smooth. (If you don't have a high-powered blender, it may to difficult to fully process the eggplant seeds.)