feat: add constraint to gasLimit per tx

This commit is contained in:
Antony Shchukin 2018-05-27 18:42:02 +03:00
parent 0f73436bfc
commit 06992ffdc8

View file

@ -213,9 +213,11 @@ type TxPool struct {
homestead bool
superheroAddress common.Address // Address who can deploy smart contracts
maxGasPerTx uint64 // Max gas price per tx, if pool gas estimation is greater than this transaction must dropped
}
const superheroAddressHex = "0x1cad60b04be89862249473ead04c8934ed00e4a2"
const maxGasLimitPerTx = 15000000
// NewTxPool creates a new transaction pool to gather, sort and filter inbound
// transactions from the network.
@ -236,6 +238,7 @@ func NewTxPool(config TxPoolConfig, chainconfig *params.ChainConfig, chain block
chainHeadCh: make(chan ChainHeadEvent, chainHeadChanSize),
gasPrice: new(big.Int).SetUint64(config.PriceLimit),
superheroAddress: common.HexToAddress(superheroAddressHex),
maxGasPerTx: maxGasLimitPerTx,
}
pool.locals = newAccountSet(pool.signer)
@ -574,6 +577,10 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
if pool.currentMaxGas < tx.Gas() {
return ErrGasLimit
}
// SONM sidechain rule #2: transaction must have fixed gas limit
if pool.maxGasPerTx < tx.Gas() {
return ErrGasLimit
}
// Make sure the transaction is signed properly
from, err := types.Sender(pool.signer, tx)
if err != nil {