use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.DUPLICATE_TRANSACTION in project hedera-services by hashgraph.
the class CreateSchedulesBeforeReconnect method runCreateSchedules.
private HapiApiSpec runCreateSchedules() {
PerfTestLoadSettings settings = new PerfTestLoadSettings(SCHEDULE_CREATION_RECONNECT_TPS, DEFAULT_MINS_FOR_RECONNECT_TESTS, DEFAULT_THREADS_FOR_RECONNECT_TESTS);
Supplier<HapiSpecOperation[]> createBurst = () -> new HapiSpecOperation[] { generateScheduleCreateOperation() };
return defaultHapiSpec("RunCreateSchedules").given(scheduleOpsEnablement(), logIt(ignore -> settings.toString()), cryptoCreate("scheduleSender").balance(initialBalance.getAsLong()).key(GENESIS).hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED).deferStatusResolution(), cryptoCreate("scheduleReceiver").key(GENESIS).hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED).deferStatusResolution(), sleepFor(10000), scheduleCreate("schedule-" + getHostName() + "-" + scheduleNumber.getAndIncrement(), cryptoTransfer(tinyBarsFromTo("scheduleSender", "scheduleReceiver", 1))).signedBy(DEFAULT_PAYER).fee(ONE_HUNDRED_HBARS).alsoSigningWith("scheduleSender").hasPrecheckFrom(STANDARD_PERMISSIBLE_PRECHECKS).hasAnyKnownStatus().deferStatusResolution().adminKey(DEFAULT_PAYER).noLogging().advertisingCreation()).when(fileUpdate(APP_PROPERTIES).payingWith(GENESIS).overridingProps(Map.of("ledger.schedule.txExpiryTimeSecs", "" + 60)), sleepFor(10000)).then(scheduleCreate("schedule-" + getHostName() + "-" + scheduleNumber.getAndIncrement(), cryptoTransfer(tinyBarsFromTo("scheduleSender", "scheduleReceiver", 1))).signedBy(DEFAULT_PAYER).fee(ONE_HUNDRED_HBARS).alsoSigningWith("scheduleSender").hasPrecheckFrom(STANDARD_PERMISSIBLE_PRECHECKS).hasAnyKnownStatus().deferStatusResolution().adminKey(DEFAULT_PAYER).noLogging().advertisingCreation(), defaultLoadTest(createBurst, settings));
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.DUPLICATE_TRANSACTION in project hedera-services by hashgraph.
the class SubmitMessageLoadTest method runSubmitMessages.
private static HapiApiSpec runSubmitMessages() {
PerfTestLoadSettings settings = new PerfTestLoadSettings();
final AtomicInteger submittedSoFar = new AtomicInteger(0);
Supplier<HapiSpecOperation[]> submitBurst = () -> new HapiSpecOperation[] { opSupplier(settings).get() };
return defaultHapiSpec("RunSubmitMessages").given(withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())), // if no pem file defined then create a new submitKey
pemFile == null ? newKeyNamed("submitKey") : keyFromPem(pemFile).name("submitKey").simpleWacl().passphrase(KeyFactory.PEM_PASSPHRASE), // if just created a new key then export spec for later reuse
pemFile == null ? withOpContext((spec, ignore) -> spec.keys().exportSimpleKey("topicSubmitKey.pem", "submitKey")) : sleepFor(100), logIt(ignore -> settings.toString())).when(fileUpdate(APP_PROPERTIES).payingWith(GENESIS).overridingProps(Map.of("hapi.throttling.buckets.fastOpBucket.capacity", "4000", "hapi.throttling.ops.consensusSubmitMessage.capacityRequired", "1.0")), cryptoCreate("sender").balance(ignore -> settings.getInitialBalance()).withRecharging().rechargeWindow(3).hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED), topicID == null ? createTopic("topic").submitKeyName("submitKey").hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED) : sleepFor(100), // wait all other thread ready
sleepFor(10000)).then(defaultLoadTest(submitBurst, settings), getAccountBalance("sender").logged());
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.DUPLICATE_TRANSACTION in project hedera-services by hashgraph.
the class FileUpdateLoadTest method runFileUpdates.
private HapiApiSpec runFileUpdates() {
PerfTestLoadSettings settings = new PerfTestLoadSettings();
final AtomicInteger submittedSoFar = new AtomicInteger(0);
final byte[] NEW_CONTENTS = TxnUtils.randomUtf8Bytes(TxnUtils.BYTES_4K);
Supplier<HapiSpecOperation[]> fileUpdateBurst = () -> new HapiSpecOperation[] { inParallel(IntStream.range(0, settings.getBurstSize()).mapToObj(i -> TxnVerbs.fileUpdate("target").fee(Integer.MAX_VALUE).contents(NEW_CONTENTS).noLogging().hasPrecheckFrom(OK, BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED).deferStatusResolution()).toArray(n -> new HapiSpecOperation[n])), logIt(ignore -> String.format("Now a total of %d file updates submitted.", submittedSoFar.addAndGet(settings.getBurstSize()))) };
return defaultHapiSpec("RunFileUpdates").given(withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())), logIt(ignore -> settings.toString())).when(fileCreate("target").contents("The initial contents!")).then(runLoadTest(fileUpdateBurst).tps(settings::getTps).tolerance(settings::getTolerancePercentage).allowedSecsBelow(settings::getAllowedSecsBelow).lasting(settings::getMins, () -> MINUTES));
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.DUPLICATE_TRANSACTION 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.DUPLICATE_TRANSACTION in project hedera-services by hashgraph.
the class TokenRelStatusChanges method statusChangesFactory.
private Function<HapiApiSpec, OpProvider> statusChangesFactory() {
var nowAssociating = new AtomicBoolean(Boolean.FALSE);
var relatableTokens = new AtomicInteger();
var relatableAccounts = new AtomicInteger();
List<String> tokens = new ArrayList<>();
List<String> accounts = new ArrayList<>();
var nextToken = new AtomicInteger(-1);
var nextAccount = new AtomicInteger(-1);
return spec -> new OpProvider() {
@Override
public List<HapiSpecOperation> suggestedInitializers() {
var ciProps = spec.setup().ciPropertiesMap();
relatableTokens.set(ciProps.getInteger("numTokens"));
relatableAccounts.set(ciProps.getInteger("numAccounts"));
List<HapiSpecOperation> initializers = new ArrayList<>();
initializers.add(tokenOpsEnablement().hasRetryPrecheckFrom(NOISY_RETRY_PRECHECKS));
IntStream.range(0, relatableTokens.get()).mapToObj(i -> "token" + i).forEach(tokens::add);
initializers.add(inParallel(tokens.stream().map(token -> tokenCreate(token).hasRetryPrecheckFrom(NOISY_RETRY_PRECHECKS)).toArray(HapiSpecOperation[]::new)));
IntStream.range(0, relatableAccounts.get()).mapToObj(i -> "account" + i).forEach(accounts::add);
initializers.add(inParallel(accounts.stream().map(account -> cryptoCreate(account).hasRetryPrecheckFrom(NOISY_RETRY_PRECHECKS)).toArray(HapiSpecOperation[]::new)));
return initializers;
}
@Override
public Optional<HapiSpecOperation> get() {
HapiSpecOperation op;
final int numTokens = relatableTokens.get();
final int numAccounts = relatableAccounts.get();
int token = nextToken.get() % numTokens;
int account = nextAccount.incrementAndGet() % numAccounts;
if (account == 0) {
token = nextToken.incrementAndGet() % numTokens;
if (token == 0) {
var current = nowAssociating.get();
nowAssociating.compareAndSet(current, !current);
}
}
if (nowAssociating.get()) {
op = tokenAssociate(accounts.get(account), tokens.get(token)).fee(ONE_HUNDRED_HBARS).hasRetryPrecheckFrom(NOISY_RETRY_PRECHECKS).hasKnownStatusFrom(OK, SUCCESS, DUPLICATE_TRANSACTION, TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT).noLogging().deferStatusResolution();
} else {
op = tokenDissociate(accounts.get(account), tokens.get(token)).fee(ONE_HUNDRED_HBARS).hasRetryPrecheckFrom(NOISY_RETRY_PRECHECKS).hasKnownStatusFrom(OK, SUCCESS, DUPLICATE_TRANSACTION, TOKEN_NOT_ASSOCIATED_TO_ACCOUNT).noLogging().deferStatusResolution();
}
return Optional.of(op);
}
};
}
Aggregations