Skip to content

Commit

Permalink
feat (batcher): allow users to specify max fee (#869)
Browse files Browse the repository at this point in the history
Co-authored-by: taturosati <“taturosati@users.noreply.github.com”>
Co-authored-by: Uriel Mihura <43704209+uri-99@users.noreply.github.com>
Co-authored-by: taturosati <taturosati@users.noreply.github.com>
Co-authored-by: Julian Arce <52429267+JuArce@users.noreply.github.com>
  • Loading branch information
5 people authored Sep 4, 2024
1 parent 94fbaee commit c6d8459
Show file tree
Hide file tree
Showing 17 changed files with 975 additions and 206 deletions.
12 changes: 12 additions & 0 deletions batcher/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions batcher/aligned-batcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ halo2_proofs = { git = "https://github.com/yetanotherco/yet-another-halo2-fork.g
bincode = "1.3.3"
aligned-sdk = { path = "../aligned-sdk" }
ciborium = "=0.2.2"
priority-queue = "2.1.0"
38 changes: 28 additions & 10 deletions batcher/aligned-batcher/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ const INITIAL_BACKOFF: u64 = 1000; // Initial backoff for the retry client in mi
const GAS_MULTIPLIER: f64 = 1.125; // Multiplier for the gas price for gas escalator
const GAS_ESCALATOR_INTERVAL: u64 = 12; // Time in seconds between gas escalations

#[derive(Debug, Clone)]
pub struct CreateNewTaskFeeParams {
pub fee_for_aggregator: U256,
pub fee_per_proof: U256,
pub gas_price: U256,
}

impl CreateNewTaskFeeParams {
pub fn new(fee_for_aggregator: U256, fee_per_proof: U256, gas_price: U256) -> Self {
CreateNewTaskFeeParams {
fee_for_aggregator,
fee_per_proof,
gas_price,
}
}
}

pub fn get_provider(eth_rpc_url: String) -> Result<Provider<RetryClient<Http>>, anyhow::Error> {
let provider = Http::from_str(eth_rpc_url.as_str())
.map_err(|e| anyhow::Error::msg(format!("Failed to create provider: {}", e)))?;
Expand Down Expand Up @@ -69,18 +86,19 @@ pub async fn try_create_new_task(
batch_data_pointer: String,
padded_leaves: Vec<[u8; 32]>,
signatures: Vec<SignatureData>,
gas_for_aggregator: U256,
gas_per_proof: U256,
fee_params: CreateNewTaskFeeParams,
payment_service: &BatcherPaymentService,
) -> Result<TransactionReceipt, BatcherSendError> {
let call = payment_service.create_new_task(
batch_merkle_root,
batch_data_pointer,
padded_leaves,
signatures,
gas_for_aggregator,
gas_per_proof,
);
let call = payment_service
.create_new_task(
batch_merkle_root,
batch_data_pointer,
padded_leaves,
signatures,
fee_params.fee_for_aggregator,
fee_params.fee_per_proof,
)
.gas_price(fee_params.gas_price);

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

Expand Down
Loading

0 comments on commit c6d8459

Please sign in to comment.