Skip to content
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

Make circuits and assignment tables: CI implementation #23

Merged
merged 4 commits into from
Jun 12, 2023
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
29 changes: 29 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test the development workflow

on:
push:
branches: [ master ]
pull_request:

concurrency:
group: ${{
( github.ref == 'refs/heads/master' &&
format('{0}/{1}', github.run_id, github.run_attempt) )
||
format('{0}/{1}', github.workflow, github.ref) }}
cancel-in-progress: true

env:
SCRIPT_NAME: docker-run.sh

jobs:
test-ll-workflow:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Run the workflow script
run: scripts/${{ env.SCRIPT_NAME }}
27 changes: 9 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
#---------------------------------------------------------------------------#
# Copyright (c) 2018-2023 Mikhail Komarov <[email protected]>
#
# Distributed under the Boost Software License, Version 1.0
# See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt
#---------------------------------------------------------------------------#

cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

cmake_policy(SET CMP0028 NEW)
cmake_policy(SET CMP0042 NEW)
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0057 NEW)
cmake_policy(SET CMP0077 NEW)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake"
"${CMAKE_CURRENT_LIST_DIR}/cmake/modules/share/modules/cmake")
"${CMAKE_CURRENT_LIST_DIR}/cmake/modules/share/modules/cmake"
"/usr/share/zkllvm")

include(CMConfig)
include(CMDeploy)
include(CMSetupVersion)
include(CircuitCompile)

cm_workspace(zkllvm)
cm_workspace(crypto3)

macro(cm_find_package NAME)
if(NOT "${NAME}" MATCHES "^${CMAKE_WORKSPACE_NAME}_.*$" AND NOT "${NAME}" STREQUAL CM)
Expand All @@ -31,5 +18,9 @@ macro(cm_find_package NAME)
endif()
endmacro()

cm_setup_version(VERSION 0.1.0 PREFIX ${CMAKE_WORKSPACE_NAME})

add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/libs/crypto3")
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/src")

#Example directories
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/src")
2 changes: 1 addition & 1 deletion libs/crypto3
31 changes: 31 additions & 0 deletions scripts/build-circuit-ll.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#/usr/bin/env bash
set -euxo pipefail

# checking files that should be produced by the compiler
check_file_exists() {
FILE1="${1}"
if [ ! -e "$FILE1" ]
then
echo "File $FILE1 was not created" >&2
exit 1
else
echo "File $FILE1 created successfully"
fi
}

rm -rf build && mkdir build && cd build
cmake -DCIRCUIT_ASSEMBLY_OUTPUT=TRUE ..
make template

check_file_exists "./src/template.ll"

assigner \
-b src/template.ll \
-i ../src/main.inp \
-c template.crct \
-t template.tbl \
-e pallas

check_file_exists "./template.crct"
check_file_exists "./template.tbl"

19 changes: 19 additions & 0 deletions scripts/docker-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#/usr/bin/env bash
set -euxo pipefail

# podman is a safer option for using on CI machines
if ! command -v podman; then
DOCKER="docker"
DOCKER_OPTS=""
else
DOCKER="podman"
DOCKER_OPTS='--detach-keys= --userns=keep-id'
fi

$DOCKER run $DOCKER_OPTS \
--rm \
--platform=linux/amd64 \
--user $(id -u ${USER}):$(id -g ${USER}) \
--volume $(pwd):/opt/zkllvm-template \
ghcr.io/nilfoundation/zkllvm-template:latest \
sh -c "bash ./scripts/build-circuit-ll.sh"
110 changes: 42 additions & 68 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,68 +1,42 @@
#---------------------------------------------------------------------------#
# Copyright (c) 2018-2023 Mikhail Komarov <[email protected]>
#
# Distributed under the Boost Software License, Version 1.0
# See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt
#---------------------------------------------------------------------------#

cm_project(template WORKSPACE_NAME ${CMAKE_WORKSPACE_NAME} LANGUAGES C CXX)

list(APPEND ${CURRENT_PROJECT_NAME}_PUBLIC_HEADERS)

list(APPEND ${CURRENT_PROJECT_NAME}_UNGROUPED_SOURCES
main.cpp)

list(APPEND ${CURRENT_PROJECT_NAME}_HEADERS
${${CURRENT_PROJECT_NAME}_PUBLIC_HEADERS})

list(APPEND ${CURRENT_PROJECT_NAME}_SOURCES
${${CURRENT_PROJECT_NAME}_UNGROUPED_SOURCES})

cm_setup_version(VERSION 0.1.0 PREFIX ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME})

add_library(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} OBJECT ${${CURRENT_PROJECT_NAME}_SOURCES})

set_target_properties(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} PROPERTIES
EXPORT_NAME ${CURRENT_PROJECT_NAME})

target_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} PUBLIC
crypto3::algebra
crypto3::block
crypto3::codec
crypto3::containers
crypto3::hash
crypto3::kdf
crypto3::mac
marshalling::core
marshalling::crypto3_algebra
marshalling::crypto3_multiprecision
marshalling::crypto3_zk
crypto3::math
crypto3::modes
crypto3::multiprecision
crypto3::passhash
crypto3::pbkdf
crypto3::threshold
crypto3::pkpad
crypto3::pubkey
crypto3::random
crypto3::stream
crypto3::vdf
crypto3::zk

${Boost_LIBRARIES})

target_include_directories(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>

${Boost_INCLUDE_DIRS})

cm_deploy(TARGETS ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}
INCLUDE include
NAMESPACE ${CMAKE_WORKSPACE_NAME}::)

if(BUILD_TESTS)
add_subdirectory(test)
endif()
function(add_example example_target)
set(prefix ARG)
set(noValues "")
set(singleValues INPUT)
set(multiValues SOURCES)
cmake_parse_arguments(${prefix}
"${noValues}"
"${singleValues}"
"${multiValues}"
${ARGN})
add_circuit(${example_target}
SOURCES ${ARG_SOURCES}

LINK_LIBRARIES
crypto3::algebra
crypto3::block
crypto3::codec
crypto3::containers
crypto3::hash
crypto3::kdf
crypto3::mac
marshalling::core
marshalling::crypto3_algebra
marshalling::crypto3_multiprecision
marshalling::crypto3_zk
crypto3::math
crypto3::modes
crypto3::multiprecision
crypto3::passhash
crypto3::pbkdf
crypto3::threshold
crypto3::pkpad
crypto3::pubkey
crypto3::random
crypto3::stream
crypto3::vdf
crypto3::zk

${Boost_LIBRARIES})
endfunction()

add_example(template SOURCES main.cpp INPUT main.inp)