Skip to content

Commit

Permalink
test: ci use local axon instead of standard eth client; update ckbMbt…
Browse files Browse the repository at this point in the history
…Verify
  • Loading branch information
wenyuanhust committed Dec 19, 2023
1 parent 2ba03e7 commit 3f8eef5
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 12 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
8 changes: 1 addition & 7 deletions contracts/clients/CkbProof.sol
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,7 @@ function ckbMbtVerify(VerifyProofPayload memory payload) view returns (bool) {
// axon_precompile_address(0x07)
address ckb_mbt_addr = address(0x0107);
(bool isSuccess, bytes memory res) = ckb_mbt_addr.staticcall(
abi.encode(
payload.verifyType,
payload.transactionsRoot,
payload.witnessesRoot,
payload.rawTransactionsRoot,
payload.proof
)
abi.encode(payload)
);

if (!isSuccess) {
Expand Down
3 changes: 1 addition & 2 deletions contracts/clients/CkbTestProof.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ library CkbTestProof {
// Create the VerifyProofPayload
VerifyProofPayload memory payload = VerifyProofPayload({
verifyType: axonObjProof.proofPayload.verifyType,
// transactionsRoot: header.transactionsRoot,
transactionsRoot: 0x7c57536c95df426f5477c344f8f949e4dfd25443d6f586b4f350ae3e4b870433,
transactionsRoot: header.transactionsRoot,
witnessesRoot: axonObjProof.proofPayload.witnessesRoot,
rawTransactionsRoot: axonObjProof.proofPayload.rawTransactionsRoot,
proof: axonObjProof.proofPayload.proof
Expand Down
11 changes: 11 additions & 0 deletions truffle-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ module.exports = {
// Gas price used for deploys. Default is 20000000000 (20 Gwei).
gasPrice: 8,
},

// forcerelay contract is too large to be executed, it needs special version of axon
axon_forcerelay: {
network_id: "*", // Any network (default: none)
provider: () => new HDWalletProvider(
"test test test test test test test test test test test junk",
process.env.AXON_HTTP_RPC_URL
),
// Gas price used for deploys. Default is 20000000000 (20 Gwei).
gasPrice: 8,
},
},

// Set default mocha options here, use special reporters etc.
Expand Down

0 comments on commit 3f8eef5

Please sign in to comment.