Search in sources :

Example 6 with InvalidTxBodyException

use of com.hederahashgraph.exception.InvalidTxBodyException in project hedera-services by hashgraph.

the class FileFeeBuilder method getSystemUnDeleteFileTxFeeMatrices.

public FeeData getSystemUnDeleteFileTxFeeMatrices(TransactionBody txBody, SigValueObj numSignatures) throws InvalidTxBodyException {
    if (txBody == null || !txBody.hasSystemUndelete()) {
        throw new InvalidTxBodyException("System UnDelete Tx Body not available for Fee Calculation");
    }
    long bpt = 0;
    long vpt = 0;
    long rbs = 0;
    long sbs = 0;
    long gas = 0;
    long tv = 0;
    long bpr = 0;
    long sbpr = 0;
    // get the bytes per second
    bpt = getCommonTransactionBodyBytes(txBody);
    bpt = bpt + BASIC_ENTITY_ID_SIZE + LONG_SIZE;
    vpt = numSignatures.getTotalSigCount();
    rbs = calculateRBS(txBody);
    long rbsNetwork = getDefaultRBHNetworkSize();
    // sbs should not be charged as the fee for storage was already paid. What if expiration is changed though?
    FeeComponents feeMatricesForTx = FeeComponents.newBuilder().setBpt(bpt).setVpt(vpt).setRbh(rbs).setSbh(sbs).setGas(gas).setTv(tv).setBpr(bpr).setSbpr(sbpr).build();
    return getFeeDataMatrices(feeMatricesForTx, numSignatures.getPayerAcctSigCount(), rbsNetwork);
}
Also used : InvalidTxBodyException(com.hederahashgraph.exception.InvalidTxBodyException) FeeComponents(com.hederahashgraph.api.proto.java.FeeComponents)

Example 7 with InvalidTxBodyException

use of com.hederahashgraph.exception.InvalidTxBodyException in project hedera-services by hashgraph.

the class SmartContractFeeBuilder method getContractCreateTxFeeMatrices.

/**
 * This method returns fee matrices for contract create transaction
 *
 * @param txBody
 * 		transaction body
 * @param sigValObj
 * 		signature value object
 * @return fee data
 * @throws InvalidTxBodyException
 * 		when transaction body is invalid
 */
public FeeData getContractCreateTxFeeMatrices(TransactionBody txBody, SigValueObj sigValObj) throws InvalidTxBodyException {
    if (txBody == null || !txBody.hasContractCreateInstance()) {
        throw new InvalidTxBodyException("ContractCreateInstance Tx Body not available for Fee Calculation");
    }
    long bpt = 0;
    long vpt = 0;
    long rbs = 0;
    long sbs = 0;
    long gas = 0;
    long tv = 0;
    long bpr = 0;
    long sbpr = 0;
    // calculate BPT - Total Bytes in Transaction
    long txBodySize = 0;
    txBodySize = getCommonTransactionBodyBytes(txBody);
    bpt = txBodySize + getContractCreateTransactionBodySize(txBody) + sigValObj.getSignatureSize();
    // vpt - verifications per transactions
    vpt = sigValObj.getTotalSigCount();
    bpr = INT_SIZE;
    rbs = getBaseTransactionRecordSize(txBody) * (RECEIPT_STORAGE_TIME_SEC + THRESHOLD_STORAGE_TIME_SEC);
    long rbsNetwork = getDefaultRBHNetworkSize() + BASIC_ENTITY_ID_SIZE * (RECEIPT_STORAGE_TIME_SEC);
    FeeComponents feeMatricesForTx = FeeComponents.newBuilder().setBpt(bpt).setVpt(vpt).setRbh(rbs).setSbh(sbs).setGas(gas).setTv(tv).setBpr(bpr).setSbpr(sbpr).build();
    return getFeeDataMatrices(feeMatricesForTx, sigValObj.getPayerAcctSigCount(), rbsNetwork);
}
Also used : InvalidTxBodyException(com.hederahashgraph.exception.InvalidTxBodyException) FeeComponents(com.hederahashgraph.api.proto.java.FeeComponents)

Example 8 with InvalidTxBodyException

use of com.hederahashgraph.exception.InvalidTxBodyException in project hedera-services by hashgraph.

the class SmartContractFeeBuilder method getContractDeleteTxFeeMatrices.

public FeeData getContractDeleteTxFeeMatrices(TransactionBody txBody, SigValueObj sigValObj) throws InvalidTxBodyException {
    if (txBody == null || !txBody.hasContractDeleteInstance()) {
        throw new InvalidTxBodyException("ContractDelete Tx Body not available for Fee Calculation");
    }
    long bpt = 0;
    long vpt = 0;
    long rbs = 0;
    long sbs = 0;
    long gas = 0;
    long tv = 0;
    long bpr = 0;
    long sbpr = 0;
    // calculate BPT - Total Bytes in Transaction
    long txBodySize = 0;
    txBodySize = getCommonTransactionBodyBytes(txBody);
    /*
		 * ContractID contractID = BASIC_ENTITY_ID_SIZE oneof obtainers { AccountID transferAccountID =
		 * BASIC_ENTITY_ID_SIZE
		 * ContractID transferContractID = BASIC_ENTITY_ID_SIZE }
		 */
    bpt = txBodySize + BASIC_ENTITY_ID_SIZE + BASIC_ENTITY_ID_SIZE + sigValObj.getSignatureSize();
    // vpt - verifications per transactions
    vpt = sigValObj.getTotalSigCount();
    bpr = INT_SIZE;
    rbs = calculateRBS(txBody);
    long rbsNetwork = getDefaultRBHNetworkSize() + BASIC_ENTITY_ID_SIZE * (RECEIPT_STORAGE_TIME_SEC);
    FeeComponents feeMatricesForTx = FeeComponents.newBuilder().setBpt(bpt).setVpt(vpt).setRbh(rbs).setSbh(sbs).setGas(gas).setTv(tv).setBpr(bpr).setSbpr(sbpr).build();
    return getFeeDataMatrices(feeMatricesForTx, sigValObj.getPayerAcctSigCount(), rbsNetwork);
}
Also used : InvalidTxBodyException(com.hederahashgraph.exception.InvalidTxBodyException) FeeComponents(com.hederahashgraph.api.proto.java.FeeComponents)

Example 9 with InvalidTxBodyException

use of com.hederahashgraph.exception.InvalidTxBodyException in project hedera-services by hashgraph.

the class ContractUpdateResourceUsage method usageGiven.

@Override
public FeeData usageGiven(TransactionBody txn, SigValueObj sigUsage, StateView view) throws InvalidTxBodyException {
    try {
        final var id = fromContractId(txn.getContractUpdateInstance().getContractID());
        Timestamp expiry = lookupAccountExpiry(id, view.accounts());
        return usageEstimator.getContractUpdateTxFeeMatrices(txn, expiry, sigUsage);
    } catch (Exception e) {
        log.debug("Unable to deduce ContractUpdate usage for {}, using defaults", txn.getTransactionID(), e);
        return FeeData.getDefaultInstance();
    }
}
Also used : Timestamp(com.hederahashgraph.api.proto.java.Timestamp) InvalidTxBodyException(com.hederahashgraph.exception.InvalidTxBodyException)

Aggregations

InvalidTxBodyException (com.hederahashgraph.exception.InvalidTxBodyException)9 FeeComponents (com.hederahashgraph.api.proto.java.FeeComponents)7 Timestamp (com.hederahashgraph.api.proto.java.Timestamp)1 DecoderException (org.apache.commons.codec.DecoderException)1