Skip to content

Commit

Permalink
Add libff and secp256k1 to arb-avm-cpp compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
hkalodner committed Jan 31, 2020
1 parent b728cea commit d2927dd
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ validator-states
docker-compose.yml
packages/arb-avm-cpp/tests/config.hpp
packages/arb-avm-cpp/rocksdb
packages/arb-avm-cpp/external/libff
packages/arb-avm-cpp/external/secp256k1
packages/arb-compiler-evm/tests/sol-syscall/code.txt
bridge_eth_addresses.json
keys.json
Expand Down
1 change: 1 addition & 0 deletions packages/arb-avm-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ file(GLOB KECCAK_SOURCES
external/keccak/*.c
)

add_subdirectory(external)
add_subdirectory(utils)
add_subdirectory(avm_values)
add_subdirectory(data_storage)
Expand Down
3 changes: 1 addition & 2 deletions packages/arb-avm-cpp/avm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ set (CMAKE_CXX_STANDARD 14)
project (avm LANGUAGES CXX)

set(LIB_HEADERS

include/avm/machine.hpp
include/avm/machinestate/machinestate.hpp
include/avm/machinestate/datastack.hpp
Expand Down Expand Up @@ -57,7 +56,7 @@ target_include_directories(avm PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../external
)

target_link_libraries(avm PUBLIC data_storage Boost::boost Boost::filesystem RocksDB::RocksDB CONAN_PKG::variant-lite Threads::Threads PRIVATE avm_utils)
target_link_libraries(avm PUBLIC data_storage Boost::boost Boost::filesystem RocksDB::RocksDB CONAN_PKG::variant-lite Threads::Threads secp256k1 libff PRIVATE avm_utils)

target_code_coverage(avm AUTO ALL)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#include <avm_values/util.hpp>
#include <bigint_utils.hpp>

#include <secp256k1_recovery.h>
#include <libff/algebra/curves/alt_bn128/alt_bn128_g1.hpp>

namespace machineoperation {

uint256_t& assumeInt(value& val) {
Expand Down
44 changes: 44 additions & 0 deletions packages/arb-avm-cpp/external/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
include(ExternalProject)
ExternalProject_Add(secp256k1_ext
GIT_REPOSITORY "https://github.com/bitcoin-core/secp256k1.git"
GIT_TAG "master"
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/secp256k1"
CONFIGURE_COMMAND ./autogen.sh COMMAND <SOURCE_DIR>/configure --enable-module-recovery --prefix <INSTALL_DIR>
BUILD_COMMAND make
UPDATE_COMMAND ""
BUILD_IN_SOURCE 1
)

add_library(secp256k1 IMPORTED STATIC GLOBAL)
add_dependencies (secp256k1 secp256k1_ext)
ExternalProject_Get_Property(secp256k1_ext install_dir)

file(MAKE_DIRECTORY ${install_dir}/include)

set_target_properties(secp256k1 PROPERTIES
"IMPORTED_LOCATION" "${install_dir}/lib/libsecp256k1.a"
"INTERFACE_INCLUDE_DIRECTORIES" "${install_dir}/include"

)

ExternalProject_Add(libff_ext
GIT_REPOSITORY "https://github.com/scipr-lab/libff"
GIT_TAG "master"
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libff"
CMAKE_ARGS -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}
-DOPENSSL_INCLUDE_DIR=${OPENSSL_ROOT_DIR}/include
-DWITH_PROCPS=OFF
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
)

add_library(libff IMPORTED STATIC GLOBAL)
add_dependencies (libff libff_ext)
ExternalProject_Get_Property(libff_ext install_dir)

file(MAKE_DIRECTORY ${install_dir}/include)

set_target_properties(libff PROPERTIES
"IMPORTED_LOCATION" "${install_dir}/lib/libff.a"
"INTERFACE_INCLUDE_DIRECTORIES" "${install_dir}/include"

)

0 comments on commit d2927dd

Please sign in to comment.