Skip to content

Commit

Permalink
Fix acceptance tests after changes for gas price enabled (#1466)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
SatpalSandhu61 authored Aug 2, 2022
1 parent 8ab2428 commit c714017
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
10 changes: 6 additions & 4 deletions consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,12 @@ var (
// 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) {

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

// Select the correct block reward based on chain progression
Expand All @@ -653,7 +655,7 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header
r.Div(blockReward, big32)
reward.Add(reward, r)
}
state.AddBalance(header.Coinbase, reward)
state.AddBalance(headerCoinbase, reward)
}

// Quorum: wrapper for accumulateRewards to be called by raft minter
Expand Down
2 changes: 1 addition & 1 deletion core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) []*types.Trans
}
log.Trace("Removed old queued transactions", "count", len(forwards))
var drops types.Transactions
if !pool.chainconfig.IsQuorum || pool.chainconfig.IsGasPriceEnabled(pool.chain.CurrentBlock().Header().Number) {
if !isQuorum || pool.chainconfig.IsGasPriceEnabled(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
14 changes: 12 additions & 2 deletions raft/minter.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,23 @@ func (minter *minter) createWork() *work {
parentNumber := parent.Number()
tstamp := generateNanoTimestamp(parent)

// Quorum:
// If gas price is enabled on next block then set correct etherbase for reward
// Note that historically, quorum was setting coinbase to 0x0,
// so need to ensure this is still the case if gas price is not enabled.
coinbase := common.Address{0x0000000000000000000000}
newBlockNumber := parentNumber.Add(parentNumber, common.Big1)
if minter.config.IsGasPriceEnabled(newBlockNumber) {
coinbase = minter.coinbase
}

header := &types.Header{
ParentHash: parent.Hash(),
Number: parentNumber.Add(parentNumber, common.Big1),
Number: newBlockNumber,
Difficulty: ethash.CalcDifficulty(minter.config, uint64(tstamp), parent.Header()),
GasLimit: minter.eth.calcGasLimitFunc(parent),
GasUsed: 0,
Coinbase: minter.coinbase,
Coinbase: coinbase,
Time: uint64(tstamp),
}

Expand Down

0 comments on commit c714017

Please sign in to comment.