Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable gas price #1446

Merged
merged 37 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
57483cb
Add support for gas price, enabled/disabled using flag in genesis.
SatpalSandhu61 Dec 16, 2019
75166c1
Ensure default gas price is set if gas price is enabled.
SatpalSandhu61 Jan 6, 2020
e54f7ab
Ensure etherbase account is set for gas price reward when using Raft.
SatpalSandhu61 Jan 6, 2020
915e6e5
Don't check for underpriced or costly transactions if gas price is di…
SatpalSandhu61 Jan 14, 2020
f42358a
Remove check for 'Gas price cannot be 0', as this is already caught b…
SatpalSandhu61 Jan 17, 2020
7799789
Fix broken unit tests.
SatpalSandhu61 Jan 17, 2020
62b3ec6
Fix broken unit tests.
SatpalSandhu61 Jan 17, 2020
edfb65e
Merge branch 'master' of https://github.com/jpmorganchase/quorum into…
SatpalSandhu61 Mar 6, 2020
897e13d
Merge from master
SatpalSandhu61 Mar 6, 2020
25bdac0
Also make changes to les SuggestPrice(), for consistency.
SatpalSandhu61 Mar 12, 2020
d0cfbd8
Merge branch 'master' of https://github.com/jpmorganchase/quorum into…
SatpalSandhu61 Mar 23, 2020
6ec7b29
Fixing unit tests. Set default PriceLimit to 1, and allow zero priced…
SatpalSandhu61 Mar 27, 2020
b386cfb
Merge branch 'master' of https://github.com/jpmorganchase/quorum into…
SatpalSandhu61 Jun 25, 2020
d84e7a2
Changes required after pulling from master with 1.9.7 upgrade
SatpalSandhu61 Jun 26, 2020
86371bd
Merge branch 'master' of https://github.com/jpmorganchase/quorum into…
SatpalSandhu61 Jun 29, 2020
5e89c8f
Disable block reward, which was being rewarded for Raft only.
SatpalSandhu61 Jul 1, 2020
ea11ba9
Merge branch 'master' of https://github.com/jpmorganchase/quorum into…
SatpalSandhu61 Aug 17, 2020
e72b3dd
Add return value for backend SetEtherbase(), so user can be notified …
SatpalSandhu61 Aug 20, 2020
9b5a26f
Merge branch 'master' of https://github.com/ConsenSys/quorum into ena…
SatpalSandhu61 Mar 18, 2022
c65937e
Fixing issues after merge from master
SatpalSandhu61 Mar 22, 2022
b2af6bd
Merge branch 'master' of https://github.com/ConsenSys/quorum into ena…
SatpalSandhu61 Apr 11, 2022
d13dc05
Ensure block rewards match upstream
SatpalSandhu61 Apr 25, 2022
edffe95
Merge branch 'master' of https://github.com/ConsenSys/quorum into ena…
SatpalSandhu61 Apr 25, 2022
bb57613
Merge branch 'master' of https://github.com/ConsenSys/quorum into ena…
SatpalSandhu61 May 13, 2022
e2e4cfd
Fix inconsistent gas usage for PMT private transactions between parti…
SatpalSandhu61 Jun 13, 2022
c8a767b
Add comment
SatpalSandhu61 Jun 16, 2022
249d364
Temporary change to run acceptance tests on this branch
SatpalSandhu61 Jun 16, 2022
ce77a7c
Disable block reward, which was being rewarded for Raft only.
SatpalSandhu61 Jun 17, 2022
460df57
Modify enableGas flag to fork from a block number.
SatpalSandhu61 Jun 22, 2022
c66e127
Correction of enableGasPrice name to enableGasPriceBlock
SatpalSandhu61 Jun 27, 2022
d7f63dc
Restore static block reward, otherwise setting isQuorum flag causes d…
SatpalSandhu61 Jul 14, 2022
d4d6878
Merge branch 'master' into enable-gas-price-v2
baptiste-b-pegasys Jul 15, 2022
66688aa
Fix failing unit tests
SatpalSandhu61 Jul 19, 2022
f36a938
Remove temporary github acceptance test workflow from branch, and fix…
SatpalSandhu61 Jul 19, 2022
506ad57
Merge branch 'master' of https://github.com/ConsenSys/quorum into ena…
SatpalSandhu61 Jul 20, 2022
cd9cce8
Add suppoort for enabling gas price using transitions
SatpalSandhu61 Jul 20, 2022
0cf170a
Correction to static block reward, fixes acceptance test.
SatpalSandhu61 Jul 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,8 @@ var (
// reward. The total reward consists of the static block reward and rewards for
// included uncles. The coinbase of each uncle block is also rewarded.
func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header *types.Header, uncles []*types.Header) {

// NOTE: this code will be executed for Raft on Quorum, so the static block reward also applies to Raft
// Select the correct block reward based on chain progression
blockReward := FrontierBlockReward
if config.IsByzantium(header.Number) {
Expand All @@ -632,6 +634,7 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header
if config.IsConstantinople(header.Number) {
blockReward = ConstantinopleBlockReward
}

// Accumulate the rewards for the miner and any included uncles
reward := new(big.Int).Set(blockReward)
r := new(big.Int)
Expand Down
7 changes: 1 addition & 6 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,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/common/prque"
"github.com/ethereum/go-ethereum/consensus"
Expand Down Expand Up @@ -727,11 +726,7 @@ func (bc *BlockChain) GasLimit() uint64 {
bc.chainmu.RLock()
defer bc.chainmu.RUnlock()

if bc.Config().IsQuorum {
return math.MaxBig256.Uint64() // HACK(joel) a very large number
} else {
return bc.CurrentBlock().GasLimit()
}
return bc.CurrentBlock().GasLimit()
}

// CurrentBlock retrieves the current head block of the canonical chain. The
Expand Down
2 changes: 1 addition & 1 deletion core/chain_makers.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (b *BlockGen) AddTxWithChain(bc *BlockChain, tx *types.Transaction) {
}
// End Quorum

receipt, _, err := ApplyTransaction(b.config, bc, &b.header.Coinbase, b.gasPool, b.statedb, privateDb, b.header, tx, &b.header.GasUsed, vm.Config{}, false, nil)
receipt, _, err := ApplyTransaction(b.config, bc, &b.header.Coinbase, b.gasPool, b.statedb, privateDb, b.header, tx, &b.header.GasUsed, vm.Config{}, false, nil, false)
if err != nil {
panic(err)
}
Expand Down
23 changes: 13 additions & 10 deletions core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, pri
blockContext := NewEVMBlockContext(header, p.bc, nil)
// Iterate over and process the individual transactions
for i, tx := range block.Transactions() {
mpsReceipt, err := handleMPS(i, tx, gp, usedGas, cfg, statedb, privateStateRepo, p.config, p.bc, header, false)
mpsReceipt, err := handleMPS(i, tx, gp, usedGas, cfg, statedb, privateStateRepo, p.config, p.bc, header, false, false)
if err != nil {
return nil, nil, nil, 0, err
}
Expand Down Expand Up @@ -112,7 +112,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, pri
}
}

if p.config.IsQuorum && tx.GasPrice() != nil && tx.GasPrice().Cmp(common.Big0) > 0 {
if p.config.IsQuorum && !p.config.IsGasEnabled(header.Number) && tx.GasPrice() != nil && tx.GasPrice().Cmp(common.Big0) > 0 {
return nil, nil, nil, 0, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), ErrInvalidGasPrice)
}

Expand Down Expand Up @@ -207,7 +207,7 @@ func PrivateStateDBForTxn(isQuorum bool, tx *types.Transaction, stateDb, private
// handling MPS scenario for a private transaction
//
// handleMPS returns the auxiliary receipt and not the standard receipt
func handleMPS(ti int, tx *types.Transaction, gp *GasPool, usedGas *uint64, cfg vm.Config, statedb *state.StateDB, privateStateRepo mps.PrivateStateRepository, config *params.ChainConfig, bc ChainContext, header *types.Header, applyOnPartiesOnly bool) (mpsReceipt *types.Receipt, err error) {
func handleMPS(ti int, tx *types.Transaction, gp *GasPool, usedGas *uint64, cfg vm.Config, statedb *state.StateDB, privateStateRepo mps.PrivateStateRepository, config *params.ChainConfig, bc ChainContext, header *types.Header, applyOnPartiesOnly bool, isInnerPrivateTxn bool) (mpsReceipt *types.Receipt, err error) {
if tx.IsPrivate() && privateStateRepo != nil && privateStateRepo.IsMPS() {
publicStateDBFactory := func() *state.StateDB {
db := statedb.Copy()
Expand All @@ -222,7 +222,7 @@ func handleMPS(ti int, tx *types.Transaction, gp *GasPool, usedGas *uint64, cfg
db.Prepare(tx.Hash(), header.Hash(), ti)
return db, nil
}
mpsReceipt, err = ApplyTransactionOnMPS(config, bc, nil, gp, publicStateDBFactory, privateStateDBFactory, header, tx, usedGas, cfg, privateStateRepo, applyOnPartiesOnly)
mpsReceipt, err = ApplyTransactionOnMPS(config, bc, nil, gp, publicStateDBFactory, privateStateDBFactory, header, tx, usedGas, cfg, privateStateRepo, applyOnPartiesOnly, isInnerPrivateTxn)
}
return
}
Expand All @@ -239,7 +239,8 @@ func handleMPS(ti int, tx *types.Transaction, gp *GasPool, usedGas *uint64, cfg
// The originalGP gas pool will not be modified
func ApplyTransactionOnMPS(config *params.ChainConfig, bc ChainContext, author *common.Address, originalGP *GasPool,
publicStateDBFactory func() *state.StateDB, privateStateDBFactory func(psi types.PrivateStateIdentifier) (*state.StateDB, error),
header *types.Header, tx *types.Transaction, usedGas *uint64, cfg vm.Config, privateStateRepo mps.PrivateStateRepository, applyOnPartiesOnly bool) (*types.Receipt, error) {
header *types.Header, tx *types.Transaction, usedGas *uint64, cfg vm.Config, privateStateRepo mps.PrivateStateRepository,
applyOnPartiesOnly bool, isInnerPrivateTxn bool) (*types.Receipt, error) {

mpsReceipt := &types.Receipt{
QuorumReceiptExtraData: types.QuorumReceiptExtraData{
Expand Down Expand Up @@ -278,7 +279,7 @@ func ApplyTransactionOnMPS(config *params.ChainConfig, bc ChainContext, author *
// use a clone of the gas pool (as we don't want to consume gas multiple times for each MPS execution, which might blow the block gasLimit on MPS node)
gp := new(GasPool).AddGas(originalGP.Gas())

_, privateReceipt, err := ApplyTransaction(config, bc, author, gp, publicStateDB, privateStateDB, header, tx, usedGas, cfg, !applyAsParty, privateStateRepo)
_, privateReceipt, err := ApplyTransaction(config, bc, author, gp, publicStateDB, privateStateDB, header, tx, usedGas, cfg, !applyAsParty, privateStateRepo, isInnerPrivateTxn)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -399,7 +400,7 @@ func applyTransaction(msg types.Message, config *params.ChainConfig, bc ChainCon
// and uses the input parameters for its environment. It returns the receipt
// for the transaction, gas used and an error if the transaction failed,
// indicating the block was invalid.
func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb, privateStateDB *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, cfg vm.Config, forceNonParty bool, privateStateRepo mps.PrivateStateRepository) (*types.Receipt, *types.Receipt, error) {
func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb, privateStateDB *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, cfg vm.Config, forceNonParty bool, privateStateRepo mps.PrivateStateRepository, isInnerPrivateTxn bool) (*types.Receipt, *types.Receipt, error) {
// Quorum - decide the privateStateDB to use
privateStateDbToUse := PrivateStateDBForTxn(config.IsQuorum, tx, statedb, privateStateDB)
// End Quorum
Expand All @@ -411,7 +412,7 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
}
}

if config.IsQuorum && tx.GasPrice() != nil && tx.GasPrice().Cmp(common.Big0) > 0 {
if config.IsQuorum && !config.IsGasEnabled(header.Number) && tx.GasPrice() != nil && tx.GasPrice().Cmp(common.Big0) > 0 {
return nil, nil, ErrInvalidGasPrice
}

Expand All @@ -421,6 +422,8 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
}
// Quorum: this tx needs to be applied as if we were not a party
msg = msg.WithEmptyPrivateData(forceNonParty && tx.IsPrivate())
// Quorum: if this is the inner private txn of a PMT then need to indicate this
msg = msg.WithInnerPrivateFlag(isInnerPrivateTxn)

// Create a new context to be used in the EVM environment
blockContext := NewEVMBlockContext(header, bc, author)
Expand Down Expand Up @@ -450,7 +453,7 @@ func ApplyInnerTransaction(bc ChainContext, author *common.Address, gp *GasPool,
singleUseGasPool := new(GasPool).AddGas(innerTx.Gas())

if privateStateRepo != nil && privateStateRepo.IsMPS() {
mpsReceipt, err := handleMPS(txIndex, innerTx, singleUseGasPool, usedGas, evmConf, stateDB, privateStateRepo, bc.Config(), bc, header, true)
mpsReceipt, err := handleMPS(txIndex, innerTx, singleUseGasPool, usedGas, evmConf, stateDB, privateStateRepo, bc.Config(), bc, header, true, true)
if err != nil {
return err
}
Expand All @@ -464,7 +467,7 @@ func ApplyInnerTransaction(bc ChainContext, author *common.Address, gp *GasPool,
prepareStates(innerTx, stateDB, privateStateDB, txIndex)

used := uint64(0)
_, innerPrivateReceipt, err := ApplyTransaction(bc.Config(), bc, author, singleUseGasPool, stateDB, privateStateDB, header, innerTx, &used, evmConf, forceNonParty, privateStateRepo)
_, innerPrivateReceipt, err := ApplyTransaction(bc.Config(), bc, author, singleUseGasPool, stateDB, privateStateDB, header, innerTx, &used, evmConf, forceNonParty, privateStateRepo, true)
if err != nil {
return err
}
Expand Down
21 changes: 15 additions & 6 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func (result *ExecutionResult) Revert() []byte {
type PrivateMessage interface {
Message
IsPrivate() bool
IsInnerPrivate() bool
}

// IntrinsicGas computes the 'intrinsic gas' for a message with the given data.
Expand Down Expand Up @@ -352,7 +353,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
} else {
to = st.to()
}
//if input is empty for the smart contract call, return
//if input is empty for the smart contract call, return (refunding any gas deducted)
if len(data) == 0 && isPrivate {
st.refundGas()
st.state.AddBalance(st.evm.Context.Coinbase, new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), st.gasPrice))
Expand Down Expand Up @@ -422,12 +423,20 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
}

func (st *StateTransition) refundGas() {
// Apply refund counter, capped to half of the used gas.
refund := st.gasUsed() / 2
if refund > st.state.GetRefund() {
refund = st.state.GetRefund()
// Quorum
if msg, ok := st.msg.(PrivateMessage); ok && msg.IsInnerPrivate() {
// Quorum
// This is the inner private transaction of a PMT, need to ensure that ALL gas is refunded to prevent
// a mismatch between a (non-participant) minter and (participant) validator.
st.gas += st.gasUsed()
} else { // run original code
// Apply refund counter, capped to half of the used gas.
refund := st.gasUsed() / 2
if refund > st.state.GetRefund() {
refund = st.state.GetRefund()
}
st.gas += refund
}
st.gas += refund

// Return ETH for remaining gas, exchanged at the original rate.
remaining := new(big.Int).Mul(new(big.Int).SetUint64(st.gas), st.gasPrice)
Expand Down
23 changes: 17 additions & 6 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ var (
// making the transaction invalid, rather a DOS protection.
ErrOversizedData = errors.New("oversized data")

// ErrInvalidGasPrice is returned if gas price is disabled, but a gas price
// is specified in the transaction
ErrInvalidGasPrice = errors.New("Gas price not 0")

// ErrEtherValueUnsupported is returned if a transaction specifies an Ether Value
Expand Down Expand Up @@ -441,6 +443,13 @@ func (pool *TxPool) GasPrice() *big.Int {
// SetGasPrice updates the minimum price required by the transaction pool for a
// new transaction, and drops all transactions below this threshold.
func (pool *TxPool) SetGasPrice(price *big.Int) {
//Quorum
if pool.chainconfig.IsQuorum && !pool.chainconfig.IsGasEnabled(pool.chain.CurrentBlock().Header().Number) {
log.Info("Transaction pool price threshold not updated as gasPrice is not enabled")
return
}
//End-Quorum

pool.mu.Lock()
defer pool.mu.Unlock()

Expand Down Expand Up @@ -581,8 +590,9 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
}
}

// Gas price must be zero for Quorum transaction
if tx.GasPriceIntCmp(common.Big0) != 0 {
// Quorum
// Reject transaction if gas price is disabled, but gas price is specified
if (!pool.chainconfig.IsGasEnabled(pool.chain.CurrentBlock().Header().Number)) && tx.GasPriceIntCmp(common.Big0) != 0 {
return ErrInvalidGasPrice
}
// Ether value is not currently supported on private transactions
Expand All @@ -593,9 +603,10 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
if err := pcore.CheckAccountPermission(tx.From(), tx.To(), tx.Value(), tx.Data(), tx.Gas(), tx.GasPrice()); err != nil {
return err
}
} else {
}
if !pool.chainconfig.IsQuorum || pool.chainconfig.IsGasEnabled(pool.chain.CurrentBlock().Header().Number) {
// Drop non-local transactions under our own minimal accepted gas price
local = local || pool.locals.contains(from) // Quorum: account may be local even if the transaction arrived from the network
local = local || pool.locals.contains(from)
if !local && tx.GasPriceIntCmp(pool.gasPrice) < 0 {
return ErrUnderpriced
}
Expand Down Expand Up @@ -648,7 +659,7 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err e
// If the transaction pool is full, discard underpriced transactions
if uint64(pool.all.Count()+numSlots(tx)) > pool.config.GlobalSlots+pool.config.GlobalQueue {
// If the new transaction is underpriced, don't accept it
if !pool.chainconfig.IsQuorum && !isLocal && pool.priced.Underpriced(tx) {
if (!pool.chainconfig.IsQuorum || pool.chainconfig.IsGasEnabled(pool.chain.CurrentBlock().Header().Number)) && !isLocal && pool.priced.Underpriced(tx) {
log.Trace("Discarding underpriced transaction", "hash", hash, "price", tx.GasPrice())
underpricedTxMeter.Mark(1)
return false, ErrUnderpriced
Expand Down Expand Up @@ -1284,7 +1295,7 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) []*types.Trans
}
log.Trace("Removed old queued transactions", "count", len(forwards))
var drops types.Transactions
if !isQuorum {
if !pool.chainconfig.IsQuorum || pool.chainconfig.IsGasEnabled(pool.chain.CurrentBlock().Header().Number) {
// 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 {
Expand Down
32 changes: 22 additions & 10 deletions core/types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,16 +489,17 @@ func (t *TransactionsByPriceAndNonce) Pop() {
//
// NOTE: In a future PR this will be removed.
type Message struct {
to *common.Address
from common.Address
nonce uint64
amount *big.Int
gasLimit uint64
gasPrice *big.Int
data []byte
accessList AccessList
checkNonce bool
isPrivate bool
to *common.Address
from common.Address
nonce uint64
amount *big.Int
gasLimit uint64
gasPrice *big.Int
data []byte
accessList AccessList
checkNonce bool
isPrivate bool
isInnerPrivate bool
}

func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accessList AccessList, checkNonce bool) Message {
Expand Down Expand Up @@ -625,6 +626,17 @@ func (m Message) IsPrivate() bool {
return m.isPrivate
}

// Quorum
func (m Message) IsInnerPrivate() bool {
return m.isInnerPrivate
}

// Quorum
func (m Message) WithInnerPrivateFlag(isInnerPrivateTxn bool) Message {
m.isInnerPrivate = isInnerPrivateTxn
return m
}

// overriding msg.data so that when tesseera.receive is invoked we get nothing back
func (m Message) WithEmptyPrivateData(b bool) Message {
if b {
Expand Down
4 changes: 2 additions & 2 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas

// Quorum
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
Expand Down Expand Up @@ -599,7 +599,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
}
}
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
Expand Down
4 changes: 2 additions & 2 deletions eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ func (api *PrivateMinerAPI) SetGasPrice(gasPrice hexutil.Big) bool {

// SetEtherbase sets the etherbase of the miner
func (api *PrivateMinerAPI) SetEtherbase(etherbase common.Address) bool {
api.e.SetEtherbase(etherbase)
return true
// Quorum: Set return value, so user can be notified if it is disallowed.
return api.e.SetEtherbase(etherbase)
}

// SetRecommitInterval updates the interval for miner sealing work recommitting.
Expand Down
6 changes: 3 additions & 3 deletions eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,10 @@ func (b *EthAPIBackend) Downloader() *downloader.Downloader {
}

func (b *EthAPIBackend) SuggestPrice(ctx context.Context) (*big.Int, error) {
if b.ChainConfig().IsQuorum {
return big.NewInt(0), nil
} else {
if !b.ChainConfig().IsQuorum || b.ChainConfig().IsGasEnabled(b.eth.blockchain.CurrentBlock().Number()) {
return b.gpo.SuggestPrice(ctx)
} else {
return big.NewInt(0), nil
}
}

Expand Down
18 changes: 12 additions & 6 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,16 +649,22 @@ func (s *Ethereum) shouldPreserve(block *types.Block) bool {
}

// SetEtherbase sets the mining reward address.
func (s *Ethereum) SetEtherbase(etherbase common.Address) {
s.lock.Lock()
defer s.lock.Unlock()
if _, ok := s.engine.(consensus.Istanbul); ok {
log.Error("Cannot set etherbase in Istanbul consensus")
return
// Quorum: method now has a return value
func (s *Ethereum) SetEtherbase(etherbase common.Address) bool {
//Quorum
consensusAlgo := s.handler.getConsensusAlgorithm()
if consensusAlgo == "istanbul" || consensusAlgo == "clique" || consensusAlgo == "raft" {
log.Error("Cannot set etherbase with selected consensus mechanism")
return false
}
//End-Quorum

s.lock.Lock()
s.etherbase = etherbase
s.lock.Unlock()

s.miner.SetEtherbase(etherbase)
return true
}

// StartMining starts the miner with the given number of CPU threads. If mining
Expand Down
6 changes: 5 additions & 1 deletion les/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,11 @@ func (b *LesApiBackend) ProtocolVersion() int {
}

func (b *LesApiBackend) SuggestPrice(ctx context.Context) (*big.Int, error) {
return b.gpo.SuggestPrice(ctx)
if !b.ChainConfig().IsQuorum || b.ChainConfig().IsGasEnabled(b.eth.BlockChain().CurrentHeader().Number) {
return b.gpo.SuggestPrice(ctx)
} else {
return big.NewInt(0), nil
}
}

func (b *LesApiBackend) ChainDb() ethdb.Database {
Expand Down
Loading