Skip to content

Commit c714017

Browse files
Fix acceptance tests after changes for gas price enabled (#1466)
* Ensure no impact if gas price is not enabled (fixes breaking acceptance tests) * Restore historic behaviour when gas price not enabled (to fix acc tests)
1 parent 8ab2428 commit c714017

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

consensus/ethash/consensus.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -625,10 +625,12 @@ var (
625625
// included uncles. The coinbase of each uncle block is also rewarded.
626626
func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header *types.Header, uncles []*types.Header) {
627627

628-
// Quorum: Disable reward for Quorum if gas price is not enabled,
629-
// otherwise static block reward will impact Raft (even though the gas price is zero)
628+
// Quorum:
629+
// Historically, quorum was adding (static) reward to account 0x0.
630+
// So need to ensure this is still the case if gas price is not enabled, otherwise reward goes to coinbase.
631+
headerCoinbase := header.Coinbase
630632
if config.IsQuorum && !config.IsGasPriceEnabled(header.Number) {
631-
return
633+
headerCoinbase = common.Address{0x0000000000000000000000}
632634
}
633635

634636
// Select the correct block reward based on chain progression
@@ -653,7 +655,7 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header
653655
r.Div(blockReward, big32)
654656
reward.Add(reward, r)
655657
}
656-
state.AddBalance(header.Coinbase, reward)
658+
state.AddBalance(headerCoinbase, reward)
657659
}
658660

659661
// Quorum: wrapper for accumulateRewards to be called by raft minter

core/tx_pool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) []*types.Trans
12871287
}
12881288
log.Trace("Removed old queued transactions", "count", len(forwards))
12891289
var drops types.Transactions
1290-
if !pool.chainconfig.IsQuorum || pool.chainconfig.IsGasPriceEnabled(pool.chain.CurrentBlock().Header().Number) {
1290+
if !isQuorum || pool.chainconfig.IsGasPriceEnabled(pool.chain.CurrentBlock().Header().Number) {
12911291
// Drop all transactions that are too costly (low balance or out of gas)
12921292
drops, _ = list.Filter(pool.currentState.GetBalance(addr), pool.currentMaxGas)
12931293
for _, tx := range drops {

raft/minter.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,23 @@ func (minter *minter) createWork() *work {
259259
parentNumber := parent.Number()
260260
tstamp := generateNanoTimestamp(parent)
261261

262+
// Quorum:
263+
// If gas price is enabled on next block then set correct etherbase for reward
264+
// Note that historically, quorum was setting coinbase to 0x0,
265+
// so need to ensure this is still the case if gas price is not enabled.
266+
coinbase := common.Address{0x0000000000000000000000}
267+
newBlockNumber := parentNumber.Add(parentNumber, common.Big1)
268+
if minter.config.IsGasPriceEnabled(newBlockNumber) {
269+
coinbase = minter.coinbase
270+
}
271+
262272
header := &types.Header{
263273
ParentHash: parent.Hash(),
264-
Number: parentNumber.Add(parentNumber, common.Big1),
274+
Number: newBlockNumber,
265275
Difficulty: ethash.CalcDifficulty(minter.config, uint64(tstamp), parent.Header()),
266276
GasLimit: minter.eth.calcGasLimitFunc(parent),
267277
GasUsed: 0,
268-
Coinbase: minter.coinbase,
278+
Coinbase: coinbase,
269279
Time: uint64(tstamp),
270280
}
271281

0 commit comments

Comments
 (0)