Skip to content

Commit d6e6585

Browse files
author
Yucong Sun
authored
Fix dependency to force libra-swarm use local client implementation. (#12)
* Fix depenedncy to force libra-swarm use local client implementation. * Try to install libra_dev into system directory
1 parent 2df09f1 commit d6e6585

File tree

12 files changed

+94
-168
lines changed

12 files changed

+94
-168
lines changed

.circleci/config.yml

+45-8
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,60 @@
1-
version: 2.0
1+
version: 2.1
2+
3+
executors:
4+
build-executor:
5+
docker:
6+
- image: circleci/rust:buster
7+
resource_class: 2xlarge
28

39
jobs:
410
build:
5-
docker:
6-
- image: circleci/rust:stretch
11+
executor: build-executor
712
steps:
813
- checkout
914
- run:
1015
name: Setup
1116
command: |
12-
sudo sh -c 'echo "deb http://deb.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/backports.list'
13-
sudo apt-get update
14-
sudo apt-get -t stretch-backports install cmake python3-dev python3-venv clang llvm
17+
sudo apt-get update && sudo apt-get upgrade -y
18+
sudo apt-get install cmake python3-dev python3-venv clang llvm libjemalloc-dev librocksdb-dev
1519
- run:
16-
name: Build everything
20+
name: Build libra-dev
1721
command: |
1822
./build.sh
1923
- run:
20-
name: Build Python stuff
24+
name: Install libra-dev
25+
command: |
26+
sudo cp libra-dev/target/debug/liblibra_dev.so /usr/lib
27+
- run:
28+
name: Test C++ client
29+
background: true
30+
when: always
31+
shell: /bin/sh
32+
command: |
33+
cd cpp
34+
./build.sh && ./test.sh
35+
touch test-done
36+
- run:
37+
name: Test Rust Client
38+
background: true
39+
when: always
40+
shell: /bin/sh
41+
command: |
42+
cd rust
43+
./test.sh
44+
touch test-done
45+
- run:
46+
name: Test Python stuff
47+
background: true
48+
when: always
49+
shell: /bin/sh
2150
command: |
2251
cd python
2352
./test.sh
53+
touch test-done
54+
- run:
55+
name: Wait for everything
56+
when: always
57+
command: |
58+
while [ ! -f cpp/test-done ]; do sleep 1; done
59+
while [ ! -f rust/test-done ]; do sleep 1; done
60+
while [ ! -f python/test-done ]; do sleep 1; done

CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ cmake_minimum_required(VERSION 3.7)
22

33
project(libra-client-dev)
44

5-
add_subdirectory(c)
65
add_subdirectory(cpp)

build.sh

-12
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,3 @@ cd ..
1111
cd rust
1212
cargo build
1313
cd ..
14-
15-
# C Stuff
16-
rm -rf build
17-
mkdir build
18-
cd build
19-
cmake ..
20-
make VERBOSE=1
21-
22-
# Test!
23-
cd rust && ./test.sh && cd ..
24-
./c/c-client
25-
./cpp/cpp-client

c/CMakeLists.txt

-17
This file was deleted.

c/main.c

-81
This file was deleted.

cpp/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

cpp/build.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# C Stuff
5+
rm -rf build
6+
mkdir build
7+
cd build || exit
8+
cmake ..
9+
make VERBOSE=1
10+
cd ..

cpp/main.cc

+18-3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ byte_string hex2bin(const std::string &in) {
3434
return result;
3535
}
3636

37+
constexpr char hexmap[] = {'0', '1', '2', '3', '4', '5', '6', '7',
38+
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
39+
40+
std::string hexStr(unsigned char *data, int len) {
41+
std::string s(len * 2, ' ');
42+
for (int i = 0; i < len; ++i) {
43+
s[2 * i] = hexmap[(data[i] & 0xF0) >> 4];
44+
s[2 * i + 1] = hexmap[data[i] & 0x0F];
45+
}
46+
return s;
47+
}
48+
3749
int main() {
3850
std::basic_string<unsigned char> blob = hex2bin(
3951
"020000002100000001674deac5e7fca75f00ca92b1ba3697f5f01ef585011beea7b361150f4504638f0800000002000000000000002100000001a208df134fefed8442b1f01fab59071898f5a1af5164e12c594de55a7004a91c8e0000002000000036ccb9ba8b4f0cd1f3e2d99338806893dff7478c69acee9b8e1247c053783a4800e876481700000000000200000000000000200000000b14ed4f5af8f8f077c7ec4313c6d395b9a7eb5f41eab9ec15367215ca9e420a01000000000000002000000032f56f77b09773aa64c78ee39943da7ec73f91cd757e325098e11b3edc4eccb10100000000000000"
@@ -44,21 +56,24 @@ int main() {
4456
<< std::endl
4557
<< "sequence: " << account_resource.sequence
4658
<< std::endl
59+
<< "authentication_key: " << hexStr(account_resource.authentication_key, 32)
60+
<< std::endl
4761
<< "delegated_key_rotation_capability: " << account_resource.delegated_key_rotation_capability
62+
<< std::endl
63+
<< "delegated_withdrawal_capability: " << account_resource.delegated_withdrawal_capability
4864
<< std::endl;
4965

5066
struct CEventHandle sent_events = account_resource.sent_events;
5167
std::cout << "sent events count: " << sent_events.count << std::endl;
52-
std::cout << std::endl;
5368

54-
std::cout << "sent events key:" << sent_events.key;
69+
std::cout << "sent events key:" << hexStr(sent_events.key, 32);
5570
std::cout << std::endl;
5671

5772
struct CEventHandle received_events = account_resource.received_events;
5873
std::cout << "received events count: " << received_events.count;
5974
std::cout << std::endl;
6075

61-
std::cout << "sent events key:" << received_events.key;
76+
std::cout << "sent events key:" << hexStr(received_events.key, 32);
6277
std::cout << std::endl;
6378

6479

cpp/test.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Test!
5+
./build/cpp-client

libra-dev/Cargo.toml

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@ libra-crypto = { git = "https://github.com/libra/libra.git", branch = "testnet"
1414
lcs = { git = "https://github.com/libra/libra.git", branch = "testnet", package = "libra-canonical-serialization" }
1515

1616
[lib]
17-
crate-type = ["staticlib"]
17+
crate-type = ["cdylib"]
18+
19+
[profile.dev]
20+
lto = true
21+
22+
[profile.release]
23+
lto = true

rust/Cargo.lock

+1-42
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

+7-3
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ serde = { version = "1.0.96", features = ["derive"] }
2525
serde_json = "1.0.40"
2626
structopt = "0.3.2"
2727

28-
# Libra C API, that is all we should need!
29-
libra-dev = { path="../libra-dev" }
28+
# TODO: this actually doesn't work, havn't figure out an way to link against an staticlib dependency yet.
29+
# libra-dev = { path="../libra-dev" }
3030

3131
# All Libra dependencies, The goal is to remove this section down to zero!
3232
# S0: Core types
@@ -58,4 +58,8 @@ compiler = { git = "https://github.com/libra/libra.git", branch = "testnet" }
5858

5959
[features]
6060
default = []
61-
fuzzing = ["proptest", "libra-crypto/fuzzing", "fixme-libra-types/fuzzing"]
61+
fuzzing = ["proptest", "libra-crypto/fuzzing", "fixme-libra-types/fuzzing"]
62+
63+
# Override depenedency to use local client implementation.
64+
[patch."https://github.com/libra/libra.git"]
65+
client = { path = "./" }

0 commit comments

Comments
 (0)