Skip to content

Commit c6d8459

Browse files
taturosatitaturosatiuri-99JuArce
authored
feat (batcher): allow users to specify max fee (#869)
Co-authored-by: taturosati <“[email protected]”> Co-authored-by: Uriel Mihura <[email protected]> Co-authored-by: taturosati <[email protected]> Co-authored-by: Julian Arce <[email protected]>
1 parent 94fbaee commit c6d8459

File tree

17 files changed

+975
-206
lines changed

17 files changed

+975
-206
lines changed

batcher/Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

batcher/aligned-batcher/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ halo2_proofs = { git = "https://github.com/yetanotherco/yet-another-halo2-fork.g
3333
bincode = "1.3.3"
3434
aligned-sdk = { path = "../aligned-sdk" }
3535
ciborium = "=0.2.2"
36+
priority-queue = "2.1.0"

batcher/aligned-batcher/src/eth/mod.rs

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,23 @@ const INITIAL_BACKOFF: u64 = 1000; // Initial backoff for the retry client in mi
2424
const GAS_MULTIPLIER: f64 = 1.125; // Multiplier for the gas price for gas escalator
2525
const GAS_ESCALATOR_INTERVAL: u64 = 12; // Time in seconds between gas escalations
2626

27+
#[derive(Debug, Clone)]
28+
pub struct CreateNewTaskFeeParams {
29+
pub fee_for_aggregator: U256,
30+
pub fee_per_proof: U256,
31+
pub gas_price: U256,
32+
}
33+
34+
impl CreateNewTaskFeeParams {
35+
pub fn new(fee_for_aggregator: U256, fee_per_proof: U256, gas_price: U256) -> Self {
36+
CreateNewTaskFeeParams {
37+
fee_for_aggregator,
38+
fee_per_proof,
39+
gas_price,
40+
}
41+
}
42+
}
43+
2744
pub fn get_provider(eth_rpc_url: String) -> Result<Provider<RetryClient<Http>>, anyhow::Error> {
2845
let provider = Http::from_str(eth_rpc_url.as_str())
2946
.map_err(|e| anyhow::Error::msg(format!("Failed to create provider: {}", e)))?;
@@ -69,18 +86,19 @@ pub async fn try_create_new_task(
6986
batch_data_pointer: String,
7087
padded_leaves: Vec<[u8; 32]>,
7188
signatures: Vec<SignatureData>,
72-
gas_for_aggregator: U256,
73-
gas_per_proof: U256,
89+
fee_params: CreateNewTaskFeeParams,
7490
payment_service: &BatcherPaymentService,
7591
) -> Result<TransactionReceipt, BatcherSendError> {
76-
let call = payment_service.create_new_task(
77-
batch_merkle_root,
78-
batch_data_pointer,
79-
padded_leaves,
80-
signatures,
81-
gas_for_aggregator,
82-
gas_per_proof,
83-
);
92+
let call = payment_service
93+
.create_new_task(
94+
batch_merkle_root,
95+
batch_data_pointer,
96+
padded_leaves,
97+
signatures,
98+
fee_params.fee_for_aggregator,
99+
fee_params.fee_per_proof,
100+
)
101+
.gas_price(fee_params.gas_price);
84102

85103
info!("Creating task for: {}", hex::encode(batch_merkle_root));
86104

0 commit comments

Comments
 (0)