Skip to content

Commit

Permalink
Merge pull request #4185 from quake/quake/light-client-extension
Browse files Browse the repository at this point in the history
feat: tweak `SendBlocksProof` message to support ckb2023
  • Loading branch information
quake authored Oct 27, 2023
2 parents 73ddfbf + c42e6ea commit 34dbc77
Show file tree
Hide file tree
Showing 8 changed files with 1,411 additions and 128 deletions.
2 changes: 1 addition & 1 deletion util/gen-types/schemas/blockchain.mol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ array Uint256 [byte; 32];

vector Bytes <byte>;
option BytesOpt (Bytes);

vector BytesOptVec <BytesOpt>;
vector BytesVec <Bytes>;
vector Byte32Vec <Byte32>;

Expand Down
39 changes: 39 additions & 0 deletions util/gen-types/schemas/extensions.mol
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,25 @@ table SendBlocksProof {
missing_block_hashes: Byte32Vec,
}

table SendBlocksProofV1 {
// Refer to `SendLastStateProof.last_header`.
last_header: VerifiableHeader,
// Refer to `SendLastStateProof.proof`.
proof: HeaderDigestVec,

// Block headers for the blocks which require verifying.
headers: HeaderVec,

// Block hashes for the blocks which were not found.
missing_block_hashes: Byte32Vec,

// Uncle hashes for the blocks which require verifying.
blocks_uncles_hash: Byte32Vec,

// Block extension for the blocks which require verifying.
blocks_extension: BytesOptVec,
}

table GetTransactionsProof {
// Refer to `GetLastStateProof.last_hash`.
last_hash: Byte32,
Expand All @@ -397,6 +416,26 @@ table SendTransactionsProof {
missing_tx_hashes: Byte32Vec,
}

table SendTransactionsProofV1 {
// Refer to `SendLastStateProof.last_header`.
last_header: VerifiableHeader,
// Refer to `SendLastStateProof.proof`.
proof: HeaderDigestVec,

// A collection of filtered blocks, which include all requested
// transactions, and be verified in the proof.
filtered_blocks: FilteredBlockVec,

// Transaction hashes for the blocks which were not found.
missing_tx_hashes: Byte32Vec,

// Uncle hashes for the blocks which require verifying.
blocks_uncles_hash: Byte32Vec,

// Block extension for the blocks which require verifying.
blocks_extension: BytesOptVec,
}

/* Types for Network/Others */

table Time {
Expand Down
16 changes: 16 additions & 0 deletions util/gen-types/src/extension/shortcut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,19 @@ impl packed::HeaderDigest {
self.as_slice() == default.as_slice()
}
}

impl From<packed::SendBlocksProofV1> for packed::LightClientMessageUnion {
fn from(item: packed::SendBlocksProofV1) -> Self {
packed::LightClientMessageUnion::SendBlocksProof(packed::SendBlocksProof::new_unchecked(
item.as_bytes(),
))
}
}

impl From<packed::SendTransactionsProofV1> for packed::LightClientMessageUnion {
fn from(item: packed::SendTransactionsProofV1) -> Self {
packed::LightClientMessageUnion::SendTransactionsProof(
packed::SendTransactionsProof::new_unchecked(item.as_bytes()),
)
}
}
Loading

0 comments on commit 34dbc77

Please sign in to comment.