diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/HandleContextImpl.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/HandleContextImpl.java index a0200faabdba..cf119910c8e1 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/HandleContextImpl.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/HandleContextImpl.java @@ -353,7 +353,12 @@ public TransactionKeys allKeysForTransaction( dispatcher.dispatchPureChecks(nestedTxn); final var nestedContext = new PreHandleContextImpl( readableStoreFactory(), nestedTxn, payerForNested, configuration(), dispatcher); - dispatcher.dispatchPreHandle(nestedContext); + try { + dispatcher.dispatchPreHandle(nestedContext); + } catch (final PreCheckException ignored) { + // We must ignore/translate the exception here, as this is key gathering, not transaction validation. + throw new PreCheckException(ResponseCodeEnum.UNRESOLVABLE_REQUIRED_SIGNERS); + } return nestedContext; } diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/prehandle/PreHandleContextImpl.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/prehandle/PreHandleContextImpl.java index 28bc0ad97da6..dfb955323326 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/prehandle/PreHandleContextImpl.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/prehandle/PreHandleContextImpl.java @@ -459,7 +459,12 @@ public TransactionKeys allKeysForTransaction( dispatcher.dispatchPureChecks(nestedTxn); final var nestedContext = new PreHandleContextImpl(storeFactory, nestedTxn, payerForNested, configuration, dispatcher); - dispatcher.dispatchPreHandle(nestedContext); + try { + dispatcher.dispatchPreHandle(nestedContext); + } catch (final PreCheckException ignored) { + // We must ignore/translate the exception here, as this is key gathering, not transaction validation. + throw new PreCheckException(ResponseCodeEnum.UNRESOLVABLE_REQUIRED_SIGNERS); + } return nestedContext; } diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/workflows/handle/HandleContextImplTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/workflows/handle/HandleContextImplTest.java index a2307fb4c0b7..06ecf97fd523 100644 --- a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/workflows/handle/HandleContextImplTest.java +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/workflows/handle/HandleContextImplTest.java @@ -19,6 +19,7 @@ import static com.hedera.hapi.node.base.ResponseCodeEnum.INSUFFICIENT_ACCOUNT_BALANCE; import static com.hedera.hapi.node.base.ResponseCodeEnum.INVALID_TRANSACTION_BODY; import static com.hedera.hapi.node.base.ResponseCodeEnum.SUCCESS; +import static com.hedera.hapi.node.base.ResponseCodeEnum.UNRESOLVABLE_REQUIRED_SIGNERS; import static com.hedera.node.app.spi.HapiUtils.functionOf; import static com.hedera.node.app.spi.fixtures.workflows.ExceptionConditions.responseCode; import static com.hedera.node.app.spi.workflows.HandleContext.TransactionCategory.CHILD; @@ -573,15 +574,14 @@ void testAllKeysForTransactionWithFailingPureCheck() throws PreCheckException { @Test void testAllKeysForTransactionWithFailingPreHandle() throws PreCheckException { - // given doThrow(new PreCheckException(INSUFFICIENT_ACCOUNT_BALANCE)) .when(dispatcher) .dispatchPreHandle(any()); - // when + // gathering keys should not throw exceptions except for inability to read a key. assertThatThrownBy(() -> context.allKeysForTransaction(defaultTransactionBody(), ERIN.accountID())) .isInstanceOf(PreCheckException.class) - .has(responseCode(INSUFFICIENT_ACCOUNT_BALANCE)); + .has(responseCode(UNRESOLVABLE_REQUIRED_SIGNERS)); } } diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/workflows/prehandle/PreHandleContextImplTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/workflows/prehandle/PreHandleContextImplTest.java index 0467b45559bc..932509b7efe2 100644 --- a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/workflows/prehandle/PreHandleContextImplTest.java +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/workflows/prehandle/PreHandleContextImplTest.java @@ -18,6 +18,7 @@ import static com.hedera.hapi.node.base.ResponseCodeEnum.INSUFFICIENT_ACCOUNT_BALANCE; import static com.hedera.hapi.node.base.ResponseCodeEnum.INVALID_TRANSACTION_BODY; +import static com.hedera.hapi.node.base.ResponseCodeEnum.UNRESOLVABLE_REQUIRED_SIGNERS; import static com.hedera.node.app.spi.fixtures.workflows.ExceptionConditions.responseCode; import static com.hedera.node.app.workflows.prehandle.PreHandleContextListUpdatesTest.A_COMPLEX_KEY; import static org.assertj.core.api.Assertions.assertThat; @@ -189,10 +190,10 @@ void testAllKeysForTransactionWithFailingPreHandle() throws PreCheckException { .when(dispatcher) .dispatchPreHandle(any()); - // then + // gathering keys should not throw exceptions except for inability to read a key. assertThatThrownBy(() -> subject.allKeysForTransaction(TransactionBody.DEFAULT, ERIN.accountID())) .isInstanceOf(PreCheckException.class) - .has(responseCode(INSUFFICIENT_ACCOUNT_BALANCE)); + .has(responseCode(UNRESOLVABLE_REQUIRED_SIGNERS)); } } }