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

Anchor height not available; scan required #904

Closed
Tracked by #1219
HonzaR opened this issue Aug 21, 2023 · 4 comments
Closed
Tracked by #1219

Anchor height not available; scan required #904

HonzaR opened this issue Aug 21, 2023 · 4 comments

Comments

@HonzaR
Copy link

HonzaR commented Aug 21, 2023

Before we start syncing blocks with the latest FFI changes cd391db in the Fast-spendability PR of Android SDK, we approach to refresh the transparent balance and other things like this:

        launch(CoroutineExceptionHandler(::onCriticalError)) {
            refreshUtxos(Account.DEFAULT)
            refreshTransparentBalance()
            refreshTransactions()
        }

But after that commit, I see this error:

cash.z.ecc.android.sdk.demoapp.mainnet main SdkSynchronizer.onCriticalError(): Critical error occurred
java.lang.RuntimeException: Anchor height not available; scan required.
at cash.z.ecc.android.sdk.internal.jni.RustBackend.getVerifiedTransparentBalance(Native Method)
at cash.z.ecc.android.sdk.internal.jni.RustBackend.access$getVerifiedTransparentBalance(RustBackend.kt:19)
at cash.z.ecc.android.sdk.internal.jni.RustBackend$Companion.getVerifiedTransparentBalance(Unknown Source:0)
at cash.z.ecc.android.sdk.internal.jni.RustBackend$Companion.access$getVerifiedTransparentBalance(RustBackend.kt:369)
at cash.z.ecc.android.sdk.internal.jni.RustBackend$getVerifiedTransparentBalance$2.invokeSuspend(RustBackend.kt:206)
at cash.z.ecc.android.sdk.internal.jni.RustBackend$getVerifiedTransparentBalance$2.invoke(Unknown Source:8)
at cash.z.ecc.android.sdk.internal.jni.RustBackend$getVerifiedTransparentBalance$2.invoke(Unknown Source:4)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:78)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:167)
at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1)
at cash.z.ecc.android.sdk.internal.jni.RustBackend.getVerifiedTransparentBalance(RustBackend.kt:205)
at cash.z.ecc.android.sdk.internal.TypesafeBackendImpl$getDownloadedUtxoBalance$verified$1.invokeSuspend(TypesafeBackendImpl.kt:131)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
at java.lang.Thread.run(Thread.java:1012)

The error is handled on the SDK side, but refreshTransactions won't happen after that caught exception from the rust layer.

  • Testnet/Mainnet doesn't matter (both impacted)
  • New/older wallet doesn't matter (both impacted)

Is that an expected behavior now?

@nuttycom
Copy link
Contributor

@HonzaR Can you verify whether updateChainTip is being called prior to this interaction? Basically everything depends upon updateChainTip at this point. That being said, I think it would be reasonable for the implementation of the various get*Balance calls to simply return zeros if no chain data is available, instead of throwing an error. #900 will also modify the balance APIs in a way that will resolve this problem, but in general if you can ensure that updateChainTip is being called prior to retrieving balances that will ensure that a variety of errors similar to this one are not reachable.

@nuttycom nuttycom added this to the Spend-before-Sync milestone Aug 22, 2023
@nuttycom
Copy link
Contributor

nuttycom commented Aug 24, 2023

I want to revisit this problem once #907 is merged and integrated into the wallet SDKs, because that integration work will require that the order of operations here is handled correctly. So, while #907 doesn't specifically fix this, it indirectly fixes it by requiring that it be fixed in order for the wallet to work at all.

@HonzaR
Copy link
Author

HonzaR commented Aug 25, 2023

@HonzaR Can you verify whether updateChainTip is being called prior to this interaction?

@nuttycom No, the updateChainTip operation is being called after this initial balance and transactions poll. That is a new SbS requirement. The error is thrown by the rust layer. I'll file a new issue on making the updateChainTip the first operation in our algorithm. Then the Electric-Coin-Company/zcash-android-wallet-sdk#1180 issue will change our approach to calling this operation and also #900 will change when we trigger the balances and transactions refreshing as well.

@nuttycom
Copy link
Contributor

nuttycom commented Sep 8, 2023

Confirmed fixed by @HonzaR

@nuttycom nuttycom closed this as completed Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants