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

chore: bump rust toolchain to 1.34.0 #451

Merged
merged 1 commit into from Apr 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -16,10 +16,10 @@ env:

matrix:
include:
- rust: 1.33.0
- rust: 1.34.0
os: osx
env: FMT=true CHECK=true TEST=true REL_PKG=darwin_amd64.zip
- rust: 1.33.0
- rust: 1.34.0
os: linux
env: TEST=true REL_PKG=linux_amd64.tar.gz

Expand Down
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion chain/src/tests/util.rs
Expand Up @@ -67,7 +67,7 @@ pub(crate) fn gen_block(
.proposal_transactions(
proposal_transactions
.iter()
.map(|tx| tx.proposal_short_id())
.map(Transaction::proposal_short_id)
.collect(),
)
.with_header_builder(header_builder)
Expand Down
6 changes: 3 additions & 3 deletions core/src/block.rs
Expand Up @@ -72,7 +72,7 @@ impl Block {
self.commit_transactions()
.iter()
.skip(1)
.map(|tx| tx.witness_hash()),
.map(Transaction::witness_hash),
);
merkle_root(&witnesses[..])
}
Expand All @@ -82,7 +82,7 @@ impl Block {
&self
.commit_transactions
.iter()
.map(|t| t.hash())
.map(Transaction::hash)
.collect::<Vec<_>>(),
)
}
Expand All @@ -92,7 +92,7 @@ impl Block {
&self
.proposal_transactions
.iter()
.map(|t| t.hash())
.map(ProposalShortId::hash)
.collect::<Vec<_>>(),
)
}
Expand Down
6 changes: 3 additions & 3 deletions core/src/cell.rs
Expand Up @@ -180,15 +180,15 @@ impl ResolvedTransaction {
}

pub fn is_double_spend(&self) -> bool {
self.cells_iter().any(|state| state.is_dead())
self.cells_iter().any(CellStatus::is_dead)
}

pub fn is_orphan(&self) -> bool {
self.cells_iter().any(|state| state.is_unknown())
self.cells_iter().any(CellStatus::is_unknown)
}

pub fn is_fully_resolved(&self) -> bool {
self.cells_iter().all(|state| state.is_live())
self.cells_iter().all(CellStatus::is_live)
}

pub fn fee(&self) -> Capacity {
Expand Down
11 changes: 11 additions & 0 deletions core/src/uncle.rs
Expand Up @@ -3,6 +3,7 @@ use crate::header::Header;
use crate::transaction::ProposalShortId;
use crate::BlockNumber;
use bincode::serialize;
use ckb_merkle_tree::merkle_root;
use hash::blake2b_256;
use numext_fixed_hash::H256;
use serde_derive::{Deserialize, Serialize};
Expand Down Expand Up @@ -41,6 +42,16 @@ impl UncleBlock {
pub fn proposal_transactions(&self) -> &[ProposalShortId] {
&self.proposal_transactions
}

pub fn cal_txs_proposal_root(&self) -> H256 {
merkle_root(
&self
.proposal_transactions
.iter()
.map(ProposalShortId::hash)
.collect::<Vec<_>>(),
)
}
}

pub fn uncles_hash(uncles: &[UncleBlock]) -> H256 {
Expand Down
12 changes: 6 additions & 6 deletions docker/hub/Dockerfile
Expand Up @@ -3,7 +3,7 @@ FROM ubuntu:bionic as ckb-builder
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=1.33.0
RUST_VERSION=1.34.0

RUN set -eux; \
apt-get update; \
Expand All @@ -19,13 +19,13 @@ RUN set -eux; \

RUN dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='2d4ddf4e53915a23dda722608ed24e5c3f29ea1688da55aa4e98765fc6223f71' ;; \
armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='be85f50dc70ee239c5bb6acb60080797841a1e7c45fbf6bae15d6bd4b37ce0e5' ;; \
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='454f00a86be75ab070149bac1f541a7b39e5d3383d6da96ad2b929867ed40167' ;; \
i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='179e3b39f11037a708874e750081f7c0d3e1a6a4c431c2ecee2295acc7b696af' ;; \
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='ce09d3de51432b34a8ff73c7aaa1edb64871b2541d2eb474441cedb8bf14c5fa' ;; \
armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='bf140b03a49abb87a601ad29ca326b4e6721be39868c90ad17cd0b76014f1789' ;; \
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='76010a472d90714f781d5a4ce618f0e1f8ce3a8b8476ce35a34b2f6ab67a8026' ;; \
i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='bde10f3e1a267923224792bb26b605b1189733c9d0c806da955e5c5c45b2868c' ;; \
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
esac; \
url="https://static.rust-lang.org/rustup/archive/1.16.0/${rustArch}/rustup-init"; \
url="https://static.rust-lang.org/rustup/archive/1.17.0/${rustArch}/rustup-init"; \
wget "$url"; \
echo "${rustupSha256} *rustup-init" | sha256sum -c -; \
chmod +x rustup-init
Expand Down
4 changes: 2 additions & 2 deletions docs/get-ckb.md
Expand Up @@ -13,13 +13,13 @@ branch.

### Install Build Dependencies

CKB is currently tested mainly with `stable-1.33.0` on Linux and macOS.
CKB is currently tested mainly with `stable-1.34.0` on Linux and macOS.

We recommend installing Rust through [rustup](https://www.rustup.rs/)

```bash
# Get rustup from rustup.rs, then in your `ckb` folder:
rustup override set 1.33.0
rustup override set 1.34.0
```

Report new breakage is welcome.
Expand Down
12 changes: 6 additions & 6 deletions miner/src/block_assembler.rs
Expand Up @@ -20,7 +20,7 @@ use lru_cache::LruCache;
use numext_fixed_hash::H256;
use numext_fixed_uint::U256;
use std::cmp;
use std::sync::{atomic::AtomicUsize, atomic::Ordering, Arc};
use std::sync::{atomic::AtomicU64, atomic::AtomicUsize, atomic::Ordering, Arc};
use std::thread;
use stop_handler::{SignalSender, StopHandler};

Expand Down Expand Up @@ -89,7 +89,7 @@ pub struct BlockAssembler<CI> {
candidate_uncles: LruCache<H256, Arc<Block>>,
config: BlockAssemblerConfig,
work_id: AtomicUsize,
last_uncles_updated_at: AtomicUsize,
last_uncles_updated_at: AtomicU64,
template_caches: Mutex<LruCache<(Cycle, u64, Version), TemplateCache>>,
}

Expand All @@ -100,7 +100,7 @@ impl<CI: ChainIndex + 'static> BlockAssembler<CI> {
config,
candidate_uncles: LruCache::new(MAX_CANDIDATE_UNCLES),
work_id: AtomicUsize::new(0),
last_uncles_updated_at: AtomicUsize::new(0),
last_uncles_updated_at: AtomicU64::new(0),
template_caches: Mutex::new(LruCache::new(TEMPLATE_CACHE_SIZE)),
}
}
Expand Down Expand Up @@ -137,7 +137,7 @@ impl<CI: ChainIndex + 'static> BlockAssembler<CI> {
let hash = uncle_block.header().hash().clone();
self.candidate_uncles.insert(hash, uncle_block);
self.last_uncles_updated_at
.store(unix_time_as_millis() as usize, Ordering::SeqCst);
.store(unix_time_as_millis(), Ordering::SeqCst);
}
_ => {
error!(target: "miner", "new_uncle_receiver closed");
Expand Down Expand Up @@ -229,7 +229,7 @@ impl<CI: ChainIndex + 'static> BlockAssembler<CI> {
self.transform_params(cycles_limit, bytes_limit, max_version);
let uncles_count_limit = self.shared.consensus().max_uncles_num() as u32;

let last_uncles_updated_at = self.last_uncles_updated_at.load(Ordering::SeqCst) as u64;
let last_uncles_updated_at = self.last_uncles_updated_at.load(Ordering::SeqCst);
let chain_state = self.shared.chain_state().lock();
let last_txs_updated_at = chain_state.get_last_txs_updated_at();

Expand Down Expand Up @@ -435,11 +435,11 @@ mod tests {
use ckb_shared::shared::SharedBuilder;
use ckb_shared::store::ChainKVStore;
use ckb_traits::ChainProvider;
use ckb_util::TryInto;
use ckb_verification::{BlockVerifier, HeaderResolverWrapper, HeaderVerifier, Verifier};
use jsonrpc_types::{BlockTemplate, CellbaseTemplate};
use numext_fixed_hash::H256;
use numext_fixed_uint::U256;
use std::convert::TryInto;
use std::sync::Arc;

fn start_chain(
Expand Down
2 changes: 1 addition & 1 deletion miner/src/miner.rs
Expand Up @@ -4,12 +4,12 @@ use ckb_core::block::{Block, BlockBuilder};
use ckb_core::header::{HeaderBuilder, RawHeader, Seal};
use ckb_core::BlockNumber;
use ckb_pow::PowEngine;
use ckb_util::TryInto;
use crossbeam_channel::Receiver;
use failure::Error;
use jsonrpc_types::{BlockTemplate, CellbaseTemplate};
use log::{debug, error, info};
use rand::{thread_rng, Rng};
use std::convert::TryInto;
use std::sync::Arc;

pub struct Miner {
Expand Down
2 changes: 1 addition & 1 deletion network/src/lib.rs
Expand Up @@ -24,7 +24,7 @@ pub use crate::{
pub use p2p::{
context::{ProtocolContext, ProtocolContextMutRef, ServiceContext, SessionContext},
multiaddr,
secio::PeerId,
secio::{PeerId, PublicKey},
service::{ServiceControl, SessionType},
ProtocolId, SessionId,
};
Expand Down
8 changes: 4 additions & 4 deletions network/src/network.rs
Expand Up @@ -11,7 +11,7 @@ use crate::protocols::{feeler::Feeler, DefaultCKBProtocolContext};
use crate::Peer;
use crate::{
Behaviour, CKBProtocol, CKBProtocolContext, NetworkConfig, PeerIndex, ProtocolId,
ProtocolVersion, ServiceContext, ServiceControl, SessionId, SessionType,
ProtocolVersion, PublicKey, ServiceContext, ServiceControl, SessionId, SessionType,
};
use ckb_util::RwLock;
use fnv::{FnvHashMap, FnvHashSet};
Expand Down Expand Up @@ -390,7 +390,7 @@ impl ServiceHandle for EventHandler {
let peer_id = session_context
.remote_pubkey
.as_ref()
.map(|pubkey| pubkey.peer_id())
.map(PublicKey::peer_id)
.expect("Secio must enabled");

let peer_store = self.network_state.peer_store();
Expand All @@ -413,7 +413,7 @@ impl ServiceHandle for EventHandler {
let peer_id = session_context
.remote_pubkey
.as_ref()
.map(|pubkey| pubkey.peer_id())
.map(PublicKey::peer_id)
.expect("Secio must enabled");
if let Ok(parsed_version) = version.parse::<ProtocolVersion>() {
match self.network_state.accept_connection(
Expand Down Expand Up @@ -505,7 +505,7 @@ impl NetworkService {
// == Build p2p service struct
let mut protocol_metas = protocols
.into_iter()
.map(|protocol| protocol.build())
.map(CKBProtocol::build)
.collect::<Vec<_>>();
protocol_metas.push(feeler_protocol.build());
protocol_metas.push(ping_meta);
Expand Down
15 changes: 6 additions & 9 deletions network/src/protocols/mod.rs
Expand Up @@ -8,7 +8,8 @@ use crate::{
errors::{Error, PeerError},
peer_store::{Behaviour, Status},
peers_registry::RegisterResult,
NetworkState, PeerIndex, ProtocolContext, ProtocolContextMutRef, ServiceControl, SessionInfo,
NetworkState, PeerIndex, ProtocolContext, ProtocolContextMutRef, PublicKey, ServiceControl,
SessionInfo,
};
use bytes::Bytes;
use log::{debug, error, info, trace, warn};
Expand Down Expand Up @@ -75,7 +76,7 @@ impl CKBProtocol {
let supported_versions = self
.supported_versions
.iter()
.map(|v| v.to_string())
.map(ToString::to_string)
.collect::<Vec<_>>();
MetaBuilder::default()
.id(self.id)
Expand Down Expand Up @@ -147,7 +148,7 @@ impl ServiceProtocol for CKBHandler {
session
.remote_pubkey
.as_ref()
.map(|pubkey| pubkey.peer_id())
.map(PublicKey::peer_id)
.expect("remote_pubkey existence checked"),
parsed_version.expect("parsed_version existence checked"),
)
Expand Down Expand Up @@ -201,11 +202,7 @@ impl ServiceProtocol for CKBHandler {

fn disconnected(&mut self, mut context: ProtocolContextMutRef) {
let session = context.session;
if let Some(peer_id) = session
.remote_pubkey
.as_ref()
.map(|pubkey| pubkey.peer_id())
{
if let Some(peer_id) = session.remote_pubkey.as_ref().map(PublicKey::peer_id) {
debug!(
target: "network",
"ckb protocol disconnect, addr: {}, protocol: {}, peer_id: {:?}",
Expand Down Expand Up @@ -235,7 +232,7 @@ impl ServiceProtocol for CKBHandler {
if let Some((peer_id, _peer_index)) = session
.remote_pubkey
.as_ref()
.map(|pubkey| pubkey.peer_id())
.map(PublicKey::peer_id)
.and_then(|peer_id| {
self.network_state
.get_peer_index(&peer_id)
Expand Down
4 changes: 2 additions & 2 deletions protocol/src/builder.rs
Expand Up @@ -412,7 +412,7 @@ impl<'a> FilteredBlock<'a> {
&block
.commit_transactions()
.iter()
.map(|tx| tx.hash())
.map(Transaction::hash)
.collect::<Vec<_>>(),
transactions_index,
);
Expand Down Expand Up @@ -637,8 +637,8 @@ mod tests {
use ckb_core::block::BlockBuilder;
use ckb_core::header::HeaderBuilder;
use ckb_core::transaction::TransactionBuilder;
use ckb_util::TryInto;
use flatbuffers::get_root;
use std::convert::TryInto;

#[test]
fn build_and_convert_header() {
Expand Down
2 changes: 1 addition & 1 deletion protocol/src/convert.rs
Expand Up @@ -2,10 +2,10 @@ use crate::cast;
use crate::protocol_generated::ckb::protocol as ckb_protocol;
use crate::FlatbuffersVectorIterator;
use ckb_core;
use ckb_util::{TryFrom, TryInto};
use failure::Error as FailureError;
use numext_fixed_hash::H256;
use numext_fixed_uint::U256;
use std::convert::{TryFrom, TryInto};

impl From<&H256> for ckb_protocol::H256 {
fn from(h256: &H256) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/module/chain.rs
Expand Up @@ -2,11 +2,11 @@ use ckb_core::cell::CellProvider;
use ckb_core::BlockNumber;
use ckb_shared::{index::ChainIndex, shared::Shared};
use ckb_traits::ChainProvider;
use ckb_util::TryInto;
use jsonrpc_core::{Error, Result};
use jsonrpc_derive::rpc;
use jsonrpc_types::{Block, CellOutputWithOutPoint, CellWithStatus, Header, OutPoint, Transaction};
use numext_fixed_hash::H256;
use std::convert::TryInto;

#[rpc]
pub trait ChainRpc {
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/module/miner.rs
Expand Up @@ -7,7 +7,6 @@ use ckb_protocol::RelayMessage;
use ckb_shared::{index::ChainIndex, shared::Shared};
use ckb_sync::NetworkProtocol;
use ckb_traits::ChainProvider;
use ckb_util::TryInto;
use ckb_verification::{HeaderResolverWrapper, HeaderVerifier, Verifier};
use flatbuffers::FlatBufferBuilder;
use jsonrpc_core::{Error, Result};
Expand All @@ -16,6 +15,7 @@ use jsonrpc_types::{Block, BlockTemplate};
use log::{debug, warn};
use numext_fixed_hash::H256;
use std::collections::HashSet;
use std::convert::TryInto;
use std::sync::Arc;

#[rpc]
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/module/pool.rs
Expand Up @@ -7,14 +7,14 @@ use ckb_shared::shared::Shared;
use ckb_shared::tx_pool::types::PoolEntry;
use ckb_sync::NetworkProtocol;
use ckb_traits::chain_provider::ChainProvider;
use ckb_util::TryInto;
use ckb_verification::TransactionError;
use flatbuffers::FlatBufferBuilder;
use jsonrpc_core::{Error, Result};
use jsonrpc_derive::rpc;
use jsonrpc_types::Transaction;
use log::{debug, warn};
use numext_fixed_hash::H256;
use std::convert::TryInto;

#[rpc]
pub trait PoolRpc {
Expand Down