use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE 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.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE in project hedera-services by hashgraph.
the class TokenTransferBasicLoadTest method activeTokenAssociatesFactory.
private Function<HapiApiSpec, OpProvider> activeTokenAssociatesFactory(PerfTestLoadSettings settings) {
int numTotalTokens = settings.getTotalTokens();
int numActiveTokenAccounts = settings.getTotalTestTokenAccounts();
int totalClients = settings.getTotalClients();
int numActiveTokens = (totalClients >= 1) ? numTotalTokens / totalClients : numTotalTokens;
AtomicLong remainingAssociations = new AtomicLong(numActiveTokens * numActiveTokenAccounts - 1);
if (log.isDebugEnabled()) {
log.debug("Total active token accounts {}, total test tokens {}, my portion of tokens {}", numActiveTokenAccounts, numTotalTokens, numActiveTokens);
}
long startAccountId = settings.getTestTreasureStartAccount();
return spec -> new OpProvider() {
@Override
public List<HapiSpecOperation> suggestedInitializers() {
return Collections.emptyList();
}
@Override
public Optional<HapiSpecOperation> get() {
long nextAssocId;
if ((nextAssocId = remainingAssociations.getAndDecrement()) < 0) {
return Optional.empty();
}
int curToken = (int) nextAssocId / numActiveTokenAccounts;
long curAccount = nextAssocId % numActiveTokenAccounts;
var accountId = "0.0." + (startAccountId + curAccount);
var op = tokenAssociate(accountId, tokenRegistryName(curToken)).payingWith(DEFAULT_PAYER).signedBy(DEFAULT_PAYER).hasRetryPrecheckFrom(BUSY, PLATFORM_TRANSACTION_NOT_CREATED, DUPLICATE_TRANSACTION, INSUFFICIENT_PAYER_BALANCE).hasPrecheckFrom(DUPLICATE_TRANSACTION, OK).hasKnownStatusFrom(SUCCESS, TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT, INVALID_TOKEN_ID, TRANSACTION_EXPIRED, TOKENS_PER_ACCOUNT_LIMIT_EXCEEDED, FAIL_INVALID, OK).fee(ONE_HUNDRED_HBARS).noLogging().suppressStats(true).deferStatusResolution();
return Optional.of(op);
}
};
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE in project hedera-services by hashgraph.
the class MixedOpsLoadTest method runMixedOps.
protected HapiApiSpec runMixedOps() {
PerfTestLoadSettings settings = new PerfTestLoadSettings();
Random r = new Random();
AtomicInteger tokenId = new AtomicInteger(0);
AtomicInteger scheduleId = new AtomicInteger(0);
Supplier<HapiSpecOperation[]> mixedOpsBurst = () -> new HapiSpecOperation[] { cryptoTransfer(tinyBarsFromTo(sender, receiver, 1L)).noLogging().payingWith(sender).signedBy(GENESIS).suppressStats(true).fee(ONE_HBAR).hasKnownStatusFrom(SUCCESS, OK, INSUFFICIENT_PAYER_BALANCE, UNKNOWN, TRANSACTION_EXPIRED).hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED, PAYER_ACCOUNT_NOT_FOUND).deferStatusResolution(), submitMessageTo(topic).message(ArrayUtils.addAll(ByteBuffer.allocate(8).putLong(Instant.now().toEpochMilli()).array(), randomUtf8Bytes(messageSize - 8))).noLogging().payingWith(GENESIS).signedBy(sender, submitKey).fee(ONE_HBAR).suppressStats(true).hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED, TOPIC_EXPIRED, INVALID_TOPIC_ID, INSUFFICIENT_PAYER_BALANCE).hasKnownStatusFrom(SUCCESS, OK, INVALID_TOPIC_ID, INSUFFICIENT_PAYER_BALANCE, UNKNOWN, TRANSACTION_EXPIRED).deferStatusResolution(), r.nextInt(100) > 5 ? cryptoTransfer(moving(1, token + r.nextInt(NUM_SUBMISSIONS)).between(sender, receiver)).payingWith(sender).signedBy(GENESIS).fee(ONE_HUNDRED_HBARS).noLogging().suppressStats(true).hasPrecheckFrom(OK, INSUFFICIENT_PAYER_BALANCE, EMPTY_TOKEN_TRANSFER_ACCOUNT_AMOUNTS, DUPLICATE_TRANSACTION).hasRetryPrecheckFrom(permissiblePrechecks).hasKnownStatusFrom(SUCCESS, OK, INSUFFICIENT_TOKEN_BALANCE, TRANSACTION_EXPIRED, INVALID_TOKEN_ID, UNKNOWN, TOKEN_NOT_ASSOCIATED_TO_ACCOUNT).deferStatusResolution() : scheduleSign(schedule + "-" + getHostName() + "-" + r.nextInt(NUM_SUBMISSIONS)).ignoreIfMissing().noLogging().alsoSigningWith(receiver).hasPrecheckFrom(OK, INVALID_SCHEDULE_ID).hasKnownStatusFrom(SUCCESS, OK, TRANSACTION_EXPIRED, INVALID_SCHEDULE_ID, UNKNOWN, SCHEDULE_ALREADY_EXECUTED).fee(ONE_HBAR).deferStatusResolution() };
return defaultHapiSpec("RunMixedOps").given(withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())), logIt(ignore -> settings.toString()), newKeyNamed("submitKey"), tokenOpsEnablement(), scheduleOpsEnablement(), cryptoCreate("treasury").hasRetryPrecheckFrom(permissiblePrechecks).key(GENESIS)).when(fileUpdate(APP_PROPERTIES).payingWith(GENESIS).overridingProps(Map.of("hapi.throttling.buckets.fastOpBucket.capacity", "1300000.0", "hapi.throttling.ops.consensusUpdateTopic.capacityRequired", "1.0", "hapi.throttling.ops.consensusGetTopicInfo.capacityRequired", "1.0", "hapi.throttling.ops.consensusSubmitMessage.capacityRequired", "1.0", "tokens.maxPerAccount", "10000000")), cryptoCreate(sender).balance(initialBalance.getAsLong()).withRecharging().key(GENESIS).rechargeWindow(3).hasRetryPrecheckFrom(permissiblePrechecks), cryptoCreate(receiver).hasRetryPrecheckFrom(permissiblePrechecks).key(GENESIS), createTopic(topic).submitKeyName("submitKey"), inParallel(IntStream.range(0, NUM_SUBMISSIONS).mapToObj(ignore -> tokenCreate("token" + tokenId.getAndIncrement()).payingWith(GENESIS).signedBy(GENESIS).fee(ONE_HUNDRED_HBARS).initialSupply(ONE_HUNDRED_HBARS).treasury("treasury").hasRetryPrecheckFrom(permissiblePrechecks).hasPrecheckFrom(DUPLICATE_TRANSACTION, OK).deferStatusResolution().noLogging()).toArray(n -> new HapiSpecOperation[n])), sleepFor(10000), inParallel(IntStream.range(0, NUM_SUBMISSIONS).mapToObj(ignore -> scheduleCreate("schedule-" + getHostName() + "-" + scheduleId.getAndIncrement(), cryptoTransfer(tinyBarsFromTo(sender, receiver, 1))).signedBy(DEFAULT_PAYER).fee(ONE_HUNDRED_HBARS).alsoSigningWith(sender).hasPrecheckFrom(STANDARD_PERMISSIBLE_PRECHECKS).hasAnyKnownStatus().deferStatusResolution().adminKey(DEFAULT_PAYER).noLogging()).toArray(n -> new HapiSpecOperation[n])), sleepFor(10000), inParallel(IntStream.range(0, NUM_SUBMISSIONS).mapToObj(i -> tokenAssociate(sender, "token" + i).payingWith(GENESIS).signedBy(GENESIS).hasRetryPrecheckFrom(permissiblePrechecks).hasPrecheckFrom(DUPLICATE_TRANSACTION, OK).hasKnownStatusFrom(SUCCESS, TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT, INVALID_TOKEN_ID, TRANSACTION_EXPIRED, TOKENS_PER_ACCOUNT_LIMIT_EXCEEDED, OK).fee(ONE_HUNDRED_HBARS).suppressStats(true).deferStatusResolution().noLogging()).toArray(n -> new HapiSpecOperation[n])), sleepFor(10000)).then(defaultLoadTest(mixedOpsBurst, settings));
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE in project hedera-services by hashgraph.
the class TokenTransferBasicLoadTest method tokenCreatesFactory.
private Function<HapiApiSpec, OpProvider> tokenCreatesFactory(PerfTestLoadSettings settings) {
int numTotalTokens = settings.getTotalTokens();
int totalClients = settings.getTotalClients();
int numActiveTokens = (totalClients >= 1) ? numTotalTokens / totalClients : numTotalTokens;
AtomicInteger remaining = new AtomicInteger(numActiveTokens - 1);
return spec -> new OpProvider() {
@Override
public List<HapiSpecOperation> suggestedInitializers() {
return Collections.emptyList();
}
@Override
public Optional<HapiSpecOperation> get() {
int next;
if ((next = remaining.getAndDecrement()) < 0) {
return Optional.empty();
}
var payingTreasury = String.format("0.0.%d", settings.getTestTreasureStartAccount() + next);
var op = tokenCreate(tokenRegistryName(next)).payingWith(DEFAULT_PAYER).signedBy(DEFAULT_PAYER).fee(ONE_HUNDRED_HBARS).initialSupply(100_000_000_000L).treasury(payingTreasury).hasRetryPrecheckFrom(BUSY, PLATFORM_TRANSACTION_NOT_CREATED, DUPLICATE_TRANSACTION, INSUFFICIENT_PAYER_BALANCE).hasPrecheckFrom(DUPLICATE_TRANSACTION, OK).hasKnownStatusFrom(SUCCESS, TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT, TOKENS_PER_ACCOUNT_LIMIT_EXCEEDED, FAIL_INVALID).suppressStats(true).noLogging();
return Optional.of(op);
}
};
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE in project hedera-services by hashgraph.
the class TokenTransfersLoadProvider method tokenTransfersFactory.
private Function<HapiApiSpec, OpProvider> tokenTransfersFactory() {
var firstDir = new AtomicBoolean(Boolean.TRUE);
var balanceInit = new AtomicLong();
var tokensPerTxn = new AtomicInteger();
var sendingAccountsPerToken = new AtomicInteger();
var receivingAccountsPerToken = new AtomicInteger();
List<String> treasuries = new ArrayList<>();
Map<String, List<String>> senders = new HashMap<>();
Map<String, List<String>> receivers = new HashMap<>();
return spec -> new OpProvider() {
@Override
public List<HapiSpecOperation> suggestedInitializers() {
var ciProps = spec.setup().ciPropertiesMap();
balanceInit.set(ciProps.getLong("balanceInit"));
tokensPerTxn.set(ciProps.getInteger("tokensPerTxn"));
sendingAccountsPerToken.set(ciProps.getInteger("sendingAccountsPerToken"));
receivingAccountsPerToken.set(ciProps.getInteger("receivingAccountsPerToken"));
var initialSupply = (sendingAccountsPerToken.get() + receivingAccountsPerToken.get()) * balanceInit.get();
List<HapiSpecOperation> initializers = new ArrayList<>();
initializers.add(tokenOpsEnablement());
/* Temporary, can be removed after the public testnet state used in
restart tests includes a fee schedule with HTS resource prices. */
if (spec.setup().defaultNode().equals(asAccount("0.0.3"))) {
initializers.add(uploadDefaultFeeSchedules(GENESIS));
} else {
initializers.add(withOpContext((spec, opLog) -> {
log.info("\n\n" + bannerWith("Waiting for a fee schedule with token ops!"));
boolean hasKnownHtsFeeSchedules = false;
SysFileSerde<String> serde = new FeesJsonToGrpcBytes();
while (!hasKnownHtsFeeSchedules) {
var query = QueryVerbs.getFileContents(FEE_SCHEDULE).fee(10_000_000_000L);
try {
allRunFor(spec, query);
var contents = query.getResponse().getFileGetContents().getFileContents().getContents();
var schedules = serde.fromRawFile(contents.toByteArray());
hasKnownHtsFeeSchedules = schedules.contains("TokenCreate");
} catch (Exception e) {
var msg = e.toString();
msg = msg.substring(msg.indexOf(":") + 2);
log.info("Couldn't check for HTS fee schedules---'{}'", msg);
}
TimeUnit.SECONDS.sleep(3);
}
log.info("\n\n" + bannerWith("A fee schedule with token ops now available!"));
spec.tryReinitializingFees();
}));
}
for (int i = 0; i < tokensPerTxn.get(); i++) {
var token = "token" + i;
var treasury = "treasury" + i;
initializers.add(cryptoCreate(treasury));
initializers.add(tokenCreate(token).treasury(treasury).initialSupply(initialSupply));
treasuries.add(treasury);
for (int j = 0; j < sendingAccountsPerToken.get(); j++) {
var sender = token + "sender" + j;
senders.computeIfAbsent(token, ignore -> new ArrayList<>()).add(sender);
initializers.add(cryptoCreate(sender));
initializers.add(tokenAssociate(sender, token));
initializers.add(cryptoTransfer(moving(balanceInit.get(), token).between(treasury, sender)));
}
for (int j = 0; j < receivingAccountsPerToken.get(); j++) {
var receiver = token + "receiver" + j;
receivers.computeIfAbsent(token, ignore -> new ArrayList<>()).add(receiver);
initializers.add(cryptoCreate(receiver));
initializers.add(tokenAssociate(receiver, token));
initializers.add(cryptoTransfer(moving(balanceInit.get(), token).between(treasury, receiver)));
}
}
for (HapiSpecOperation op : initializers) {
if (op instanceof HapiTxnOp) {
((HapiTxnOp) op).hasRetryPrecheckFrom(NOISY_RETRY_PRECHECKS);
}
}
return initializers;
}
@Override
public Optional<HapiSpecOperation> get() {
HapiSpecOperation op;
var numTokens = tokensPerTxn.get();
var numSenders = sendingAccountsPerToken.get();
var numReceivers = receivingAccountsPerToken.get();
if (firstDir.get()) {
var xfers = new TokenMovement[numTokens * numSenders];
for (int i = 0; i < numTokens; i++) {
var token = "token" + i;
for (int j = 0; j < numSenders; j++) {
var receivers = new String[numReceivers];
for (int k = 0; k < numReceivers; k++) {
receivers[k] = token + "receiver" + k;
}
xfers[i * numSenders + j] = moving(numReceivers, token).distributing(token + "sender" + j, receivers);
}
}
op = cryptoTransfer(xfers).hasKnownStatusFrom(OK, DUPLICATE_TRANSACTION, SUCCESS, UNKNOWN, INSUFFICIENT_PAYER_BALANCE).hasRetryPrecheckFrom(NOISY_RETRY_PRECHECKS).hasPrecheckFrom(OK, PLATFORM_NOT_ACTIVE).noLogging().deferStatusResolution();
firstDir.set(Boolean.FALSE);
} else {
var xfers = new TokenMovement[numTokens * numReceivers];
for (int i = 0; i < numTokens; i++) {
var token = "token" + i;
for (int j = 0; j < numReceivers; j++) {
var senders = new String[numSenders];
for (int k = 0; k < numSenders; k++) {
senders[k] = token + "sender" + k;
}
xfers[i * numReceivers + j] = moving(numSenders, token).distributing(token + "receiver" + j, senders);
}
}
op = cryptoTransfer(xfers).hasKnownStatusFrom(OK, DUPLICATE_TRANSACTION, SUCCESS, UNKNOWN, INSUFFICIENT_PAYER_BALANCE).hasRetryPrecheckFrom(NOISY_RETRY_PRECHECKS).hasPrecheckFrom(OK, PLATFORM_NOT_ACTIVE).noLogging().deferStatusResolution();
firstDir.set(Boolean.TRUE);
}
return Optional.of(op);
}
};
}
Aggregations