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

feat: complete ckb-light-client on relayer #387

Merged
merged 14 commits into from
Dec 11, 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
3 changes: 1 addition & 2 deletions .github/workflows/ibc-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ jobs:
env:
SRC_DIR: ${{ github.workspace }}/ibc-test-src
# https://github.com/axonweb3/axon/commits/forcerelay-dev
# commit: 7ae97ae5ffd3429746315acea77a742f6bdb6f0c
AXON_COMMIT: forcerelay-dev
AXON_COMMIT: 922fc3858b4c470a39b3ae98a479980e774896b5
IBC_CONTRACT_COMMIT: c5417573ec15c8aaab048caa1ec5f3bd50c2170e
strategy:
fail-fast: false
Expand Down
58 changes: 48 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/relayer-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ tree_hash_derive = { git = "https://github.com/synapseweb3/lighthouse", rev = "2
thiserror = "1.0"
ethereum-types = "0.14.1"
hex = "0.4"
axon-tools = { git = "https://github.com/axonweb3/axon.git", package = "axon-tools", rev = "06340ba4", version = "0.1.1", features = [
axon-tools = { git = "https://github.com/axonweb3/axon.git", package = "axon-tools", rev = "dd35f500", version = "0.1.1", features = [
"impl-serde",
"proof",
"std",
Expand Down
5 changes: 3 additions & 2 deletions crates/relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ tree_hash = { git = "https://github.com/synapseweb3/lighthouse", rev = "2c246d6"

eth_light_client_in_ckb-verification = { version = "0.2.3", git = "https://github.com/synapseweb3/eth-light-client-in-ckb", tag = "v0.2.3" }
eth_light_client_in_ckb-prover = { version = "0.2.3", git = "https://github.com/synapseweb3/eth-light-client-in-ckb", tag = "v0.2.3" }
axon-tools = { git = "https://github.com/axonweb3/axon.git", package = "axon-tools", rev = "06340ba4", version = "0.1.1", features = [
axon-tools = { git = "https://github.com/axonweb3/axon.git", package = "axon-tools", rev = "dd35f500", version = "0.1.1", features = [
"impl-serde",
"proof",
"std",
"precompile",
] }

subtle-encoding = "0.5"
Expand Down Expand Up @@ -104,7 +105,7 @@ jsonrpc-core = "18.0"
strum = { version = "0.24.1", features = ["derive"] }
lazy_static = "1.4.0"

ckb-ics-axon = { git = "https://github.com/synapseweb3/ckb-ics.git", rev = "b026840b9599ba" }
ckb-ics-axon = { git = "https://github.com/synapseweb3/ckb-ics.git", rev = "a3c3c3a2" }
cstr_core = "0.2.6"
rlp = "0.5.2"

Expand Down
11 changes: 10 additions & 1 deletion crates/relayer/src/chain/ckb/communication.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use ckb_jsonrpc_types::{
BlockNumber, BlockView, CellWithStatus, ChainInfo, HeaderView, JsonBytes, OutPoint,
OutputsValidator, RawTxPool, Transaction, TransactionWithStatusResponse, TxPoolInfo,
OutputsValidator, RawTxPool, Transaction, TransactionAndWitnessProof,
TransactionWithStatusResponse, TxPoolInfo,
};
use ckb_sdk::rpc::ckb_indexer::{Cell, Pagination, SearchKey};
use ckb_types::H256;
Expand All @@ -19,6 +20,8 @@ pub trait CkbReader {

fn get_tip_header(&self) -> Response<HeaderView>;

fn get_header(&self, hash: &H256) -> Response<Option<HeaderView>>;

fn get_transaction(&self, hash: &H256) -> Response<Option<TransactionWithStatusResponse>>;

fn get_live_cell(&self, out_point: &OutPoint, with_data: bool) -> Response<CellWithStatus>;
Expand All @@ -28,6 +31,12 @@ pub trait CkbReader {
hashes: Vec<H256>,
) -> Response<Vec<Option<TransactionWithStatusResponse>>>;

fn get_transaction_and_witness_proof(
&self,
tx_hashes: Vec<H256>,
block_hash: H256,
) -> Response<TransactionAndWitnessProof>;

fn fetch_live_cells(
&self,
search_key: SearchKey,
Expand Down
16 changes: 14 additions & 2 deletions crates/relayer/src/chain/ckb/mock_rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

use ckb_jsonrpc_types::{
BlockNumber, BlockView, CellWithStatus, ChainInfo, Header, HeaderView, JsonBytes, OutPoint,
OutputsValidator, RawTxPool, ResponseFormat, Transaction, TransactionView,
TransactionWithStatusResponse, TxPoolInfo, TxStatus,
OutputsValidator, RawTxPool, ResponseFormat, Transaction, TransactionAndWitnessProof,
TransactionView, TransactionWithStatusResponse, TxPoolInfo, TxStatus,
};
use ckb_sdk::rpc::ckb_indexer::{Cell, Pagination, SearchKey};
use ckb_types::{packed, prelude::*, H256};
Expand Down Expand Up @@ -105,6 +105,10 @@ impl CkbReader for RpcClient {
Box::pin(async { Ok(resp) })
}

fn get_header(&self, _hash: &H256) -> Rpc<Option<HeaderView>> {
todo!()
}

fn get_transaction(&self, hash: &H256) -> Rpc<Option<TransactionWithStatusResponse>> {
let transaction = ResponseFormat::<TransactionView>::json(Default::default());
let resp = TransactionWithStatusResponse {
Expand All @@ -127,6 +131,14 @@ impl CkbReader for RpcClient {
todo!()
}

fn get_transaction_and_witness_proof(
&self,
tx_hashes: Vec<H256>,
block_hash: H256,
) -> Rpc<TransactionAndWitnessProof> {
todo!()
}

fn fetch_live_cells(
&self,
search_key: SearchKey,
Expand Down
23 changes: 22 additions & 1 deletion crates/relayer/src/chain/ckb/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

use ckb_jsonrpc_types::{
BlockNumber, BlockView, CellWithStatus, ChainInfo, HeaderView, JsonBytes, OutPoint,
OutputsValidator, RawTxPool, Transaction, TransactionWithStatusResponse, TxPoolInfo, Uint32,
OutputsValidator, RawTxPool, Transaction, TransactionAndWitnessProof,
TransactionWithStatusResponse, TxPoolInfo, Uint32,
};
use ckb_sdk::rpc::ckb_indexer::{Cell, Order, Pagination, SearchKey};
use ckb_types::H256;
Expand Down Expand Up @@ -97,6 +98,10 @@ impl CkbReader for RpcClient {
jsonrpc!("get_tip_header", Target::CKB, self, HeaderView).boxed()
}

fn get_header(&self, hash: &H256) -> Rpc<Option<HeaderView>> {
jsonrpc!("get_header", Target::CKB, self, Option<HeaderView>, hash).boxed()
}

fn get_transaction(&self, hash: &H256) -> Rpc<Option<TransactionWithStatusResponse>> {
jsonrpc!(
"get_transaction",
Expand Down Expand Up @@ -141,6 +146,22 @@ impl CkbReader for RpcClient {
.boxed()
}

fn get_transaction_and_witness_proof(
&self,
tx_hashes: Vec<H256>,
block_hash: H256,
) -> Rpc<TransactionAndWitnessProof> {
jsonrpc!(
"get_transaction_and_witness_proof",
Target::CKB,
self,
TransactionAndWitnessProof,
tx_hashes,
block_hash
)
.boxed()
}

fn fetch_live_cells(
&self,
search_key: SearchKey,
Expand Down
Loading
Loading