Solar system formation in two steps