') + ')', '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); } })(); })(); feat (batcher): allow users to specify max fee by taturosati · Pull Request #869 · yetanotherco/aligned_layer · GitHub
Skip to content

feat (batcher): allow users to specify max fee - #869

Merged
JuArce merged 50 commits into
mainfrom
860-feat-batcher-payment-service-allow-users-to-specify-max-fee
Sep 4, 2024
Merged

feat (batcher): allow users to specify max fee#869
JuArce merged 50 commits into
mainfrom
860-feat-batcher-payment-service-allow-users-to-specify-max-fee

Conversation

@taturosati

@taturosatitaturosati commented Aug 27, 2024

Copy link
Copy Markdown
Contributor

Users can now specify a max fee for a certain task. They sign this max fee, the contract then verifies that what the fee the batcher set * tx gas price is less than that max fee.

The batcher builds the batch putting the highest max fees first, but making it as big as possible without making it invalid (adding a fee that was too low).

The batcher also checks that a single user has not specified a bigger max fee for a bigger nonce, since this would cause the greater nonce to be sent first.

The batcher allows a user to replace a pending task by specifying the same nonce and a bigger fee. To prevent issues with this, the batcher checks that there is not a smaller nonce with a smaller fee (same as when adding a new task).

To send a task with a specific max_fee and nonce run in the batcher/aligned dir:

cargo run --release -- submit \
--proving_system Groth16Bn254 \
--proof ../../scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs/ineq_1_groth16.proof \
--public_input ../../scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs/ineq_1_groth16.pub \
--vk ../../scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs/ineq_1_groth16.vk \
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
--private_key 0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356 \
--nonce 0 \
--max_fee 10000000000000

Note that if you don't specify a nonce it will fetch from disk cache / rpc and if you don't specify a max fee, it has a default.

Also note that you will need a funded account for this, since if not the batcher will just replace max fee and nonce. To fund that private key you can run:

cast send 0x7969c5eD335650692Bc04293B07F5BF2e7A673C0 --private-key 0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356 --value 100ether

@taturosatitaturosati self-assigned this Aug 27, 2024
@taturosatitaturosati linked an issue Aug 27, 2024 that may be closed by this pull request
@taturosati
taturosati marked this pull request as ready for review August 27, 2024 18:53
Comment threadbatcher/aligned-batcher/src/lib.rs Outdated
Comment threadcontracts/src/core/BatcherPaymentService.sol Outdated

@uri-99uri-99 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should the Batcher close the first connection with a client if a proof is sent again with same nonce and bigger fee?
Its odd if a user has many open connections with the same nonce.

@uri-99uri-99 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ser resolve TODO please

Comment threadbatcher/aligned-batcher/src/lib.rs Outdated
Comment threadbatcher/aligned-batcher/src/lib.rs Outdated
Comment threadbatcher/aligned-batcher/src/lib.rs

@uri-99uri-99 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Considering this PR adds informing different errors to the client (invalid fee, invalid nonce, etc), reverted txs should also be informed to the client

issue about this:
#919

Comment threadbatcher/aligned-batcher/src/lib.rs
Comment threadbatcher/aligned-batcher/src/lib.rs Outdated
Comment threadbatcher/aligned-batcher/src/lib.rs Outdated
Comment threadbatcher/aligned-batcher/src/lib.rs Outdated
Comment threadbatcher/aligned-batcher/src/lib.rs
Comment threadbatcher/aligned-batcher/src/lib.rs
Comment threadbatcher/aligned-batcher/src/lib.rs Outdated
Comment threadbatcher/aligned-batcher/src/lib.rs Outdated
@JuArce
JuArce merged commit c6d8459 into mainSep 4, 2024
@JuArce
JuArce deleted the 860-feat-batcher-payment-service-allow-users-to-specify-max-fee branch September 4, 2024 17:21
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat (batcher-payment-service): allow users to specify max fee

5 participants

@taturosati@MauroToscano@uri-99@JuArce@entropidelic