Skip to content

Commit 5b8e5e3

Browse files
committed
refactor: do not change signature as it is not needed
1 parent 6af00e6 commit 5b8e5e3

3 files changed

Lines changed: 6 additions & 48 deletions

File tree

batcher/aligned-batcher/src/lib.rs

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ use types::errors::{BatcherError, TransactionSendError};
5353

5454
use crate::config::{ConfigFromYaml, ContractDeploymentOutput};
5555
use crate::telemetry::sender::TelemetrySender;
56-
use crate::types::non_paying::NonPayingReplacementData;
5756

5857
mod config;
5958
mod connection;
@@ -575,20 +574,20 @@ impl Batcher {
575574
};
576575

577576
let addr;
578-
let signature;
577+
let signature = client_msg.signature;
579578
let nonced_verification_data;
580579

581580
if self.has_to_pay(&addr_in_msg) {
582581
addr = addr_in_msg;
583-
signature = client_msg.signature;
584582
nonced_verification_data = client_msg.verification_data.clone();
585583
} else {
586584
info!("Generating non-paying data");
587-
let non_paying_data = self.generate_non_paying_data(&client_msg).await;
588585
// If the user is not required to pay, substitute their address with a pre-funded Aligned address
589-
addr = non_paying_data.address;
590-
signature = non_paying_data.signature;
591-
nonced_verification_data = non_paying_data.nonced_verification_data;
586+
addr = self.non_paying_config.as_ref().unwrap().replacement.address();
587+
// Substitute the max_fee to a high enough value to cover the gas cost of the proof
588+
let mut aux_verification_data = client_msg.verification_data.clone();
589+
aux_verification_data.max_fee = (DEFAULT_MAX_FEE_PER_PROOF * 100).into(); // 2_000 gas per proof * 100 gwei gas price (upper bound) * 100 to make sure it is enough
590+
nonced_verification_data = aux_verification_data
592591
}
593592

594593
// When pre-verification is enabled, batcher will verify proofs for faster feedback with clients
@@ -1739,36 +1738,6 @@ impl Batcher {
17391738
Some(non_paying_conf.replacement.address())
17401739
}
17411740

1742-
/// Only relevant for testing and for users to easily use Aligned in testnet.
1743-
async fn generate_non_paying_data(
1744-
&self,
1745-
client_msg: &SubmitProofMessage,
1746-
) -> NonPayingReplacementData {
1747-
// This unwrap is safe because we check if the non-paying config is set before calling this function.
1748-
let non_paying_config = self.non_paying_config.as_ref().unwrap();
1749-
1750-
let nonced_verification_data = NoncedVerificationData::new(
1751-
client_msg.verification_data.verification_data.clone(),
1752-
client_msg.verification_data.nonce,
1753-
(DEFAULT_MAX_FEE_PER_PROOF * 100).into(), // 2_000 gas per proof * 100 gwei gas price (upper bound) * 100 to make sure it is enough
1754-
self.chain_id,
1755-
self.payment_service.address(),
1756-
);
1757-
1758-
// We need to sign a message with the non-paying replacement address
1759-
let non_paying_replacement_msg = SubmitProofMessage::new(
1760-
client_msg.verification_data.clone(),
1761-
non_paying_config.replacement.clone(),
1762-
)
1763-
.await;
1764-
1765-
NonPayingReplacementData {
1766-
address: non_paying_config.replacement.address(),
1767-
nonced_verification_data,
1768-
signature: non_paying_replacement_msg.signature,
1769-
}
1770-
}
1771-
17721741
/// Gets the balance of user with address `addr` from Ethereum.
17731742
/// Retries on recoverable errors using exponential backoff up to `ETHEREUM_CALL_MAX_RETRIES` times:
17741743
/// (0,5 secs - 1 secs - 2 secs - 4 secs - 8 secs)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
pub(crate) mod batch_queue;
22
pub(crate) mod batch_state;
33
pub mod errors;
4-
pub(crate) mod non_paying;
54
pub(crate) mod user_state;

batcher/aligned-batcher/src/types/non_paying.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)