Skip to content

Commit

Permalink
Remove shanghai hf config
Browse files Browse the repository at this point in the history
Signed-off-by: Cody Born <codyborn@outlook.com>
  • Loading branch information
codyborn committed Jul 31, 2022
1 parent 57f1fd2 commit 188d201
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ default boolean isConsensusMigration() {

OptionalLong getParisBlockNumber();

OptionalLong getShanghaiBlockNumber();
OptionalLong getEIP1153BlockNumber();

Optional<Wei> getBaseFeePerGas();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ public OptionalLong getParisBlockNumber() {
}

@Override
public OptionalLong getShanghaiBlockNumber() {
return getOptionalLong("shanghaiblock");
public OptionalLong getEIP1153BlockNumber() {
return getOptionalLong("eip1153Block");
}

@Override
Expand Down Expand Up @@ -453,7 +453,7 @@ public Map<String, Object> asMap() {
getArrowGlacierBlockNumber().ifPresent(l -> builder.put("arrowGlacierBlock", l));
getGrayGlacierBlockNumber().ifPresent(l -> builder.put("grayGlacierBlock", l));
getParisBlockNumber().ifPresent(l -> builder.put("parisBlock", l));
getShanghaiBlockNumber().ifPresent(l -> builder.put("shanghaiBlock", l));
getEIP1153BlockNumber().ifPresent(l -> builder.put("eip1153Block", l));
getTerminalBlockNumber().ifPresent(l -> builder.put("terminalBlockNumber", l));
getTerminalBlockHash().ifPresent(h -> builder.put("terminalBlockHash", h.toHexString()));

Expand Down Expand Up @@ -573,7 +573,7 @@ public List<Long> getForks() {
getArrowGlacierBlockNumber(),
getGrayGlacierBlockNumber(),
getParisBlockNumber(),
getShanghaiBlockNumber(),
getEIP1153BlockNumber(),
getTerminalBlockNumber(),
getEcip1015BlockNumber(),
getDieHardBlockNumber(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions {
private OptionalLong arrowGlacierBlockNumber = OptionalLong.empty();
private OptionalLong grayGlacierBlockNumber = OptionalLong.empty();
private OptionalLong parisBlockNumber = OptionalLong.empty();
private OptionalLong shanghaiBlockNumber = OptionalLong.empty();
private OptionalLong eip1153BlockNumber = OptionalLong.empty();
private OptionalLong terminalBlockNumber = OptionalLong.empty();
private Optional<Hash> terminalBlockHash = Optional.empty();
private Optional<UInt256> terminalTotalDifficulty = Optional.empty();
Expand Down Expand Up @@ -218,8 +218,8 @@ public OptionalLong getParisBlockNumber() {
}

@Override
public OptionalLong getShanghaiBlockNumber() {
return shanghaiBlockNumber;
public OptionalLong getEIP1153BlockNumber() {
return eip1153BlockNumber;
}

@Override
Expand Down Expand Up @@ -350,7 +350,7 @@ public Map<String, Object> asMap() {
getArrowGlacierBlockNumber().ifPresent(l -> builder.put("arrowGlacierBlock", l));
getGrayGlacierBlockNumber().ifPresent(l -> builder.put("grayGlacierBlock", l));
getParisBlockNumber().ifPresent(l -> builder.put("parisBlock", l));
getShanghaiBlockNumber().ifPresent(l -> builder.put("shanghaiBlock", l));
getEIP1153BlockNumber().ifPresent(l -> builder.put("eip1153Block", l));
getTerminalBlockNumber().ifPresent(l -> builder.put("terminalBlockNumber", l));
getTerminalBlockHash().ifPresent(h -> builder.put("terminalBlockHash", h));
// classic fork blocks
Expand Down Expand Up @@ -489,8 +489,8 @@ public StubGenesisConfigOptions parisBlock(final long blockNumber) {
return this;
}

public StubGenesisConfigOptions shanghaiBlock(final long blockNumber) {
shanghaiBlockNumber = OptionalLong.of(blockNumber);
public StubGenesisConfigOptions eip1153Block(final long blockNumber) {
eip1153BlockNumber = OptionalLong.of(blockNumber);
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion config/src/test/resources/all_forks.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"arrowGlacierBlock": 12,
"grayGlacierBlock": 13,
"parisBlock": 14,
"shanghaiBlock": 15,
"eip1153Block": 15,
"ecip1015Block": 102,
"dieHardBlock": 103,
"gothamBlock": 104,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ public ProtocolSpecBuilder parisDefinition(final GenesisConfigOptions genesisCon
evmConfiguration);
}

public ProtocolSpecBuilder shanghaiDefinition(final GenesisConfigOptions genesisConfigOptions) {
return MainnetProtocolSpecs.shanghaiDefinition(
public ProtocolSpecBuilder eip1153Definition(final GenesisConfigOptions genesisConfigOptions) {
return MainnetProtocolSpecs.eip1153Definition(
chainId,
contractSizeLimit,
evmStackSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import org.hyperledger.besu.evm.gascalculator.PetersburgGasCalculator;
import org.hyperledger.besu.evm.gascalculator.SpuriousDragonGasCalculator;
import org.hyperledger.besu.evm.gascalculator.TangerineWhistleGasCalculator;
import org.hyperledger.besu.evm.gascalculator.ShanghaiGasCalculator;
import org.hyperledger.besu.evm.gascalculator.EIP1153GasCalculator;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.processor.ContractCreationProcessor;
import org.hyperledger.besu.evm.processor.MessageCallProcessor;
Expand Down Expand Up @@ -633,7 +633,8 @@ static ProtocolSpecBuilder parisDefinition(
.name("ParisFork");
}

static ProtocolSpecBuilder shanghaiDefinition(
// TODO EIP-1153 change for the actual fork name when known
static ProtocolSpecBuilder eip1153Definition(
final Optional<BigInteger> chainId,
final OptionalInt configContractSizeLimit,
final OptionalInt configStackSizeLimit,
Expand All @@ -652,9 +653,9 @@ static ProtocolSpecBuilder shanghaiDefinition(
evmConfiguration)
.evmBuilder(
(gasCalculator, jdCacheConfig) ->
MainnetEVMs.shanghai(gasCalculator, chainId.orElse(BigInteger.ZERO), evmConfiguration))
.gasCalculator(ShanghaiGasCalculator::new)
.name("ShanghaiFork");
MainnetEVMs.eip1153(gasCalculator, chainId.orElse(BigInteger.ZERO), evmConfiguration))
.gasCalculator(EIP1153GasCalculator::new)
.name("EIP-1153");
}

private static TransactionReceipt frontierTransactionReceiptFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private TreeMap<Long, BuilderMapEntry> buildMilestoneMap(
create(
config.getGrayGlacierBlockNumber(), specFactory.grayGlacierDefinition(config)),
create(config.getParisBlockNumber(), specFactory.parisDefinition(config)),
create(config.getShanghaiBlockNumber(), specFactory.shanghaiDefinition(config)),
create(config.getEIP1153BlockNumber(), specFactory.eip1153Definition(config)),
// Classic Milestones
create(config.getEcip1015BlockNumber(), specFactory.tangerineWhistleDefinition()),
create(config.getDieHardBlockNumber(), specFactory.dieHardDefinition()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public static Object[][] scenarios() {
@Before
public void setUp() {
ProtocolSchedule protocolSchedule = MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().shanghaiBlock(0), EvmConfiguration.DEFAULT);
new StubGenesisConfigOptions().eip1153Block(0), EvmConfiguration.DEFAULT);
codeExecutor = new TestCodeExecutor(protocolSchedule,
account -> account.setStorageValue(UInt256.ZERO, UInt256.valueOf(0)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/
package org.hyperledger.besu.ethereum.vm.operations;

import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.units.bigints.UInt256;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
Expand All @@ -23,14 +22,10 @@
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.MessageFrameTestFixture;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.frame.ExceptionalHaltReason;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.gascalculator.ConstantinopleGasCalculator;
import org.hyperledger.besu.evm.gascalculator.EIP1153GasCalculator;
import org.hyperledger.besu.evm.gascalculator.GasCalculator;
import org.hyperledger.besu.evm.gascalculator.LondonGasCalculator;
import org.hyperledger.besu.evm.gascalculator.ShanghaiGasCalculator;
import org.hyperledger.besu.evm.operation.Operation.OperationResult;
import org.hyperledger.besu.evm.operation.SStoreOperation;
import org.hyperledger.besu.evm.operation.TLoadOperation;
import org.hyperledger.besu.evm.operation.TStoreOperation;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
Expand All @@ -49,7 +44,7 @@

public class TStoreOperationTest {

private static final GasCalculator gasCalculator = new ShanghaiGasCalculator();
private static final GasCalculator gasCalculator = new EIP1153GasCalculator();

private MessageFrame createMessageFrame(
final Address address, final long initialGas, final long remainingGas) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static ReferenceTestProtocolSchedules create() {
builder.put(
"ArrowGlacier", createSchedule(new StubGenesisConfigOptions().arrowGlacierBlock(0)));
builder.put("GrayGlacier", createSchedule(new StubGenesisConfigOptions().grayGlacierBlock(0)));
builder.put("Shanghai", createSchedule(new StubGenesisConfigOptions().shanghaiBlock(0)));
builder.put("EIP1153", createSchedule(new StubGenesisConfigOptions().eip1153Block(0)));
return new ReferenceTestProtocolSchedules(builder.build());
}

Expand Down
17 changes: 9 additions & 8 deletions evm/src/main/java/org/hyperledger/besu/evm/MainnetEVMs.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
import org.hyperledger.besu.evm.gascalculator.BerlinGasCalculator;
import org.hyperledger.besu.evm.gascalculator.ByzantiumGasCalculator;
import org.hyperledger.besu.evm.gascalculator.ConstantinopleGasCalculator;
import org.hyperledger.besu.evm.gascalculator.EIP1153GasCalculator;
import org.hyperledger.besu.evm.gascalculator.FrontierGasCalculator;
import org.hyperledger.besu.evm.gascalculator.GasCalculator;
import org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator;
import org.hyperledger.besu.evm.gascalculator.LondonGasCalculator;
import org.hyperledger.besu.evm.gascalculator.PetersburgGasCalculator;
import org.hyperledger.besu.evm.gascalculator.ShanghaiGasCalculator;
import org.hyperledger.besu.evm.gascalculator.SpuriousDragonGasCalculator;
import org.hyperledger.besu.evm.gascalculator.TangerineWhistleGasCalculator;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
Expand Down Expand Up @@ -398,25 +398,26 @@ public static void registerParisOperations(
registry.put(new PrevRanDaoOperation(gasCalculator));
}

public static EVM shanghai(final BigInteger chainId, final EvmConfiguration evmConfiguration) {
return shanghai(new ShanghaiGasCalculator(), chainId, evmConfiguration);
// TODO EIP-1153 change for the actual fork name when known
public static EVM eip1153(final BigInteger chainId, final EvmConfiguration evmConfiguration) {
return eip1153(new EIP1153GasCalculator(), chainId, evmConfiguration);
}

public static EVM shanghai(
public static EVM eip1153(
final GasCalculator gasCalculator,
final BigInteger chainId,
final EvmConfiguration evmConfiguration) {
return new EVM(shanghaiOperations(gasCalculator, chainId), gasCalculator, evmConfiguration);
return new EVM(eip1153Operations(gasCalculator, chainId), gasCalculator, evmConfiguration);
}

public static OperationRegistry shanghaiOperations(
public static OperationRegistry eip1153Operations(
final GasCalculator gasCalculator, final BigInteger chainId) {
OperationRegistry operationRegistry = new OperationRegistry();
registerShanghaiOperations(operationRegistry, gasCalculator, chainId);
registerEIP1153Operations(operationRegistry, gasCalculator, chainId);
return operationRegistry;
}

public static void registerShanghaiOperations(
public static void registerEIP1153Operations(
final OperationRegistry registry,
final GasCalculator gasCalculator,
final BigInteger chainID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
*/
package org.hyperledger.besu.evm.gascalculator;

public class ShanghaiGasCalculator extends LondonGasCalculator {
public class EIP1153GasCalculator extends LondonGasCalculator {

private static final long TLOAD_GAS = WARM_STORAGE_READ_COST;
private static final long TSTORE_GAS = WARM_STORAGE_READ_COST;

public ShanghaiGasCalculator() {}
public EIP1153GasCalculator() {}

// EIP-1153
@Override
Expand Down

0 comments on commit 188d201

Please sign in to comment.