libp2p-core 0.31.0 (from crates.io) (#37)

This commit is contained in:
folex 2022-01-28 16:15:20 +03:00 committed by GitHub
parent c2f63cb41e
commit b76954782b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 240 additions and 109 deletions

View File

@ -16,19 +16,19 @@ jobs:
sudo bash .github/download_marine.sh
- restore_cache:
keys:
- trust-graph00-{{ checksum "./service/Cargo.lock" }}-{{ checksum "./Cargo.lock" }}-{{ checksum "./keypair/Cargo.lock" }}
- trust-graph00-{{ checksum "./Cargo.lock" }}
- run: |
rustup target add wasm32-wasi
cargo test --no-fail-fast --release --all-features --
cd ./service
./build.sh
mkdir data
mkdir -p data
cargo test --no-fail-fast --release --all-features -- --test-threads=1
- save_cache:
paths:
- ~/.cargo
- ~/.rustup
key: trust-graph00-{{ checksum "./Cargo.lock" }-{{ checksum "./service/Cargo.lock" }}}-{{ checksum "./keypair/Cargo.lock" }}
key: trust-graph00-{{ checksum "./Cargo.lock" }}
workflows:

313
Cargo.lock generated
View File

@ -64,6 +64,12 @@ dependencies = [
"asn1_der_derive",
]
[[package]]
name = "asn1_der"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e22d1f4b888c298a027c99dc9048015fac177587de20fc30232a057dfbe24a21"
[[package]]
name = "asn1_der_derive"
version = "0.1.2"
@ -95,6 +101,12 @@ dependencies = [
"rustc-demangle",
]
[[package]]
name = "base64"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]]
name = "bincode"
version = "1.3.3"
@ -146,6 +158,15 @@ dependencies = [
"generic-array 0.14.4",
]
[[package]]
name = "block-buffer"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1d36a02058e76b040de25a4464ba1c80935655595b661505c8b39b664828b95"
dependencies = [
"generic-array 0.14.4",
]
[[package]]
name = "block-padding"
version = "0.1.5"
@ -379,6 +400,15 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]]
name = "crypto-common"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "683d6b536309245c849479fba3da410962a43ed8e51c26b729208ec0ac2798d0"
dependencies = [
"generic-array 0.14.4",
]
[[package]]
name = "crypto-mac"
version = "0.7.0"
@ -527,6 +557,17 @@ dependencies = [
"generic-array 0.14.4",
]
[[package]]
name = "digest"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b697d66081d42af4fba142d56918a3cb21dc8eb63372c6b85d14f44fb9c5979b"
dependencies = [
"block-buffer 0.10.0",
"crypto-common",
"generic-array 0.14.4",
]
[[package]]
name = "ed25519"
version = "1.3.0"
@ -650,9 +691,9 @@ checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
[[package]]
name = "fixedbitset"
version = "0.2.0"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
checksum = "279fb028e20b3c4c320317955b77c5e0c9701f05a1d309905d6fc702cdc5053e"
[[package]]
name = "fluence-app-service"
@ -696,73 +737,6 @@ dependencies = [
"wasmer-wasi-fl",
]
[[package]]
name = "fluence-fork-libp2p-core"
version = "0.27.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77ffef53cfb8b873bf75998669b0aedd5212907d29d8be8e7915c4695967c40d"
dependencies = [
"asn1_der",
"bs58 0.4.0",
"ed25519-dalek",
"either",
"fluence-fork-multistream-select",
"fluence-fork-parity-multiaddr",
"fnv",
"futures",
"futures-timer",
"lazy_static",
"libsecp256k1",
"log",
"multihash",
"parking_lot 0.11.2",
"pin-project 1.0.8",
"prost",
"prost-build",
"rand 0.7.3",
"ring",
"rw-stream-sink",
"serde",
"sha2 0.9.8",
"smallvec",
"thiserror",
"unsigned-varint 0.7.1",
"void",
"zeroize",
]
[[package]]
name = "fluence-fork-multistream-select"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34dacd25fddb6fed5c3fa6109fb29e4eea49b731a2548e09f4e54620fa4d6310"
dependencies = [
"bytes",
"futures",
"log",
"pin-project 1.0.8",
"smallvec",
"unsigned-varint 0.7.1",
]
[[package]]
name = "fluence-fork-parity-multiaddr"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06228daafbf129ef49806f15779857012c01d49658930d086498e78f12191da7"
dependencies = [
"arrayref",
"bs58 0.4.0",
"byteorder",
"data-encoding",
"multihash",
"percent-encoding",
"serde",
"static_assertions",
"unsigned-varint 0.7.1",
"url",
]
[[package]]
name = "fluence-it-types"
version = "0.3.1"
@ -780,14 +754,14 @@ dependencies = [
name = "fluence-keypair"
version = "0.5.1"
dependencies = [
"asn1_der",
"asn1_der 0.6.3",
"bs58 0.3.1",
"ed25519",
"ed25519-dalek",
"eyre",
"fluence-fork-libp2p-core",
"lazy_static",
"libsecp256k1",
"libp2p-core",
"libsecp256k1 0.3.5",
"quickcheck",
"rand 0.7.3",
"ring",
@ -1043,6 +1017,16 @@ dependencies = [
"digest 0.8.1",
]
[[package]]
name = "hmac"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840"
dependencies = [
"crypto-mac 0.8.0",
"digest 0.9.0",
]
[[package]]
name = "hmac-drbg"
version = "0.2.0"
@ -1051,7 +1035,18 @@ checksum = "c6e570451493f10f6581b48cdd530413b63ea9e780f544bfd3bdcaa0d89d1a7b"
dependencies = [
"digest 0.8.1",
"generic-array 0.12.4",
"hmac",
"hmac 0.7.1",
]
[[package]]
name = "hmac-drbg"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1"
dependencies = [
"digest 0.9.0",
"generic-array 0.14.4",
"hmac 0.8.1",
]
[[package]]
@ -1195,6 +1190,41 @@ version = "0.2.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f98a04dce437184842841303488f70d0188c5f51437d2a834dc097eafa909a01"
[[package]]
name = "libp2p-core"
version = "0.31.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a24250cce58fb6ccb32e26647c1c25b48b6f7bd2d6fb3d6dba72001a6694b385"
dependencies = [
"asn1_der 0.7.5",
"bs58 0.4.0",
"ed25519-dalek",
"either",
"fnv",
"futures",
"futures-timer",
"instant",
"lazy_static",
"libsecp256k1 0.7.0",
"log",
"multiaddr",
"multihash",
"multistream-select",
"parking_lot 0.11.2",
"pin-project 1.0.8",
"prost",
"prost-build",
"rand 0.8.4",
"ring",
"rw-stream-sink",
"sha2 0.10.1",
"smallvec",
"thiserror",
"unsigned-varint",
"void",
"zeroize",
]
[[package]]
name = "libsecp256k1"
version = "0.3.5"
@ -1204,13 +1234,61 @@ dependencies = [
"arrayref",
"crunchy",
"digest 0.8.1",
"hmac-drbg",
"hmac-drbg 0.2.0",
"rand 0.7.3",
"sha2 0.8.2",
"subtle 2.4.1",
"typenum",
]
[[package]]
name = "libsecp256k1"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0452aac8bab02242429380e9b2f94ea20cea2b37e2c1777a1358799bbe97f37"
dependencies = [
"arrayref",
"base64",
"digest 0.9.0",
"hmac-drbg 0.3.0",
"libsecp256k1-core",
"libsecp256k1-gen-ecmult",
"libsecp256k1-gen-genmult",
"rand 0.8.4",
"serde",
"sha2 0.9.8",
"typenum",
]
[[package]]
name = "libsecp256k1-core"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451"
dependencies = [
"crunchy",
"digest 0.9.0",
"subtle 2.4.1",
]
[[package]]
name = "libsecp256k1-gen-ecmult"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809"
dependencies = [
"libsecp256k1-core",
]
[[package]]
name = "libsecp256k1-gen-genmult"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c"
dependencies = [
"libsecp256k1-core",
]
[[package]]
name = "libsqlite3-sys"
version = "0.23.1"
@ -1533,16 +1611,34 @@ dependencies = [
]
[[package]]
name = "multihash"
version = "0.13.2"
name = "multiaddr"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dac63698b887d2d929306ea48b63760431ff8a24fac40ddb22f9c7f49fb7cab"
checksum = "48ee4ea82141951ac6379f964f71b20876d43712bea8faf6dd1a375e08a46499"
dependencies = [
"arrayref",
"bs58 0.4.0",
"byteorder",
"data-encoding",
"multihash",
"percent-encoding",
"serde",
"static_assertions",
"unsigned-varint",
"url",
]
[[package]]
name = "multihash"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "752a61cd890ff691b4411423d23816d5866dd5621e4d1c5687a53b94b5a979d8"
dependencies = [
"digest 0.9.0",
"generic-array 0.14.4",
"multihash-derive",
"sha2 0.9.8",
"unsigned-varint 0.5.1",
"unsigned-varint",
]
[[package]]
@ -1568,6 +1664,20 @@ dependencies = [
"serde",
]
[[package]]
name = "multistream-select"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "363a84be6453a70e63513660f4894ef815daf88e3356bffcda9ca27d810ce83b"
dependencies = [
"bytes",
"futures",
"log",
"pin-project 1.0.8",
"smallvec",
"unsigned-varint",
]
[[package]]
name = "nix"
version = "0.15.0"
@ -1742,9 +1852,9 @@ dependencies = [
[[package]]
name = "petgraph"
version = "0.5.1"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7"
checksum = "4a13a2fa9d0b63e5f22328828741e523766fff0ee9e779316902290dff3f824f"
dependencies = [
"fixedbitset",
"indexmap",
@ -1870,9 +1980,9 @@ dependencies = [
[[package]]
name = "prost"
version = "0.7.0"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e6984d2f1a23009bd270b8bb56d0926810a3d483f59c987d77969e9d8e840b2"
checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001"
dependencies = [
"bytes",
"prost-derive",
@ -1880,30 +1990,32 @@ dependencies = [
[[package]]
name = "prost-build"
version = "0.7.0"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32d3ebd75ac2679c2af3a92246639f9fcc8a442ee420719cc4fe195b98dd5fa3"
checksum = "62941722fb675d463659e49c4f3fe1fe792ff24fe5bbaa9c08cd3b98a1c354f5"
dependencies = [
"bytes",
"heck",
"itertools 0.9.0",
"itertools 0.10.3",
"lazy_static",
"log",
"multimap",
"petgraph",
"prost",
"prost-types",
"regex",
"tempfile",
"which",
]
[[package]]
name = "prost-derive"
version = "0.7.0"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "169a15f3008ecb5160cba7d37bcd690a7601b6d30cfb87a117d45e59d52af5d4"
checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe"
dependencies = [
"anyhow",
"itertools 0.9.0",
"itertools 0.10.3",
"proc-macro2",
"quote",
"syn",
@ -1911,9 +2023,9 @@ dependencies = [
[[package]]
name = "prost-types"
version = "0.7.0"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b518d7cdd93dab1d1122cf07fa9a60771836c668dde9d9e2a139f957f0d9f1bb"
checksum = "534b7a0e836e3c482d2693070f982e39e7611da9695d4d1f5a4b186b51faef0a"
dependencies = [
"bytes",
"prost",
@ -2364,6 +2476,17 @@ dependencies = [
"opaque-debug 0.3.0",
]
[[package]]
name = "sha2"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99c3bd8169c58782adad9290a9af5939994036b76187f7b4f0e6de91dbbfc0ec"
dependencies = [
"cfg-if 1.0.0",
"cpufeatures",
"digest 0.10.1",
]
[[package]]
name = "signature"
version = "1.4.0"
@ -2517,8 +2640,8 @@ dependencies = [
"bs58 0.3.1",
"derivative",
"failure",
"fluence-fork-libp2p-core",
"fluence-keypair",
"libp2p-core",
"log",
"nonempty",
"rand 0.7.3",
@ -2539,8 +2662,8 @@ dependencies = [
"bincode",
"boolinator",
"bs58 0.3.1",
"fluence-fork-libp2p-core",
"fluence-keypair",
"libp2p-core",
"log",
"marine-rs-sdk",
"marine-rs-sdk-test",
@ -2618,12 +2741,6 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "unsigned-varint"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fdeedbf205afadfe39ae559b75c3240f24e257d0ca27e85f85cb82aa19ac35"
[[package]]
name = "unsigned-varint"
version = "0.7.1"

View File

@ -8,7 +8,7 @@ license = "Apache-2.0"
repository = "https://github.com/fluencelabs/trust-graph"
[dependencies]
libp2p-core = { package = "fluence-fork-libp2p-core", version = "0.27.2", features = ["secp256k1"] }
libp2p-core = { version = "0.31", default-features = false, features = [ "secp256k1" ] }
serde = { version = "1.0.118", features = ["derive"] }
fluence-keypair = { path = "./keypair", version = "0.5.0" }

View File

@ -23,7 +23,7 @@ asn1_der = "0.6.1"
sha2 = "0.9.1"
zeroize = "1"
serde_bytes = "0.11"
libp2p-core = { package = "fluence-fork-libp2p-core", version = "0.27.2", features = ["secp256k1"]}
libp2p-core = { version = "0.31", default-features = false, features = [ "secp256k1" ] }
eyre = "0.6.5"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]

View File

@ -0,0 +1,3 @@
[toolchain]
channel = "nightly-2022-01-16"
targets = [ "x86_64-apple-darwin", "x86_64-unknown-linux-gnu" ]

View File

@ -109,7 +109,7 @@ impl PublicKey {
}
pub fn to_peer_id(&self) -> PeerId {
PeerId::from_public_key(self.clone().into())
PeerId::from_public_key(&self.clone().into())
}
pub fn get_key_format(&self) -> KeyFormat {
@ -164,13 +164,24 @@ impl TryFrom<libp2p_core::PeerId> for PublicKey {
type Error = DecodingError;
fn try_from(peer_id: libp2p_core::PeerId) -> Result<Self, Self::Error> {
Ok(peer_id
.as_public_key()
Ok(as_public_key(&peer_id)
.ok_or(DecodingError::PublicKeyNotInlined(peer_id.to_base58()))?
.into())
}
}
/// Convert PeerId to libp2p's PublicKey
fn as_public_key(peer_id: &PeerId) -> Option<libp2p_core::PublicKey> {
use libp2p_core::multihash;
let mhash = peer_id.as_ref();
match multihash::Code::try_from(mhash.code()) {
Ok(multihash::Code::Identity) => libp2p_core::PublicKey::from_protobuf_encoding(mhash.digest()).ok(),
_ => None,
}
}
#[cfg(test)]
mod tests {
use super::*;

View File

@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2021-09-01"
channel = "nightly-2022-01-16"
targets = [ "x86_64-apple-darwin", "x86_64-unknown-linux-gnu" ]

View File

@ -16,7 +16,7 @@ fluence-keypair = { version = "0.5.0", path = "../keypair" }
marine-rs-sdk = { version = "0.6.14", features = ["logger"] }
marine-sqlite-connector = "0.5.2"
libp2p-core = { package = "fluence-fork-libp2p-core", version = "0.27.2", features = ["secp256k1"]}
libp2p-core = { version = "0.31", default-features = false, features = [ "secp256k1" ] }
log = "0.4.8"
anyhow = "1.0.31"

View File

@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2021-09-01"
channel = "nightly-2022-01-16"
targets = [ "x86_64-apple-darwin", "x86_64-unknown-linux-gnu" ]