4. (Problem from the 29th Russian Mathematical Olympiad) Find all prime numbers $p$ such that $p^{x}=y^{3}+1$ holds, where $x, y$ are positive integers.
4. Since $p^{x}=(y+1)\left(y^{2}-y+1\right), y>0$, then $y+1 \geqslant 2$. Let $y+1=p^{t}(t \in \mathbf{N}, 1 \leqslant t \leqslant x)$, then $y=p^{t}-1$, substituting into the original equation gives $\left(p^{t}-1\right)^{2}-\left(p^{t}-1\right)+1=p^{r-t}, p^{2 t}-3 p^{t}+3=p^{x-t}$, hence $p^{x-t}\left(p^{3 t-t}-1\right)=3\left(p^{t}-1\right)$.
(1) When $p=2$, $p^{3 t-x}-1, p^{t}-1$ are odd numbers, then $p^{x-t}$ is odd, so $x=t, y^{2}-y+1=1$, thus $y=1, p=2$, $x=1$.
(2) When $p \neq 2$, $p$ is an odd number, $p^{3 t-x}-1, p^{t}-1$ are even numbers, $p^{x-t}$ is odd, thus $3 \mid p^{x-t}$ or $3 \mid\left(p^{3 t-x}-1\right)$. When 3 $\mid p^{x-t}$, $p=3, x=t+1$, then $y^{2}-y+1=3$, solving gives $y=2, x=2$; When $3 \mid\left(p^{3 t-x}-1\right)$, $p^{x-1} \mid\left(p^{t}-1\right)$, so $x=$ $t$.
From (1) we get $y=1, p=2$, which contradicts $p \neq 2$. In summary, there are two solutions: $(p, x, y)=(2,1,1),(3,2,2)$.