Place a large cooking pot or pan on medium flame on stove. Pour oil into the pot and let warm up.
To the hot oil, add whole spices - bay leaf, cinnamon stick, green cardamom, cloves and black peppercorns. Skip any spices you don't have at hand or don't prefer. Fry the spices in hot oil taking care not to burn them.
Add the chopped onions and cook them on low medium heat until golden brown. Takes about 8-12 minutes.
Next, chopped garlic & ginger and cook for 1-2 minutes till you start smelling the aroma. If you like pronounced heat, you can add few green chillies at this stage.
Reduce the heat to low and add the spice powders- red chili powder, cumin powder, coriander powder, and turmeric powder. Add ? cup water and cook the spices with onion for 2-3 minutes while stirring regularly.
Introduce the tomatoes next and sprinkle sugar and salt. At this stage if you want, you can also add 8-10 cashews (I don't). Mix the tomatoes well.
Pour 1 cup hot water and cover. Cook this masala on low heat for 6-8 minutes untill the tomatoes soften.
Open the oil lid, bump up the heat to medium flame and then start frying the masala. As you go, mash the tomatoes using the back of spoon to break them more. Slowly you will see that the oil starts separating from the mix along the sides of the pot and tiny oily bubbles on top of the masala. This process takes 8-10 minutes. This slow cooking is very important to develop flavors and color of the paste, please do not rush. Allow the masala to reduce till it acquires beautiful reddish to brown color but dont dry out.
Remove the pot from stove and allow the masala to cool a little bit. Pick and discard the cinnamom stick and bay leaf.
Transfer to a blender jar and pulse a few times to process to a coarse consistency.
Portion the onion tomato masala as needed in air tight containers or in freezer safe food containers. I use silicone soup trays for portioning ½ cup. It stays good for up to 5 days refrigerated and 1.5-2 months in the freezer without losing flavor.
Once frozen, you can unmold and store the masala cubes in a zip lock bag in the freezer.