Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cannotUseMoreThanChildContractLimit test #9707

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.hedera.node.app.service.contract.impl.exec.systemcontracts.hts.HtsCall;
import com.hedera.node.app.service.contract.impl.exec.systemcontracts.hts.HtsCallFactory;
import com.hedera.node.app.service.contract.impl.exec.utils.FrameUtils;
import com.hedera.node.app.spi.workflows.HandleException;
import edu.umd.cs.findbugs.annotations.NonNull;
import javax.inject.Inject;
import javax.inject.Singleton;
Expand Down Expand Up @@ -69,6 +70,8 @@ private static FullResult resultOfExecuting(
final HtsCall.PricedResult pricedResult;
try {
pricedResult = call.execute(frame);
} catch (final HandleException handleException) {
throw handleException;
} catch (final Exception internal) {
log.error("Unhandled failure for input {} to HTS system contract", input, internal);
return haltResult(ExceptionalHaltReason.PRECOMPILE_ERROR, frame.getRemainingGas());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static com.hedera.hapi.node.base.ResponseCodeEnum.CONTRACT_REVERT_EXECUTED;
import static com.hedera.hapi.node.base.ResponseCodeEnum.INSUFFICIENT_GAS;
import static com.hedera.hapi.node.base.ResponseCodeEnum.INVALID_CONTRACT_ID;
import static com.hedera.hapi.node.base.ResponseCodeEnum.MAX_CHILD_RECORDS_EXCEEDED;
import static com.hedera.hapi.node.base.ResponseCodeEnum.MAX_CONTRACT_STORAGE_EXCEEDED;
import static com.hedera.hapi.node.base.ResponseCodeEnum.MAX_STORAGE_IN_PRICE_REGIME_HAS_BEEN_USED;
import static com.hedera.hapi.node.base.ResponseCodeEnum.SUCCESS;
Expand Down Expand Up @@ -73,6 +74,7 @@ public record HederaEvmTransactionResult(
Bytes.wrap(MAX_STORAGE_IN_PRICE_REGIME_HAS_BEEN_USED.name());
private static final Bytes INSUFFICIENT_GAS_REASON = Bytes.wrap(INSUFFICIENT_GAS.name());
private static final Bytes INVALID_CONTRACT_REASON = Bytes.wrap(INVALID_CONTRACT_ID.name());
private static final Bytes MAX_CHILD_RECORDS_EXCEEDED_REASON = Bytes.wrap(MAX_CHILD_RECORDS_EXCEEDED.name());

/**
* Converts this result to a {@link ContractFunctionResult} for a transaction based on the given
Expand Down Expand Up @@ -137,6 +139,8 @@ public ResponseCodeEnum finalStatus() {
return INSUFFICIENT_GAS;
} else if (revertReason.equals(INVALID_CONTRACT_REASON)) {
return INVALID_CONTRACT_ID;
} else if (revertReason.equals(MAX_CHILD_RECORDS_EXCEEDED_REASON)) {
return MAX_CHILD_RECORDS_EXCEEDED;
} else {
return CONTRACT_REVERT_EXECUTED;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public List<HapiSpec> getSpecsInSuite() {
cannotUseMoreThanChildContractLimit());
}

@HapiTest
private HapiSpec cannotUseMoreThanChildContractLimit() {
final var illegalNumChildren =
HapiSpecSetup.getDefaultNodeProps().getInteger("consensus.handle.maxFollowingRecords") + 1;
Expand Down