Skip to content

Fix dependency to force libra-swarm use local client implementation. #12

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

Merged
merged 2 commits into from
Nov 19, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 45 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,60 @@
version: 2.0
version: 2.1

executors:
build-executor:
docker:
- image: circleci/rust:buster
resource_class: 2xlarge

jobs:
build:
docker:
- image: circleci/rust:stretch
executor: build-executor
steps:
- checkout
- run:
name: Setup
command: |
sudo sh -c 'echo "deb http://deb.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/backports.list'
sudo apt-get update
sudo apt-get -t stretch-backports install cmake python3-dev python3-venv clang llvm
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install cmake python3-dev python3-venv clang llvm libjemalloc-dev librocksdb-dev
- run:
name: Build everything
name: Build libra-dev
command: |
./build.sh
- run:
name: Build Python stuff
name: Install libra-dev
command: |
sudo cp libra-dev/target/debug/liblibra_dev.so /usr/lib
- run:
name: Test C++ client
background: true
when: always
shell: /bin/sh
command: |
cd cpp
./build.sh && ./test.sh
touch test-done
- run:
name: Test Rust Client
background: true
when: always
shell: /bin/sh
command: |
cd rust
./test.sh
touch test-done
- run:
name: Test Python stuff
background: true
when: always
shell: /bin/sh
command: |
cd python
./test.sh
touch test-done
- run:
name: Wait for everything
when: always
command: |
while [ ! -f cpp/test-done ]; do sleep 1; done
while [ ! -f rust/test-done ]; do sleep 1; done
while [ ! -f python/test-done ]; do sleep 1; done
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ cmake_minimum_required(VERSION 3.7)

project(libra-client-dev)

add_subdirectory(c)
add_subdirectory(cpp)
12 changes: 0 additions & 12 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,3 @@ cd ..
cd rust
cargo build
cd ..

# C Stuff
rm -rf build
mkdir build
cd build
cmake ..
make VERBOSE=1

# Test!
cd rust && ./test.sh && cd ..
./c/c-client
./cpp/cpp-client
17 changes: 0 additions & 17 deletions c/CMakeLists.txt

This file was deleted.

81 changes: 0 additions & 81 deletions c/main.c

This file was deleted.

1 change: 1 addition & 0 deletions cpp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
10 changes: 10 additions & 0 deletions cpp/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -euo pipefail

# C Stuff
rm -rf build
mkdir build
cd build || exit
cmake ..
make VERBOSE=1
cd ..
21 changes: 18 additions & 3 deletions cpp/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ byte_string hex2bin(const std::string &in) {
return result;
}

constexpr char hexmap[] = {'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};

std::string hexStr(unsigned char *data, int len) {
std::string s(len * 2, ' ');
for (int i = 0; i < len; ++i) {
s[2 * i] = hexmap[(data[i] & 0xF0) >> 4];
s[2 * i + 1] = hexmap[data[i] & 0x0F];
}
return s;
}

int main() {
std::basic_string<unsigned char> blob = hex2bin(
"020000002100000001674deac5e7fca75f00ca92b1ba3697f5f01ef585011beea7b361150f4504638f0800000002000000000000002100000001a208df134fefed8442b1f01fab59071898f5a1af5164e12c594de55a7004a91c8e0000002000000036ccb9ba8b4f0cd1f3e2d99338806893dff7478c69acee9b8e1247c053783a4800e876481700000000000200000000000000200000000b14ed4f5af8f8f077c7ec4313c6d395b9a7eb5f41eab9ec15367215ca9e420a01000000000000002000000032f56f77b09773aa64c78ee39943da7ec73f91cd757e325098e11b3edc4eccb10100000000000000"
Expand All @@ -44,21 +56,24 @@ int main() {
<< std::endl
<< "sequence: " << account_resource.sequence
<< std::endl
<< "authentication_key: " << hexStr(account_resource.authentication_key, 32)
<< std::endl
<< "delegated_key_rotation_capability: " << account_resource.delegated_key_rotation_capability
<< std::endl
<< "delegated_withdrawal_capability: " << account_resource.delegated_withdrawal_capability
<< std::endl;

struct CEventHandle sent_events = account_resource.sent_events;
std::cout << "sent events count: " << sent_events.count << std::endl;
std::cout << std::endl;

std::cout << "sent events key:" << sent_events.key;
std::cout << "sent events key:" << hexStr(sent_events.key, 32);
std::cout << std::endl;

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

std::cout << "sent events key:" << received_events.key;
std::cout << "sent events key:" << hexStr(received_events.key, 32);
std::cout << std::endl;


Expand Down
5 changes: 5 additions & 0 deletions cpp/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -euo pipefail

# Test!
./build/cpp-client
8 changes: 7 additions & 1 deletion libra-dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ libra-crypto = { git = "https://github.com/libra/libra.git", branch = "testnet"
lcs = { git = "https://github.com/libra/libra.git", branch = "testnet", package = "libra-canonical-serialization" }

[lib]
crate-type = ["staticlib"]
crate-type = ["cdylib"]

[profile.dev]
lto = true

[profile.release]
lto = true
43 changes: 1 addition & 42 deletions rust/Cargo.lock

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

10 changes: 7 additions & 3 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ serde = { version = "1.0.96", features = ["derive"] }
serde_json = "1.0.40"
structopt = "0.3.2"

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

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

[features]
default = []
fuzzing = ["proptest", "libra-crypto/fuzzing", "fixme-libra-types/fuzzing"]
fuzzing = ["proptest", "libra-crypto/fuzzing", "fixme-libra-types/fuzzing"]

# Override depenedency to use local client implementation.
[patch."https://github.com/libra/libra.git"]
client = { path = "./" }