use of com.hedera.services.bdd.suites.perf.PerfTestLoadSettings in project hedera-services by hashgraph.
the class MixedSmartContractOpsLoadTest method RunMixedSmartContractOps.
protected HapiApiSpec RunMixedSmartContractOps() {
PerfTestLoadSettings settings = new PerfTestLoadSettings();
final AtomicInteger createdSoFar = new AtomicInteger(0);
final String SOME_BYTE_CODE = "contractByteCode";
final String UPDATABLE_CONTRACT = "updatableContract";
final String CONTRACT_NAME_PREFIX = "testContract";
final String PAYABLE_FILE = "payableByteCode";
final String PAYABLE_CONTRACT = "payableContract";
final String LOOKUP_FILE = "lookUpByteCode";
final String LOOKUP_CONTRACT = "lookUpContract";
final String CIVILIAN_ACCOUNT = "civilian";
final int depositAmount = 1;
Supplier<HapiSpecOperation[]> mixedOpsBurst = () -> new HapiSpecOperation[] { /* create a contract */
contractCreate(CONTRACT_NAME_PREFIX + createdSoFar.getAndIncrement()).bytecode(SOME_BYTE_CODE).hasAnyPrecheck().deferStatusResolution(), /* update the memo and do get info on the contract that needs to be updated */
contractUpdate(UPDATABLE_CONTRACT).newMemo(new String(randomUtf8Bytes(memoLength.getAsInt()))).hasAnyPrecheck().deferStatusResolution(), /* call balance lookup contract and contract to deposit funds*/
contractCallLocal(LOOKUP_CONTRACT, BALANCE_LOOKUP_ABI, spec -> new Object[] { spec.registry().getAccountID(CIVILIAN_ACCOUNT).getAccountNum() }).payingWith(GENESIS), contractCall(PAYABLE_CONTRACT, ContractResources.DEPOSIT_ABI, depositAmount).sending(depositAmount).suppressStats(true).deferStatusResolution() };
return defaultHapiSpec("RunMixedSmartContractOps").given(withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())), logIt(ignore -> settings.toString())).when(/* create an account */
cryptoCreate(CIVILIAN_ACCOUNT).balance(ONE_HUNDRED_HBARS), /* create a file with some contents and contract with it */
fileCreate(SOME_BYTE_CODE).path(ContractResources.VALID_BYTECODE_PATH), contractCreate(UPDATABLE_CONTRACT).bytecode(SOME_BYTE_CODE).adminKey(THRESHOLD), /* create a contract which does a query to look up balance of the civilan account */
fileCreate(LOOKUP_FILE).path(ContractResources.BALANCE_LOOKUP_BYTECODE_PATH), contractCreate(LOOKUP_CONTRACT).bytecode(LOOKUP_FILE).adminKey(THRESHOLD), /* create a contract that does a transaction to deposit funds */
fileCreate(PAYABLE_FILE).path(ContractResources.PAYABLE_CONTRACT_BYTECODE_PATH), contractCreate(PAYABLE_CONTRACT).bytecode(PAYABLE_FILE).adminKey(THRESHOLD), /* get contract info on all contracts created */
getContractInfo(LOOKUP_CONTRACT).hasExpectedInfo().logged(), getContractInfo(PAYABLE_CONTRACT).hasExpectedInfo().logged(), getContractInfo(UPDATABLE_CONTRACT).hasExpectedInfo().logged()).then(defaultLoadTest(mixedOpsBurst, settings));
}
use of com.hedera.services.bdd.suites.perf.PerfTestLoadSettings in project hedera-services by hashgraph.
the class SStoreOperationLoadTest method runContractCalls.
private HapiApiSpec runContractCalls() {
PerfTestLoadSettings settings = new PerfTestLoadSettings();
final AtomicInteger submittedSoFar = new AtomicInteger(0);
long setValue = 0x1234abdeL;
Supplier<HapiSpecOperation[]> callBurst = () -> new HapiSpecOperation[] { contractCall("perf", ContractResources.BIG_ARRAY_CHANGE_ARRAY_ABI, setValue).noLogging().payingWith("sender").suppressStats(true).hasKnownStatusFrom(UNKNOWN, SUCCESS).hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED).deferStatusResolution() };
return defaultHapiSpec("runContractCalls").given(withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())), logIt(ignore -> settings.toString())).when(cryptoCreate("sender").balance(initialBalance.getAsLong()).withRecharging().rechargeWindow(3).hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED), fileCreate("contractBytecode").path(ContractResources.BIG_ARRAY_BYTECODE_PATH).hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED), contractCreate("perf").bytecode("contractBytecode").hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED), getContractInfo("perf").hasExpectedInfo().logged(), // Initialize storage size
contractCall("perf", ContractResources.BIG_ARRAY_SET_SIZE_ABI, size).hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED).gas(300_000)).then(defaultLoadTest(callBurst, settings));
}
use of com.hedera.services.bdd.suites.perf.PerfTestLoadSettings in project hedera-services by hashgraph.
the class CryptoTransferLoadTestWithAutoAccounts method runCryptoTransfers.
protected HapiApiSpec runCryptoTransfers() {
PerfTestLoadSettings settings = new PerfTestLoadSettings();
Supplier<HapiSpecOperation[]> transferBurst = () -> {
String sender = "sender";
String receiver;
if (r.nextInt(10) < 5) {
receiver = "alias" + r.nextInt(AUTO_ACCOUNTS);
} else {
receiver = "receiver";
}
if (receiver.startsWith("alias")) {
return new HapiSpecOperation[] { cryptoTransfer(tinyBarsFromToWithAlias(sender, receiver, 1L)).logging().payingWith(sender).signedBy(GENESIS).suppressStats(true).fee(100_000_000L).hasKnownStatusFrom(SUCCESS, OK, INSUFFICIENT_PAYER_BALANCE, UNKNOWN, TRANSACTION_EXPIRED, INSUFFICIENT_ACCOUNT_BALANCE).hasRetryPrecheckFrom(BUSY, PLATFORM_TRANSACTION_NOT_CREATED).deferStatusResolution() };
}
return new HapiSpecOperation[] { cryptoTransfer(tinyBarsFromTo(sender, receiver, 1L)).noLogging().payingWith(sender).signedBy(GENESIS).suppressStats(true).fee(100_000_000L).hasKnownStatusFrom(SUCCESS, OK, INSUFFICIENT_PAYER_BALANCE, UNKNOWN, TRANSACTION_EXPIRED, INSUFFICIENT_ACCOUNT_BALANCE).hasRetryPrecheckFrom(BUSY, PLATFORM_TRANSACTION_NOT_CREATED).deferStatusResolution() };
};
return defaultHapiSpec("RunCryptoTransfersWithAutoAccounts").given(withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())), logIt(ignore -> settings.toString())).when(cryptoCreate("sender").balance(ignore -> settings.getInitialBalance()).payingWith(GENESIS).withRecharging().key(GENESIS).rechargeWindow(3).logging().hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED), cryptoCreate("receiver").payingWith(GENESIS).hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED).key(GENESIS).logging(), withOpContext((spec, opLog) -> {
List<HapiSpecOperation> ops = new ArrayList<>();
for (int i = 0; i < AUTO_ACCOUNTS; i++) {
var alias = "alias" + i;
ops.add(newKeyNamed(alias));
ops.add(cryptoTransfer(tinyBarsFromToWithAlias(DEFAULT_PAYER, alias, ONE_HBAR)));
}
allRunFor(spec, ops);
})).then(defaultLoadTest(transferBurst, settings), getAccountBalance("sender").logged());
}
use of com.hedera.services.bdd.suites.perf.PerfTestLoadSettings in project hedera-services by hashgraph.
the class MixedTransferCallAndSubmitLoadTest method runMixedTransferCallAndSubmits.
private HapiApiSpec runMixedTransferCallAndSubmits() {
PerfTestLoadSettings settings = new PerfTestLoadSettings();
final AtomicInteger submittedSoFar = new AtomicInteger(0);
Supplier<HapiSpecOperation[]> transferBurst = () -> new HapiSpecOperation[] { inParallel(flattened(IntStream.range(0, settings.getBurstSize() / 2).mapToObj(ignore -> cryptoTransfer(tinyBarsFromTo("sender", "receiver", 1L)).noLogging().hasPrecheckFrom(OK, BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED).deferStatusResolution()).toArray(n -> new HapiSpecOperation[n]), IntStream.range(0, settings.getBurstSize() / 25).mapToObj(i -> contractCall("simpleStorage", ContractResources.SIMPLE_STORAGE_SETTER_ABI, i).noLogging().hasPrecheckFrom(OK, BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED).deferStatusResolution()).toArray(n -> new HapiSpecOperation[n]), IntStream.range(0, settings.getBurstSize() / 2).mapToObj(ignore -> submitMessageTo("topic").message("A fascinating item of general interest!").noLogging().hasPrecheckFrom(OK, BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED).deferStatusResolution()).toArray(n -> new HapiSpecOperation[n]))), logIt(ignore -> String.format("Now a 25:1 ratio of %d transfers+messages : calls submitted in total.", submittedSoFar.addAndGet(settings.getBurstSize() / 25 * 26))) };
return defaultHapiSpec("RunMixedTransferCallAndSubmits").given(withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())), logIt(ignore -> settings.toString())).when(createTopic("topic"), cryptoCreate("sender").balance(999_999_999_999_999L), cryptoCreate("receiver"), fileCreate("bytecode").path(ContractResources.SIMPLE_STORAGE_BYTECODE_PATH), contractCreate("simpleStorage").bytecode("bytecode")).then(runLoadTest(transferBurst).tps(settings::getTps).tolerance(settings::getTolerancePercentage).allowedSecsBelow(settings::getAllowedSecsBelow).lasting(settings::getMins, () -> MINUTES));
}
use of com.hedera.services.bdd.suites.perf.PerfTestLoadSettings in project hedera-services by hashgraph.
the class TokenTransferBasicLoadTest method runTokenTransferBasicLoadTest.
private HapiApiSpec runTokenTransferBasicLoadTest() {
PerfTestLoadSettings settings = new PerfTestLoadSettings();
Supplier<HapiSpecOperation[]> tokenTransferBurst = () -> new HapiSpecOperation[] { opSupplier(settings).get() };
return defaultHapiSpec("TokenTransferBasicLoadTest").given(withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap()))).when(sourcing(() -> runWithProvider(tokenCreatesFactory(settings)).lasting(// 10s as buffering time
() -> settings.getTotalTokens() / ESTIMATED_TOKEN_CREATION_RATE + 10, () -> TimeUnit.SECONDS).totalOpsToSumbit(() -> (int) Math.ceil((double) (settings.getTotalTokens()) / settings.getTotalClients())).maxOpsPerSec(() -> (EXPECTED_MAX_OPS_PER_SEC / settings.getTotalClients())).maxPendingOps(() -> MAX_PENDING_OPS_FOR_SETUP)), sourcing(() -> runWithProvider(activeTokenAssociatesFactory(settings)).lasting(() -> (settings.getTotalTokens() * settings.getTotalTestTokenAccounts() / EXPECTED_MAX_OPS_PER_SEC) + // 30s as buffering time
30, () -> TimeUnit.SECONDS).totalOpsToSumbit(() -> (int) Math.ceil((double) (settings.getTotalTokens()) / settings.getTotalClients()) * settings.getTotalTestTokenAccounts()).maxOpsPerSec(() -> (EXPECTED_MAX_OPS_PER_SEC / settings.getTotalClients())).maxPendingOps(() -> MAX_PENDING_OPS_FOR_SETUP)), sleepFor(2000)).then(defaultLoadTest(tokenTransferBurst, settings));
}
Aggregations