Optimality of variational inference for stochastic block model with missing links