HackMD
  • Prime
    Prime  Full-text search on all paid plans
    Search anywhere and reach everything in a Workspace with Prime plan.
    Got it
      • Create new note
      • Create a note from template
    • Prime  Full-text search on all paid plans
      Prime  Full-text search on all paid plans
      Search anywhere and reach everything in a Workspace with Prime plan.
      Got it
      • Sharing Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • More (Comment, Invitee)
      • Publishing
        Everyone on the web can find and read all notes of this public team.
        After the note is published, everyone on the web can find and read this note.
        See all published notes on profile page.
      • Commenting Enable
        Disabled Forbidden Owners Signed-in users Everyone
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Invitee
      • No invitee
      • Options
      • Versions and GitHub Sync
      • Transfer ownership
      • Delete this note
      • Template
      • Save as template
      • Insert from template
      • Export
      • Dropbox
      • Google Drive
      • Gist
      • Import
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
      • Download
      • Markdown
      • HTML
      • Raw HTML
    Menu Sharing Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Versions and GitHub Sync Transfer ownership Delete this note
    Export
    Dropbox Google Drive Gist
    Import
    Dropbox Google Drive Gist Clipboard
    Download
    Markdown HTML Raw HTML
    Back
    Sharing
    Sharing Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Note Permission
    Read
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Write
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    More (Comment, Invitee)
    Publishing
    Everyone on the web can find and read all notes of this public team.
    After the note is published, everyone on the web can find and read this note.
    See all published notes on profile page.
    More (Comment, Invitee)
    Commenting Enable
    Disabled Forbidden Owners Signed-in users Everyone
    Permission
    Owners
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Invitee
    No invitee
       owned this note    owned this note      
    Published Linked with GitHub
    Like BookmarkBookmarked
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Coordinator Service for MACI I have finished the feature for MACI coordinator service. Two PR have been merged: [v1.0](https://github.com/appliedzkp/maci/pull/327) and [v0.10](https://github.com/appliedzkp/maci/pull/338). ## Overal structure There are two roles in the cordinator service: admin (i.e. maci coordinator) and user (i.e. normal user). The responsibility for admin is to maintain the code updated and the backend services for normal users. The user just need sends http request to the backend server to interact with the MACI service such as signup and publish messages. The coordinator service has been wrapped into two docker instances: one for the backend server to accept user request; one for mongodb service to store all necessary informations of the current state such as smart contract addresses, zero knowledge proof keys etc. ![](https://i.imgur.com/ND645nU.png) There are two modes: development mode and production mode. For developers and cordinator, it's convenient for them to be able to quickly change the code and test the results. Hence the backend docker instance mounts the code repo to the developer's local repo. For production mode, all the code repos will be included into the docker instance instead of mount to local repo. ## Project Setup The project can be setup in two different ways. One for developing purpose, which the codes are linked to the developers' local machine, so it is easy to modify the codes and test the results. The other is for production purpose, where the codes are stored in docker image, so there will be no code changes when starting the docker services. ### development environment #### setup ```bash= ######################## ### dependency setup ### ######################## # needed for both v0.10.x and v1.0.x versions sudo apt-get install build-essential libgmp-dev && \ libsodium-dev nasm git nlohmann-json3-dev g++ jq ######################## ### maci v1.0.x setup### ######################## # reference: https://appliedzkp.github.io/maci/installation.html # install rapicsnark for v1.0.0 git clone https://github.com/iden3/rapidsnark.git && \ cd rapidsnark && \ git checkout 1c13721de4a316b0b254c310ccec9341f5e2208e npm install && \ git submodule init && \ git submodule update && \ npx task createFieldSources && \ npx task buildProver # install maci for v1.0 git clone https://github.com/appliedzkp/maci.git && \ cd maci && git checkout v1\ npm i && npm run bootstrap && npm run build cd contracts && npm run compileSol # zkey setup for v1.0 npx zkey-manager compile -c zkeys.config.yml npx zkey-manager downloadPtau -c zkeys.config.yml npx zkey-manager genZkeys -c zkeys.config.yml # setup docker environment docker build -t maci-node:v0.5 - < LightDockerfile cd docker ./setup.sh ######################### ### maci v0.10.x setup### ######################### # install rust if haven't done it before curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # install zkutil cargo install zkutil --version 0.3.2 # install maci for v0.10.x git clone https://github.com/appliedzkp/maci.git maci_v0_10 cd maci_v0_10 && npm i && npm run bootstrap && npm run build cd circuits && ./scripts/buildBatchUpdateStateTreeSnark.sh && \ ./scripts/buildQuadVoteTallySnark.sh cd ../contracts && npm run compileSol #################### ### docker setup ### #################### # step 1: install docker # reference: https://docs.docker.com/engine/install/ubuntu/ # step 2: run docker as non-root user # https://docs.docker.com/engine/install/linux-postinstall/ # step 3: install docker-compose # https://docs.docker.com/compose/install/ # pull and update docker image # make sure the image name (maci-node:v0.5) match the name in docker-compose.yml cd maci/docker docker build -t maci-node:v0.5 - < LightDockerfile # change host.docker.internal to docker network ip (for Linux machine) ./setup.sh ``` #### development and test ```bash= ### Setup for developer # (1) docker/docker-compose.yml: manually replace ETH_PROVIDER from 127.0.0.1 to docker network ip # (2) server/docker.sh: manually replace SCRIPT location to local maci repo location. # This local maci location should match in docker-compose.yml. # In my case, it's # SCRIPT='node /root/dev-maci/server/index.js' ### In one terminal # if for v1.0 cd contracts && npm run hardhat # if for v0.10 cd contracts && npm run ganache ### In second terminal cd server && ./docker.sh -u # whenever modified the code, just restart the docker instance by Ctrl+c and restart the service ./docker.sh -r ### In third terminal # if for v1.0 cd server && ./test.sh # if for v0.10 cd server && ./test_v0_10.sh ### turnoff docker after finish cd server && ./docker.sh -d ``` ### production environment #### setup ```bash= git clone https://github.com/appliedzkp/maci.git git checkout v1 #### setup zkeys if you haven't download it in local machine # (1) in this case, remove the zkey mapping in docker/docker-compose.yml # (2) login into docker cd maci/server && ./docker.sh -u # then Ctrl-C ./docker.sh -l # (3) generate zkey inside docker instance cd ~/maci/cli && ./gen_zkey.sh ``` #### test ```bash= ### In one terminal cd server && ./docker.sh -u ## In second terminal cd server && ./docker.sh -l # now in docker # if for v1.0 cd /root/maci/contracts && npm run hardhat # if for v0.10 cd /root/maci_v0_10/contracts && npm run ganache ### In third terminal, admin role cd server && ./docker.sh -l # now in docker cd /root/maci/server # run any commands for admin, e.g. # if for v1.0 ./admin.sh deploy ./admin.sh store # if for v0.10 ./admin_v0_10.sh deploy ./admin_v0_10.sh store ### In fourth terminal, user role # in local machine, not inside docker cd server # run any commands for user, e.g. # if for v1.0 ./user.sh signup -p $pk -x $maci # if for v0.10 ./user_v0_10.sh signup -p $pk -x $maci ``` ###### tags: `public`

    Import from clipboard

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lost their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template is not available.


    Upgrade

    All
    • All
    • Team
    No template found.

    Create custom template


    Upgrade

    Delete template

    Do you really want to delete this template?

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Tutorials

    Book Mode Tutorial

    Slide Mode Tutorial

    YAML Metadata

    Contacts

    Facebook

    Twitter

    Feedback

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions

    Versions and GitHub Sync

    Sign in to link this note to GitHub Learn more
    This note is not linked with GitHub Learn more
     
    Add badge Pull Push GitHub Link Settings
    Upgrade now

    Version named by    

    More Less
    • Edit
    • Delete

    Note content is identical to the latest version.
    Compare with
      Choose a version
      No search result
      Version not found

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub

        Please sign in to GitHub and install the HackMD app on your GitHub repo. Learn more

         Sign in to GitHub

        HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Available push count

        Upgrade

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Upgrade

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully