Search in sources :

Example 1 with StaticEntityAccess

use of com.hedera.services.store.contracts.StaticEntityAccess in project hedera-services by hashgraph.

the class ContractCallLocalResourceUsage method usageFor.

private FeeData usageFor(final Query query, final ResponseType type, final StateView view, @Nullable final Map<String, Object> queryCtx) {
    try {
        final var op = query.getContractCallLocal();
        ContractCallLocalResponse response;
        if (null == queryCtx) {
            response = dummyResponse(op.getContractID());
        } else {
            final var entityAccess = new StaticEntityAccess(view, aliasManager, validator, properties);
            final var codeCache = new CodeCache(nodeProperties, entityAccess);
            final var worldState = new HederaWorldState(ids, entityAccess, codeCache, properties);
            evmTxProcessor.setWorldState(worldState);
            response = CallLocalExecutor.execute(accountStore, evmTxProcessor, op, aliasManager);
            queryCtx.put(CONTRACT_CALL_LOCAL_CTX_KEY, response);
        }
        final var nonGasUsage = usageEstimator.getContractCallLocalFeeMatrices(op.getFunctionParameters().size(), response.getFunctionResult(), type);
        return nonGasUsage.toBuilder().setNodedata(nonGasUsage.getNodedata().toBuilder().setGas(op.getGas())).build();
    } catch (final Exception internal) {
        log.warn("Usage estimation unexpectedly failed for {}!", query, internal);
        throw new IllegalStateException(internal);
    }
}
Also used : CodeCache(com.hedera.services.store.contracts.CodeCache) HederaWorldState(com.hedera.services.store.contracts.HederaWorldState) ContractCallLocalResponse(com.hederahashgraph.api.proto.java.ContractCallLocalResponse) StaticEntityAccess(com.hedera.services.store.contracts.StaticEntityAccess)

Aggregations

CodeCache (com.hedera.services.store.contracts.CodeCache)1 HederaWorldState (com.hedera.services.store.contracts.HederaWorldState)1 StaticEntityAccess (com.hedera.services.store.contracts.StaticEntityAccess)1 ContractCallLocalResponse (com.hederahashgraph.api.proto.java.ContractCallLocalResponse)1