From 6a268cfb635fe1c4964d76a3b7ff747e74c56474 Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Mon, 6 Feb 2023 17:53:00 -0500 Subject: [PATCH] chain: explicitly check that gasLimit is above zero --- chain/types/message.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chain/types/message.go b/chain/types/message.go index a25cd05b6..becd2c010 100644 --- a/chain/types/message.go +++ b/chain/types/message.go @@ -207,6 +207,10 @@ func (m *Message) ValidForBlockInclusion(minGas int64, version network.Version) return xerrors.Errorf("'GasLimit' field cannot be greater than a block's gas limit (%d > %d)", m.GasLimit, build.BlockGasLimit) } + if m.GasLimit <= 0 { + return xerrors.Errorf("'GasLimit' field %d must be positive", m.GasLimit) + } + // since prices might vary with time, this is technically semantic validation if m.GasLimit < minGas { return xerrors.Errorf("'GasLimit' field cannot be less than the cost of storing a message on chain %d < %d", m.GasLimit, minGas)