ChainSafe / forest

🌲 Rust Filecoin Node Implementation
https://forest.chainsafe.io
Apache License 2.0
638 stars 156 forks source link

forest panics at heaviest_tipset #2694

Closed creativcoder closed 1 year ago

creativcoder commented 1 year ago

Describe the bug

Forest panics when run post db clean at calling heaviest_tipset during startup. The file backed chain metadata info was introduced in https://github.com/ChainSafe/forest/pull/2635

context:

    /// Returns the currently tracked heaviest tipset.
    pub fn heaviest_tipset(&self) -> Arc<Tipset> {
        self.tipset_from_keys(self.file_backed_heaviest_tipset_keys.lock().inner())
            .expect("Failed to load heaviest tipset")
    }

To Reproduce Steps to reproduce the behavior:

  1. Run forest-cli --chain calibnet db clean
  2. Run forest --chain calibnet --encrypt-keystore false
  3. See error

Log output

Log Output ```➜ forest2 git:(main) forest --chain calibnet --encrypt-keystore false 2023-03-21T12:06:05.680299Z INFO forest: Using default calibnet config 2023-03-21T12:06:05.681304Z INFO forest::daemon: Starting Forest daemon, version 0.6.0+git.3e68aa3f 2023-03-21T12:06:05.681409Z INFO forest_libp2p::service: Could not decode networking keystore! 2023-03-21T12:06:05.681867Z INFO forest_utils::io: Permissions set to 0600 on File { fd: 9, path: "/root/.local/share/forest/libp2p/keypair", read: false, write: true } 2023-03-21T12:06:05.682079Z INFO forest::daemon: PeerId: 12D3KooWG5KKNqbhVQ6u3M75rXiJMwKdR8UbTdnvNWqemb5Ds4CR 2023-03-21T12:06:05.682111Z WARN forest::daemon: Warning: Keystore encryption disabled! 2023-03-21T12:06:05.682291Z INFO forest::daemon: Admin token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJBbGxvdyI6WyJyZWFkIiwid3JpdGUiLCJzaWduIiwiYWRtaW4iXSwiZXhwIjoxNjg0NTg0MzY1fQ.OTKQSVTZbNsxJ2T10u6Q_fujfmZfiktHTzcTSGIAD-Y 2023-03-21T12:06:05.683556Z INFO forest::daemon: Prometheus server started at 0.0.0.0:6116 2023-03-21T12:06:05.689456Z INFO forest_genesis: Initialized genesis: BlockHeader: Cid(bafy2bzacecyaggy24wol5ruvs6qm73gjibs2l2iyhcqmvi7r7a4ph7zx3yqd4) 2023-03-21T12:06:05.690566Z INFO forest::daemon: Using network :: calibnet thread 'main' panicked at 'Failed to load heaviest tipset: NotFound("Key for header")', /root/forest2/blockchain/chain/src/store/chain_store.rs:240:14 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace [1] 3452847 IOT instruction (core dumped) target/release/forest --chain calibnet --encrypt-keystore false ```

Expected behaviour

Screenshots

Environment (please complete the following information):

Other information and links

lemmih commented 1 year ago

Yeah, this is because we aren't cleaning up the HEAD file. We should really be validating it.

elmattic commented 1 year ago

Just reproduced it now as well:

thread 'main' panicked at 'Failed to load heaviest tipset: NotFound("Key for header")', /Users/guillaume/Code/forest/blockchain/chain/src/store/chain_store.rs:234:14

Note that I didn't do anything special (e.g. cleaning db or anything else). Just hit ctrl+c to stop forest then relaunched it.