In most cases the freehub body of 8 & 10 speed are the same. There are possibly some exceptions since many wheels have hubs that are 'Shimano compatible' but may not be 100% the same.
Cassettes may also have minor differences, and small tweaks may be needed to indexing. Cassettes also differ in how the innermost cog is designed, some are designed to slightly overhang the freehub body rear, towards the spokes.
Chain length and rear derailleur capacity are also considerations if the cassettes' tooth count differ by a large amount.