The stellar distribution function and local vertical potential from Gaia DR2