This is a prerequesite for rollups.
Work done by @galfour squashed, cherry picked and moved to V3 by me