From b8bcab7f7321eab5a5f29ae058bd05640b0da1c7 Mon Sep 17 00:00:00 2001 From: bojie Date: Mon, 18 Mar 2019 23:55:32 +0800 Subject: app: validate gas price while preparing block (#274) Skip tx which is under price and add test case. Use the key which has balance in test case to run test more correctly. --- dex/app.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'dex/app.go') diff --git a/dex/app.go b/dex/app.go index d82d46658..3f580f12e 100644 --- a/dex/app.go +++ b/dex/app.go @@ -181,6 +181,7 @@ func (d *DexconApp) preparePayload(ctx context.Context, position coreTypes.Posit } blockGasLimit := new(big.Int).SetUint64(d.gov.DexconConfiguration(position.Round).BlockGasLimit) + minGasPrice := d.gov.DexconConfiguration(position.Round).MinGasPrice blockGasUsed := new(big.Int) allTxs := make([]*types.Transaction, 0, 10000) @@ -216,6 +217,11 @@ addressMap: // Warning: the pending tx will also affect by syncing, so startIndex maybe negative for i := startIndex; i >= 0 && i < len(txs); i++ { tx := txs[i] + if minGasPrice.Cmp(tx.GasPrice()) > 0 { + log.Error("Invalid gas price minGas(%v) > get(%v)", minGasPrice, tx.GasPrice()) + break + } + intrGas, err := core.IntrinsicGas(tx.Data(), tx.To() == nil, true) if err != nil { log.Error("Failed to calculate intrinsic gas", "error", err) -- cgit v1.2.3