Skip to content

Commit

Permalink
merge main (had conflicts)
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan <[email protected]>
  • Loading branch information
pinges committed Aug 18, 2023
2 parents 5ea940f + 210927e commit 93cc543
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 22 deletions.
4 changes: 2 additions & 2 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@
| Joshua Fernandes | joshuafernandes | joshuafernandes |
| Lucas Saldanha | lucassaldanha | lucassaldanha |
| Sally MacFarlane | macfarla | macfarla |
| Mark Terry | mark-terry | m.terry |
| Karim Taam | matkt | matkt |
| Meredith Baxter | mbaxter | mbaxter |
| Stefan Pingel | pinges | pinges |
| Danno Ferrin | shemnon | shemnon |
| Simon Dudley | siladu | siladu |
| Usman Saleem | usmansaleem | usmansaleem |
| Zhenyang Shi | wcgcyx | wcgcyx |


## Emeritus Maintainers
Expand All @@ -47,6 +45,7 @@
| Frank Li | frankisawesome | frankliawesome |
| Ivaylo Kirilov | iikirilov | iikirilov |
| Madeline Murray | MadelineMurray | madelinemurray |
| Mark Terry | mark-terry | m.terry |
| Nicolas Massart | NicolasMassart | NicolasMassart |
| Trent Mohay | rain-on | trent.mohay |
| Rai Sur | RatanRSur | ratanraisur |
Expand All @@ -55,6 +54,7 @@
| Taccat Isid | taccatisid | taccatisid |
| Tim Beiko | timbeiko | timbeiko |
| Vijay Michalik | vmichalik | VijayMichalik |
| Zhenyang Shi | wcgcyx | wcgcyx |

## Becoming a Maintainer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,23 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext)
final EnginePayloadParameter blockParam =
requestContext.getRequiredParameter(0, EnginePayloadParameter.class);

Optional<List<String>> maybeVersionedHashParam =
final Optional<List<String>> maybeVersionedHashParam =
requestContext.getOptionalList(1, String.class);

Object reqId = requestContext.getRequest().getId();
Optional<List<VersionedHash>> maybeVersionedHashes;
final Object reqId = requestContext.getRequest().getId();

Optional<String> maybeParentBeaconBlockRootParam =
requestContext.getOptionalParameter(2, String.class);
final Optional<Bytes32> maybeParentBeaconBlockRoot =
maybeParentBeaconBlockRootParam.map(Bytes32::fromHexString);

ValidationResult<RpcErrorType> forkValidationResult =
validateForkSupported(reqId, blockParam, maybeParentBeaconBlockRoot);
if (!forkValidationResult.isValid()) {
return new JsonRpcErrorResponse(reqId, forkValidationResult);
}

final Optional<List<VersionedHash>> maybeVersionedHashes;
try {
maybeVersionedHashes = extractVersionedHashes(maybeVersionedHashParam);
} catch (RuntimeException ex) {
Expand All @@ -124,16 +136,7 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext)
.addArgument(() -> Json.encodePrettily(blockParam))
.log();

Optional<String> maybeParentBeaconBlockRootParam =
requestContext.getOptionalParameter(2, String.class);
final Optional<Bytes32> maybeParentBeaconBlockRoot =
maybeParentBeaconBlockRootParam.map(Bytes32::fromHexString);

ValidationResult<RpcErrorType> forkValidationResult =
validateForkSupported(reqId, blockParam, maybeParentBeaconBlockRoot);
if (!forkValidationResult.isValid()) {
return new JsonRpcErrorResponse(reqId, forkValidationResult);
}

final Optional<List<Withdrawal>> maybeWithdrawals =
Optional.ofNullable(blockParam.getWithdrawals())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ protected ValidationResult<RpcErrorType> validateForkSupported(
if (payloadParameter.getTimestamp() >= cancunTimestamp) {
if (payloadParameter.getDataGasUsed() == null
|| payloadParameter.getExcessDataGas() == null) {
return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing data gas fields");
return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing blob gas fields");
} else if (maybeParentBeaconBlockRoot.isEmpty()) {
return ValidationResult.invalid(
RpcErrorType.INVALID_PARAMS, "Missing parent beacon block root");
} else {
return ValidationResult.valid();
}
} else {
return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Fork not supported");
return ValidationResult.invalid(RpcErrorType.UNSUPPORTED_FORK, "Fork not supported");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public enum RpcErrorType {
INVALID_FORKCHOICE_STATE(-38002, "Invalid forkchoice state"),
INVALID_PAYLOAD_ATTRIBUTES(-38003, "Invalid payload attributes"),
INVALID_RANGE_REQUEST_TOO_LARGE(-38004, "Too large request"),
UNSUPPORTED_FORK(-38005, "Unsupported fork"),
// Miner failures
COINBASE_NOT_SET(-32010, "Coinbase not set. Unable to start mining without a coinbase"),
NO_HASHES_PER_SECOND(-32011, "No hashes being generated by the current node"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ public void before() {
@Test
public void shouldInvalidPayloadOnShortVersionedHash() {
Bytes shortHash = Bytes.fromHexString("0x" + "69".repeat(31));

EnginePayloadParameter payload = mock(EnginePayloadParameter.class);
when(payload.getTimestamp()).thenReturn(30l);
when(payload.getExcessDataGas()).thenReturn("99");
when(payload.getDataGasUsed()).thenReturn(9l);

JsonRpcResponse badParam =
method.response(
new JsonRpcRequestContext(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.hyperledger.besu.evmtool.B11rSubCommand.COMMAND_ALIAS;
import static org.hyperledger.besu.evmtool.B11rSubCommand.COMMAND_NAME;

import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.referencetests.BlockchainReferenceTestCaseSpec.ReferenceTestBlockHeader;
Expand Down Expand Up @@ -154,6 +155,8 @@ public B11rSubCommand(final EvmToolCommand parentCommand) {
@Override
public void run() {
LogConfigurator.setLevel("", "OFF");
// presume ethereum mainnet for reference and state tests
SignatureAlgorithmFactory.setDefaultInstance();
ObjectMapper objectMapper = JsonUtils.createObjectMapper();
final ObjectReader b11rReader = objectMapper.reader();

Expand Down Expand Up @@ -212,7 +215,7 @@ public void run() {

if (config.has("txs")) {
String txsString = config.get("txs").textValue();
if (txsString.length() > 0) {
if (!txsString.isEmpty()) {
txsBytes = Bytes.fromHexString(txsString);
}
}
Expand All @@ -224,7 +227,7 @@ public void run() {
BytesValueRLPOutput rlpOut = new BytesValueRLPOutput();
rlpOut.startList();
newHeader.writeTo(rlpOut);
if (txsBytes != null && txsBytes.size() > 0) {
if (txsBytes != null && !txsBytes.isEmpty()) {
rlpOut.writeRaw(txsBytes);
} else {
rlpOut.startList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.crypto.SignatureAlgorithmType;
import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
Expand All @@ -33,6 +35,8 @@
import java.util.function.Supplier;
import javax.inject.Named;

import picocli.CommandLine;

class MainnetGenesisFileModule extends GenesisFileModule {

MainnetGenesisFileModule(final String genesisConfig) {
Expand All @@ -49,6 +53,19 @@ ProtocolSchedule provideProtocolSchedule(
final GenesisConfigOptions configOptions,
@Named("Fork") final Optional<String> fork,
@Named("RevertReasonEnabled") final boolean revertReasonEnabled) {

final Optional<String> ecCurve = configOptions.getEcCurve();
if (ecCurve.isEmpty()) {
SignatureAlgorithmFactory.setDefaultInstance();
} else {
try {
SignatureAlgorithmFactory.setInstance(SignatureAlgorithmType.create(ecCurve.get()));
} catch (final IllegalArgumentException e) {
throw new CommandLine.InitializationException(
"Invalid genesis file configuration for ecCurve. " + e.getMessage());
}
}

if (fork.isPresent()) {
var schedules = createSchedules();
var schedule = schedules.get(fork.map(String::toLowerCase).get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.hyperledger.besu.ethereum.referencetests.ReferenceTestProtocolSchedules.shouldClearEmptyAccounts;
import static org.hyperledger.besu.evmtool.StateTestSubCommand.COMMAND_NAME;

import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.datatypes.DataGas;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
Expand Down Expand Up @@ -115,6 +116,8 @@ public StateTestSubCommand() {
@Override
public void run() {
LogConfigurator.setLevel("", "OFF");
// presume ethereum mainnet for reference and state tests
SignatureAlgorithmFactory.setDefaultInstance();
final ObjectMapper stateTestMapper = JsonUtils.createObjectMapper();

final JavaType javaType =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static org.hyperledger.besu.evmtool.T8nExecutor.extractTransactions;

import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestEnv;
Expand Down Expand Up @@ -65,6 +66,8 @@ public class T8nServerSubCommand implements Runnable {
@Override
public void run() {
LogConfigurator.setLevel("", "OFF");
// presume ethereum mainnet for reference and state tests
SignatureAlgorithmFactory.setDefaultInstance();
Vertx.vertx()
.createHttpServer(
new HttpServerOptions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.hyperledger.besu.evmtool.T8nSubCommand.COMMAND_ALIAS;
import static org.hyperledger.besu.evmtool.T8nSubCommand.COMMAND_NAME;

import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.Transaction;
Expand Down Expand Up @@ -169,6 +170,8 @@ public T8nSubCommand(final EvmToolCommand parentCommand) {
@Override
public void run() {
LogConfigurator.setLevel("", "OFF");
// presume ethereum mainnet for reference and state tests
SignatureAlgorithmFactory.setDefaultInstance();
final ObjectMapper objectMapper = JsonUtils.createObjectMapper();
final ObjectReader t8nReader = objectMapper.reader();

Expand Down Expand Up @@ -321,7 +324,7 @@ public void disposeTracer(final OperationTracer tracer) {
}
}

if (outputObject.size() > 0) {
if (!outputObject.isEmpty()) {
parentCommand.out.println(writer.writeValueAsString(outputObject));
}
} catch (IOException ioe) {
Expand Down
3 changes: 2 additions & 1 deletion evm/src/main/java/org/hyperledger/besu/evm/MainnetEVMs.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.evm;

import org.hyperledger.besu.evm.gascalculator.BerlinGasCalculator;
import org.hyperledger.besu.evm.gascalculator.ByzantiumGasCalculator;
import org.hyperledger.besu.evm.gascalculator.CancunGasCalculator;
import org.hyperledger.besu.evm.gascalculator.ConstantinopleGasCalculator;
Expand Down Expand Up @@ -546,7 +547,7 @@ public static EVM berlin(final EvmConfiguration evmConfiguration) {
* @return the evm
*/
public static EVM berlin(final BigInteger chainId, final EvmConfiguration evmConfiguration) {
return berlin(new IstanbulGasCalculator(), chainId, evmConfiguration);
return berlin(new BerlinGasCalculator(), chainId, evmConfiguration);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.evm.precompile;

import static org.hyperledger.besu.evm.internal.Words.clampedAdd;
import static org.hyperledger.besu.evm.internal.Words.clampedMultiply;
import static org.hyperledger.besu.evm.internal.Words.clampedToInt;
import static org.hyperledger.besu.evm.internal.Words.clampedToLong;
Expand Down Expand Up @@ -154,9 +155,9 @@ public static long multiplicationComplexity(final long x) {
if (x <= 64) {
return square(x);
} else if (x <= 1024) {
return (square(x) / 4) + (x * 96) - 3072;
return clampedAdd((square(x) / 4), clampedMultiply(x, 96)) - 3072;
} else {
return (square(x) / 16) + (480 * x) - 199680;
return clampedAdd((square(x) / 16), clampedMultiply(480, x)) - 199680;
}
}

Expand Down

0 comments on commit 93cc543

Please sign in to comment.