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: tweak SendBlocksProof message to support ckb2023 #4185

Merged
merged 2 commits into from
Oct 27, 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
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