Skip to content
Open
162 changes: 151 additions & 11 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ members = [
"tesseract/consensus/relayer",
"tesseract/consensus/polygon",
"tesseract/consensus/tendermint",
"tesseract/consensus/proof-indexer",


# Airdrop
Expand Down Expand Up @@ -350,6 +351,7 @@ tesseract-grandpa = { path = "tesseract/consensus/grandpa" }
tesseract-consensus = { path = "tesseract/consensus/relayer" }
tesseract-polygon = { path = "tesseract/consensus/polygon" }
tesseract-tendermint = { path = "tesseract/consensus/tendermint" }
proof-indexer = { path = "tesseract/consensus/proof-indexer" }


[workspace.dependencies.codec]
Expand Down
33 changes: 33 additions & 0 deletions sdk/packages/indexer/src/configs/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1987,3 +1987,36 @@ type HyperbridgeCollatorRewardTransaction @entity {
"""
createdAt: Date! @index
}

"""
ZK consensus proofs indexed by the relayer. Applications query these proofs
and submit them on-chain via HandlerV2.handleConsensus().
"""
type ZkConsensusProof @entity {
id: ID!
Copy link
Copy Markdown
Member

@Wizdave97 Wizdave97 Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unique constraint needed here or else the ON CONFLICT check in insertion will fail


"""
Full SCALE-encoded ConsensusMessage bytes
"""
consensusProof: Bytes!

"""
Relay chain block height finalized by this proof
"""
finalizedHeight: BigInt! @index

"""
Parachain block height finalized by this proof
"""
finalizedParachainHeight: BigInt! @index

"""
Validator set ID that signed this proof
"""
validatorSetId: BigInt! @index

"""
Timestamp when the proof was stored
"""
createdAt: Date! @index
}
1 change: 1 addition & 0 deletions tesseract/consensus/beefy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ sp-consensus-beefy = { workspace = true }
tesseract-substrate = { workspace = true }
tesseract-primitives = { workspace = true }
zk-beefy = { path = "zk" }
proof-indexer = { workspace = true }
rsmq_async = { workspace = true }
redis-async = { version = "0.17.1", features = ["with-rustls"] }

Expand Down
4 changes: 3 additions & 1 deletion tesseract/consensus/beefy/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ use std::pin::Pin;
/// Consensus proof message exchanged between prover and host
#[derive(Clone, Debug, Encode, Decode)]
pub struct ConsensusProof {
/// The height that is now finalized by this consensus message
/// The relay chain height finalized by this consensus message
pub finalized_height: u32,
/// The parachain height finalized by this consensus message
pub finalized_parachain_height: u64,
/// The validator set id responsible for signing this message
pub set_id: u64,
/// The consensus message in question
Expand Down
8 changes: 6 additions & 2 deletions tesseract/consensus/beefy/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ where

Ok(())
}

}

#[async_trait::async_trait]
Expand Down Expand Up @@ -182,7 +183,10 @@ where
let item =
self.backend.receive_mandatory_proof(&counterparty_state_machine).await;

let QueueMessage { id, proof: ConsensusProof { message, set_id, .. } } =
let QueueMessage {
id,
proof: ConsensusProof { message, set_id, .. },
} =
match item {
Ok(Some(message)) => message,
// no new items in the queue, continue to process messages queue
Expand Down Expand Up @@ -265,7 +269,7 @@ where

let QueueMessage {
id,
proof: ConsensusProof { message, finalized_height, set_id },
proof: ConsensusProof { message, finalized_height, set_id, .. },
} = match item {
Ok(Some(message)) => message,
Ok(None) => break, // no new items in the queue
Expand Down
Loading
Loading