shell, base: Move hash tracking into base.

So that external components can also use it.

Depends on #1387.