mirror of https://github.com/poanetwork/quorum.git
Re-enable gas price.
This change removes all the places we had intentionally disabled non-0 gas price.
This commit is contained in:
parent
3214705480
commit
5e1547551d
|
@ -28,7 +28,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/math"
|
|
||||||
"github.com/ethereum/go-ethereum/common/mclock"
|
"github.com/ethereum/go-ethereum/common/mclock"
|
||||||
"github.com/ethereum/go-ethereum/consensus"
|
"github.com/ethereum/go-ethereum/consensus"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
|
@ -322,11 +321,7 @@ func (bc *BlockChain) GasLimit() *big.Int {
|
||||||
bc.mu.RLock()
|
bc.mu.RLock()
|
||||||
defer bc.mu.RUnlock()
|
defer bc.mu.RUnlock()
|
||||||
|
|
||||||
if bc.Config().IsQuorum {
|
|
||||||
return math.MaxBig256 // HACK(joel) a very large number
|
|
||||||
} else {
|
|
||||||
return bc.currentBlock.GasLimit()
|
return bc.currentBlock.GasLimit()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// LastBlockHash return the hash of the HEAD block.
|
// LastBlockHash return the hash of the HEAD block.
|
||||||
|
|
|
@ -104,10 +104,6 @@ func ApplyTransaction(config *params.ChainConfig, bc *BlockChain, author *common
|
||||||
privateState = statedb
|
privateState = statedb
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.IsQuorum && tx.GasPrice() != nil && tx.GasPrice().Cmp(common.Big0) > 0 {
|
|
||||||
return nil, nil, nil, ErrInvalidGasPrice
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := tx.AsMessage(types.MakeSigner(config, header.Number))
|
msg, err := tx.AsMessage(types.MakeSigner(config, header.Number))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
|
|
|
@ -292,8 +292,10 @@ func (st *StateTransition) TransitionDb() (ret []byte, requiredGas, usedGas *big
|
||||||
}
|
}
|
||||||
requiredGas = new(big.Int).Set(st.gasUsed())
|
requiredGas = new(big.Int).Set(st.gasUsed())
|
||||||
|
|
||||||
|
if !isPrivate {
|
||||||
st.refundGas()
|
st.refundGas()
|
||||||
st.state.AddBalance(st.evm.Coinbase, new(big.Int).Mul(st.gasUsed(), st.gasPrice))
|
st.state.AddBalance(st.evm.Coinbase, new(big.Int).Mul(st.gasUsed(), st.gasPrice))
|
||||||
|
}
|
||||||
|
|
||||||
if isPrivate {
|
if isPrivate {
|
||||||
return ret, new(big.Int), new(big.Int), vmerr != nil, err
|
return ret, new(big.Int), new(big.Int), vmerr != nil, err
|
||||||
|
|
|
@ -78,8 +78,6 @@ var (
|
||||||
// than some meaningful limit a user might use. This is not a consensus error
|
// than some meaningful limit a user might use. This is not a consensus error
|
||||||
// making the transaction invalid, rather a DOS protection.
|
// making the transaction invalid, rather a DOS protection.
|
||||||
ErrOversizedData = errors.New("oversized data")
|
ErrOversizedData = errors.New("oversized data")
|
||||||
|
|
||||||
ErrInvalidGasPrice = errors.New("Gas price not 0")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -546,11 +544,6 @@ func (pool *TxPool) local() map[common.Address]types.Transactions {
|
||||||
// validateTx checks whether a transaction is valid according to the consensus
|
// validateTx checks whether a transaction is valid according to the consensus
|
||||||
// rules and adheres to some heuristic limits of the local node (price and size).
|
// rules and adheres to some heuristic limits of the local node (price and size).
|
||||||
func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
|
func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
|
||||||
isQuorum := pool.chainconfig.IsQuorum
|
|
||||||
|
|
||||||
if isQuorum && tx.GasPrice().Cmp(common.Big0) != 0 {
|
|
||||||
return ErrInvalidGasPrice
|
|
||||||
}
|
|
||||||
// Heuristic limit, reject transactions over 32KB to prevent DOS attacks
|
// Heuristic limit, reject transactions over 32KB to prevent DOS attacks
|
||||||
if tx.Size() > 32*1024 {
|
if tx.Size() > 32*1024 {
|
||||||
return ErrOversizedData
|
return ErrOversizedData
|
||||||
|
@ -571,7 +564,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
|
||||||
}
|
}
|
||||||
// Drop non-local transactions under our own minimal accepted gas price
|
// Drop non-local transactions under our own minimal accepted gas price
|
||||||
local = local || pool.locals.contains(from) // account may be local even if the transaction arrived from the network
|
local = local || pool.locals.contains(from) // account may be local even if the transaction arrived from the network
|
||||||
if !isQuorum && !local && pool.gasPrice.Cmp(tx.GasPrice()) > 0 {
|
if !local && pool.gasPrice.Cmp(tx.GasPrice()) > 0 {
|
||||||
return ErrUnderpriced
|
return ErrUnderpriced
|
||||||
}
|
}
|
||||||
// Ensure the transaction adheres to nonce ordering
|
// Ensure the transaction adheres to nonce ordering
|
||||||
|
@ -584,7 +577,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
|
||||||
return ErrInsufficientFunds
|
return ErrInsufficientFunds
|
||||||
}
|
}
|
||||||
intrGas := IntrinsicGas(tx.Data(), tx.To() == nil, pool.homestead)
|
intrGas := IntrinsicGas(tx.Data(), tx.To() == nil, pool.homestead)
|
||||||
if !isQuorum && tx.Gas().Cmp(intrGas) < 0 {
|
if tx.Gas().Cmp(intrGas) < 0 {
|
||||||
return ErrIntrinsicGas
|
return ErrIntrinsicGas
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -614,7 +607,7 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (bool, error) {
|
||||||
// If the transaction pool is full, discard underpriced transactions
|
// If the transaction pool is full, discard underpriced transactions
|
||||||
if uint64(len(pool.all)) >= pool.config.GlobalSlots+pool.config.GlobalQueue {
|
if uint64(len(pool.all)) >= pool.config.GlobalSlots+pool.config.GlobalQueue {
|
||||||
// If the new transaction is underpriced, don't accept it
|
// If the new transaction is underpriced, don't accept it
|
||||||
if !pool.chainconfig.IsQuorum && pool.priced.Underpriced(tx, pool.locals) {
|
if pool.priced.Underpriced(tx, pool.locals) {
|
||||||
log.Trace("Discarding underpriced transaction", "hash", hash, "price", tx.GasPrice())
|
log.Trace("Discarding underpriced transaction", "hash", hash, "price", tx.GasPrice())
|
||||||
underpricedTxCounter.Inc(1)
|
underpricedTxCounter.Inc(1)
|
||||||
return false, ErrUnderpriced
|
return false, ErrUnderpriced
|
||||||
|
@ -899,7 +892,6 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) {
|
||||||
delete(pool.all, hash)
|
delete(pool.all, hash)
|
||||||
pool.priced.Removed()
|
pool.priced.Removed()
|
||||||
}
|
}
|
||||||
if !isQuorum {
|
|
||||||
// Drop all transactions that are too costly (low balance or out of gas)
|
// Drop all transactions that are too costly (low balance or out of gas)
|
||||||
drops, _ := list.Filter(pool.currentState.GetBalance(addr), pool.currentMaxGas)
|
drops, _ := list.Filter(pool.currentState.GetBalance(addr), pool.currentMaxGas)
|
||||||
for _, tx := range drops {
|
for _, tx := range drops {
|
||||||
|
@ -909,7 +901,6 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) {
|
||||||
pool.priced.Removed()
|
pool.priced.Removed()
|
||||||
queuedNofundsCounter.Inc(1)
|
queuedNofundsCounter.Inc(1)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Gather all executable transactions and promote them
|
// Gather all executable transactions and promote them
|
||||||
for _, tx := range list.Ready(pool.pendingState.GetNonce(addr)) {
|
for _, tx := range list.Ready(pool.pendingState.GetNonce(addr)) {
|
||||||
hash := tx.Hash()
|
hash := tx.Hash()
|
||||||
|
|
|
@ -194,7 +194,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
|
||||||
evm.StateDB.CreateAccount(addr)
|
evm.StateDB.CreateAccount(addr)
|
||||||
}
|
}
|
||||||
if evm.ChainConfig().IsQuorum {
|
if evm.ChainConfig().IsQuorum {
|
||||||
// skip transfer if value /= 0 (see note: Quorum, States, and Value Transfer)
|
// skip transfer if value == 0 (see note: Quorum, States, and Value Transfer)
|
||||||
if value.Sign() != 0 {
|
if value.Sign() != 0 {
|
||||||
if evm.quorumReadOnly {
|
if evm.quorumReadOnly {
|
||||||
return nil, gas, ErrReadOnlyValueTransfer
|
return nil, gas, ErrReadOnlyValueTransfer
|
||||||
|
@ -391,7 +391,7 @@ func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.I
|
||||||
evm.StateDB.SetNonce(contractAddr, 1)
|
evm.StateDB.SetNonce(contractAddr, 1)
|
||||||
}
|
}
|
||||||
if evm.ChainConfig().IsQuorum {
|
if evm.ChainConfig().IsQuorum {
|
||||||
// skip transfer if value /= 0 (see note: Quorum, States, and Value Transfer)
|
// skip transfer if value == 0 (see note: Quorum, States, and Value Transfer)
|
||||||
if value.Sign() != 0 {
|
if value.Sign() != 0 {
|
||||||
if evm.quorumReadOnly {
|
if evm.quorumReadOnly {
|
||||||
return nil, common.Address{}, gas, ErrReadOnlyValueTransfer
|
return nil, common.Address{}, gas, ErrReadOnlyValueTransfer
|
||||||
|
|
|
@ -196,11 +196,8 @@ func (b *EthApiBackend) ProtocolVersion() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *EthApiBackend) SuggestPrice(ctx context.Context) (*big.Int, error) {
|
func (b *EthApiBackend) SuggestPrice(ctx context.Context) (*big.Int, error) {
|
||||||
if b.ChainConfig().IsQuorum {
|
// NOTE(joel): this was set to 0 in the previous version of Quorum
|
||||||
return big.NewInt(0), nil
|
|
||||||
} else {
|
|
||||||
return b.gpo.SuggestPrice(ctx)
|
return b.gpo.SuggestPrice(ctx)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *EthApiBackend) ChainDb() ethdb.Database {
|
func (b *EthApiBackend) ChainDb() ethdb.Database {
|
||||||
|
|
|
@ -617,6 +617,8 @@ func (s *PublicBlockChainAPI) doCall(ctx context.Context, args CallArgs, blockNr
|
||||||
gas = big.NewInt(50000000)
|
gas = big.NewInt(50000000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE(joel): let's keep the default gas price 0 for now, but note this as a
|
||||||
|
// spot that might be tweaked in the future.
|
||||||
if gasPrice.Sign() == 0 && !s.b.ChainConfig().IsQuorum {
|
if gasPrice.Sign() == 0 && !s.b.ChainConfig().IsQuorum {
|
||||||
gasPrice = new(big.Int).SetUint64(defaultGasPrice)
|
gasPrice = new(big.Int).SetUint64(defaultGasPrice)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue