Skip to content

Commit

Permalink
Define EIP6110 protocol spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ensi321 committed Feb 19, 2023
1 parent e7a36dd commit 8ebb906
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ public OptionalLong getCancunTime() {
return getOptionalLong("cancuntime");
}

@Override
public OptionalLong getEIP6110Time() {
return getOptionalLong("eip6110time");
}

@Override
public OptionalLong getFutureEipsTime() {
return getOptionalLong("futureeipstime");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions {
private OptionalLong mergeNetSplitBlockNumber = OptionalLong.empty();
private OptionalLong shanghaiTime = OptionalLong.empty();
private OptionalLong cancunTime = OptionalLong.empty();
private OptionalLong eip6110Time = OptionalLong.empty();
private OptionalLong futureEipsTime = OptionalLong.empty();
private OptionalLong experimentalEipsTime = OptionalLong.empty();
private OptionalLong terminalBlockNumber = OptionalLong.empty();
Expand Down Expand Up @@ -231,6 +232,11 @@ public OptionalLong getCancunTime() {
return cancunTime;
}

@Override
public OptionalLong getEIP6110Time() {
return eip6110Time;
}

@Override
public OptionalLong getFutureEipsTime() {
return futureEipsTime;
Expand Down Expand Up @@ -619,6 +625,17 @@ public StubGenesisConfigOptions cancunTime(final long timestamp) {
return this;
}

/**
* Cancun time.
*
* @param timestamp the timestamp
* @return the stub genesis config options
*/
public StubGenesisConfigOptions eip6110Time(final long timestamp) {
eip6110Time = OptionalLong.of(timestamp);
return this;
}

/**
* Future EIPs Time block.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.hyperledger.besu.ethereum.MainnetBlockValidator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Deposit;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
Expand Down Expand Up @@ -748,6 +749,29 @@ static ProtocolSpecBuilder cancunDefinition(
.name("Cancun");
}

static ProtocolSpecBuilder eip6110Definition(
final Optional<BigInteger> chainId,
final OptionalInt configContractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions,
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {

return cancunDefinition(
chainId,
configContractSizeLimit,
configStackSizeLimit,
enableRevertReason,
genesisConfigOptions,
quorumCompatibilityMode,
evmConfiguration)
.depositsProcessor(new DepositsProcessor())
.depositsValidator(new DepositsValidator.AllowedDeposits())
.name("Eip6110");

}

static ProtocolSpecBuilder futureEipsDefinition(
final Optional<BigInteger> chainId,
final OptionalInt configContractSizeLimit,
Expand Down Expand Up @@ -871,6 +895,7 @@ public BlockProcessingResult processBlock(
final List<Transaction> transactions,
final List<BlockHeader> ommers,
final Optional<List<Withdrawal>> withdrawals,
final Optional<List<Deposit>> deposits,
final PrivateMetadataUpdater privateMetadataUpdater) {
updateWorldStateForDao(worldState);
return wrapped.processBlock(
Expand All @@ -880,6 +905,7 @@ public BlockProcessingResult processBlock(
transactions,
ommers,
withdrawals,
deposits,
privateMetadataUpdater);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.hyperledger.besu.ethereum.BlockProcessingResult;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Deposit;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.Withdrawal;
Expand Down Expand Up @@ -89,6 +90,7 @@ public BlockProcessingResult processBlock(
final List<Transaction> transactions,
final List<BlockHeader> ommers,
final Optional<List<Withdrawal>> withdrawals,
final Optional<List<Deposit>> deposits,
final PrivateMetadataUpdater privateMetadataUpdater) {

if (privateMetadataUpdater != null) {
Expand All @@ -108,6 +110,7 @@ public BlockProcessingResult processBlock(
transactions,
ommers,
withdrawals,
deposits,
metadataUpdater);
metadataUpdater.commit();
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public class ProtocolSpecBuilder {
new WithdrawalsValidator.ProhibitedWithdrawals();
private WithdrawalsProcessor withdrawalsProcessor;

private DepositsValidator depositsValidator =
new DepositsValidator.ProhibitedDeposits();
private DepositsProcessor depositsProcessor;

private FeeMarket feeMarket = FeeMarket.legacy();
private BadBlockManager badBlockManager;
private PoWHasher powHasher = PoWHasher.ETHASH_LIGHT;
Expand Down Expand Up @@ -257,6 +261,16 @@ public ProtocolSpecBuilder withdrawalsProcessor(final WithdrawalsProcessor withd
return this;
}

public ProtocolSpecBuilder depositsValidator(final DepositsValidator depositsValidator) {
this.depositsValidator = depositsValidator;
return this;
}

public ProtocolSpecBuilder depositsProcessor(final DepositsProcessor depositsProcessor) {
this.depositsProcessor = depositsProcessor;
return this;
}

public ProtocolSpec build(final HeaderBasedProtocolSchedule protocolSchedule) {
checkNotNull(gasCalculatorBuilder, "Missing gasCalculator");
checkNotNull(gasLimitCalculator, "Missing gasLimitCalculator");
Expand Down Expand Up @@ -363,7 +377,9 @@ public ProtocolSpec build(final HeaderBasedProtocolSchedule protocolSchedule) {
badBlockManager,
Optional.ofNullable(powHasher),
withdrawalsValidator,
Optional.ofNullable(withdrawalsProcessor));
Optional.ofNullable(withdrawalsProcessor),
depositsValidator,
Optional.ofNullable(depositsProcessor));
}

private PrivateTransactionProcessor createPrivateTransactionProcessor(
Expand Down

0 comments on commit 8ebb906

Please sign in to comment.