Skip to content

Commit

Permalink
Release 0.10 (#141)
Browse files Browse the repository at this point in the history
* Preparations for the upcoming release

* Fix lints

* Release 0.10
  • Loading branch information
alekseysidorov committed Dec 14, 2018
1 parent f0bc684 commit f59f3fa
Show file tree
Hide file tree
Showing 25 changed files with 143 additions and 130 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,3 @@ __pycache__/
# other
*.orig
.python-version

#protobuf generated files
src/proto/btc_anchoring.rs
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ addons:
rust:
# Feel free to bump this version if you need features of newer Rust.
# Sync with badge in README.md
- 1.30.1
- 1.31.0

matrix:
allow_failures:
Expand All @@ -55,28 +55,24 @@ jobs:
include:
# Formatting & other lints that do not require compilation
- name: lints
rust: 1.30.1 # Use fresh rustfmt
install:
- rustup component add rustfmt-preview
- rustup component add rustfmt
- rustfmt -V
- nvm install 8 && nvm use 8
- npm install cspell
- ./node_modules/.bin/cspell --version
- npm install markdownlint-cli
- ./node_modules/.bin/markdownlint --version
script:
# Force build.rs execution.
- cargo check
- cargo fmt -- --check
- find . -not -path "./src/proto/btc_anchoring.rs" -not -path "./target/**" -name "*.rs" | xargs ./node_modules/.bin/cspell
- find . -not -path "./node_modules/*" -name "*.md" | xargs ./node_modules/.bin/cspell
- find . -not -path "./node_modules/*" -name "*.md" | xargs ./node_modules/.bin/markdownlint --config .markdownlintrc

# Clippy linting
- name: clippy
rust: nightly-2018-11-25 # Use fresh clippy
install:
- rustup component add clippy-preview
- rustup component add clippy
- cargo clippy --version
script:
- cargo clippy --all -- -D warnings
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## 0.10.0 - 2018-12-14

### Internal improvements

- Updated to the `Rust-bitcoin 0.14` release (#134).
Expand Down
17 changes: 8 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "exonum-btc-anchoring"
version = "0.9.0"
version = "0.10.0"
authors = ["The Exonum Team <[email protected]>"]
homepage = "https://exonum.com/doc/advanced/bitcoin-anchoring/"
repository = "https://github.com/exonum/exonum-btc-anchoring"
Expand All @@ -20,13 +20,17 @@ btc-transaction-utils = "0.4"
byteorder = "1.2"
clap = "2.32"
derive_more = "0.13"
display_derive = "0.0"
exonum = "0.10.0"
exonum_bitcoinrpc = "0.6"
exonum-derive = "0.10.0"
exonum-testkit = "0.10.0"
failure = "0.1"
failure_derive = "0.1"
hex = "0.3"
log = "0.4"
maplit = "1.0"
matches = "0.1"
protobuf = { version = "2.2", features = ["with-serde"] }
rand = "0.4"
secp256k1 = { version = "0.11", features = ["serde"] }
serde = "1.0"
Expand All @@ -35,17 +39,12 @@ serde_json = "1.0"
serde_str = "0.1"
structopt = "0.2"
toml = "0.4"
protobuf = { version = "=2.2.0", features = ["with-serde"] }

exonum = { git = "https://github.com/exonum/exonum", rev = "5dcbfc5561bfaf9f9a3c8264f7bdba463bf074ba" }
exonum-testkit = { git = "https://github.com/exonum/exonum", rev = "5dcbfc5561bfaf9f9a3c8264f7bdba463bf074ba" }
exonum_derive = { git = "https://github.com/exonum/exonum", rev = "5dcbfc5561bfaf9f9a3c8264f7bdba463bf074ba" }

[dev-dependencies]
exonum-configuration = { git = "https://github.com/exonum/exonum", rev = "5dcbfc5561bfaf9f9a3c8264f7bdba463bf074ba" }
exonum-configuration = "0.10.0"
libc = "0.2"
pretty_assertions = "0.5"
proptest = "0.8"

[build-dependencies]
protoc-rust = "=2.2.0"
exonum-build = "0.10.0"
20 changes: 9 additions & 11 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
extern crate protoc_rust;
extern crate exonum_build;

use protoc_rust::Customize;
use exonum_build::protobuf_generate;
use std::env;

fn main() {
protoc_rust::run(protoc_rust::Args {
out_dir: "src/proto",
input: &["src/proto/btc_anchoring.proto"],
includes: &["src/proto"],
customize: Customize {
serde_derive: Some(true),
..Default::default()
},
}).expect("protoc");
let exonum_protos = env::var("DEP_EXONUM_PROTOBUF_PROTOS").unwrap();
protobuf_generate(
"src/proto",
&["src/proto", &exonum_protos],
"protobuf_mod.rs",
);
}
3 changes: 2 additions & 1 deletion examples/btc_payload_extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
extern crate exonum;
extern crate exonum_btc_anchoring;

extern crate hex;
extern crate serde_json;
extern crate structopt;
#[macro_use]
extern crate failure;

use hex::FromHex;
use structopt::StructOpt;

use exonum::encoding::serialize::FromHex;
use exonum_btc_anchoring::btc::Transaction;

/// BTC anchoring payload extractor
Expand Down
7 changes: 4 additions & 3 deletions exonum-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ libsodium
libssl
listunspent
locktime
Mainnet
mainnet
Mainnet
maintainer's
maplit
markdownlint
Expand Down Expand Up @@ -141,14 +141,15 @@ proptest
proto
protobuf
protoc
PROTOS
pubkey
pubkeyhash
pubkeys
PUSHBYTES
readonly
reddit
Regtest
regtest
Regtest
reimplemented
repr
reqwest
Expand Down Expand Up @@ -244,4 +245,4 @@ whitelisted
writeln
wtxid
Xqsmt
Zsmmr
Zsmmr
3 changes: 1 addition & 2 deletions src/blockchain/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ pub enum SignatureError {
/// Received signature is for the incorrect anchoring transaction.
#[fail(
display = "Received signature is for the incorrect anchoring transaction. Expected: {}. Received: {}.",
expected_id,
received_id
expected_id, received_id
)]
Unexpected {
/// Expected identifier of the anchoring transaction.
Expand Down
6 changes: 4 additions & 2 deletions src/blockchain/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ impl Transaction for TxSignature {
return Err(SignatureError::Unexpected {
expected_id: expected_transaction.id(),
received_id: tx.id(),
}.into());
}
.into());
}

let redeem_script = schema.actual_state().actual_configuration().redeem_script();
Expand All @@ -96,7 +97,8 @@ impl Transaction for TxSignature {
} else {
return Err(SignatureError::MissingPublicKey {
validator_id: self.validator,
}.into());
}
.into());
};

let input_signer = InputSigner::new(redeem_script.clone());
Expand Down
10 changes: 5 additions & 5 deletions src/btc/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ macro_rules! impl_wrapper_for_bitcoin_consensus_encoding {
}
}

impl ::exonum::encoding::serialize::FromHex for $name {
impl ::hex::FromHex for $name {
type Error = ::failure::Error;

fn from_hex<T: AsRef<[u8]>>(hex: T) -> Result<Self, Self::Error> {
let bytes = ::exonum::encoding::serialize::decode_hex(hex)?;
let bytes = ::hex::decode(hex)?;
let inner = ::bitcoin::consensus::deserialize(bytes.as_ref())?;
Ok($name(inner))
}
}

impl ::exonum::encoding::serialize::ToHex for $name {
impl ::hex::ToHex for $name {
fn write_hex<W: ::std::fmt::Write>(&self, w: &mut W) -> ::std::fmt::Result {
let bytes = ::bitcoin::consensus::serialize(&self.0);
bytes.write_hex(w)
Expand All @@ -71,7 +71,7 @@ macro_rules! impl_string_conversions_for_hex {
($name:ident) => {
impl ::std::fmt::LowerHex for $name {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
use exonum::encoding::serialize::ToHex;
use hex::ToHex;
let mut buf = String::new();
self.write_hex(&mut buf).unwrap();
write!(f, "{}", buf)
Expand All @@ -88,7 +88,7 @@ macro_rules! impl_string_conversions_for_hex {
type Err = ::failure::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
use exonum::encoding::serialize::FromHex;
use hex::FromHex;
Self::from_hex(s).map_err(From::from)
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/btc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use bitcoin::network::constants::Network;
use bitcoin::util::address;
use bitcoin::util::privkey;
use btc_transaction_utils;
use hex::{self, FromHex, ToHex};

use rand::{self, Rng};
use secp256k1;
Expand Down Expand Up @@ -68,18 +69,18 @@ impl ::std::fmt::Debug for Privkey {
}
}

impl ::exonum::encoding::serialize::FromHex for PublicKey {
impl FromHex for PublicKey {
type Error = ::failure::Error;

fn from_hex<T: AsRef<[u8]>>(hex: T) -> Result<Self, Self::Error> {
let bytes = ::exonum::encoding::serialize::decode_hex(hex)?;
let bytes = hex::decode(hex)?;
let context = secp256k1::Secp256k1::without_caps();
let inner = secp256k1::PublicKey::from_slice(&context, &bytes)?;
Ok(PublicKey(inner))
}
}

impl ::exonum::encoding::serialize::ToHex for PublicKey {
impl ToHex for PublicKey {
fn write_hex<W: ::std::fmt::Write>(&self, w: &mut W) -> ::std::fmt::Result {
let bytes = self.0.serialize();
bytes.as_ref().write_hex(w)
Expand Down Expand Up @@ -114,18 +115,18 @@ impl Deref for Address {
}
}

impl ::exonum::encoding::serialize::FromHex for InputSignature {
impl FromHex for InputSignature {
type Error = ::failure::Error;

fn from_hex<T: AsRef<[u8]>>(hex: T) -> Result<Self, Self::Error> {
let bytes = ::exonum::encoding::serialize::decode_hex(hex)?;
let bytes = hex::decode(hex)?;
let context = secp256k1::Secp256k1::without_caps();
let inner = btc_transaction_utils::InputSignature::from_bytes(&context, bytes)?;
Ok(InputSignature(inner))
}
}

impl ::exonum::encoding::serialize::ToHex for InputSignature {
impl ToHex for InputSignature {
fn write_hex<W: ::std::fmt::Write>(&self, w: &mut W) -> ::std::fmt::Result {
self.0.as_ref().write_hex(w)
}
Expand Down
14 changes: 6 additions & 8 deletions src/btc/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ pub struct PayloadV1Builder {

pub type PayloadBuilder = PayloadV1Builder;

#[cfg_attr(
feature = "cargo-clippy",
allow(clippy::len_without_is_empty)
)]
#[cfg_attr(feature = "cargo-clippy", allow(clippy::len_without_is_empty))]
impl PayloadV1 {
fn read(bytes: &[u8]) -> Option<Self> {
let kind = bytes[0];
Expand Down Expand Up @@ -193,7 +190,8 @@ impl Payload {
} else {
None
}
}).and_then(|instr| {
})
.and_then(|instr| {
if let Instruction::PushBytes(bytes) = instr {
if bytes.len() < PAYLOAD_HEADER_LEN {
return None;
Expand Down Expand Up @@ -234,10 +232,10 @@ impl From<PayloadV1> for Payload {
#[cfg(test)]
mod tests {
use exonum::crypto::{hash, Hash};
use exonum::encoding::serialize::{decode_hex, encode_hex};
use exonum::helpers::Height;

use bitcoin::blockdata::script::Script;
use hex;

use super::{Payload, PayloadBuilder};

Expand All @@ -248,13 +246,13 @@ mod tests {

impl HexValue for Script {
fn from_hex(hex: impl AsRef<[u8]>) -> Self {
let bytes = decode_hex(hex).unwrap();
let bytes = hex::decode(hex).unwrap();
Script::from(bytes)
}

fn to_hex(&self) -> String {
let bytes = self[..].to_vec();
encode_hex(bytes)
hex::encode(bytes)
}
}

Expand Down
Loading

0 comments on commit f59f3fa

Please sign in to comment.