diff --git a/core/blockchain.go b/core/blockchain.go index 464d04481..106218b2e 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -28,7 +28,6 @@ import ( "time" "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/consensus" "github.com/ethereum/go-ethereum/core/state" @@ -322,11 +321,7 @@ func (bc *BlockChain) GasLimit() *big.Int { bc.mu.RLock() 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. diff --git a/core/state_processor.go b/core/state_processor.go index 7d59ed54b..78707a580 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -104,10 +104,6 @@ func ApplyTransaction(config *params.ChainConfig, bc *BlockChain, author *common 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)) if err != nil { return nil, nil, nil, err diff --git a/core/state_transition.go b/core/state_transition.go index 19caf3c5f..f76028be0 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -292,8 +292,10 @@ func (st *StateTransition) TransitionDb() (ret []byte, requiredGas, usedGas *big } requiredGas = new(big.Int).Set(st.gasUsed()) - st.refundGas() - st.state.AddBalance(st.evm.Coinbase, new(big.Int).Mul(st.gasUsed(), st.gasPrice)) + if !isPrivate { + st.refundGas() + st.state.AddBalance(st.evm.Coinbase, new(big.Int).Mul(st.gasUsed(), st.gasPrice)) + } if isPrivate { return ret, new(big.Int), new(big.Int), vmerr != nil, err diff --git a/core/tx_pool.go b/core/tx_pool.go index c4d79c43c..ed910e554 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -78,8 +78,6 @@ var ( // than some meaningful limit a user might use. This is not a consensus error // making the transaction invalid, rather a DOS protection. ErrOversizedData = errors.New("oversized data") - - ErrInvalidGasPrice = errors.New("Gas price not 0") ) 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 // rules and adheres to some heuristic limits of the local node (price and size). 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 if tx.Size() > 32*1024 { 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 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 } // Ensure the transaction adheres to nonce ordering @@ -584,7 +577,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { return ErrInsufficientFunds } 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 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 uint64(len(pool.all)) >= pool.config.GlobalSlots+pool.config.GlobalQueue { // 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()) underpricedTxCounter.Inc(1) return false, ErrUnderpriced @@ -899,16 +892,14 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) { delete(pool.all, hash) pool.priced.Removed() } - if !isQuorum { - // Drop all transactions that are too costly (low balance or out of gas) - drops, _ := list.Filter(pool.currentState.GetBalance(addr), pool.currentMaxGas) - for _, tx := range drops { - hash := tx.Hash() - log.Trace("Removed unpayable queued transaction", "hash", hash) - delete(pool.all, hash) - pool.priced.Removed() - queuedNofundsCounter.Inc(1) - } + // Drop all transactions that are too costly (low balance or out of gas) + drops, _ := list.Filter(pool.currentState.GetBalance(addr), pool.currentMaxGas) + for _, tx := range drops { + hash := tx.Hash() + log.Trace("Removed unpayable queued transaction", "hash", hash) + delete(pool.all, hash) + pool.priced.Removed() + queuedNofundsCounter.Inc(1) } // Gather all executable transactions and promote them for _, tx := range list.Ready(pool.pendingState.GetNonce(addr)) { diff --git a/core/vm/evm.go b/core/vm/evm.go index 20247d2c1..2affb4791 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -194,7 +194,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas evm.StateDB.CreateAccount(addr) } 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 evm.quorumReadOnly { 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) } 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 evm.quorumReadOnly { return nil, common.Address{}, gas, ErrReadOnlyValueTransfer diff --git a/eth/api_backend.go b/eth/api_backend.go index 50418c952..83a7191de 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -196,11 +196,8 @@ func (b *EthApiBackend) ProtocolVersion() int { } func (b *EthApiBackend) SuggestPrice(ctx context.Context) (*big.Int, error) { - if b.ChainConfig().IsQuorum { - return big.NewInt(0), nil - } else { - return b.gpo.SuggestPrice(ctx) - } + // NOTE(joel): this was set to 0 in the previous version of Quorum + return b.gpo.SuggestPrice(ctx) } func (b *EthApiBackend) ChainDb() ethdb.Database { diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index e2106bd27..1a4a75994 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -617,6 +617,8 @@ func (s *PublicBlockChainAPI) doCall(ctx context.Context, args CallArgs, blockNr 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 { gasPrice = new(big.Int).SetUint64(defaultGasPrice) }