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);
}
}
Aggregations