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.
This commit is contained in:
Dev Ojha 2018-12-10 09:56:49 -08:00 committed by Ethan Buchman
parent 41eaf0e31d
commit d5d0d2bd77

View File

@ -108,6 +108,10 @@ func PostCheckMaxGas(maxGas int64) PostCheckFunc {
if maxGas == -1 { if maxGas == -1 {
return nil return nil
} }
if res.GasWanted < 0 {
return fmt.Errorf("gas wanted %d is negative",
res.GasWanted)
}
if res.GasWanted > maxGas { if res.GasWanted > maxGas {
return fmt.Errorf("gas wanted %d is greater than max gas %d", return fmt.Errorf("gas wanted %d is greater than max gas %d",
res.GasWanted, maxGas) res.GasWanted, maxGas)