Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid duplicated sections when batching #3872

Closed
grarco opened this issue Oct 2, 2024 · 0 comments · Fixed by #3882
Closed

Avoid duplicated sections when batching #3872

grarco opened this issue Oct 2, 2024 · 0 comments · Fixed by #3882

Comments

@grarco
Copy link
Contributor

grarco commented Oct 2, 2024

In the function we use to construct a batch we push all the sections of an inner tx in the batch, even though some of these might already be present.

pub fn add_inner_tx(&mut self, other: Tx, cmt: TxCommitments) -> bool {
if !self.header.batch.insert(cmt) {
return false;
}
// TODO: avoid duplicated sections to reduce the size of the message
self.sections.extend(other.sections);
true
}

We should try to check if a section is already in the batch and, in this case, avoid pushing another identical one. This would lead to smaller transactions and a lower gas cost. In doing so, though, we should pay attention to the Commitments of that tx, which are computed on the salted sections: we might need to update the commitments to point to the equivalent section with a different salt.

@grarco grarco changed the title Avoid duplicated sections in when batching Avoid duplicated sections when batching Oct 2, 2024
@grarco grarco self-assigned this Oct 2, 2024
@grarco grarco added this to the Nice to have and non-breaking milestone Oct 2, 2024
@mergify mergify bot closed this as completed in #3882 Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant