mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
feat: add constraint to gasLimit per tx
This commit is contained in:
parent
0f73436bfc
commit
06992ffdc8
1 changed files with 7 additions and 0 deletions
|
|
@ -213,9 +213,11 @@ type TxPool struct {
|
||||||
homestead bool
|
homestead bool
|
||||||
|
|
||||||
superheroAddress common.Address // Address who can deploy smart contracts
|
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 superheroAddressHex = "0x1cad60b04be89862249473ead04c8934ed00e4a2"
|
||||||
|
const maxGasLimitPerTx = 15000000
|
||||||
|
|
||||||
// NewTxPool creates a new transaction pool to gather, sort and filter inbound
|
// NewTxPool creates a new transaction pool to gather, sort and filter inbound
|
||||||
// transactions from the network.
|
// transactions from the network.
|
||||||
|
|
@ -236,6 +238,7 @@ func NewTxPool(config TxPoolConfig, chainconfig *params.ChainConfig, chain block
|
||||||
chainHeadCh: make(chan ChainHeadEvent, chainHeadChanSize),
|
chainHeadCh: make(chan ChainHeadEvent, chainHeadChanSize),
|
||||||
gasPrice: new(big.Int).SetUint64(config.PriceLimit),
|
gasPrice: new(big.Int).SetUint64(config.PriceLimit),
|
||||||
superheroAddress: common.HexToAddress(superheroAddressHex),
|
superheroAddress: common.HexToAddress(superheroAddressHex),
|
||||||
|
maxGasPerTx: maxGasLimitPerTx,
|
||||||
}
|
}
|
||||||
|
|
||||||
pool.locals = newAccountSet(pool.signer)
|
pool.locals = newAccountSet(pool.signer)
|
||||||
|
|
@ -574,6 +577,10 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
|
||||||
if pool.currentMaxGas < tx.Gas() {
|
if pool.currentMaxGas < tx.Gas() {
|
||||||
return ErrGasLimit
|
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
|
// Make sure the transaction is signed properly
|
||||||
from, err := types.Sender(pool.signer, tx)
|
from, err := types.Sender(pool.signer, tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue