use of org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator in project besu by hyperledger.
the class RefundSstoreGasTest method scenarios.
@Parameters(name = "calculator: {0}, original: {2}, current: {3}, new: {4}")
public static Object[][] scenarios() {
final GasCalculator constantinople = new ConstantinopleGasCalculator();
final GasCalculator petersburg = new PetersburgGasCalculator();
final GasCalculator istanbul = new IstanbulGasCalculator();
return new Object[][] { // Zero no-op
{ "constantinople", constantinople, ZERO, ZERO, ZERO, 200L, 0L }, { "petersburg", petersburg, ZERO, ZERO, ZERO, 5_000L, 0L }, { "istanbul", istanbul, ZERO, ZERO, ZERO, 800L, 0L }, // Zero fresh change
{ "constantinople", constantinople, ZERO, ZERO, ONE, 20_000L, 0L }, { "petersburg", petersburg, ZERO, ZERO, ONE, 20_000L, 0L }, { "istanbul", istanbul, ZERO, ZERO, ONE, 20_000L, 0L }, // Dirty, reset to zero
{ "constantinople", constantinople, ZERO, ONE, ZERO, 200L, 19_800L }, { "petersburg", petersburg, ZERO, ONE, ZERO, 5_000L, 15_000L }, { "istanbul", istanbul, ZERO, ONE, ZERO, 800L, 19_200L }, // Dirty, changed but not reset
{ "constantinople", constantinople, ZERO, ONE, TWO, 200L, 0L }, { "petersburg", petersburg, ZERO, ONE, TWO, 5_000L, 0L }, { "istanbul", istanbul, ZERO, ONE, TWO, 800L, 0L }, // Dirty no-op
{ "constantinople", constantinople, ZERO, ONE, ONE, 200L, 0L }, { "petersburg", petersburg, ZERO, ONE, ONE, 5_000L, 0L }, { "istanbul", istanbul, ZERO, ONE, ONE, 800L, 0L }, // Dirty, zero no-op
{ "constantinople", constantinople, ONE, ZERO, ZERO, 200L, 0L }, { "petersburg", petersburg, ONE, ZERO, ZERO, 5_000L, 0L }, { "istanbul", istanbul, ONE, ZERO, ZERO, 800L, 0L }, // Dirty, reset to non-zero
{ "constantinople", constantinople, ONE, ZERO, ONE, 200L, -15_000L + 4_800L }, { "petersburg", petersburg, ONE, ZERO, ONE, 20_000L, 0L }, { "istanbul", istanbul, ONE, ZERO, ONE, 800L, -15_000L + 4_200L }, // Fresh change to zero
{ "constantinople", constantinople, ONE, ONE, ZERO, 5_000L, 15_000L }, { "petersburg", petersburg, ONE, ONE, ZERO, 5_000L, 15_000L }, { "istanbul", istanbul, ONE, ONE, ZERO, 5_000L, 15_000L }, // Fresh change with all non-zero
{ "constantinople", constantinople, ONE, ONE, TWO, 5_000L, 0L }, { "petersburg", petersburg, ONE, ONE, TWO, 5_000L, 0L }, { "istanbul", istanbul, ONE, ONE, TWO, 5_000L, 0L }, // Dirty, clear originally set value
{ "constantinople", constantinople, ONE, TWO, ZERO, 200L, 15_000L }, { "petersburg", petersburg, ONE, TWO, ZERO, 5_000L, 15_000L }, { "istanbul", istanbul, ONE, TWO, ZERO, 800L, 15_000L }, // Non-zero no-op
{ "constantinople", constantinople, ONE, ONE, ONE, 200L, 0L }, { "petersburg", petersburg, ONE, ONE, ONE, 5_000L, 0L }, { "istanbul", istanbul, ONE, ONE, ONE, 800L, 0L } };
}
use of org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator in project besu by hyperledger.
the class IntrinsicGasTest method data.
@Parameters
public static Collection<Object[]> data() {
final GasCalculator frontier = new FrontierGasCalculator();
final GasCalculator istanbul = new IstanbulGasCalculator();
return Arrays.asList(new Object[][] { // EnoughGAS
{ frontier, 21952L, "0xf86d80018259d894095e7baea6a6c7c4c2dfeb977efac326af552d870a8e0358ac39584bc98a7c979f984b031ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a01fffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" }, { istanbul, 21224L, "0xf86d80018259d894095e7baea6a6c7c4c2dfeb977efac326af552d870a8e0358ac39584bc98a7c979f984b031ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a01fffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" }, // FirstZeroBytes
{ frontier, 21180L, "0xf87c80018261a894095e7baea6a6c7c4c2dfeb977efac326af552d870a9d00000000000000000000000000010000000000000000000000000000001ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a01fffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" }, { istanbul, 21128L, "0xf87c80018261a894095e7baea6a6c7c4c2dfeb977efac326af552d870a9d00000000000000000000000000010000000000000000000000000000001ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a01fffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" }, // LastZeroBytes
{ frontier, 21180L, "0xf87c80018261a894095e7baea6a6c7c4c2dfeb977efac326af552d870a9d01000000000000000000000000000000000000000000000000000000001ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a01fffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" }, { istanbul, 21128L, "0xf87c80018261a894095e7baea6a6c7c4c2dfeb977efac326af552d870a9d01000000000000000000000000000000000000000000000000000000001ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a01fffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" }, // NotEnoughGAS
{ frontier, 21952L, "0xf86d800182521c94095e7baea6a6c7c4c2dfeb977efac326af552d870a8e0358ac39584bc98a7c979f984b031ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" }, { istanbul, 21224L, "0xf86d800182521c94095e7baea6a6c7c4c2dfeb977efac326af552d870a8e0358ac39584bc98a7c979f984b031ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" }, // ZeroBytes
{ frontier, 21116L, "0xf87c80018261a894095e7baea6a6c7c4c2dfeb977efac326af552d870a9d00000000000000000000000000000000000000000000000000000000001ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a01fffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" }, { istanbul, 21116L, "0xf87c80018261a894095e7baea6a6c7c4c2dfeb977efac326af552d870a9d00000000000000000000000000000000000000000000000000000000001ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a01fffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" } });
}
use of org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator in project besu by hyperledger.
the class Benchmarks method benchRipeMD.
private static void benchRipeMD() {
final RIPEMD160PrecompiledContract contract = new RIPEMD160PrecompiledContract(new IstanbulGasCalculator());
final byte[] warmupData = new byte[240];
final Bytes warmupBytes = Bytes.wrap(warmupData);
for (int i = 0; i < HASH_WARMUP; i++) {
contract.compute(warmupBytes, fakeFrame);
}
for (int len = 0; len <= 256; len += 8) {
final byte[] data = new byte[len];
random.nextBytes(data);
final Bytes bytes = Bytes.wrap(data);
final Stopwatch timer = Stopwatch.createStarted();
for (int i = 0; i < HASH_ITERATIONS; i++) {
contract.compute(bytes, fakeFrame);
}
timer.stop();
final double elapsed = timer.elapsed(TimeUnit.NANOSECONDS) / 1.0e9D;
final double perCall = elapsed / HASH_ITERATIONS;
final double gasSpent = perCall * GAS_PER_SECOND_STANDARD;
System.out.printf("ripemd %,d bytes for %,d gas. Charging %,d gas.%n", len, (int) gasSpent, contract.gasRequirement(bytes));
}
}
use of org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator in project besu by hyperledger.
the class Benchmarks method benchSha256.
public static void benchSha256() {
final SHA256PrecompiledContract contract = new SHA256PrecompiledContract(new IstanbulGasCalculator());
final byte[] warmupData = new byte[240];
final Bytes warmupBytes = Bytes.wrap(warmupData);
for (int i = 0; i < HASH_WARMUP; i++) {
contract.compute(warmupBytes, fakeFrame);
}
for (int len = 0; len <= 256; len += 8) {
final byte[] data = new byte[len];
random.nextBytes(data);
final Bytes bytes = Bytes.wrap(data);
final Stopwatch timer = Stopwatch.createStarted();
for (int i = 0; i < HASH_ITERATIONS; i++) {
contract.compute(bytes, fakeFrame);
}
timer.stop();
final double elapsed = timer.elapsed(TimeUnit.NANOSECONDS) / 1.0e9D;
final double perCall = elapsed / HASH_ITERATIONS;
final double gasSpent = perCall * GAS_PER_SECOND_STANDARD;
System.out.printf("sha256 %,d bytes for %,d gas. Charging %,d gas.%n", len, (int) gasSpent, contract.gasRequirement(bytes));
}
}
use of org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator in project besu by hyperledger.
the class Benchmarks method benchBNMUL.
private static void benchBNMUL() {
final Bytes g1Point1 = Bytes.concatenate(Bytes.fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001"), Bytes.fromHexString("0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd45"));
final Bytes scalar = Bytes.fromHexString("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
final Bytes arg = Bytes.concatenate(g1Point1, scalar);
final AltBN128MulPrecompiledContract contract = AltBN128MulPrecompiledContract.istanbul(new IstanbulGasCalculator());
final double gasSpent = runBenchmark(arg, contract);
System.out.printf("BNMUL for %,d gas. Charging %,d gas.%n", (int) gasSpent, contract.gasRequirement(arg));
}
Aggregations