Pat the beef dry and cut it into 1 1/2-inch cubes. Season lightly with salt and black pepper.
Heat 1 tbsp oil in a heavy Dutch oven over medium-high heat. Brown the beef in 2 or 3 batches for 6 to 8 minutes per batch. Transfer the browned beef to a plate.
Lower the heat to medium. Add another 1 tbsp oil if needed. Add the onion, garlic, ginger, and scallion whites. Cook for 3 to 4 minutes until fragrant. Add the star anise, cinnamon stick, bay leaves, and Sichuan peppercorns if using. Stir for 30 seconds.
Return the beef to the pot. Add the Shaoxing wine and scrape up the browned bits. Add the soy sauce, dark soy sauce, sugar, and water or broth. Bring to a gentle simmer.
Cover, reduce the heat to low, and simmer for 1 hour 30 minutes, or until the beef is fork tender. Alternatively, braise in a 325°F oven for 1 hour 45 minutes.
Add the potatoes and carrots if using. Cover and simmer for 25 to 30 minutes, until the potatoes are tender and the beef is very soft.
If the sauce is thin, uncover and simmer for 10 to 15 minutes. If it is too thick, add a splash of hot water. Taste and adjust with salt, soy sauce, or a pinch of sugar.
Remove the whole spices. Let the stew rest for 5 minutes.
Serve hot with steamed jasmine rice and scatter with scallion greens.