Neptune-Crypto / neptune-core

anonymous peer-to-peer cash
Apache License 2.0
25 stars 7 forks source link

assertion `left == right` failed: Archival mutator set must be synced to tip for successful MUTXO recovery #142

Closed elielnfinic closed 5 months ago

elielnfinic commented 5 months ago

Description

This bug occurs when I run neptune-core --peers 127.0.0.1:9798 on MacOS and make the program to panic.

Steps to reproduce the problem

How to reproduce the error : Clone the repository on Mac Check out to release branch git checkout release Build for release cargo build --release Change directory to release/target Run ./neptune-core --peers 127.0.0.1:9798

I would like to mention that prior to running this, I successfully run ./neptune-cli generate-wallet and ./neptune-cli export-seed-phrase.

Specifications

Version : neptune-core 0.0.5 Platform : MacOS / MacBook Pro M1 Pro / Sonoma 14.1.1

Here is the full output of the error :

./neptune-core --peers 127.0.0.1:9798   
2024-04-26T05:56:10.942446Z  INFO ThreadId(01) neptune_core: Data directory is /Users/my_user_name/Library/Application Support/org.neptune.neptune/alpha
2024-04-26T05:56:10.942927Z  INFO ThreadId(01) neptune_core::models::state::wallet: ***** Reading wallet from /Users/my_user_name/Library/Application Support/org.neptune.neptune/alpha/wallet/wallet.dat *****

2024-04-26T05:56:10.943263Z  INFO ThreadId(01) neptune_core: Now getting wallet state. This may take a while if the database needs pruning.
2024-04-26T05:56:10.966988Z  INFO ThreadId(01) neptune_core: Got wallet state.
2024-04-26T05:56:10.987217Z  INFO ThreadId(01) neptune_core: Got block index database
2024-04-26T05:56:11.002694Z  INFO ThreadId(01) neptune_core: Got peer database
2024-04-26T05:56:11.020294Z  INFO ThreadId(01) neptune_core: Got archival mutator set
2024-04-26T05:56:11.02294Z  INFO ThreadId(01) neptune_core: Now listening for incoming transactions
2024-04-26T05:56:11.023089Z  INFO ThreadId(01) neptune_core: Most known canonical block has height 0
2024-04-26T05:56:11.023094Z  INFO ThreadId(01) neptune_core: Checking if we need to restore UTXOs
thread 'main' panicked at /Users/my_user_name/Desktop/new-neptune/neptune-core/src/models/state/mod.rs:610:9:
assertion `left == right` failed: Archival mutator set must be synced to tip for successful MUTXO recovery
  left: Digest([BFieldElement(9185962703704822055), BFieldElement(13305356197975853341), BFieldElement(12352772365370870018), BFieldElement(13109829415261833840), BFieldElement(15684651660353932478)])
 right: Digest([BFieldElement(5514367468280484491), BFieldElement(10780848294298297395), BFieldElement(793893767288748564), BFieldElement(9893268623412539041), BFieldElement(176176993305136537)])
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
aszepieniec commented 5 months ago

Thanks for the detailed report. I tried reproducing this on my ubuntu machine, but failed -- so that points to something that's different when on MacOS. I'm not sure what that might be, but let's look.

The assert that triggers the crash comes from the following lines in models/state/mod.rs:

    /// In case the wallet database is corrupted or deleted, this method will restore
    /// monitored UTXO data structures from recovery data. This method should only be
    /// called on startup, not while the program is running, since it will only restore
    /// a wallet state, if the monitored UTXOs have been deleted. Not merely if they
    /// are not synced with a valid mutator set membership proof. And this corruption
    /// can only happen if the wallet database is deleted or corrupted.
    pub(crate) async fn restore_monitored_utxos_from_recovery_data(&mut self) -> Result<()> {
        let tip_hash = self.chain.light_state().hash();
        let ams_ref = &self.chain.archival_state().archival_mutator_set;

        assert_eq!(
            tip_hash,
            ams_ref.get_sync_label(),
            "Archival mutator set must be synced to tip for successful MUTXO recovery"
        );
    [...]

The documentation suggests that this method is only called if neptune-core knows about owned UTXOs and expects to find their membership proofs but fails in that latter step. Did you produce this error on a completely fresh install of neptune-core, or did something go on before the crash?

elielnfinic commented 5 months ago

My bad, I think the mistake I made was using the executable in target/release instead of installing it into ~/.cargo/bin/ by using cargo install --locked --path .. After doing that, everything worked like a charm. So, I have all the installation steps for Mac here.