1313// limitations under the License.
1414
1515use alloy:: {
16- hex:: FromHex ,
17- network:: EthereumWallet ,
18- node_bindings:: Anvil ,
19- primitives:: { FixedBytes , U256 } ,
20- providers:: ProviderBuilder ,
16+ network:: EthereumWallet , node_bindings:: Anvil , primitives:: U256 , providers:: ProviderBuilder ,
2117 signers:: local:: PrivateKeySigner ,
2218} ;
2319use alloy_sol_types:: sol;
@@ -27,7 +23,7 @@ use reqwest::header;
2723use serde:: { Deserialize , Serialize } ;
2824use serde_with:: { base64:: Base64 , serde_as, DisplayFromStr } ;
2925use std:: sync:: Arc ;
30- use tendermint_rpc:: HttpClient ;
26+ use tendermint_rpc:: { Client , HttpClient } ;
3127
3228sol ! (
3329 #[ sol( rpc) ]
3733
3834const CELESTIA_RPC_URL : & str = "https://celestia-testnet.brightlystake.com" ;
3935
40- const BATCH_START : u64 = 10 ;
41- const BATCH_END : u64 = 42 ;
42- const PROOF_HEIGHT : u64 = 15 ;
36+ const BATCH_START : u32 = 2768370 ;
37+ const BATCH_END : u32 = 2768400 ;
38+ const PROOF_HEIGHT : u32 = 2768375 ;
4339
4440/// Type matches Celestia API endpoint for generating proof.
4541/// https://docs.celestia.org/developers/blobstream-proof-queries#_1-data-root-inclusion-proof
@@ -78,27 +74,34 @@ async fn e2e_basic_range() -> anyhow::Result<()> {
7874
7975 let verifier = MockVerifier :: deploy ( & provider, [ 0 , 0 , 0 , 0 ] . into ( ) ) . await ?;
8076
77+ let tm_client = Arc :: new ( HttpClient :: new ( CELESTIA_RPC_URL ) ?) ;
78+ let trusted_block_hash = tm_client
79+ . header ( BATCH_START - 1 )
80+ . await ?
81+ . header
82+ . hash ( )
83+ . as_bytes ( )
84+ . try_into ( )
85+ . unwrap ( ) ;
86+
8187 // Deploy the contract.
8288 let contract = IBlobstream :: deploy (
8389 & provider,
8490 anvil. addresses ( ) [ 0 ] ,
8591 verifier. address ( ) . clone ( ) ,
8692 // Uses Celestia block hash at height below proving range on Mocha
87- FixedBytes :: < 32 > :: from_hex (
88- "5C5451567973D8658A607D58F035BA9078291E33D880A0E6E67145C717E6B11B" ,
89- ) ?,
90- BATCH_START - 1 ,
93+ trusted_block_hash,
94+ BATCH_START as u64 - 1 ,
9195 )
9296 . await ?;
9397
94- let client = Arc :: new ( HttpClient :: new ( CELESTIA_RPC_URL ) ?) ;
95-
96- let receipt = prove_block_range ( client, BATCH_START ..BATCH_END ) . await ?;
98+ let receipt =
99+ prove_block_range ( tm_client. clone ( ) , BATCH_START as u64 ..BATCH_END as u64 ) . await ?;
97100
98101 post_batch ( & contract, & receipt) . await ?;
99102
100103 let height = contract. latestHeight ( ) . call ( ) . await ?;
101- assert_eq ! ( height. _0, BATCH_END - 1 ) ;
104+ assert_eq ! ( height. _0, BATCH_END as u64 - 1 ) ;
102105
103106 // Somewhat hacky to do this manually, seems no Rust tooling for this endpoint.
104107 let http_client = reqwest:: Client :: new ( ) ;
@@ -115,16 +118,23 @@ async fn e2e_basic_range() -> anyhow::Result<()> {
115118 let response: DataRootInclusionResponse =
116119 serde_json:: from_value ( response[ "result" ] [ "proof" ] . clone ( ) ) ?;
117120
121+ let proof_data_root = tm_client
122+ . header ( PROOF_HEIGHT )
123+ . await ?
124+ . header
125+ . data_hash
126+ . unwrap ( )
127+ . as_bytes ( )
128+ . try_into ( )
129+ . unwrap ( ) ;
118130 // Validate data root inclusion.
119131 let is_valid = contract
120132 . verifyAttestation (
121133 U256 :: from ( 1 ) ,
122134 DataRootTuple {
123135 height : U256 :: from ( PROOF_HEIGHT ) ,
124136 // TODO this is fixed from on chain, but could be pulled from node to be dynamic
125- dataRoot : FixedBytes :: < 32 > :: from_hex (
126- "3D96B7D238E7E0456F6AF8E7CDF0A67BD6CF9C2089ECB559C659DCAA1F880353" ,
127- ) ?,
137+ dataRoot : proof_data_root,
128138 } ,
129139 BinaryMerkleProof {
130140 sideNodes : response
0 commit comments