diff options
author | bojie <bojie@dexon.org> | 2019-03-18 23:55:32 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:58 +0800 |
commit | 0913656f3dd8cb53661923fd33f14a0a25befb71 (patch) | |
tree | 85d05022ba0a4bcb661e9b142ca329d0f674da8f /dex/app.go | |
parent | 3b2a10e72d5e7113b803b2099eb27c2acbe5a6b9 (diff) | |
download | dexon-0913656f3dd8cb53661923fd33f14a0a25befb71.tar.gz dexon-0913656f3dd8cb53661923fd33f14a0a25befb71.tar.zst dexon-0913656f3dd8cb53661923fd33f14a0a25befb71.zip |
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.
Diffstat (limited to 'dex/app.go')
-rw-r--r-- | dex/app.go | 6 |
1 files changed, 6 insertions, 0 deletions
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) |