Skip to content

Commit 28ad362

Browse files
Seulgi Kimsgkim126
authored andcommitted
Upgrade primitives
1 parent 05f183f commit 28ad362

File tree

20 files changed

+222
-137
lines changed

20 files changed

+222
-137
lines changed

Cargo.lock

Lines changed: 158 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ env_logger = "0.5.3"
4141
never-type = "0.1.0"
4242
panic_hook = { path = "util/panic_hook" }
4343
parking_lot = "0.11.0"
44-
primitives = { git = "https://github.com/CodeChain-io/rust-codechain-primitives.git", version = "0.4" }
44+
primitives = { git = "https://github.com/CodeChain-io/rust-codechain-primitives.git", version = "0.5", tag = "v0.5.1" }
4545
rpassword = "2.0.0"
4646
rustc-serialize = "0.3"
4747
serde = "1.0"

basic_module/account/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ authors = ["CodeChain Team <hi@codechain.io>"]
55
edition = "2018"
66

77
[dependencies]
8-
ccrypto = { package = "codechain-crypto", git = "https://github.com/CodeChain-io/rust-codechain-crypto.git", version = "0.2" }
8+
ccrypto = { package = "codechain-crypto", git = "https://github.com/CodeChain-io/rust-codechain-crypto.git", version = "0.3", tag = "v0.3.0" }
99
ckey = {package = "codechain-key", path = "../../key" }
1010
coordinator = {package = "coordinator", path = "../../coordinator" }
1111
lazy_static = "1.2"
1212
parking_lot = "0.11.0"
13-
primitives = { git = "https://github.com/CodeChain-io/rust-codechain-primitives.git", version = "0.4" }
13+
primitives = { git = "https://github.com/CodeChain-io/rust-codechain-primitives.git", version = "0.5", tag = "v0.5.1" }
1414
serde = "1.0"
1515
serde_cbor = "0.11.1"
1616
serde_derive = "1.0"

basic_module/staking/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ authors = ["CodeChain Team <hi@codechain.io>"]
55
edition = "2018"
66

77
[dependencies]
8-
ccrypto = { package ="codechain-crypto", git = "https://github.com/CodeChain-io/rust-codechain-crypto.git", version = "0.2" }
8+
ccrypto = { package ="codechain-crypto", git = "https://github.com/CodeChain-io/rust-codechain-crypto.git", version = "0.3", tag = "v0.3.0" }
99
coordinator = { path = "../../coordinator" }
1010
fkey = { path = "../../key", package = "codechain-key" }
1111
ftypes = { path = "../../types", package = "codechain-types" }
1212
lazy_static = "1.4"
1313
parking_lot = "0.11.0"
14-
primitives = { git = "https://github.com/CodeChain-io/rust-codechain-primitives.git", version = "0.4" }
14+
primitives = { git = "https://github.com/CodeChain-io/rust-codechain-primitives.git", version = "0.5", tag = "v0.5.1" }
1515
serde = { version = "1.0", features = ["derive"] }
1616
serde_cbor = "0.11.1"
1717
serde_derive = "1.0.105"

coordinator/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ authors = ["CodeChain Team <hi@codechain.io>"]
55
edition = "2018"
66

77
[dependencies]
8-
ccrypto = { package = "codechain-crypto", git = "https://github.com/CodeChain-io/rust-codechain-crypto.git", version = "0.2" }
8+
ccrypto = { package = "codechain-crypto", git = "https://github.com/CodeChain-io/rust-codechain-crypto.git", version = "0.3", tag = "v0.3.0" }
99
ckey = {package = "codechain-key", path = "../key" }
1010
ctypes = { package = "codechain-types", path = "../types" }
11-
primitives = { git = "https://github.com/CodeChain-io/rust-codechain-primitives.git", version = "0.4" }
12-
rlp = { git = "https://github.com/CodeChain-io/rlp.git", version = "0.4" }
11+
primitives = { git = "https://github.com/CodeChain-io/rust-codechain-primitives.git", version = "0.5", tag = "v0.5.1" }
12+
rlp = { git = "https://github.com/CodeChain-io/rlp.git", version = "0.5", tag = "v0.5.0" }

core/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ authors = ["CodeChain Team <hi@codechain.io>"]
55
edition = "2018"
66

77
[dependencies]
8-
ccrypto = { package = "codechain-crypto", git = "https://github.com/CodeChain-io/rust-codechain-crypto.git", version = "0.2" }
9-
cdb = { package = "codechain-db", git = "https://github.com/CodeChain-io/rust-codechain-db.git", version = "0.2" }
8+
ccrypto = { package = "codechain-crypto", git = "https://github.com/CodeChain-io/rust-codechain-crypto.git", version = "0.3", tag = "v0.3.0" }
9+
cdb = { package = "codechain-db", git = "https://github.com/CodeChain-io/rust-codechain-db.git", version = "0.2", tag = "v0.2.0" }
1010
cio = { package = "codechain-io", path = "../util/io" }
1111
cjson = { package = "codechain-json", path = "../json" }
1212
ckey = { package = "codechain-key", path = "../key" }
@@ -28,11 +28,11 @@ lru-cache = "0.1.2"
2828
merkle-trie = { git = "https://github.com/CodeChain-io/rust-merkle-trie.git", version = "0.4" }
2929
num-rational = "0.2.1"
3030
parking_lot = "0.11.0"
31-
primitives = { git = "https://github.com/CodeChain-io/rust-codechain-primitives.git", version = "0.4" }
31+
primitives = { git = "https://github.com/CodeChain-io/rust-codechain-primitives.git", version = "0.5", tag = "v0.5.1" }
3232
rand = "0.6.1"
33-
rlp = { git = "https://github.com/CodeChain-io/rlp.git", version = "0.4" }
34-
rlp_compress = { git = "https://github.com/CodeChain-io/rlp.git", version = "0.2" }
35-
rlp_derive = { git = "https://github.com/CodeChain-io/rlp.git", version = "0.2" }
33+
rlp = { git = "https://github.com/CodeChain-io/rlp.git", version = "0.5", tag = "v0.5.0" }
34+
rlp_compress = { git = "https://github.com/CodeChain-io/rlp.git", version = "0.5", tag = "v0.5.0" }
35+
rlp_derive = { git = "https://github.com/CodeChain-io/rlp.git", version = "0.5", tag = "v0.5.0" }
3636
snap = "0.2"
3737
table = { path = "../util/table" }
3838

core/src/client/test_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use ctypes::{BlockHash, BlockId, BlockNumber, CommonParams, Header as BlockHeade
5858
use kvdb::KeyValueDB;
5959
use merkle_trie::skewed_merkle_root;
6060
use parking_lot::RwLock;
61-
use primitives::{Bytes, H256};
61+
use primitives::{u256_from_u128, BigEndianHash, Bytes, H256};
6262
use rlp::{Encodable, Rlp, RlpStream};
6363
use std::collections::HashMap;
6464
use std::mem;
@@ -242,7 +242,7 @@ impl TestBlockChainClient {
242242
let block_id = n.into();
243243
let hash = self.block_hash(&block_id).unwrap();
244244
let mut header: BlockHeader = self.block_header(&block_id).unwrap().decode();
245-
header.set_parent_hash(H256::from(42).into());
245+
header.set_parent_hash(H256::from_uint(&u256_from_u128(42u128)).into());
246246
let mut rlp = RlpStream::new_list(3);
247247
rlp.append(&header);
248248
rlp.append_raw(&::rlp::NULL_RLP, 1);

core/src/consensus/tendermint/vote_regression_checker.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ mod tests {
4141

4242
use crate::consensus::VoteStep;
4343

44-
use primitives::H256;
44+
use primitives::{u256_from_u128, BigEndianHash, H256};
4545

4646
#[test]
4747
fn test_initial_set() {
@@ -74,12 +74,12 @@ mod tests {
7474

7575
checker.check(&VoteOn {
7676
step: VoteStep::new(100, 10, Step::Prevote),
77-
block_hash: Some(H256::from(1).into()),
77+
block_hash: Some(H256::from_uint(&u256_from_u128(1u128)).into()),
7878
});
7979

8080
assert!(checker.check(&VoteOn {
8181
step: VoteStep::new(101, 10, Step::Prevote),
82-
block_hash: Some(H256::from(2).into())
82+
block_hash: Some(H256::from_uint(&u256_from_u128(2u128)).into()),
8383
}))
8484
}
8585

@@ -89,12 +89,12 @@ mod tests {
8989

9090
checker.check(&VoteOn {
9191
step: VoteStep::new(100, 10, Step::Prevote),
92-
block_hash: Some(H256::from(1).into()),
92+
block_hash: Some(H256::from_uint(&u256_from_u128(1u128)).into()),
9393
});
9494

9595
assert!(!checker.check(&VoteOn {
9696
step: VoteStep::new(99, 10, Step::Prevote),
97-
block_hash: Some(H256::from(2).into())
97+
block_hash: Some(H256::from_uint(&u256_from_u128(2u128)).into()),
9898
}))
9999
}
100100

@@ -104,12 +104,12 @@ mod tests {
104104

105105
checker.check(&VoteOn {
106106
step: VoteStep::new(100, 10, Step::Prevote),
107-
block_hash: Some(H256::from(1).into()),
107+
block_hash: Some(H256::from_uint(&u256_from_u128(1u128)).into()),
108108
});
109109

110110
assert!(checker.check(&VoteOn {
111111
step: VoteStep::new(100, 11, Step::Prevote),
112-
block_hash: Some(H256::from(2).into())
112+
block_hash: Some(H256::from_uint(&u256_from_u128(2u128)).into()),
113113
}))
114114
}
115115

@@ -119,12 +119,12 @@ mod tests {
119119

120120
checker.check(&VoteOn {
121121
step: VoteStep::new(100, 10, Step::Prevote),
122-
block_hash: Some(H256::from(1).into()),
122+
block_hash: Some(H256::from_uint(&u256_from_u128(1u128)).into()),
123123
});
124124

125125
assert!(!checker.check(&VoteOn {
126126
step: VoteStep::new(100, 9, Step::Prevote),
127-
block_hash: Some(H256::from(2).into())
127+
block_hash: Some(H256::from_uint(&u256_from_u128(2u128)).into()),
128128
}))
129129
}
130130

@@ -134,12 +134,12 @@ mod tests {
134134

135135
checker.check(&VoteOn {
136136
step: VoteStep::new(100, 10, Step::Prevote),
137-
block_hash: Some(H256::from(1).into()),
137+
block_hash: Some(H256::from_uint(&u256_from_u128(1u128)).into()),
138138
});
139139

140140
assert!(checker.check(&VoteOn {
141141
step: VoteStep::new(100, 10, Step::Precommit),
142-
block_hash: Some(H256::from(2).into())
142+
block_hash: Some(H256::from_uint(&u256_from_u128(2u128)).into())
143143
}))
144144
}
145145

@@ -149,12 +149,12 @@ mod tests {
149149

150150
checker.check(&VoteOn {
151151
step: VoteStep::new(100, 10, Step::Prevote),
152-
block_hash: Some(H256::from(1).into()),
152+
block_hash: Some(H256::from_uint(&u256_from_u128(1u128)).into()),
153153
});
154154

155155
assert!(!checker.check(&VoteOn {
156156
step: VoteStep::new(100, 10, Step::Propose),
157-
block_hash: Some(H256::from(2).into())
157+
block_hash: Some(H256::from_uint(&u256_from_u128(2u128)).into())
158158
}))
159159
}
160160

@@ -180,12 +180,12 @@ mod tests {
180180

181181
checker.check(&VoteOn {
182182
step: VoteStep::new(100, 10, Step::Prevote),
183-
block_hash: Some(H256::from(1).into()),
183+
block_hash: Some(H256::from_uint(&u256_from_u128(1u128)).into()),
184184
});
185185

186186
assert!(!checker.check(&VoteOn {
187187
step: VoteStep::new(100, 10, Step::Prevote),
188-
block_hash: Some(H256::from(2).into())
188+
block_hash: Some(H256::from_uint(&u256_from_u128(2u128)).into())
189189
}))
190190
}
191191
}

discovery/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ authors = ["CodeChain Team <hi@codechain.io>"]
55
edition = "2018"
66

77
[dependencies]
8-
ccrypto = { package = "codechain-crypto", git = "https://github.com/CodeChain-io/rust-codechain-crypto.git", version = "0.2" }
8+
ccrypto = { package = "codechain-crypto", git = "https://github.com/CodeChain-io/rust-codechain-crypto.git", version = "0.3", tag = "v0.3.0" }
99
codechain-logger = { path = "../util/logger" }
1010
cnetwork = { package = "codechain-network", path = "../network" }
1111
ctimer = { package = "codechain-timer", path = "../util/timer" }
1212
log = "0.4.6"
1313
never-type = "0.1.0"
1414
parking_lot = "0.11.0"
15-
primitives = { git = "https://github.com/CodeChain-io/rust-codechain-primitives.git", version = "0.4" }
15+
primitives = { git = "https://github.com/CodeChain-io/rust-codechain-primitives.git", version = "0.5", tag = "v0.5.1" }
1616
rand = "0.6.1"
17-
rlp = { git = "https://github.com/CodeChain-io/rlp.git", version = "0.4" }
17+
rlp = { git = "https://github.com/CodeChain-io/rlp.git", version = "0.5", tag = "v0.5.0" }
1818
time = "0.1"
1919

2020
[dev-dependencies]

discovery/src/node_id.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub fn address_to_hash(addr: &SocketAddr) -> H128 {
5454
}
5555
let octets: [u8; 16] = ip.to_ipv6_compatible().octets();
5656
let mut hash = H128::blake(&octets);
57-
let hash_len = hash.len();
57+
let hash_len = H128::len_bytes();
5858
hash.as_mut()[hash_len - 2] ^= (port >> 8) as u8;
5959
hash.as_mut()[hash_len - 1] ^= (port & 0xFF) as u8;
6060
hash
@@ -70,8 +70,7 @@ fn log2_distance(addr: &SocketAddr, datum: &H128) -> usize {
7070
const B: usize = 16 * 8;
7171
const BYTES_SIZE: usize = B / 8;
7272
debug_assert_eq!(B % 8, 0);
73-
let mut distance_as_bytes: [u8; BYTES_SIZE] = [0; BYTES_SIZE];
74-
distance.copy_to(&mut distance_as_bytes);
73+
let distance_as_bytes: [u8; BYTES_SIZE] = distance.to_fixed_bytes();
7574

7675
let mut same_prefix_length: usize = 0;
7776
const MASKS: [u8; 8] =

0 commit comments

Comments
 (0)