FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Issue when saving to remote data storage, error not being handled · Issue #267 · BitVM/BitVM · GitHub

/ BitVM Public

Issue when saving to remote data storage, error not being handled #267

Description

ERROR Description:

When executing the “initiate peg-in” command, if bitVM encounters issues while saving data to the remote storage (AWS S3, FTP, FTPS etc…), it will continue to broadcast the transaction even if the data hasn't been saved correctly. This may lead to discrepancies, since other instances of bitVM (other verifiers, operators, etc.) will rely on that information to perform other relevant operations.

kritian@:~/demos/BitVM$ ./target/release/bridge initiate-peg-in --utxo ee29855315760b5b839ad20c9ce19a1e235c54afc2431b2a527b97458c0ab8e5:1 --destinat
ion_address 0x8C6bF4b04363910443cCc8F3B71B267EC3b96241
Using data file path: bridge_data/Operator 0/testnet/ethereum_sepolia/031ba4854cef9979134eb93ead94caf049af97974817b1b65448b94b620353f11b
Writing data file to 1741653513934-bridge-client-data-demo-feb-2025.json (size: 1134)
**Failed to push: Failed to save data file**
Created peg-in graph with ID: 7E2785CCC8BCA6422050E2BA2AE35FE76D293205AA2DCBEDFC93EEB6D265C740
Broadcasting deposit...
Tx broadcasted successfully. Txid: 27b80f3a93cab6206f9e3f9040803a53341203b27fcb1f019030e5f6e5be3e5

What's being saved?

The BitVM client is trying to save the BitVMClientPublicData structure, which contains:

  1. Version number
  2. Peg-in graphs - critical data about peg-in transactions
  3. Peg-out graphs - critical data about peg-out transactions

This data is essential for the proper functioning of the BitVM bridge, as it maintains the state of all transactions and allows different nodes to stay in sync.

Where is it being saved?

The BitVM client attempts to save data in two places:

1.Remote Data Store - The system supports multiple remote backends:

  • ◦ AWS S3
  • ◦ FTP
  • ◦ FTPS
  • ◦ SFTP

The client attempts to initialize these backends during startup by checking for environment variables with credentials. If no credentials are found for any backend, operations like saving data files will fail with "Failed to save data file" errors.

2.Local File System - Even if the remote save fails, the client tries to save a local copy at:

CopyInsert
bridge_data/{user_prefix}/{source_network}/{destination_network}/{public_key}

Whereis the Error happening?

The error is happening in the remote data store. Looking at the get_driver() method in data_store.rs, we can see that if none of the remote backends (AWS S3, FTP, FTPS, SFTP) are configured, it returns an error with CLIENT_MISSING_CREDENTIALS_ERROR.

This error is then propagated up to write_compressed_data(), which returns "Failed to save data file", and finally to save_to_data_store(), which logs "Failed to push: Failed to save data file".

pub async fn write_compressed_data(
        &self,
        contents: &Vec<u8>,
        file_path: Option<&str>,
    ) -> Result<(String, usize), String> {
        match self.get_driver() {
            Ok(driver) => {
                let time = SystemTime::now()
                    .duration_since(UNIX_EPOCH)
                    .unwrap()
                    .as_millis();
                let file_name = self.create_file_name(time);
                let response = driver
                    .upload_compressed_object(&file_name, contents, file_path)
                    .await;

                match response {
                    Ok(size) => Ok((file_name, size)),
                    Err(_) => Err(String::from("Failed to save data file")),
                }
            }
            Err(err) => Err(err.to_string()),
        }
    }

This is potentially critical. The data being saved contains the state of all peg-in and peg-out transactions. If this data is not properly saved and shared, other nodes in the network won't be able to see your transactions or respond to them appropriately.

I am about to open a PR to fix this as I wish to contribute to the project

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL