keeper: fix tx size limits on charge collateral fee batching

This commit is contained in:
Christian Kamm 2024-02-26 09:21:53 +01:00
parent d9f55c4c22
commit 54674e4b20
4 changed files with 9 additions and 4 deletions

View File

@ -552,7 +552,12 @@ async fn send_batched_log_errors_no_confirm(
current_batch.append(ixs.clone());
tx_builder.instructions = current_batch.clone().to_instructions();
if !tx_builder.transaction_size().is_ok() || current_batch.cu > max_cu {
if tx_builder
.transaction_size()
.map(|ts| !ts.is_within_limit())
.unwrap_or(true)
|| current_batch.cu > max_cu
{
tx_builder.instructions = previous_batch.to_instructions();
match tx_builder.send(client).await {
Err(err) => error!("could not send transaction: {err:?}"),

View File

@ -92,7 +92,7 @@ impl<'a> LiquidateHelper<'a> {
let exceeds_cu_limit = new_ixs.cu > self.config.max_cu_per_transaction;
let exceeds_size_limit = {
tx_builder.instructions = new_ixs.clone().to_instructions();
!tx_builder.transaction_size()?.is_ok()
!tx_builder.transaction_size()?.is_within_limit()
};
if exceeds_cu_limit || exceeds_size_limit {
break;

View File

@ -231,7 +231,7 @@ impl Rebalancer {
.prepare_swap_transaction(full)
.await?;
let tx_size = builder.transaction_size()?;
if tx_size.is_ok() {
if tx_size.is_within_limit() {
return Ok((builder, full.clone()));
}
trace!(

View File

@ -2233,7 +2233,7 @@ pub struct TransactionSize {
}
impl TransactionSize {
pub fn is_ok(&self) -> bool {
pub fn is_within_limit(&self) -> bool {
let limit = Self::limit();
self.length <= limit.length && self.accounts <= limit.accounts
}