Search in sources :

Example 1 with UsageAccumulator

use of com.hedera.services.usage.state.UsageAccumulator in project hedera-services by hashgraph.

the class HapiTokenFreeze method usageEstimate.

private FeeData usageEstimate(TransactionBody txn, SigValueObj svo) {
    UsageAccumulator accumulator = new UsageAccumulator();
    final var tokenFreezeMeta = TOKEN_OPS_USAGE_UTILS.tokenFreezeUsageFrom();
    final var baseTransactionMeta = new BaseTransactionMeta(txn.getMemoBytes().size(), 0);
    TokenOpsUsage tokenOpsUsage = new TokenOpsUsage();
    tokenOpsUsage.tokenFreezeUsage(suFrom(svo), baseTransactionMeta, tokenFreezeMeta, accumulator);
    return AdapterUtils.feeDataFrom(accumulator);
}
Also used : BaseTransactionMeta(com.hedera.services.usage.BaseTransactionMeta) UsageAccumulator(com.hedera.services.usage.state.UsageAccumulator) TokenOpsUsage(com.hedera.services.usage.token.TokenOpsUsage)

Example 2 with UsageAccumulator

use of com.hedera.services.usage.state.UsageAccumulator in project hedera-services by hashgraph.

the class HapiTokenBurn method usageEstimate.

private FeeData usageEstimate(TransactionBody txn, SigValueObj svo) {
    UsageAccumulator accumulator = new UsageAccumulator();
    final var tokenBurnMeta = TOKEN_OPS_USAGE_UTILS.tokenBurnUsageFrom(txn, subType);
    final var baseTransactionMeta = new BaseTransactionMeta(txn.getMemoBytes().size(), 0);
    TokenOpsUsage tokenOpsUsage = new TokenOpsUsage();
    tokenOpsUsage.tokenBurnUsage(suFrom(svo), baseTransactionMeta, tokenBurnMeta, accumulator);
    return AdapterUtils.feeDataFrom(accumulator);
}
Also used : BaseTransactionMeta(com.hedera.services.usage.BaseTransactionMeta) UsageAccumulator(com.hedera.services.usage.state.UsageAccumulator) TokenOpsUsage(com.hedera.services.usage.token.TokenOpsUsage)

Example 3 with UsageAccumulator

use of com.hedera.services.usage.state.UsageAccumulator in project hedera-services by hashgraph.

the class HapiTokenCreate method usageEstimate.

private FeeData usageEstimate(TransactionBody txn, SigValueObj svo) {
    UsageAccumulator accumulator = new UsageAccumulator();
    final var tokenCreateMeta = TOKEN_OPS_USAGE_UTILS.tokenCreateUsageFrom(txn);
    final var baseTransactionMeta = new BaseTransactionMeta(txn.getMemoBytes().size(), 0);
    TokenOpsUsage tokenOpsUsage = new TokenOpsUsage();
    tokenOpsUsage.tokenCreateUsage(suFrom(svo), baseTransactionMeta, tokenCreateMeta, accumulator);
    return AdapterUtils.feeDataFrom(accumulator);
}
Also used : BaseTransactionMeta(com.hedera.services.usage.BaseTransactionMeta) UsageAccumulator(com.hedera.services.usage.state.UsageAccumulator) TokenOpsUsage(com.hedera.services.usage.token.TokenOpsUsage)

Example 4 with UsageAccumulator

use of com.hedera.services.usage.state.UsageAccumulator in project hedera-services by hashgraph.

the class HapiTokenWipe method usageEstimate.

private FeeData usageEstimate(TransactionBody txn, SigValueObj svo) {
    UsageAccumulator accumulator = new UsageAccumulator();
    final var tokenWipeMeta = TOKEN_OPS_USAGE_UTILS.tokenWipeUsageFrom(txn, subType);
    final var baseTransactionMeta = new BaseTransactionMeta(txn.getMemoBytes().size(), 0);
    TokenOpsUsage tokenOpsUsage = new TokenOpsUsage();
    tokenOpsUsage.tokenWipeUsage(suFrom(svo), baseTransactionMeta, tokenWipeMeta, accumulator);
    return AdapterUtils.feeDataFrom(accumulator);
}
Also used : BaseTransactionMeta(com.hedera.services.usage.BaseTransactionMeta) UsageAccumulator(com.hedera.services.usage.state.UsageAccumulator) TokenOpsUsage(com.hedera.services.usage.token.TokenOpsUsage)

Example 5 with UsageAccumulator

use of com.hedera.services.usage.state.UsageAccumulator in project hedera-services by hashgraph.

the class AccessorBasedUsagesTest method worksAsExpectedForCryptoTransfer.

@Test
void worksAsExpectedForCryptoTransfer() {
    int multiplier = 30;
    final var baseMeta = new BaseTransactionMeta(100, 2);
    final var xferMeta = new CryptoTransferMeta(1, 3, 7, 4);
    final var usageAccumulator = new UsageAccumulator();
    given(dynamicProperties.feesTokenTransferUsageMultiplier()).willReturn(multiplier);
    given(txnAccessor.getFunction()).willReturn(CryptoTransfer);
    given(txnAccessor.availXferUsageMeta()).willReturn(xferMeta);
    given(txnAccessor.baseUsageMeta()).willReturn(baseMeta);
    subject.assess(sigUsage, txnAccessor, usageAccumulator);
    verify(cryptoOpsUsage).cryptoTransferUsage(sigUsage, xferMeta, baseMeta, usageAccumulator);
    assertEquals(multiplier, xferMeta.getTokenMultiplier());
}
Also used : BaseTransactionMeta(com.hedera.services.usage.BaseTransactionMeta) CryptoTransferMeta(com.hedera.services.usage.crypto.CryptoTransferMeta) UsageAccumulator(com.hedera.services.usage.state.UsageAccumulator) TokenMint(com.hederahashgraph.api.proto.java.HederaFunctionality.TokenMint) Test(org.junit.jupiter.api.Test)

Aggregations

BaseTransactionMeta (com.hedera.services.usage.BaseTransactionMeta)17 UsageAccumulator (com.hedera.services.usage.state.UsageAccumulator)17 TokenOpsUsage (com.hedera.services.usage.token.TokenOpsUsage)8 Test (org.junit.jupiter.api.Test)8 ByteString (com.google.protobuf.ByteString)6 Key (com.hederahashgraph.api.proto.java.Key)5 SigUsage (com.hedera.services.usage.SigUsage)4 SignatureMap (com.hederahashgraph.api.proto.java.SignatureMap)2 MoreObjects (com.google.common.base.MoreObjects)1 BoolValue (com.google.protobuf.BoolValue)1 Int32Value (com.google.protobuf.Int32Value)1 StringValue (com.google.protobuf.StringValue)1 UInt64Value (com.google.protobuf.UInt64Value)1 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)1 HapiPropertySource (com.hedera.services.bdd.spec.HapiPropertySource)1 PropertySource.asAccountString (com.hedera.services.bdd.spec.PropertySource.asAccountString)1 AdapterUtils (com.hedera.services.bdd.spec.fees.AdapterUtils)1 FeeCalculator (com.hedera.services.bdd.spec.fees.FeeCalculator)1 QueryVerbs.getAccountInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo)1 HapiGetAccountInfo (com.hedera.services.bdd.spec.queries.crypto.HapiGetAccountInfo)1