|
|
|
@ -14,9 +14,15 @@ |
|
|
|
|
*/ |
|
|
|
|
package org.hyperledger.besu.ethereum.mainnet; |
|
|
|
|
|
|
|
|
|
import org.hyperledger.besu.ethereum.core.Account; |
|
|
|
|
import org.hyperledger.besu.ethereum.core.TransactionReceipt; |
|
|
|
|
import org.hyperledger.besu.ethereum.core.Wei; |
|
|
|
|
import org.hyperledger.besu.ethereum.core.WorldState; |
|
|
|
|
import org.hyperledger.besu.ethereum.mainnet.contractvalidation.MaxCodeSizeRule; |
|
|
|
|
import org.hyperledger.besu.ethereum.vm.MessageFrame; |
|
|
|
|
|
|
|
|
|
import java.math.BigInteger; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.Optional; |
|
|
|
|
import java.util.OptionalInt; |
|
|
|
|
|
|
|
|
@ -83,4 +89,61 @@ public class ClassicProtocolSpecs { |
|
|
|
|
gasCalculator -> new MainnetTransactionValidator(gasCalculator, true, chainId)) |
|
|
|
|
.name("DefuseDifficultyBomb"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static ProtocolSpecBuilder<Void> atlantisDefinition( |
|
|
|
|
final Optional<BigInteger> chainId, |
|
|
|
|
final OptionalInt configContractSizeLimit, |
|
|
|
|
final OptionalInt configStackSizeLimit, |
|
|
|
|
final boolean enableRevertReason) { |
|
|
|
|
final int contractSizeLimit = |
|
|
|
|
configContractSizeLimit.orElse(MainnetProtocolSpecs.SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT); |
|
|
|
|
final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE); |
|
|
|
|
return gothamDefinition(chainId, configContractSizeLimit, configStackSizeLimit) |
|
|
|
|
.evmBuilder(MainnetEvmRegistries::byzantium) |
|
|
|
|
.gasCalculator(SpuriousDragonGasCalculator::new) |
|
|
|
|
.skipZeroBlockRewards(true) |
|
|
|
|
.messageCallProcessorBuilder( |
|
|
|
|
(evm, precompileContractRegistry) -> |
|
|
|
|
new MainnetMessageCallProcessor(evm, precompileContractRegistry)) |
|
|
|
|
.precompileContractRegistryBuilder(MainnetPrecompiledContractRegistries::byzantium) |
|
|
|
|
.difficultyCalculator(ClassicDifficultyCalculators.EIP100) |
|
|
|
|
.transactionReceiptFactory( |
|
|
|
|
enableRevertReason |
|
|
|
|
? ClassicProtocolSpecs::byzantiumTransactionReceiptFactoryWithReasonEnabled |
|
|
|
|
: ClassicProtocolSpecs::byzantiumTransactionReceiptFactory) |
|
|
|
|
.contractCreationProcessorBuilder( |
|
|
|
|
(gasCalculator, evm) -> |
|
|
|
|
new MainnetContractCreationProcessor( |
|
|
|
|
gasCalculator, |
|
|
|
|
evm, |
|
|
|
|
true, |
|
|
|
|
Collections.singletonList(MaxCodeSizeRule.of(contractSizeLimit)), |
|
|
|
|
1)) |
|
|
|
|
.transactionProcessorBuilder( |
|
|
|
|
(gasCalculator, |
|
|
|
|
transactionValidator, |
|
|
|
|
contractCreationProcessor, |
|
|
|
|
messageCallProcessor) -> |
|
|
|
|
new MainnetTransactionProcessor( |
|
|
|
|
gasCalculator, |
|
|
|
|
transactionValidator, |
|
|
|
|
contractCreationProcessor, |
|
|
|
|
messageCallProcessor, |
|
|
|
|
true, |
|
|
|
|
stackSizeLimit, |
|
|
|
|
Account.DEFAULT_VERSION)) |
|
|
|
|
.name("Atlantis"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static TransactionReceipt byzantiumTransactionReceiptFactory( |
|
|
|
|
final TransactionProcessor.Result result, final WorldState worldState, final long gasUsed) { |
|
|
|
|
return new TransactionReceipt( |
|
|
|
|
result.isSuccessful() ? 1 : 0, gasUsed, result.getLogs(), Optional.empty()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static TransactionReceipt byzantiumTransactionReceiptFactoryWithReasonEnabled( |
|
|
|
|
final TransactionProcessor.Result result, final WorldState worldState, final long gasUsed) { |
|
|
|
|
return new TransactionReceipt( |
|
|
|
|
result.isSuccessful() ? 1 : 0, gasUsed, result.getLogs(), result.getRevertReason()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|