General relativity as the equation of state of spin foam