From d5d0d2bd778e2e330d156fc97a4ed6d45fe14991 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Mon, 10 Dec 2018 09:56:49 -0800 Subject: [PATCH] Make mempool fail txs with negative gas wanted (#2994) This is only one part of #2989. We also need to fix the application, and add rules to consensus to ensure this. --- mempool/mempool.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mempool/mempool.go b/mempool/mempool.go index 8f70ec6c8..a64ce9188 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -108,6 +108,10 @@ func PostCheckMaxGas(maxGas int64) PostCheckFunc { if maxGas == -1 { return nil } + if res.GasWanted < 0 { + return fmt.Errorf("gas wanted %d is negative", + res.GasWanted) + } if res.GasWanted > maxGas { return fmt.Errorf("gas wanted %d is greater than max gas %d", res.GasWanted, maxGas)