KasarLabs / barknet

https://kasar.io
MIT License
13 stars 0 forks source link

net/bitcoin_client #3

Open antiyro opened 1 year ago

antiyro commented 1 year ago

Description:

Establish a BitcoinClient struct within the bitcoin module to facilitate interactions with the Bitcoin network. This structure must conform to the DaClient trait.

Tasks:

  1. Define the BitcoinClient Struct:

    • Fields:

      • rpc_client: An instance or connection to a Bitcoin RPC client. This field will allow direct interactions with a Bitcoin node.
      • network_type: Specifies the Bitcoin network (mainnet, testnet, regtest).
      • mode: Specifies the mode of data availability (e.g., DaMode::Sovereign).
      • Additional fields can be integrated based on specific requirements, such as authentication credentials, wallet addresses, etc.
    • Example Structure:

      pub struct BitcoinClient {
      rpc_client: RpcClient,  // Use the appropriate type from the Bitcoin-da crate
      network_type: String,
      mode: DaMode,
      // Add other fields as required
      }
  2. Implement the DaClient Trait for BitcoinClient:

    • Method Skeletons:

      • Based on the DaClient trait, define the methods that BitcoinClient will need to implement.
      • Initially, these methods can return default values or unimplemented!() to be filled in later.
    • Example Skeleton:

      impl DaClient for BitcoinClient {
      fn get_mode(&self) -> DaMode {
          self.mode
      }
      
      async fn last_published_state(&self) -> Result<I256> {
          unimplemented!()  // Placeholder
      }
      
      async fn publish_state_diff(&self, state_diff: Vec<U256>) -> Result<()> {
          unimplemented!()  // Placeholder
      }
      }
  3. Implement DaClient Methods with Bitcoin-da Functionality:

    • get_mode:

      • This method should return the data availability mode of the client. If you've set it in the struct, this can be returned directly.
    • last_published_state:

      • Adapt this method to fetch the last published state from the Bitcoin network. Depending on how data is stored or marked on Bitcoin (e.g., via OP_RETURN or other mechanisms), this method should retrieve and return the relevant state.
      • Use functionalities from the Bitcoin-da crate to interact with the Bitcoin network and fetch the required data.
    • publish_state_diff:

      • This method should publish a state difference to the Bitcoin network. Depending on the size and nature of the state difference, it may need to be split and embedded across multiple Bitcoin transactions.
      • Utilize the Bitcoin-da crate's capabilities to create, sign, and broadcast the necessary Bitcoin transactions.
    • Additional Considerations:

      • Given the distinct nature of Bitcoin (e.g., UTXO model, transaction sizes), some adaptations might be necessary compared to the Ethereum implementation.
0xEniotna commented 1 year ago

So it should be here we call read and write

0xEniotna commented 1 year ago

This is almost OK. There is an issue with last_published_state

github-actions[bot] commented 1 year ago

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a 👍 Because this issue is marked as stale, it will be closed and locked in 7 days if no further activity occurs. Thank you for your contributions!