') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); fix (sdk): add sender address to wait for verification function by taturosati · Pull Request #909 · yetanotherco/aligned_layer · GitHub
Skip to content
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 batcher/aligned-sdk/abi/AlignedLayerServiceManager.json

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions batcher/aligned-sdk/src/communication/batch.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,11 +44,17 @@ pub async fn await_batch_verification(
aligned_verification_data: &AlignedVerificationData,
rpc_url: &str,
chain: Chain,
payment_service_addr: &str,
) -> Result<(), errors::SubmitError> {
for _ in 0..RETRIES {
if is_proof_verified(aligned_verification_data, chain.clone(), rpc_url)
.await
.is_ok_and(|r| r)
if is_proof_verified(
aligned_verification_data,
chain.clone(),
rpc_url,
payment_service_addr,
)
.await
.is_ok_and(|r| r)
{
return Ok(());
}
Expand Down
39 changes: 36 additions & 3 deletions batcher/aligned-sdk/src/sdk.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -40,6 +40,7 @@ use futures_util::{
/// * `verification_data` - An array of verification data of each proof.
/// * `wallet` - The wallet used to sign the proof.
/// * `nonce` - The nonce of the submitter address. See `get_next_nonce`.
/// * `payment_service_addr` - The address of the payment service contract.
/// # Returns
/// * An array of aligned verification data obtained when submitting the proof.
/// # Errors
Expand All@@ -66,13 +67,19 @@ pub async fn submit_multiple_and_wait_verification(
verification_data: &[VerificationData],
wallet: Wallet<SigningKey>,
nonce: U256,
payment_service_addr: &str,
) -> Result<Vec<AlignedVerificationData>, errors::SubmitError> {
let aligned_verification_data =
submit_multiple(batcher_url, verification_data, wallet, nonce).await?;

for aligned_verification_data_item in aligned_verification_data.iter() {
await_batch_verification(aligned_verification_data_item, eth_rpc_url, chain.clone())
.await?;
await_batch_verification(
aligned_verification_data_item,
eth_rpc_url,
chain.clone(),
payment_service_addr,
)
.await?;
}

Ok(aligned_verification_data)
Expand DownExpand Up@@ -182,6 +189,7 @@ async fn _submit_multiple(
/// * `verification_data` - The verification data of the proof.
/// * `wallet` - The wallet used to sign the proof.
/// * `nonce` - The nonce of the submitter address. See `get_next_nonce`.
/// * `payment_service_addr` - The address of the payment service contract.
/// # Returns
/// * The aligned verification data obtained when submitting the proof.
/// # Errors
Expand All@@ -208,6 +216,7 @@ pub async fn submit_and_wait_verification(
verification_data: &VerificationData,
wallet: Wallet<SigningKey>,
nonce: U256,
payment_service_addr: &str,
) -> Result<AlignedVerificationData, errors::SubmitError> {
let verification_data = vec![verification_data.clone()];

Expand All@@ -218,6 +227,7 @@ pub async fn submit_and_wait_verification(
&verification_data,
wallet,
nonce,
payment_service_addr,
)
.await?;

Expand DownExpand Up@@ -265,6 +275,7 @@ pub async fn submit(
/// * `aligned_verification_data` - The aligned verification data obtained when submitting the proofs.
/// * `chain` - The chain on which the verification will be done.
/// * `eth_rpc_url` - The URL of the Ethereum RPC node.
/// * `payment_service_addr` - The address of the payment service.
/// # Returns
/// * A boolean indicating whether the proof was verified on-chain and is included in the batch.
/// # Errors
Expand All@@ -275,25 +286,38 @@ pub async fn is_proof_verified(
aligned_verification_data: &AlignedVerificationData,
chain: Chain,
eth_rpc_url: &str,
payment_service_addr: &str,
) -> Result<bool, errors::VerificationError> {
let eth_rpc_provider =
Provider::<Http>::try_from(eth_rpc_url).map_err(|e: url::ParseError| {
errors::VerificationError::EthereumProviderError(e.to_string())
})?;
_is_proof_verified(aligned_verification_data, chain, eth_rpc_provider).await

_is_proof_verified(
aligned_verification_data,
chain,
eth_rpc_provider,
payment_service_addr,
)
.await
}

async fn _is_proof_verified(
aligned_verification_data: &AlignedVerificationData,
chain: Chain,
eth_rpc_provider: Provider<Http>,
payment_service_addr: &str,
) -> Result<bool, errors::VerificationError> {
let contract_address = match chain {
Chain::Devnet => "0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8",
Chain::Holesky => "0x58F280BeBE9B34c9939C3C39e0890C81f163B623",
Chain::HoleskyStage => "0x9C5231FC88059C086Ea95712d105A2026048c39B",
};

let payment_service_addr = payment_service_addr
.parse::<Address>()
.map_err(|e| errors::VerificationError::HexDecodingError(e.to_string()))?;

// All the elements from the merkle proof have to be concatenated
let merkle_proof: Vec<u8> = aligned_verification_data
.batch_inclusion_proof
Expand All@@ -317,6 +341,7 @@ async fn _is_proof_verified(
aligned_verification_data.batch_merkle_root,
merkle_proof.into(),
aligned_verification_data.index_in_batch.into(),
payment_service_addr,
);

let result = call
Expand DownExpand Up@@ -405,6 +430,8 @@ mod test {

use ethers::signers::LocalWallet;

const BATCHER_PAYMENT_SERVICE_ADDR: &str = "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0";
Comment thread
JuArce marked this conversation as resolved.

#[tokio::test]
async fn test_submit_success() {
let base_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
Expand DownExpand Up@@ -438,6 +465,7 @@ mod test {
&verification_data,
wallet,
U256::zero(),
BATCHER_PAYMENT_SERVICE_ADDR,
)
.await
.unwrap();
Expand DownExpand Up@@ -471,6 +499,7 @@ mod test {
&verification_data,
wallet,
U256::zero(),
BATCHER_PAYMENT_SERVICE_ADDR,
)
.await;

Expand DownExpand Up@@ -512,6 +541,7 @@ mod test {
&verification_data,
wallet,
U256::zero(),
BATCHER_PAYMENT_SERVICE_ADDR,
)
.await
.unwrap();
Expand All@@ -522,6 +552,7 @@ mod test {
&aligned_verification_data[0],
Chain::Devnet,
"http://localhost:8545",
BATCHER_PAYMENT_SERVICE_ADDR,
)
.await
.unwrap();
Expand DownExpand Up@@ -562,6 +593,7 @@ mod test {
&verification_data,
wallet,
U256::zero(),
BATCHER_PAYMENT_SERVICE_ADDR,
)
.await
.unwrap();
Expand All@@ -577,6 +609,7 @@ mod test {
&aligned_verification_data_modified,
Chain::Devnet,
"http://localhost:8545",
BATCHER_PAYMENT_SERVICE_ADDR,
)
.await
.unwrap();
Expand Down
7 changes: 7 additions & 0 deletions batcher/aligned/src/main.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -162,6 +162,12 @@ pub struct VerifyProofOnchainArgs {
default_value = "devnet"
)]
chain: ChainArg,
#[arg(
name = "Batcher Payment Service Eth Address",
long = "payment_service_addr",
default_value = "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0"
)]
payment_service_addr: String,
}

#[derive(Parser, Debug)]
Expand DownExpand Up@@ -360,6 +366,7 @@ async fn main() -> Result<(), AlignedError> {
&aligned_verification_data,
chain,
&verify_inclusion_args.eth_rpc_url,
&verify_inclusion_args.payment_service_addr,
)
.await?;

Expand Down
6 changes: 6 additions & 0 deletions docs/3_guides/1.2_SDK_api_reference.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -95,6 +95,7 @@ pub async fn submit_and_wait_verification(
verification_data: &VerificationData,
wallet: Wallet<SigningKey>,
nonce: U256,
payment_service_addr: &str,
) -> Result<AlignedVerificationData, errors::SubmitError>
```

Expand All@@ -106,6 +107,7 @@ pub async fn submit_and_wait_verification(
- `verification_data` - The verification data for the proof.
- `wallet` - The wallet used to sign the proof. Should be using correct chain id. See `get_chain_id`.
- `nonce` - The nonce of the submitter address. See `get_next_nonce`.
- `payment_service_addr` - The address of the batcher payment service contract.

#### Returns

Expand DownExpand Up@@ -143,6 +145,7 @@ pub async fn submit_multiple_and_wait_verification(
verification_data: &[VerificationData],
wallet: Wallet<SigningKey>,
nonce: U256,
payment_service_addr: &str,
) -> Result<Vec<AlignedVerificationData>, errors::SubmitError>
```

Expand All@@ -154,6 +157,7 @@ pub async fn submit_multiple_and_wait_verification(
- `verification_data` - A verification data array.
- `wallet` - The wallet used to sign the proof. Should be using correct chain id. See `get_chain_id`.
- `nonce` - The nonce of the submitter address. See `get_next_nonce`.
- `payment_service_addr` - The address of the batcher payment service contract.

#### Returns

Expand DownExpand Up@@ -187,6 +191,7 @@ pub async fn is_proof_verified(
aligned_verification_data: AlignedVerificationData,
chain: Chain,
eth_rpc_url: &str,
payment_service_addr: &str,
) -> Result<bool, errors::VerificationError>
```

Expand All@@ -195,6 +200,7 @@ pub async fn is_proof_verified(
- `aligned_verification_data` - The aligned verification data obtained when submitting the proofs.
- `chain` - The chain on which the verification will be done.
- `eth_rpc_url` - The URL of the Ethereum RPC node.
- `payment_service_addr` - The address of the batcher payment service contract.

#### Returns

Expand Down