From: Arik Sosman Date: Thu, 1 Aug 2024 14:55:46 +0000 (-0700) Subject: Further experimentation to patch against rust-bitcoin changes. X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=07daa2d6367517f1593e0a828d1a1be236b46ad4;p=rust-lightning Further experimentation to patch against rust-bitcoin changes. --- diff --git a/Cargo.toml b/Cargo.toml index 0aa7f7624..59b545992 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,6 +43,11 @@ panic = "abort" [patch.crates-io.possiblyrandom] path = "possiblyrandom" +[patch.crates-io] +bitcoin = { path = "../../rust-bitcoin/bitcoin" } +bitcoin-io = {path = "../../rust-bitcoin/io" } +bitcoin_hashes = {path = "../../rust-bitcoin/hashes"} + [workspace.lints.rust.unexpected_cfgs] level = "forbid" # When adding a new cfg attribute, ensure that it is added to this list. diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 894638425..29a7864c1 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -22,7 +22,8 @@ lightning = { path = "../lightning", features = ["regex", "hashbrown", "_test_ut lightning-invoice = { path = "../lightning-invoice" } lightning-rapid-gossip-sync = { path = "../lightning-rapid-gossip-sync" } bech32 = "0.9.1" -bitcoin = { version = "0.32.2", features = ["secp-lowmemory"] } +#bitcoin = { version = "0.32.2", features = ["secp-lowmemory"] } +bitcoin = { path = "../../../rust-bitcoin/bitcoin", features = ["secp-lowmemory"] } hex = { package = "hex-conservative", version = "0.1.1", default-features = false } afl = { version = "0.12", optional = true } diff --git a/lightning-background-processor/Cargo.toml b/lightning-background-processor/Cargo.toml index c780cc3d6..aa2151a74 100644 --- a/lightning-background-processor/Cargo.toml +++ b/lightning-background-processor/Cargo.toml @@ -21,7 +21,8 @@ no-std = ["lightning/no-std", "lightning-rapid-gossip-sync/no-std"] default = ["std"] [dependencies] -bitcoin = { version = "0.32.2", default-features = false } +#bitcoin = { version = "0.32.2", default-features = false } +bitcoin = { path = "../../../rust-bitcoin/bitcoin", default-features = false } lightning = { version = "0.0.123-beta", path = "../lightning", default-features = false } lightning-rapid-gossip-sync = { version = "0.0.123-beta", path = "../lightning-rapid-gossip-sync", default-features = false } diff --git a/lightning-block-sync/Cargo.toml b/lightning-block-sync/Cargo.toml index c02084c16..040edd346 100644 --- a/lightning-block-sync/Cargo.toml +++ b/lightning-block-sync/Cargo.toml @@ -18,7 +18,8 @@ rest-client = [ "serde_json", "chunked_transfer" ] rpc-client = [ "serde_json", "chunked_transfer" ] [dependencies] -bitcoin = "0.32.2" +#bitcoin = "0.32.2" +bitcoin = { path = "../../../rust-bitcoin/bitcoin" } hex = { package = "hex-conservative", version = "0.1.1", default-features = false } lightning = { version = "0.0.123-beta", path = "../lightning" } tokio = { version = "1.35", features = [ "io-util", "net", "time", "rt" ], optional = true } diff --git a/lightning-custom-message/Cargo.toml b/lightning-custom-message/Cargo.toml index d3c2e5708..2c429bfdd 100644 --- a/lightning-custom-message/Cargo.toml +++ b/lightning-custom-message/Cargo.toml @@ -14,7 +14,8 @@ all-features = true rustdoc-args = ["--cfg", "docsrs"] [dependencies] -bitcoin = "0.32.2" +#bitcoin = "0.32.2" +bitcoin = { path = "../../../rust-bitcoin/bitcoin" } lightning = { version = "0.0.123-beta", path = "../lightning" } [lints] diff --git a/lightning-invoice/Cargo.toml b/lightning-invoice/Cargo.toml index e7b14d876..6cc13c822 100644 --- a/lightning-invoice/Cargo.toml +++ b/lightning-invoice/Cargo.toml @@ -24,7 +24,8 @@ bech32 = { version = "0.9.1", default-features = false } lightning = { version = "0.0.123-beta", path = "../lightning", default-features = false } secp256k1 = { version = "0.28.0", default-features = false, features = ["recovery", "alloc"] } serde = { version = "1.0.118", optional = true } -bitcoin = { version = "0.32.2", default-features = false } +#bitcoin = { version = "0.32.2", default-features = false } +bitcoin = { path = "../../../rust-bitcoin/bitcoin", default-features = false } [dev-dependencies] lightning = { version = "0.0.123-beta", path = "../lightning", default-features = false, features = ["_test_utils"] } diff --git a/lightning-net-tokio/Cargo.toml b/lightning-net-tokio/Cargo.toml index ede8cc0a7..d2509613d 100644 --- a/lightning-net-tokio/Cargo.toml +++ b/lightning-net-tokio/Cargo.toml @@ -15,7 +15,8 @@ all-features = true rustdoc-args = ["--cfg", "docsrs"] [dependencies] -bitcoin = "0.32.2" +#bitcoin = "0.32.2" +bitcoin = { path = "../../../rust-bitcoin/bitcoin" } lightning = { version = "0.0.123-beta", path = "../lightning" } tokio = { version = "1.35", features = [ "rt", "sync", "net", "time" ] } diff --git a/lightning-persister/Cargo.toml b/lightning-persister/Cargo.toml index e315fb791..351619ab6 100644 --- a/lightning-persister/Cargo.toml +++ b/lightning-persister/Cargo.toml @@ -14,7 +14,8 @@ all-features = true rustdoc-args = ["--cfg", "docsrs"] [dependencies] -bitcoin = "0.32.2" +#bitcoin = "0.32.2" +bitcoin = { path = "../../../rust-bitcoin/bitcoin" } lightning = { version = "0.0.123-beta", path = "../lightning" } [target.'cfg(windows)'.dependencies] @@ -25,7 +26,8 @@ criterion = { version = "0.4", optional = true, default-features = false } [dev-dependencies] lightning = { version = "0.0.123-beta", path = "../lightning", features = ["_test_utils"] } -bitcoin = { version = "0.32.2", default-features = false } +#bitcoin = { version = "0.32.2", default-features = false } +bitcoin = { path = "../../../rust-bitcoin/bitcoin", default-features = false } [lints] workspace = true diff --git a/lightning-rapid-gossip-sync/Cargo.toml b/lightning-rapid-gossip-sync/Cargo.toml index 9d9f3d23e..7a76d03c1 100644 --- a/lightning-rapid-gossip-sync/Cargo.toml +++ b/lightning-rapid-gossip-sync/Cargo.toml @@ -16,7 +16,8 @@ std = ["lightning/std"] [dependencies] lightning = { version = "0.0.123-beta", path = "../lightning", default-features = false } -bitcoin = { version = "0.32.2", default-features = false } +#bitcoin = { version = "0.32.2", default-features = false } +bitcoin = { path = "../../../rust-bitcoin/bitcoin", default-features = false } [target.'cfg(ldk_bench)'.dependencies] criterion = { version = "0.4", optional = true, default-features = false } diff --git a/lightning-transaction-sync/Cargo.toml b/lightning-transaction-sync/Cargo.toml index 0243d7604..e198e36d4 100644 --- a/lightning-transaction-sync/Cargo.toml +++ b/lightning-transaction-sync/Cargo.toml @@ -24,7 +24,8 @@ async-interface = [] [dependencies] lightning = { version = "0.0.123-beta", path = "../lightning", default-features = false, features = ["std"] } -bitcoin = { version = "0.32.2", default-features = false } +#bitcoin = { version = "0.32.2", default-features = false } +bitcoin = { path = "../../../rust-bitcoin/bitcoin", default-features = false } bdk-macros = "0.6" futures = { version = "0.3", optional = true } esplora-client = { version = "0.7", default-features = false, optional = true } diff --git a/lightning/Cargo.toml b/lightning/Cargo.toml index b0d68fc10..26213f4dc 100644 --- a/lightning/Cargo.toml +++ b/lightning/Cargo.toml @@ -42,6 +42,7 @@ default = ["std", "grind_signatures"] [dependencies] bech32 = { version = "0.9.1", default-features = false } bitcoin = { version = "0.32.2", default-features = false, features = ["secp-recovery"] } +# bitcoin = { path = "../../../rust-bitcoin/bitcoin", default-features = false, features = ["secp-recovery"] } hashbrown = { version = "0.13", optional = true, default-features = false } possiblyrandom = { version = "0.2", optional = true, default-features = false } @@ -57,6 +58,7 @@ regex = "1.5.6" [dev-dependencies.bitcoin] version = "0.32.2" +# path = "../../../rust-bitcoin/bitcoin" default-features = false features = ["bitcoinconsensus", "secp-recovery"] diff --git a/lightning/src/util/ser.rs b/lightning/src/util/ser.rs index ec9022ca4..3978823b1 100644 --- a/lightning/src/util/ser.rs +++ b/lightning/src/util/ser.rs @@ -14,7 +14,7 @@ //! [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor use crate::prelude::*; -use crate::io::{self, Read, Seek, Write}; +use crate::io::{self, Read, Seek, Take, Write, BufRead}; use crate::io_extras::{copy, sink}; use core::hash::Hash; use crate::sync::{Mutex, RwLock}; @@ -112,6 +112,7 @@ pub struct FixedLengthReader<'a, R: Read> { bytes_read: u64, total_bytes: u64, } + impl<'a, R: Read> FixedLengthReader<'a, R> { /// Returns a new [`FixedLengthReader`]. pub fn new(read: &'a mut R, total_bytes: u64) -> Self { @@ -153,6 +154,18 @@ impl<'a, R: Read> Read for FixedLengthReader<'a, R> { } } +// impl<'a, R: Read> Read for &mut FixedLengthReader<'a, R> { +// #[inline] +// fn read(&mut self, buf: &mut [u8]) -> Result { +// (**self).read(buf) +// } +// +// #[inline] +// fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), io::Error> { +// (**self).read_exact(buf) +// } +// } + impl<'a, R: Read> LengthRead for FixedLengthReader<'a, R> { #[inline] fn total_bytes(&self) -> u64 { @@ -189,6 +202,30 @@ impl Read for ReadTrackingReader { } } +// impl Read for &mut ReadTrackingReader { +// #[inline] +// fn read(&mut self, buf: &mut [u8]) -> Result { +// (**self).read(buf) +// } +// +// #[inline] +// fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), io::Error> { +// (**self).read_exact(buf) +// } +// } + +// impl Read for &mut &mut ReadTrackingReader { +// #[inline] +// fn read(&mut self, buf: &mut [u8]) -> Result { +// (**self).read(buf) +// } +// +// #[inline] +// fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), io::Error> { +// (**self).read_exact(buf) +// } +// } + /// A trait that various LDK types implement allowing them to be written out to a [`Writer`]. /// /// This is not exported to bindings users as we only export serialization to/from byte arrays instead @@ -243,7 +280,7 @@ pub trait Readable where Self: Sized { /// Reads a `Self` in from the given [`Read`]. - fn read(reader: &mut R) -> Result; + fn read(reader: &mut R) -> Result; } /// A trait that various LDK types implement allowing them to be read in from a @@ -1234,7 +1271,7 @@ macro_rules! impl_consensus_ser { } impl Readable for $bitcoin_type { - fn read(r: &mut R) -> Result { + fn read(r: &mut R) -> Result { match consensus::encode::Decodable::consensus_decode(r) { Ok(t) => Ok(t), Err(consensus::encode::Error::Io(ref e)) if e.kind() == io::ErrorKind::UnexpectedEof => Err(DecodeError::ShortRead),