Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
Signed-off-by: Danno Ferrin <[email protected]>
  • Loading branch information
shemnon committed Sep 30, 2023
1 parent 513e0f6 commit 3d50d26
Show file tree
Hide file tree
Showing 10 changed files with 527 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"cli": [
"--notime",
"--json",
"--code",
"4131ff",
"--coinbase",
"4444588443C3A91288C5002483449ABA1054192B",
"--fork",
"paris"
],
"stdin": "",
"stdout": [
{
"pc": 0,
"op": 65,
"gas": "0x2540b91f8",
"gasCost": "0x2",
"memSize": 0,
"stack": [],
"depth": 1,
"refund": 0,
"opName": "COINBASE"
},
{
"pc": 1,
"op": 49,
"gas": "0x2540b91f6",
"gasCost": "0xa28",
"memSize": 0,
"stack": [
"0x4444588443c3a91288c5002483449aba1054192b"
],
"depth": 1,
"refund": 0,
"opName": "BALANCE"
},
{
"pc": 2,
"op": 255,
"gas": "0x2540b87ce",
"gasCost": "0x1388",
"memSize": 0,
"stack": [
"0x0"
],
"depth": 1,
"refund": 0,
"opName": "SELFDESTRUCT"
},
{
"gasUser": "0x1db2",
"gasTotal": "0x1db2",
"output": "0x"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"cli": [
"--notime",
"--json",
"--code",
"4131ff",
"--coinbase",
"4444588443C3A91288C5002483449ABA1054192B",
"--fork",
"shanghai"
],
"stdin": "",
"stdout": [
{
"pc": 0,
"op": 65,
"gas": "0x2540b91f8",
"gasCost": "0x2",
"memSize": 0,
"stack": [],
"depth": 1,
"refund": 0,
"opName": "COINBASE"
},
{
"pc": 1,
"op": 49,
"gas": "0x2540b91f6",
"gasCost": "0x64",
"memSize": 0,
"stack": [
"0x4444588443c3a91288c5002483449aba1054192b"
],
"depth": 1,
"refund": 0,
"opName": "BALANCE"
},
{
"pc": 2,
"op": 255,
"gas": "0x2540b9192",
"gasCost": "0x1388",
"memSize": 0,
"stack": [
"0x0"
],
"depth": 1,
"refund": 0,
"opName": "SELFDESTRUCT"
},
{
"gasUser": "0x13ee",
"gasTotal": "0x13ee",
"output": "0x"
}
]
}
16 changes: 16 additions & 0 deletions evm/src/main/java/org/hyperledger/besu/evm/EVM.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.hyperledger.besu.evm.operation.AddOperation;
import org.hyperledger.besu.evm.operation.AndOperation;
import org.hyperledger.besu.evm.operation.ByteOperation;
import org.hyperledger.besu.evm.operation.ChainIdOperation;
import org.hyperledger.besu.evm.operation.DivOperation;
import org.hyperledger.besu.evm.operation.DupOperation;
import org.hyperledger.besu.evm.operation.ExpOperation;
Expand Down Expand Up @@ -139,6 +140,21 @@ public EvmSpecVersion getEvmVersion() {
return evmSpecVersion;
}

/**
* Return the ChainId this Executor is using, or empty if the EVM version does not expose chain
* ID.
*
* @return the ChainId, or empty if not exposed.
*/
public Optional<Bytes> getChainId() {
Operation op = operations.get(ChainIdOperation.OPCODE);
if (op instanceof ChainIdOperation chainIdOperation) {
return Optional.of(chainIdOperation.getChainId());
} else {
return Optional.empty();
}
}

/**
* Run to halt.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public enum EvmSpecVersion {
FRONTIER(0, true, "Frontier", "Finalized"),
/** Homestead evm spec version. */
HOMESTEAD(0, true, "Homestead", "Finalized"),
/** Tangerine Whistle evm spec version. */
TANGERINE_WHISTLE(0, true, "Tangerine Whistle", "Finalized"),
/** Spurious Dragon evm spec version. */
SPURIOUS_DRAGON(0, true, "Spuruous Dragon", "Finalized"),
/** Byzantium evm spec version. */
BYZANTIUM(0, true, "Byzantium", "Finalized"),
/** Constantinople evm spec version. */
Expand Down
36 changes: 26 additions & 10 deletions evm/src/main/java/org/hyperledger/besu/evm/MainnetEVMs.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,12 @@ public static void registerHomesteadOperations(
* @return the evm
*/
public static EVM spuriousDragon(final EvmConfiguration evmConfiguration) {
return homestead(new SpuriousDragonGasCalculator(), evmConfiguration);
GasCalculator gasCalculator = new SpuriousDragonGasCalculator();
return new EVM(
homesteadOperations(gasCalculator),
gasCalculator,
evmConfiguration,
EvmSpecVersion.SPURIOUS_DRAGON);
}

/**
Expand All @@ -338,7 +343,12 @@ public static EVM spuriousDragon(final EvmConfiguration evmConfiguration) {
* @return the evm
*/
public static EVM tangerineWhistle(final EvmConfiguration evmConfiguration) {
return homestead(new TangerineWhistleGasCalculator(), evmConfiguration);
GasCalculator gasCalculator = new TangerineWhistleGasCalculator();
return new EVM(
homesteadOperations(gasCalculator),
gasCalculator,
evmConfiguration,
EvmSpecVersion.TANGERINE_WHISTLE);
}

/**
Expand Down Expand Up @@ -413,11 +423,16 @@ public static EVM constantinople(final EvmConfiguration evmConfiguration) {
*/
public static EVM constantinople(
final GasCalculator gasCalculator, final EvmConfiguration evmConfiguration) {
var version = EvmSpecVersion.CONSTANTINOPLE;
return constantiNOPEl(gasCalculator, evmConfiguration, version);
}

private static EVM constantiNOPEl(
final GasCalculator gasCalculator,
final EvmConfiguration evmConfiguration,
final EvmSpecVersion version) {
return new EVM(
constantinopleOperations(gasCalculator),
gasCalculator,
evmConfiguration,
EvmSpecVersion.CONSTANTINOPLE);
constantinopleOperations(gasCalculator), gasCalculator, evmConfiguration, version);
}

/**
Expand Down Expand Up @@ -455,7 +470,8 @@ public static void registerConstantinopleOperations(
* @return the evm
*/
public static EVM petersburg(final EvmConfiguration evmConfiguration) {
return constantinople(new PetersburgGasCalculator(), evmConfiguration);
return constantiNOPEl(
new PetersburgGasCalculator(), evmConfiguration, EvmSpecVersion.PETERSBURG);
}

/**
Expand Down Expand Up @@ -1145,7 +1161,7 @@ public static void registerFutureEipsOperations(
* @return the evm
*/
public static EVM experimentalEips(final EvmConfiguration evmConfiguration) {
return futureEips(DEV_NET_CHAIN_ID, evmConfiguration);
return experimentalEips(DEV_NET_CHAIN_ID, evmConfiguration);
}

/**
Expand All @@ -1157,7 +1173,7 @@ public static EVM experimentalEips(final EvmConfiguration evmConfiguration) {
*/
public static EVM experimentalEips(
final BigInteger chainId, final EvmConfiguration evmConfiguration) {
return futureEips(chainId, evmConfiguration);
return experimentalEips(new CancunGasCalculator(), chainId, evmConfiguration);
}

/**
Expand All @@ -1176,7 +1192,7 @@ public static EVM experimentalEips(
experimentalEipsOperations(gasCalculator, chainId),
gasCalculator,
evmConfiguration,
EvmSpecVersion.FUTURE_EIPS);
EvmSpecVersion.EXPERIMENTAL_EIPS);
}

/**
Expand Down
Loading

0 comments on commit 3d50d26

Please sign in to comment.