Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edition 2018 #635

Closed
wants to merge 15 commits into from
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Expand Up @@ -24,7 +24,7 @@ jobs:
DO_BENCH: true
AS_DEPENDENCY: true
DO_NO_STD: true
- rust: 1.29.0
- rust: 1.36.0
env:
AS_DEPENDENCY: true
PIN_VERSIONS: true
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -9,6 +9,7 @@ documentation = "https://docs.rs/bitcoin/"
description = "General purpose library for using and interoperating with Bitcoin and other cryptocurrencies."
keywords = [ "crypto", "bitcoin" ]
readme = "README.md"
edition = "2018"


[features]
Expand Down
21 changes: 3 additions & 18 deletions README.md
Expand Up @@ -51,25 +51,10 @@ please join us in
[libera.chat](https://libera.chat).

## Minimum Supported Rust Version (MSRV)
This library should always compile with any combination of features on **Rust 1.29**.
This library should always compile with any combination of features on **Rust 1.36**.

Because some dependencies have broken the build in minor/patch releases, to
compile with 1.29.0 you will need to run the following version-pinning command:
```
cargo update -p cc --precise "1.0.41" --verbose
```

In order to use the `use-serde` feature or to build the unit tests with 1.29.0,
the following version-pinning commands are also needed:
```
cargo update --package "serde" --precise "1.0.98"
cargo update --package "serde_derive" --precise "1.0.98"
```

For the feature `base64` to work with 1.29.0 we also need to pin `byteorder`:
```
cargo update -p byteorder --precise "1.3.4"
```
No pinning of dependencies is currently required but it may change in the future.
Please report if you find such case.

## Installing Rust
Rust can be installed using your package manager of choice or
Expand Down
6 changes: 0 additions & 6 deletions contrib/test.sh
Expand Up @@ -10,15 +10,10 @@ fi

pin_common_verions() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think we can rename this into cleanup

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of keeping it if some dependencies update their MSRV. But not really sure if it's better than renaming.

cargo generate-lockfile --verbose
cargo update -p cc --precise "1.0.41" --verbose
cargo update -p serde --precise "1.0.98" --verbose
cargo update -p serde_derive --precise "1.0.98" --verbose
}

# Pin `cc` for Rust 1.29
if [ "$PIN_VERSIONS" = true ]; then
pin_common_verions
cargo update -p byteorder --precise "1.3.4"
fi

if [ "$DO_COV" = true ]
Expand Down Expand Up @@ -90,7 +85,6 @@ then
cd dep_test
echo 'bitcoin = { path = "..", features = ["use-serde"] }' >> Cargo.toml

# Pin `cc` for Rust 1.29
if [ -n "$PIN_VERSIONS" ]; then
pin_common_verions
fi
Expand Down
2 changes: 0 additions & 2 deletions examples/bip32.rs
@@ -1,5 +1,3 @@
extern crate bitcoin;

use std::{env, process};
use std::str::FromStr;

Expand Down
2 changes: 0 additions & 2 deletions examples/handshake.rs
@@ -1,5 +1,3 @@
extern crate bitcoin;

use std::net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr, TcpStream};
use std::time::{SystemTime, UNIX_EPOCH};
use std::{env, process};
Expand Down
46 changes: 23 additions & 23 deletions src/blockdata/block.rs
Expand Up @@ -20,22 +20,22 @@
//! these blocks and the blockchain.
//!

use prelude::*;
use crate::prelude::*;

use core::fmt;

use util;
use util::Error::{BlockBadTarget, BlockBadProofOfWork};
use util::hash::bitcoin_merkle_root;
use hashes::{Hash, HashEngine};
use hash_types::{Wtxid, BlockHash, TxMerkleNode, WitnessMerkleNode, WitnessCommitment};
use util::uint::Uint256;
use consensus::encode::Encodable;
use network::constants::Network;
use blockdata::transaction::Transaction;
use blockdata::constants::{max_target, WITNESS_SCALE_FACTOR};
use blockdata::script;
use VarInt;
use crate::util;
use crate::util::Error::{BlockBadTarget, BlockBadProofOfWork};
use crate::util::hash::bitcoin_merkle_root;
use crate::hashes::{Hash, HashEngine};
use crate::hash_types::{Wtxid, BlockHash, TxMerkleNode, WitnessMerkleNode, WitnessCommitment};
use crate::util::uint::Uint256;
use crate::consensus::encode::Encodable;
use crate::network::constants::Network;
use crate::blockdata::transaction::Transaction;
use crate::blockdata::constants::{max_target, WITNESS_SCALE_FACTOR};
use crate::blockdata::script;
use crate::VarInt;

/// A block header, which contains all the block's information except
/// the actual transactions
Expand Down Expand Up @@ -299,7 +299,7 @@ pub enum Bip34Error {
}

impl fmt::Display for Bip34Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Bip34Error::Unsupported => write!(f, "block doesn't support BIP34"),
Bip34Error::NotPresent => write!(f, "BIP34 push not present in block's coinbase"),
Expand All @@ -311,17 +311,17 @@ impl fmt::Display for Bip34Error {
}

#[cfg(feature = "std")]
impl ::std::error::Error for Bip34Error {}
impl std::error::Error for Bip34Error {}

#[cfg(test)]
mod tests {
use hashes::hex::FromHex;
use crate::hashes::hex::FromHex;

use blockdata::block::{Block, BlockHeader};
use consensus::encode::{deserialize, serialize};
use util::uint::Uint256;
use util::Error::{BlockBadTarget, BlockBadProofOfWork};
use network::constants::Network;
use crate::blockdata::block::{Block, BlockHeader};
use crate::consensus::encode::{deserialize, serialize};
use crate::util::uint::Uint256;
use crate::util::Error::{BlockBadTarget, BlockBadProofOfWork};
use crate::network::constants::Network;

#[test]
fn test_coinbase_and_bip34() {
Expand Down Expand Up @@ -462,8 +462,8 @@ mod tests {
#[cfg(all(test, feature = "unstable"))]
mod benches {
use super::Block;
use EmptyWrite;
use consensus::{deserialize, Encodable};
use crate::EmptyWrite;
use crate::consensus::{deserialize, Encodable};
use hashes::hex::FromHex;
use test::{black_box, Bencher};

Expand Down
31 changes: 14 additions & 17 deletions src/blockdata/constants.rs
Expand Up @@ -19,18 +19,16 @@
//! single transaction
//!

use prelude::*;
use crate::prelude::*;

use core::default::Default;

use hashes::hex::{HexIterator, Error as HexError};
use hashes::sha256d;
use blockdata::opcodes;
use blockdata::script;
use blockdata::transaction::{OutPoint, Transaction, TxOut, TxIn};
use blockdata::block::{Block, BlockHeader};
use network::constants::Network;
use util::uint::Uint256;
use crate::hashes::hex::{HexIterator, Error as HexError};
use crate::hashes::sha256d;
use crate::blockdata::opcodes;
use crate::blockdata::script;
use crate::blockdata::transaction::{OutPoint, Transaction, TxOut, TxIn};
use crate::blockdata::block::{Block, BlockHeader};
use crate::network::constants::Network;
use crate::util::uint::Uint256;

/// The maximum allowable sequence number
pub const MAX_SEQUENCE: u32 = 0xFFFFFFFF;
Expand Down Expand Up @@ -165,13 +163,12 @@ pub fn genesis_block(network: Network) -> Block {

#[cfg(test)]
mod test {
use core::default::Default;
use hashes::hex::FromHex;
use crate::hashes::hex::FromHex;

use network::constants::Network;
use consensus::encode::serialize;
use blockdata::constants::{genesis_block, bitcoin_genesis_tx};
use blockdata::constants::{MAX_SEQUENCE, COIN_VALUE};
use crate::network::constants::Network;
use crate::consensus::encode::serialize;
use crate::blockdata::constants::{genesis_block, bitcoin_genesis_tx};
use crate::blockdata::constants::{MAX_SEQUENCE, COIN_VALUE};

#[test]
fn bitcoin_genesis_first_transaction() {
Expand Down
4 changes: 2 additions & 2 deletions src/blockdata/opcodes.rs
Expand Up @@ -22,7 +22,7 @@

#[cfg(feature = "serde")] use serde;

#[cfg(feature = "serde")] use prelude::*;
#[cfg(feature = "serde")] use crate::prelude::*;

use core::{fmt, convert::From};

Expand Down Expand Up @@ -560,7 +560,7 @@ pub mod all {
}

impl fmt::Debug for All {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("OP_")?;
match *self {
All {code: x} if x <= 75 => write!(f, "PUSHBYTES_{}", self.code),
Expand Down