From 28e3c4b239d10e3bb6d3304ccfde6ad2fed78952 Mon Sep 17 00:00:00 2001 From: Ian Shim <100327837+ian-shim@users.noreply.github.com> Date: Thu, 14 Mar 2024 20:55:34 -0700 Subject: [PATCH] Fix: division by zero panic in assignment (#340) --- core/assignment.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/assignment.go b/core/assignment.go index e64df17c3a..4aea2c5994 100644 --- a/core/assignment.go +++ b/core/assignment.go @@ -105,6 +105,9 @@ func (c *StdAssignmentCoordinator) GetAssignments(state *OperatorState, blobLeng gammaChunkLength := big.NewInt(int64(info.ChunkLength) * int64((info.QuorumThreshold - info.AdversaryThreshold))) denom := new(big.Int).Mul(gammaChunkLength, totalStakes) + if denom.Cmp(big.NewInt(0)) == 0 { + return nil, AssignmentInfo{}, fmt.Errorf("gammaChunkLength %d and total stake in quorum %d must be greater than 0", gammaChunkLength, totalStakes) + } m := roundUpDivideBig(num, denom) numChunks += uint(m.Uint64())