use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SIGNATURE in project hedera-services by hashgraph.
the class ContractKeysHTSSuite method burnTokenWithFullPrefixAndPartialPrefixKeys.
private HapiApiSpec burnTokenWithFullPrefixAndPartialPrefixKeys() {
final var theAccount = "anybody";
final var burnContractByteCode = "burnContractByteCode";
final var amount = 99L;
final var fungibleToken = "fungibleToken";
final var theContract = "mintContract";
final var firstBurnTxn = "firstBurnTxn";
final var secondBurnTxn = "secondBurnTxn";
final AtomicLong fungibleNum = new AtomicLong();
return defaultHapiSpec("burnTokenWithFullPrefixAndPartialPrefixKeys").given(newKeyNamed(MULTI_KEY), cryptoCreate(theAccount).balance(10 * ONE_HUNDRED_HBARS), cryptoCreate(TOKEN_TREASURY), fileCreate(burnContractByteCode).payingWith(theAccount), updateLargeFile(theAccount, burnContractByteCode, extractByteCode(ContractResources.ORDINARY_CALLS_CONTRACT)), tokenCreate(fungibleToken).tokenType(TokenType.FUNGIBLE_COMMON).initialSupply(100).treasury(TOKEN_TREASURY).adminKey(MULTI_KEY).supplyKey(MULTI_KEY).exposingCreatedIdTo(idLit -> fungibleNum.set(asDotDelimitedLongArray(idLit)[2]))).when(sourcing(() -> contractCreate(theContract).bytecode(burnContractByteCode).payingWith(theAccount).gas(GAS_TO_OFFER))).then(withOpContext((spec, opLog) -> allRunFor(spec, contractCall(theContract, BURN_TOKEN_ORDINARY_CALL, asAddress(spec.registry().getTokenID(fungibleToken)), 1, new ArrayList<Long>()).via(firstBurnTxn).payingWith(theAccount).signedBy(MULTI_KEY).signedBy(theAccount).hasKnownStatus(SUCCESS), contractCall(theContract, BURN_TOKEN_ORDINARY_CALL, asAddress(spec.registry().getTokenID(fungibleToken)), 1, new ArrayList<Long>()).via(secondBurnTxn).payingWith(theAccount).alsoSigningWithFullPrefix(MULTI_KEY).hasKnownStatus(SUCCESS))), childRecordsCheck(firstBurnTxn, SUCCESS, recordWith().status(INVALID_SIGNATURE)), childRecordsCheck(secondBurnTxn, SUCCESS, recordWith().status(SUCCESS).newTotalSupply(99)), getTokenInfo(fungibleToken).hasTotalSupply(amount), getAccountBalance(TOKEN_TREASURY).hasTokenBalance(fungibleToken, amount));
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SIGNATURE in project hedera-services by hashgraph.
the class ContractCreateSuite method receiverSigReqTransferRecipientMustSignWithFullPubKeyPrefix.
private HapiApiSpec receiverSigReqTransferRecipientMustSignWithFullPubKeyPrefix() {
final var justSendInitcode = "justSendInitcode";
final var sendInternalAndDelegateInitcode = "sendInternalAndDelegateInitcode";
final var justSend = "justSend";
final var sendInternalAndDelegate = "sendInternalAndDelegate";
final var beneficiary = "civilian";
final var balanceToDistribute = 1_000L;
final AtomicLong justSendContractNum = new AtomicLong();
final AtomicLong beneficiaryAccountNum = new AtomicLong();
return defaultHapiSpec("ReceiverSigReqTransferRecipientMustSignWithFullPubKeyPrefix").given(cryptoCreate(beneficiary).balance(0L).receiverSigRequired(true).exposingCreatedIdTo(id -> beneficiaryAccountNum.set(id.getAccountNum())), fileCreate(justSendInitcode).path(ContractResources.JUST_SEND_BYTECODE_PATH), fileCreate(sendInternalAndDelegateInitcode).path(ContractResources.SEND_INTERNAL_AND_DELEGATE_BYTECODE_PATH)).when(contractCreate(justSend).bytecode(justSendInitcode).gas(300_000L).exposingNumTo(justSendContractNum::set), contractCreate(sendInternalAndDelegate).bytecode(sendInternalAndDelegateInitcode).gas(300_000L).balance(balanceToDistribute)).then(/* Sending requires receiver signature */
sourcing(() -> contractCall(sendInternalAndDelegate, SEND_REPEATEDLY_ABI, justSendContractNum.get(), beneficiaryAccountNum.get(), balanceToDistribute / 2).hasKnownStatus(INVALID_SIGNATURE)), /* But it's not enough to just sign using an incomplete prefix */
sourcing(() -> contractCall(sendInternalAndDelegate, SEND_REPEATEDLY_ABI, justSendContractNum.get(), beneficiaryAccountNum.get(), balanceToDistribute / 2).signedBy(DEFAULT_PAYER, beneficiary).hasKnownStatus(INVALID_SIGNATURE)), /* We have to specify the full prefix so the sig can be verified async */
getAccountInfo(beneficiary).logged(), sourcing(() -> contractCall(sendInternalAndDelegate, SEND_REPEATEDLY_ABI, justSendContractNum.get(), beneficiaryAccountNum.get(), balanceToDistribute / 2).alsoSigningWithFullPrefix(beneficiary)), getAccountBalance(beneficiary).logged());
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SIGNATURE in project hedera-services by hashgraph.
the class AccountBalancesClientSaveLoadTest method accountsCreate.
private Function<HapiApiSpec, OpProvider> accountsCreate(PerfTestLoadSettings settings) {
totalTestTokens = settings.getTotalTokens() > 10 ? settings.getTotalTokens() : TOTAL_TEST_TOKENS;
totalTreasureAccounts = totalTestTokens;
totalAccounts = settings.getTotalAccounts() > 100 ? settings.getTotalAccounts() : TOTAL_ACCOUNT;
log.info("Total accounts: {}", totalAccounts);
log.info("Total tokens: {}", totalTestTokens);
AtomicInteger moreToCreate = new AtomicInteger(totalAccounts);
return spec -> new OpProvider() {
@Override
public List<HapiSpecOperation> suggestedInitializers() {
log.info("Now running accountsCreate initializer");
return Collections.emptyList();
}
@Override
public Optional<HapiSpecOperation> get() {
int next;
next = moreToCreate.getAndDecrement();
if (next <= 0) {
return Optional.empty();
}
var op = cryptoCreate(String.format("%s%d", ACCT_NAME_PREFIX, next)).balance((long) (r.nextInt((int) ONE_HBAR) + MIN_ACCOUNT_BALANCE)).key(GENESIS).fee(ONE_HUNDRED_HBARS).withRecharging().rechargeWindow(30).hasRetryPrecheckFrom(NOISY_RETRY_PRECHECKS).hasPrecheckFrom(DUPLICATE_TRANSACTION, OK, INSUFFICIENT_TX_FEE).hasKnownStatusFrom(SUCCESS, INVALID_SIGNATURE).noLogging().deferStatusResolution();
return Optional.of(op);
}
};
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SIGNATURE in project hedera-services by hashgraph.
the class R5BugChecks method enforcesSigRequirements.
private HapiApiSpec enforcesSigRequirements() {
KeyShape complexSrShape = listOf(SIMPLE, threshOf(1, 3));
SigControl activeSig = complexSrShape.signedWith(sigs(ON, sigs(OFF, OFF, ON)));
SigControl inactiveSig = complexSrShape.signedWith(sigs(OFF, sigs(ON, ON, ON)));
return defaultHapiSpec("EnforcesSigRequirements").given(newKeyNamed("srKey").shape(complexSrShape), fileCreate("bytecode").path(ContractResources.LAST_TRACKING_SENDER_BYTECODE_PATH), contractCreate("sponsor").bytecode("bytecode").balance(10), cryptoCreate("noSr").balance(0L), cryptoCreate("sr").key("srKey").balance(0L).receiverSigRequired(true)).when(contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("sr").getAccountNum(), 5 }).hasKnownStatus(INVALID_SIGNATURE), contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("sr").getAccountNum(), 5 }).signedBy(GENESIS, "sr").sigControl(ControlForKey.forKey("sr", inactiveSig)).hasKnownStatus(INVALID_SIGNATURE), contractCallLocal("sponsor", ContractResources.HOW_MUCH_ABI).has(resultWith().resultThruAbi(ContractResources.HOW_MUCH_ABI, isLiteralResult(new Object[] { BigInteger.valueOf(0) }))), getAccountBalance("sr").hasTinyBars(0L)).then(contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("noSr").getAccountNum(), 1 }), contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("sr").getAccountNum(), 5 }).signedBy(GENESIS, "sr").sigControl(ControlForKey.forKey("sr", activeSig)), contractCallLocal("sponsor", ContractResources.HOW_MUCH_ABI).has(resultWith().resultThruAbi(ContractResources.HOW_MUCH_ABI, isLiteralResult(new Object[] { BigInteger.valueOf(5) }))), getAccountBalance("sr").hasTinyBars(5L), getAccountBalance("noSr").hasTinyBars(1L));
}
Aggregations