From ad24132a4e9a161b1c1412c728d0de21daf02e89 Mon Sep 17 00:00:00 2001 From: Wasif Iqbal Date: Tue, 10 Oct 2023 14:18:11 -0500 Subject: [PATCH] Fix division by zero --- miner/environment_diff.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/miner/environment_diff.go b/miner/environment_diff.go index d41dfd7a30..4b17a65baf 100644 --- a/miner/environment_diff.go +++ b/miner/environment_diff.go @@ -270,7 +270,13 @@ func (envDiff *environmentDiff) commitSBundle(b *types.SimSBundle, chData chainD return errors.New("coinbase balance decreased") } - gotEGP := new(big.Int).Div(coinbaseDelta, gasDelta) + var gotEGP *big.Int + if gasDelta.Cmp(common.Big0) == 0 { + gotEGP = new(big.Int).SetUint64(0) + } else { + gotEGP = new(big.Int).Div(coinbaseDelta, gasDelta) + } + simEGP := new(big.Int).Set(b.MevGasPrice) // allow > 1% difference