Skip to content

improve gas estimation#267

Closed
Fraccaman wants to merge 1 commit into1.0.0-maintfrom
fix-gas-estimate-2
Closed

improve gas estimation#267
Fraccaman wants to merge 1 commit into1.0.0-maintfrom
fix-gas-estimate-2

Conversation

@Fraccaman
Copy link
Collaborator

@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
Contributor

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


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

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
Contributor

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
Contributor

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