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

improve gas estimation #267

Closed
wants to merge 1 commit into from
Closed

improve gas estimation #267

wants to merge 1 commit into from

Conversation

Fraccaman
Copy link
Member

@Fraccaman Fraccaman commented Feb 6, 2025

No description provided.

MaspTxRef::MaspSection(masp_tx_id) => {
transaction
.get_masp_section(&masp_tx_id)
.map(|bundle| bundle.clone().into_data().sapling_bundle().map(|bundle| bundle.shielded_spends.len() + bundle.shielded_outputs.len()).unwrap_or_default()).unwrap_or_default() as u64
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and down below it might be nice to also account for the length of the shielded_converts vector since conversions affect the gas cost too. But let me know, maybe this would make the indexer algorithm too overfitted on the details of masp txs

@@ -459,13 +462,36 @@ impl Transaction {
acc
});

let notes = masp_refs.clone().into_iter().map(|masp_ref| {
match masp_ref {
MaspTxRef::MaspSection(masp_tx_id) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we should check if this specific masp ref belongs to this inner tx

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes so, we'd need to check if the inner tx we are currently analyzing is a successful masp tx and if so pop from the head of the masp_refs vector the next element and run the match expression here above. It's a bit unlucky cause the events don't carry the exact inner tx index of that masp data (it's not needed when constructing the local state of a shielded wallet) so we kind of have to do this manually in here. We should have the batch event somewhere here so that we can check the exit code of this inner tx. Understanding if it is a masp tx could be slightly more complex: we'd need to deserialize the tx data and see if it is a transfer, ibc transfer or neither. If none, then this is not a masp tx. If it is either a transfer or an ibc transfer we should check if it contains the pointer to the same MaspTxRef that we expect: if so we extract, otherwise we skip

@grarco
Copy link

grarco commented Feb 14, 2025

Closing this in favor of #275

@grarco grarco closed this Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants