Skip to content

Commit

Permalink
Merge branch 'main' into citation
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelAPB authored Jun 29, 2023
2 parents ea3fb0f + 14f5145 commit 553b8ba
Show file tree
Hide file tree
Showing 92 changed files with 1,480 additions and 393 deletions.
54 changes: 51 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ jobs:
- name: Run Verifier in Cosmos test
run: nix develop -c yarn test './tests/cosmosLightClient/test-verifier-in-cosmos.ts'

- name: Run Solidity verifier tests
run: nix develop -c make test-groth16-verifier

- name: Run circom tests
run: nix develop -c make test-circom-circuits

Expand All @@ -69,3 +66,54 @@ jobs:

# - name: Run Verifier in EOS test
# run: nix develop -c yarn test './tests/eosLightClient/test-verifier-in-EOS.ts'

- name: Run Verify given proof - test using bncurve and constantine
run: nix develop -c nim c -r 'tests/verify_proof/verify_given_proof_test.nim'

SolidityVerifierTests:
needs: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-22.11
install_url: https://releases.nixos.org/nix/nix-2.15.0/install

- uses: cachix/cachix-action@v12
with:
name: nix-blockchain-development
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- name: Install Node.js dependencies
run: nix develop -c yarn install --immutable

- name: Run Solidity verifier tests
run: nix develop -c make evm-simulation

OneShotSyncingSimulation:
needs: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-22.11
install_url: https://releases.nixos.org/nix/nix-2.15.0/install

- uses: cachix/cachix-action@v12
with:
name: nix-blockchain-development
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- name: Install Node.js dependencies
run: nix develop -c yarn install --immutable

- name: Run one shot syncing simulation
run: nix develop -c make one-shot-syncing-simulation
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@
[submodule "vendor/eos"]
path = vendor/eos
url = https://github.com/EOSIO/eos.git
[submodule "vendor/constantine"]
path = vendor/constantine
url = [email protected]:metacraft-labs/constantine.git
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ test-solidity-beacon-light-client-verifier:
yarn hardhat test test/BeaconLightClientReadyProofs.test.ts

test-circom-circuits:
cd beacon-light-client/circom && \
./test/run_snarkit2_tests.sh
./beacon-light-client/circom/test/run_snarkit2_tests.sh --force_recompile
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ make build-relay-image

Which will build the relayimage for you. To run it

You can also pull the image from docker hub

```
docker pull dimaranti/dendreth
```

```bash
docker run -it --env-file .env -v relayvolume:/DendrETH/build relayimage
```
Expand Down Expand Up @@ -174,6 +180,53 @@ LC_CHIADO=0xAa5eeb05D0B080b366CB6feA00d16216B24FB9bE
LC_EVMOS=0x8E4D36CD13015EA6F384cab3342156b3dC5d0a53
```

And also it needs to contain the hashi adapter addresses

Sample `.env`

```
USER_PRIVATE_KEY=private_key
ALCHEMY_API_KEY=api_key
REDIS_HOST=localhost
REDIS_PORT=6379
PROVER_SERVER_HOST=http://127.0.0.1
PROVER_SERVER_PORT=5000
INITIAL_SLOT=5860953
SLOTS_JUMP=32
PRATTER=TRUE
MAINNET=FALSE
LC_GOERLI=0xf65B59bc947865490eF92D8461e8B5D0eA87c343
LC_OPTIMISTIC_GOERLI=
LC_BASE_GOERLI=
LC_ARBITRUM_GOERLI=
LC_SEPOLIA=
LC_MUMBAI=
LC_FUJI=
LC_FANTOM=
LC_ALFAJORES=
LC_BSC=
LC_AURORA=
LC_GNOSIS=
LC_CHIADO=
LC_EVMOS=
LC_MALAGA=
GOERLI_HASHI=0x4169ea397fe83F55e732E11390807b3722374f78
OPTIMISTIC_HASHI=''
BASE_HASHI=''
ARBITRUM_HASHI=''
SEPOLIA_HASHI=''
MUMBAI_HASHI=''
FANTOM_HASHI=''
ALFAJORES_HASHI=''
CHIADO_HASHI=''
EVMOS_HASHI=''
MALAGA_HASHI=''
AURORA_HASHI=''
GNOSIS_HASHI=''
FUJI_HASHI=''
BSC_HASHI=''
```

### How does the relayer work?

We utilize BullMQ for our system.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
pragma circom 2.0.3;
pragma circom 2.1.5;

include "hash_two.circom";
include "../../../node_modules/circomlib/circuits/comparators.circom";
include "utils.circom";
include "../../../node_modules/circomlib/circuits/bitify.circom";

include "utils/arrays.circom";
include "utils/numerical.circom";

template IsValidMerkleBranchOut(N) {
signal input branch[N][256];
Expand All @@ -14,12 +17,14 @@ template IsValidMerkleBranchOut(N) {

component hashers[N];
component isZero[N];

component idx2Bits;
idx2Bits = Num2Bits(N+1);
idx2Bits.in <== index;
for(var i = 0; i < N; i++) {
hashers[i] = HashTwo();
isZero[i] = IsZero();

isZero[i].in <-- (index \ (2**i)) % 2;
isZero[i].in <== idx2Bits.out[i];

var current[256];

Expand All @@ -33,6 +38,5 @@ template IsValidMerkleBranchOut(N) {
}
}


out <== IsEqualArrays(256)([root, hashers[N - 1].out]);
}
3 changes: 1 addition & 2 deletions beacon-light-client/circom/circuits/light_client.circom
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ include "hash_tree_root_beacon_header.circom";
include "ssz_num.circom";
include "../../../vendor/circom-pairing/circuits/bls_signature.circom";

template LightClient(N) {
var K = 7;
template LightClient(N, K) {
signal input prevHeaderHash[256];
signal input nextHeaderHash[256];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ include "is_first.circom";
include "../../../vendor/circom-pairing/circuits/bls_signature.circom";
include "../../../vendor/circom-pairing/circuits/bn254/groth16.circom";

template LightClientRecursive(N) {
var K = 7;
template LightClientRecursive(N, K) {
var pubInpCount = 4;

// BN254 facts
Expand Down
52 changes: 0 additions & 52 deletions beacon-light-client/circom/circuits/utils.circom

This file was deleted.

44 changes: 44 additions & 0 deletions beacon-light-client/circom/circuits/utils/arrays.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
pragma circom 2.1.5;

include "../../../../node_modules/circomlib/circuits/comparators.circom";
include "../../../../node_modules/circomlib/circuits/bitify.circom";

template Selector(N) {
signal input in[N];
signal input index;
signal output out;

signal sums[N + 1];
sums[0] <== 0;

component eqs[N];

// For each item, check whether its index equals the input index.
for (var i = 0; i < N; i ++) {
eqs[i] = IsEqual();
eqs[i].in[0] <== i;
eqs[i].in[1] <== index;

// eqs[i].out is 1 if the index matches. As such, at most one input to
sums[i + 1] <== sums[i] + eqs[i].out * in[i];
}

// Returns 0 + 0 + ... + item
out <== sums[N];
}

template IsEqualArrays(N) {
signal input in[2][N];
signal output out;

signal isEqual[N];
var counter = 0;

for(var i = 0; i < N; i++) {
isEqual[i] <== IsEqual()([in[0][i], in[1][i]]);

counter += isEqual[i];
}

out <== IsEqual()([N, counter]);
}
26 changes: 26 additions & 0 deletions beacon-light-client/circom/circuits/utils/bits.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
pragma circom 2.1.5;

include "../../../../node_modules/circomlib/circuits/comparators.circom";
include "../../../../node_modules/circomlib/circuits/bitify.circom";

template LessThanBitsCheck(n) {
signal input in[2];
signal output out;

signal bitCheck1[n] <== Num2Bits(n)(in[0]);

signal bitCheck2[n] <== Num2Bits(n)(in[1]);

out <== LessThan(n)(in);
}

template LessThanOrEqualBitsCheck(n) {
signal input in[2];
signal output out;

signal bitCheck1[n] <== Num2Bits(n)(in[0]);

signal bitCheck2[n] <== Num2Bits(n)(in[1]);

out <== LessEqThan(n)(in);
}
Loading

0 comments on commit 553b8ba

Please sign in to comment.