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

chore: Fix ContractKeysHTSSuite records #10110

Merged
merged 13 commits into from
Dec 7, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,9 @@
gasRequirement,
null);
}

public static FullResult haltResult(final long gasRequirement) {
return new FullResult(
PrecompiledContract.PrecompileContractResult.halt(Bytes.EMPTY, Optional.empty()), gasRequirement, null);

Check warning on line 129 in hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/FullResult.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/FullResult.java#L128-L129

Added lines #L128 - L129 were not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import static com.hedera.hapi.node.base.ResponseCodeEnum.SUCCESS;
import static com.hedera.node.app.service.contract.impl.exec.systemcontracts.FullResult.haltResult;
import static com.hedera.node.app.service.contract.impl.exec.systemcontracts.FullResult.revertResult;
import static com.hedera.node.app.service.contract.impl.exec.utils.FrameUtils.contractsConfigOf;
import static com.hedera.node.app.service.contract.impl.exec.utils.FrameUtils.unqualifiedDelegateDetected;
import static com.hedera.node.app.service.contract.impl.utils.ConversionUtils.asNumberedContractId;
Expand Down Expand Up @@ -73,8 +72,9 @@
attempt = callFactory.createCallAttemptFrom(input, frame);
call = requireNonNull(attempt.asExecutableCall());
if (frame.isStatic() && !call.allowsStaticFrame()) {
return revertResult(
STATIC_CALL_REVERT_REASON, contractsConfigOf(frame).precompileHtsDefaultGasCost());
// FUTURE - we should really set an explicit halt reason here; instead we just halt the frame
// without setting a halt reason to simulate mono-service for differential testing
return haltResult(contractsConfigOf(frame).precompileHtsDefaultGasCost());

Check warning on line 77 in hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/HtsSystemContract.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/HtsSystemContract.java#L77

Added line #L77 was not covered by tests
}
} catch (final RuntimeException e) {
log.debug("Failed to create HTS call from input {}", input, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ protected Map<TokenID, List<NftTransfer>> nftChangesFrom(
AccountID receiverAccountId = null;
final var builder = NftTransfer.newBuilder();
if (modifiedNft != null) {
if (modifiedNft.hasOwnerId()) {
if (modifiedNft.hasOwnerId() && !AccountID.DEFAULT.equals(modifiedNft.ownerId())) {
receiverAccountId = modifiedNft.ownerId();
} else {
receiverAccountId = token.treasuryAccountId();
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public enum SnapshotMatchMode {
* Allows for non-deterministic amounts.
*/
NONDETERMINISTIC_TRANSACTION_FEES,
/**
* Allows for non-deterministic nonce. This can happen when there is a NodeStakeUpdate transaction in the
* mix.
*/
NONDETERMINISTIC_NONCE,
/**
* Lets a spec advertise itself as being non-deterministic.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import static com.hedera.services.bdd.spec.utilops.records.SnapshotMatchMode.NONDETERMINISTIC_CONSTRUCTOR_PARAMETERS;
import static com.hedera.services.bdd.spec.utilops.records.SnapshotMatchMode.NONDETERMINISTIC_CONTRACT_CALL_RESULTS;
import static com.hedera.services.bdd.spec.utilops.records.SnapshotMatchMode.NONDETERMINISTIC_FUNCTION_PARAMETERS;
import static com.hedera.services.bdd.spec.utilops.records.SnapshotMatchMode.NONDETERMINISTIC_NONCE;
import static com.hedera.services.bdd.spec.utilops.records.SnapshotMatchMode.NONDETERMINISTIC_TRANSACTION_FEES;
import static com.hedera.services.bdd.suites.TargetNetworkType.STANDALONE_MONO_NETWORK;
import static com.hedera.services.bdd.suites.contract.Utils.asInstant;
Expand Down Expand Up @@ -172,8 +173,8 @@ public class SnapshotModeOp extends UtilOp implements SnapshotOp {

public static void main(String... args) throws IOException {
// Helper to review the snapshot saved for a particular HapiSuite-HapiSpec combination
final var snapshotFileMeta =
new SnapshotFileMeta("CryptoTransferHTS", "hapiTransferFromForFungibleTokenToSystemAccountsFails");
final var snapshotFileMeta = new SnapshotFileMeta(
"ContractKeysHTS", "DissociatePrecompileWithDelegateContractKeyForNonFungibleVanilla");
final var maybeSnapshot = suiteSnapshotsFrom(
resourceLocOf(PROJECT_ROOT_SNAPSHOT_RESOURCES_LOC, snapshotFileMeta.suiteName()))
.flatMap(
Expand Down Expand Up @@ -739,6 +740,8 @@ private boolean shouldSkip(@NonNull final String expectedName, @NonNull final Cl
return matchModes.contains(NONDETERMINISTIC_CONTRACT_CALL_RESULTS);
} else if ("constructorParameters".equals(expectedName)) {
return matchModes.contains(NONDETERMINISTIC_CONSTRUCTOR_PARAMETERS);
} else if ("nonce".equals(expectedName)) {
return matchModes.contains(NONDETERMINISTIC_NONCE);
} else if ("gas".equals(expectedName) || "gasUsed".equals(expectedName)) {
return matchModes.contains(ACCEPTED_MONO_GAS_CALCULATION_DIFFERENCE);
} else {
Expand Down
Loading
Loading