Signed-off-by: Karim Taam <karim.t2am@gmail.com>
pull/6920/head
Karim Taam 11 months ago
parent 18e18994af
commit 4a3ea8a2dc
  1. 1
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  2. 6
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/ForestWorldStateArchive.java
  3. 33
      ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/core/TransactionTest.java
  4. 5
      ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/core/TransactionTestCaseSpec.java
  5. 29
      ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/rlp/RLPRefTest.java

@ -2905,7 +2905,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
+ getMiningParameters().getMinTransactionGasPrice().toDecimalString() + getMiningParameters().getMinTransactionGasPrice().toDecimalString()
+ ", since it cannot be greater than the value of min-gas-price"); + ", since it cannot be greater than the value of min-gas-price");
txPoolConfBuilder.minGasPrice(getMiningParameters().getMinTransactionGasPrice()); txPoolConfBuilder.minGasPrice(getMiningParameters().getMinTransactionGasPrice());
txPoolConfBuilder.minGasPrice(getMiningParameters().getMinTransactionGasPrice());
} }
} }

@ -13,17 +13,17 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
*/ */
package org.hyperledger.besu.ethereum.forest; package org.hyperledger.besu.ethereum.trie.forest;
import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.forest.storage.ForestWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.forest.worldview.ForestMutableWorldState;
import org.hyperledger.besu.ethereum.proof.WorldStateProof; import org.hyperledger.besu.ethereum.proof.WorldStateProof;
import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider; import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider;
import org.hyperledger.besu.ethereum.trie.MerkleTrie; import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.forest.worldview.ForestMutableWorldState;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;

@ -26,6 +26,7 @@ import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import org.hyperledger.besu.evm.gascalculator.BerlinGasCalculator; import org.hyperledger.besu.evm.gascalculator.BerlinGasCalculator;
import org.hyperledger.besu.evm.gascalculator.ByzantiumGasCalculator; import org.hyperledger.besu.evm.gascalculator.ByzantiumGasCalculator;
import org.hyperledger.besu.evm.gascalculator.CancunGasCalculator;
import org.hyperledger.besu.evm.gascalculator.ConstantinopleGasCalculator; import org.hyperledger.besu.evm.gascalculator.ConstantinopleGasCalculator;
import org.hyperledger.besu.evm.gascalculator.FrontierGasCalculator; import org.hyperledger.besu.evm.gascalculator.FrontierGasCalculator;
import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.hyperledger.besu.evm.gascalculator.GasCalculator;
@ -33,6 +34,7 @@ import org.hyperledger.besu.evm.gascalculator.HomesteadGasCalculator;
import org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator; import org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator;
import org.hyperledger.besu.evm.gascalculator.LondonGasCalculator; import org.hyperledger.besu.evm.gascalculator.LondonGasCalculator;
import org.hyperledger.besu.evm.gascalculator.PetersburgGasCalculator; 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.SpuriousDragonGasCalculator;
import org.hyperledger.besu.evm.gascalculator.TangerineWhistleGasCalculator; import org.hyperledger.besu.evm.gascalculator.TangerineWhistleGasCalculator;
import org.hyperledger.besu.testutil.JsonTestParameters; import org.hyperledger.besu.testutil.JsonTestParameters;
@ -54,7 +56,8 @@ public class TransactionTest {
return REFERENCE_TEST_PROTOCOL_SCHEDULES return REFERENCE_TEST_PROTOCOL_SCHEDULES
.getByName(name) .getByName(name)
.getByBlockHeader(BlockHeaderBuilder.createDefault().buildBlockHeader()) .getByBlockHeader(BlockHeaderBuilder.createDefault().buildBlockHeader())
.getTransactionValidatorFactory().get(); .getTransactionValidatorFactory()
.get();
} }
private static final String TEST_CONFIG_FILE_DIR_PATH = "TransactionTests/"; private static final String TEST_CONFIG_FILE_DIR_PATH = "TransactionTests/";
@ -62,7 +65,9 @@ public class TransactionTest {
public static Stream<Arguments> getTestParametersForConfig() { public static Stream<Arguments> getTestParametersForConfig() {
return JsonTestParameters.create(TransactionTestCaseSpec.class) return JsonTestParameters.create(TransactionTestCaseSpec.class)
.generator((name, fullPath, spec, collector) -> collector.add(name, fullPath, spec, true)) .generator((name, fullPath, spec, collector) -> collector.add(name, fullPath, spec, true))
.generate(TEST_CONFIG_FILE_DIR_PATH).stream().map(params -> Arguments.of(params[0], params[1])); .generate(TEST_CONFIG_FILE_DIR_PATH)
.stream()
.map(params -> Arguments.of(params[0], params[1]));
} }
@ParameterizedTest(name = "Name: {0}") @ParameterizedTest(name = "Name: {0}")
@ -125,8 +130,30 @@ public class TransactionTest {
milestone(spec, name, "London", new LondonGasCalculator(), Optional.of(Wei.of(0))); milestone(spec, name, "London", new LondonGasCalculator(), Optional.of(Wei.of(0)));
} }
@ParameterizedTest(name = "Name: {0}")
@MethodSource("getTestParametersForConfig")
public void merge(final String name, final TransactionTestCaseSpec spec) {
milestone(spec, name, "Merge", new LondonGasCalculator(), Optional.of(Wei.of(0)));
}
@ParameterizedTest(name = "Name: {0}")
@MethodSource("getTestParametersForConfig")
public void shanghai(final String name, final TransactionTestCaseSpec spec) {
milestone(spec, name, "Shanghai", new ShanghaiGasCalculator(), Optional.of(Wei.of(0)));
}
@ParameterizedTest(name = "Name: {0}")
@MethodSource("getTestParametersForConfig")
public void cancun(final String name, final TransactionTestCaseSpec spec) {
milestone(spec, name, "Cancun", new CancunGasCalculator(), Optional.of(Wei.of(0)));
}
public void milestone( public void milestone(
final TransactionTestCaseSpec spec, final String name, final String milestone, final GasCalculator gasCalculator, final Optional<Wei> baseFee) { final TransactionTestCaseSpec spec,
final String name,
final String milestone,
final GasCalculator gasCalculator,
final Optional<Wei> baseFee) {
final TransactionTestCaseSpec.Expectation expected = spec.expectation(milestone); final TransactionTestCaseSpec.Expectation expected = spec.expectation(milestone);

@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes;
import org.junit.jupiter.api.Assumptions;
/** A Transaction test case specification. */ /** A Transaction test case specification. */
@JsonIgnoreProperties({"_info"}) @JsonIgnoreProperties({"_info"})
@ -109,9 +110,7 @@ public class TransactionTestCaseSpec {
public Expectation expectation(final String milestone) { public Expectation expectation(final String milestone) {
final Expectation expectation = expectations.get(milestone); final Expectation expectation = expectations.get(milestone);
if (expectation == null) { Assumptions.assumeFalse(expectation == null, () -> "No expectation for milestone " + milestone);
throw new IllegalStateException("Expectation for milestone " + milestone + " not found");
}
return expectation; return expectation;
} }

@ -16,12 +16,13 @@ package org.hyperledger.besu.ethereum.rlp;
import static org.junit.jupiter.api.Assumptions.assumeTrue; import static org.junit.jupiter.api.Assumptions.assumeTrue;
import org.assertj.core.api.Assertions;
import org.hyperledger.besu.ethereum.rlp.util.RLPTestUtil; import org.hyperledger.besu.ethereum.rlp.util.RLPTestUtil;
import org.hyperledger.besu.testutil.JsonTestParameters; import org.hyperledger.besu.testutil.JsonTestParameters;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.apache.tuweni.bytes.Bytes;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.MethodSource;
@ -29,23 +30,45 @@ import org.junit.jupiter.params.provider.MethodSource;
/** The Ethereum reference RLP tests. */ /** The Ethereum reference RLP tests. */
public class RLPRefTest { public class RLPRefTest {
private static final String TEST_CONFIG_FILES = "RLPTests/rlptest.json"; private static final String[] TEST_CONFIG_FILES = {
"RLPTests/rlptest.json", "RLPTests/invalidRLPTest.json"
};
private static final Bytes INVALID = Bytes.fromHexString("0x494e56414c4944");
public static Stream<Arguments> getTestParametersForConfig() { public static Stream<Arguments> getTestParametersForConfig() {
return JsonTestParameters.create(RLPRefTestCaseSpec.class).generate(TEST_CONFIG_FILES).stream().map(params -> Arguments.of(params[0], params[1], params[2])); return JsonTestParameters.create(RLPRefTestCaseSpec.class).generate(TEST_CONFIG_FILES).stream()
.map(params -> Arguments.of(params[0], params[1], params[2]));
} }
@ParameterizedTest(name = "Name: {0}") @ParameterizedTest(name = "Name: {0}")
@MethodSource("getTestParametersForConfig") @MethodSource("getTestParametersForConfig")
public void encode(final String name, final RLPRefTestCaseSpec spec, final boolean runTest) { public void encode(final String name, final RLPRefTestCaseSpec spec, final boolean runTest) {
assumeTrue(runTest, "Test was blacklisted"); assumeTrue(runTest, "Test was blacklisted");
if (!spec.getIn().equals(INVALID)) {
Assertions.assertThat(RLPTestUtil.encode(spec.getIn())).isEqualTo(spec.getOut()); Assertions.assertThat(RLPTestUtil.encode(spec.getIn())).isEqualTo(spec.getOut());
} }
}
@ParameterizedTest(name = "Name: {0}") @ParameterizedTest(name = "Name: {0}")
@MethodSource("getTestParametersForConfig") @MethodSource("getTestParametersForConfig")
public void decode(final String name, final RLPRefTestCaseSpec spec, final boolean runTest) { public void decode(final String name, final RLPRefTestCaseSpec spec, final boolean runTest) {
assumeTrue(runTest, "Test was blacklisted"); assumeTrue(runTest, "Test was blacklisted");
if (spec.getIn().equals(INVALID)) {
Assertions.assertThatThrownBy(() -> RLPTestUtil.decode(spec.getOut()))
.isInstanceOf(RLPException.class);
Assertions.assertThatThrownBy(() -> decode2(RLP.input(spec.getOut())))
.isInstanceOf(RLPException.class);
} else {
Assertions.assertThat(RLPTestUtil.decode(spec.getOut())).isEqualTo(spec.getIn()); Assertions.assertThat(RLPTestUtil.decode(spec.getOut())).isEqualTo(spec.getIn());
} }
} }
private static Object decode2(final RLPInput in) {
if (in.nextIsList()) {
return in.readList(RLPRefTest::decode2);
} else {
return in.readBytes();
}
}
}

Loading…
Cancel
Save