Remove merge block processor as block rewards are already disabled for Paris and above in the protocol schedule (#5357)

Signed-off-by: Jason Frame <jason.frame@consensys.net>
This commit is contained in:
Jason Frame
2023-04-21 15:07:27 +10:00
committed by GitHub
parent 031101603b
commit b137432c25
3 changed files with 4 additions and 85 deletions

View File

@@ -1,71 +0,0 @@
/*
* Copyright Hyperledger Besu Contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.consensus.merge;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockProcessor;
import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor;
import org.hyperledger.besu.ethereum.mainnet.MiningBeneficiaryCalculator;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import java.util.List;
/** The Merge block processor. */
public class MergeBlockProcessor extends MainnetBlockProcessor {
private final MergeContext mergeContext;
/**
* Instantiates a new Merge block processor.
*
* @param transactionProcessor the transaction processor
* @param transactionReceiptFactory the transaction receipt factory
* @param blockReward the block reward
* @param miningBeneficiaryCalculator the mining beneficiary calculator
* @param skipZeroBlockRewards the skip zero block rewards
* @param protocolSchedule the header based protocol scheduler
*/
public MergeBlockProcessor(
final MainnetTransactionProcessor transactionProcessor,
final TransactionReceiptFactory transactionReceiptFactory,
final Wei blockReward,
final MiningBeneficiaryCalculator miningBeneficiaryCalculator,
final boolean skipZeroBlockRewards,
final ProtocolSchedule protocolSchedule) {
super(
transactionProcessor,
transactionReceiptFactory,
blockReward,
miningBeneficiaryCalculator,
skipZeroBlockRewards,
protocolSchedule);
this.mergeContext = PostMergeContext.get();
}
@Override
protected boolean rewardCoinbase(
final MutableWorldState worldState,
final BlockHeader header,
final List<BlockHeader> ommers,
final boolean skipZeroBlockRewards) {
if (!mergeContext.isPostMerge()) {
return super.rewardCoinbase(worldState, header, ommers, skipZeroBlockRewards);
}
// do not issue block rewards post-merge
return true;
}
}

View File

@@ -70,9 +70,8 @@ public class MergeProtocolSchedule {
MergeProtocolSchedule.applyMergeSpecificModifications(
specBuilder, config.getChainId()));
if (config.getShanghaiTime().isPresent()) {
postMergeModifications.put(
config.getShanghaiTime().getAsLong(),
MergeProtocolSchedule::unapplyMergeModificationsFromShanghaiOnwards);
// unapply merge modifications from Shanghai onwards
postMergeModifications.put(config.getShanghaiTime().getAsLong(), Function.identity());
}
return new ProtocolScheduleBuilder(
@@ -93,7 +92,6 @@ public class MergeProtocolSchedule {
(gasCalculator, jdCacheConfig) ->
MainnetEVMs.paris(
gasCalculator, chainId.orElse(BigInteger.ZERO), EvmConfiguration.DEFAULT))
.blockProcessorBuilder(MergeBlockProcessor::new)
.blockHeaderValidatorBuilder(MergeProtocolSchedule::getBlockHeaderValidator)
.blockReward(Wei.ZERO)
.difficultyCalculator((a, b, c) -> BigInteger.ZERO)
@@ -102,15 +100,6 @@ public class MergeProtocolSchedule {
.name("Paris");
}
private static ProtocolSpecBuilder unapplyMergeModificationsFromShanghaiOnwards(
final ProtocolSpecBuilder specBuilder) {
// TODO Withdrawals Get rid of MergeBlockProcessor
// inherits merge config from MainnetProtocolSpecs.parisDefinition
// This would be Function.identify() but MergeBlockProcessor can't be used in
// MainnetProtocolSpecs due to circular dependency
return specBuilder.blockProcessorBuilder(MergeBlockProcessor::new);
}
private static BlockHeaderValidator.Builder getBlockHeaderValidator(final FeeMarket feeMarket) {
return MergeValidationRulesetFactory.mergeBlockHeaderValidator(feeMarket);
}

View File

@@ -21,6 +21,7 @@ import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockProcessor;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.evm.operation.InvalidOperation;
@@ -97,7 +98,7 @@ public class MergeProtocolScheduleTest {
.isEqualTo(BigInteger.ZERO);
assertThat(spec.getBlockReward()).isEqualTo(Wei.ZERO);
assertThat(spec.isSkipZeroBlockRewards()).isTrue();
assertThat(spec.getBlockProcessor()).isInstanceOf(MergeBlockProcessor.class);
assertThat(spec.getBlockProcessor()).isInstanceOf(MainnetBlockProcessor.class);
}
private BlockHeader blockHeader(final long number) {