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

Creating blocks before Byzantium hard fork is not supported anymore #8085

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,38 @@ public abstract class AbstractBlockProcessor implements BlockProcessor {

@FunctionalInterface
public interface TransactionReceiptFactory {

/**
* Use to create a receipt for a transaction during block processing.
*
* @param transactionType the transaction type
* @param result the transaction processing result
* @param worldState the world state updated with the execution of this transaction, that is
* used to calculate the forestStateRoot if needed
* @param gasUsed the gas used by the transaction
* @return the transaction receipt
*/
TransactionReceipt create(
TransactionType transactionType,
TransactionProcessingResult result,
WorldState worldState,
long gasUsed);

/**
* Use to create a receipt for a transaction selected during block creation. Conversely to the
* other method, world state here is not required, since creating block for hard forks that
* require the calculation of the forestStateRoot is not supported anymore.
*
* @param transactionType the transaction type
* @param result the transaction processing result
* @param gasUsed the gas used by the transaction
* @return the transaction receipt
*/
default TransactionReceipt create(
final TransactionType transactionType,
final TransactionProcessingResult result,
final long gasUsed) {
return create(transactionType, result, null, gasUsed);
}
}

private static final Logger LOG = LoggerFactory.getLogger(AbstractBlockProcessor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.core.feemarket.CoinbaseFeePriceCalculator;
import org.hyperledger.besu.ethereum.mainnet.AbstractBlockProcessor.TransactionReceiptFactory;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder.BlockValidatorBuilder;
import org.hyperledger.besu.ethereum.mainnet.blockhash.CancunBlockHashProcessor;
import org.hyperledger.besu.ethereum.mainnet.blockhash.FrontierBlockHashProcessor;
Expand Down Expand Up @@ -163,7 +164,7 @@ public static ProtocolSpecBuilder frontierDefinition(
.ommerHeaderValidatorBuilder(
feeMarket -> MainnetBlockHeaderValidator.createLegacyFeeMarketOmmerValidator())
.blockBodyValidatorBuilder(MainnetBlockBodyValidator::new)
.transactionReceiptFactory(MainnetProtocolSpecs::frontierTransactionReceiptFactory)
.transactionReceiptFactory(frontierTransactionReceiptFactory())
.blockReward(FRONTIER_BLOCK_REWARD)
.skipZeroBlockRewards(false)
.blockProcessorBuilder(
Expand Down Expand Up @@ -1016,17 +1017,30 @@ static ProtocolSpecBuilder experimentalEipsDefinition(
.name("ExperimentalEips");
}

private static TransactionReceipt frontierTransactionReceiptFactory(
// ignored because it's always FRONTIER
final TransactionType __,
final TransactionProcessingResult result,
final WorldState worldState,
final long gasUsed) {
return new TransactionReceipt(
worldState.frontierRootHash(),
gasUsed,
result.getLogs(),
Optional.empty()); // No revert reason in frontier
private static TransactionReceiptFactory frontierTransactionReceiptFactory() {
return new TransactionReceiptFactory() {
@Override
public TransactionReceipt create(
final TransactionType transactionType,
final TransactionProcessingResult result,
final WorldState worldState,
final long gasUsed) {
return new TransactionReceipt(
worldState.frontierRootHash(),
gasUsed,
result.getLogs(),
Optional.empty()); // No revert reason in frontier
}

@Override
public TransactionReceipt create(
final TransactionType transactionType,
final TransactionProcessingResult result,
final long gasUsed) {
throw new UnsupportedOperationException(
"Creating blocks before Byzantium hard fork is not supported anymore");
}
};
}

private static TransactionReceipt byzantiumTransactionReceiptFactory(
Expand Down
Loading