Skip to content

Commit

Permalink
Merge pull request #38 from wenyuanhust/master
Browse files Browse the repository at this point in the history
feat: implement verifyMembership

Because only transactionsRoot is used in CkbHeader, so the mocked getTestHeader only contains valid transactionsRoot.
  • Loading branch information
Flouse authored Dec 19, 2023
2 parents d5df972 + 3f8eef5 commit 267a055
Show file tree
Hide file tree
Showing 8 changed files with 503 additions and 8 deletions.
43 changes: 40 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,55 @@ on:
jobs:
test:
runs-on: ubuntu-latest
env:
SRC_DIR: ${{ github.workspace }}
# https://github.com/axonweb3/axon/commits/forcerelay-dev
AXON_COMMIT: 343f329b78b8187e28fdac9e9af6c28222656b92
AXON_HTTP_RPC_URL: "http://127.0.0.1:8000"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
cache-dependency-path: 'yarn.lock'

- name: Prepare Axon source
run: git clone --recursive https://github.com/axonweb3/axon.git $SRC_DIR/axon && cd $SRC_DIR/axon && git checkout $AXON_COMMIT

- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: "."

- name: Cache axon bin
id: cache-axon-bin
uses: actions/cache@v3
env:
cache-name: cache-axon-bin
with:
path: ${{env.SRC_DIR}}/axon/target/release/axon
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.AXON_COMMIT }}

- name: Build Axon
if: ${{ steps.cache-axon-bin.outputs.cache-hit != 'true' }}
uses: actions-rs/cargo@v1
with:
command: build
args: --release --manifest-path ${{env.SRC_DIR}}/axon/Cargo.toml

- name: Add axon bin to path
run: echo "${{env.SRC_DIR}}/axon/target/release/" >> $GITHUB_PATH

- name: Config axon
run: axon init --config ${{env.SRC_DIR}}/axon/devtools/chain/config.toml --chain-spec ${{env.SRC_DIR}}/axon/devtools/chain/specs/single_node/chain-spec.toml

- name: Start axon
run: axon run --config ${{env.SRC_DIR}}/axon/devtools/chain/config.toml &

- run: yarn install
- run: npx truffle version

- name: Run Ethereum locally for test
run: npx ganache > ganache.log &
- run: yarn compile
- name: Run test
run: npx truffle test
run: npx truffle test --network axon_forcerelay
12 changes: 7 additions & 5 deletions contracts/clients/CkbClient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ pragma solidity ^0.8.9;
import "../core/02-client/ILightClient.sol";
import "../core/02-client/IBCHeight.sol";
import "../proto/Client.sol";
import "./CkbProof.sol";

// MokkClient implements https://github.com/datachainlab/ibc-mock-client
// WARNING: This client is intended to be used for testing purpose. Therefore, it is not generally available in a production, except in a fully trusted environment.
contract CkbClient is ILightClient {
using CkbProof for *;
uint64 private constant MAX_UINT64 = 18446744073709551615;
constructor() {}

Expand Down Expand Up @@ -66,12 +68,12 @@ contract CkbClient is ILightClient {
Height.Data calldata,
uint64,
uint64,
bytes calldata,
bytes memory,
bytes calldata proof,
bytes memory,
bytes calldata
) external pure override returns (bool) {
return true;
bytes memory path,
bytes calldata value
) external override returns (bool) {
return CkbProof.verifyProof(proof, path, value);
}

/**
Expand Down
Loading

0 comments on commit 267a055

Please sign in to comment.