diff --git a/.gitignore b/.gitignore index 2c83608..be2922b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ Cargo.lock !justfile *.db +*.hints diff --git a/Cargo.toml b/Cargo.toml index 4d27bb1..7de75f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [workspace] members = ["accumulator", "hintfile", "network"] default-members = ["accumulator", "hintfile", "network"] -resolver = "3" +resolver = "2" [workspace.dependencies] bitcoin = { git = "https://github.com/rust-bitcoin/rust-bitcoin", default-features = false, rev = "16cc257c3695dea0e7301a5fa9cab44b8ed60598" } diff --git a/accumulator/Cargo.toml b/accumulator/Cargo.toml index 825ee15..52546c3 100644 --- a/accumulator/Cargo.toml +++ b/accumulator/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "accumulator" version = "0.1.0" -edition = "2024" +edition = "2021" [dependencies] bitcoin = { workspace = true } diff --git a/flake.lock b/flake.lock deleted file mode 100644 index 6d192e0..0000000 --- a/flake.lock +++ /dev/null @@ -1,96 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1752687322, - "narHash": "sha256-RKwfXA4OZROjBTQAl9WOZQFm7L8Bo93FQwSJpAiSRvo=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "6e987485eb2c77e5dcc5af4e3c70843711ef9251", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1744536153, - "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" - } - }, - "rust-overlay": { - "inputs": { - "nixpkgs": "nixpkgs_2" - }, - "locked": { - "lastModified": 1752806774, - "narHash": "sha256-4cHeoR2roN7d/3J6gT+l6o7J2hTrBIUiCwVdDNMeXzE=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "3c90219b3ba1c9790c45a078eae121de48a39c55", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 46a30ee..0000000 --- a/flake.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ - description = "A rust devshell - copied from oxalica/rust-overlay"; - - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - rust-overlay.url = "github:oxalica/rust-overlay"; - flake-utils.url = "github:numtide/flake-utils"; - }; - - outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }: - flake-utils.lib.eachDefaultSystem (system: - let - overlays = [ (import rust-overlay) ]; - pkgs = import nixpkgs { - inherit system overlays; - }; - in - { - devShells.default = with pkgs; mkShell { - buildInputs = [ - pkg-config - rust-bin.nightly.latest.default - ]; - }; - } - ); -} diff --git a/hintfile/Cargo.toml b/hintfile/Cargo.toml index fc0e009..5a45232 100644 --- a/hintfile/Cargo.toml +++ b/hintfile/Cargo.toml @@ -1,6 +1,11 @@ [package] name = "hintfile" version = "0.1.0" -edition = "2024" +edition = "2021" [dependencies] +bitcoin = { workspace = true } +kernel = { package = "bitcoinkernel", git = "https://github.com/alexanderwiederin/rust-bitcoinkernel.git" } + +[[bin]] +name = "construct" diff --git a/hintfile/src/bin/construct.rs b/hintfile/src/bin/construct.rs new file mode 100644 index 0000000..dbf7d5e --- /dev/null +++ b/hintfile/src/bin/construct.rs @@ -0,0 +1,40 @@ +use std::{fs::File, sync::Arc}; + +use bitcoin::consensus; +use kernel::{ChainType, ChainstateManager, ChainstateManagerOptions, ContextBuilder, KernelError}; + +fn main() { + let mut file = File::create("./signet.hints").unwrap(); + + let mut args = std::env::args(); + let _ = args.next(); + let data_dir = args.next().expect("Usage: "); + let mut blocks_dir = data_dir.clone(); + blocks_dir.push_str("/blocks"); + println!("Initializing"); + let ctx = ContextBuilder::new() + .chain_type(ChainType::SIGNET) + .build() + .unwrap(); + let options = ChainstateManagerOptions::new(&ctx, &data_dir, &blocks_dir).unwrap(); + let context = Arc::new(ctx); + let chainman = ChainstateManager::new(options, context).unwrap(); + println!("Chain state initialized"); + let genesis = chainman.get_block_index_genesis(); + let mut current = chainman.get_next_block_index(genesis).unwrap(); + loop { + let block = chainman.read_block_data(¤t).unwrap(); + let bytes: Vec = block.into(); + let block = consensus::deserialize::(&bytes).unwrap(); + let (_, transactions) = block.into_parts(); + println!("On block {}", current.height()); + let mut delta: u64 = 0; + let mut block_offsets: Vec = Vec::new(); + for tx in transactions {} + match chainman.get_next_block_index(current) { + Ok(next) => current = next, + Err(KernelError::OutOfBounds) => break, + Err(e) => panic!("{e}"), + } + } +} diff --git a/network/Cargo.toml b/network/Cargo.toml index bd127d3..e100f2c 100644 --- a/network/Cargo.toml +++ b/network/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "peers" version = "0.1.0" -edition = "2024" +edition = "2021" [dependencies] tokio = { version = "1", default-features = false, optional = true, features = [