This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
forked from matter-labs/zksync-era
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: inscriber example #17
Merged
irnb
merged 9 commits into
feat/bitcoin-integration
from
feat/inscriber-example-and-fix
Aug 23, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d797199
add inscriber example [ci skip]
irnb 4b344ad
fix witness size and count issue [ci skip]
irnb 0fadae9
fix controllblock [ci skip]
irnb 519d000
secure substraction [ci skip]
irnb 1f1fb36
run cargo fmt [ci skip]
irnb fb4dfb4
convert feerate from sat/kb to sat/b [ci skip]
irnb faad6e7
convert utxo fetching approach [ci skip]
irnb 33accac
add unit test for inscriber [ci skip]
irnb fc38ba4
add unit test for inscriber [ci skip]
irnb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
use via_btc_client::types as inscribe_types; | ||
use via_btc_client::{inscriber::Inscriber, types::BitcoinNetwork, types::NodeAuth}; | ||
|
||
use anyhow::{Context, Result}; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
// get the node url and private key from the environment | ||
|
||
// export BITCOIN_NODE_URL="http://example.com:8332" | ||
// export BITCOIN_PRV=example_wif | ||
|
||
let url = std::env::var("BITCOIN_NODE_URL").context("BITCOIN_NODE_URL not set")?; | ||
let prv = std::env::var("BITCOIN_PRV").context("BITCOIN_PRV not set")?; | ||
|
||
let mut inscriber_instance = Inscriber::new( | ||
&url, | ||
BitcoinNetwork::Regtest, | ||
NodeAuth::UserPass("via".to_string(), "via".to_string()), | ||
&prv, | ||
None, | ||
) | ||
.await | ||
.context("Failed to create Inscriber")?; | ||
|
||
println!( | ||
"balance: {}", | ||
inscriber_instance | ||
.get_balance() | ||
.await | ||
.context("Failed to get balance")? | ||
); | ||
|
||
let l1_da_batch_ref = inscribe_types::L1BatchDAReferenceInput { | ||
l1_batch_hash: zksync_basic_types::H256([0; 32]), | ||
l1_batch_index: zksync_basic_types::L1BatchNumber(0_u32), | ||
da_identifier: "da_identifier_celestia".to_string(), | ||
blob_id: "batch_temp_blob_id".to_string(), | ||
}; | ||
|
||
let l1_batch_da_txid = inscriber_instance | ||
.inscribe(inscribe_types::InscriptionMessage::L1BatchDAReference( | ||
l1_da_batch_ref, | ||
)) | ||
.await | ||
.context("Failed to inscribe L1BatchDAReference")?; | ||
|
||
println!("---------------------------------First Inscription---------------------------------"); | ||
let context = inscriber_instance.get_context_snapshot()?; | ||
println!("context: {:?}", context); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to implement There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. awesome, i'll add your suggestion in my next PR thanks |
||
|
||
let l1_da_proof_ref = inscribe_types::ProofDAReferenceInput { | ||
l1_batch_reveal_txid: l1_batch_da_txid[1], | ||
da_identifier: "da_identifier_celestia".to_string(), | ||
blob_id: "proof_temp_blob_id".to_string(), | ||
}; | ||
|
||
let _da_proof_ref_reveal_txid = inscriber_instance | ||
.inscribe(inscribe_types::InscriptionMessage::ProofDAReference( | ||
l1_da_proof_ref, | ||
)) | ||
.await | ||
.context("Failed to inscribe ProofDAReference")?; | ||
|
||
println!( | ||
"---------------------------------Second Inscription---------------------------------" | ||
); | ||
let context = inscriber_instance.get_context_snapshot()?; | ||
|
||
println!("context: {:?}", context); | ||
|
||
println!("---------------------------------End---------------------------------"); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we could use the
tracing
crate here. It will help understand how logs will look like in productioncheckout the indexer example