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

fix(sequencer): move fee event recording to tx level #1718

Merged
merged 4 commits into from
Oct 24, 2024

Conversation

ethanoroshiba
Copy link
Contributor

@ethanoroshiba ethanoroshiba commented Oct 22, 2024

Summary

Moves ABCI fee events to FinalizeBlock.tx_results to identify fees on a per transaction basis.

Background

Post-fee rework, fee ABCI event construction was happening outside of transaction execution and (wrongly) included in the FinalizeBlock.events field of the finalize block response. This made it difficult to identify which fee events were related to which transaction.

This patch moves fee event construction back into the (atomic) transaction execution, so that the generated ABCI fee events per transaction are again part of FinalizeBlock.tx_results.

For example for Astrotek fees will again show up next to each transaction.

Changes

  • Moved fee event construction back into transaction execution.

Testing

Adjusted fee event unit test to ensure fee event is returned as part of transaction execution.

@github-actions github-actions bot added the sequencer pertaining to the astria-sequencer crate label Oct 22, 2024
@ethanoroshiba ethanoroshiba marked this pull request as ready for review October 22, 2024 19:48
@ethanoroshiba ethanoroshiba requested a review from a team as a code owner October 22, 2024 19:48
Copy link
Member

@SuperFluffy SuperFluffy left a comment

Choose a reason for hiding this comment

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

I don't understand the patch notes: they are a very mechanical description of what was done but really explain why and to what effect. Can you explain what this means in terms of the execution flow? At which step of block production (in cometbft terms) are the events generated now?

If the event construction no longer happens as part of End Block, where does it happen now?

The patch notes also notes that this is a fix but it is not clear what is being fixed. Why is it a problem that the event is associated with the block and not the transaction? Weren't the sourceTransactionId and sourceActionIndex fields in the event intended to address this?

@ethanoroshiba
Copy link
Contributor Author

@SuperFluffy I attempted to update the patch notes to reflect the methodology behind the changes more. Let me know if this works for you. As for why I called it "fix", this is because it was pointed out as an issue that a transaction's fees were no longer being recorded with the transaction itself. That was the reason we added the source action and transaction id to the fee events though, so it may be a UX decision. I'll bring it up offline.

@joroshiba
Copy link
Member

The patch notes also notes that this is a fix but it is not clear what is being fixed. Why is it a problem that the event is associated with the block and not the transaction?

@SuperFluffy Changing where the events are generated changes the external API for fees. You can no longer discover the fee paid by querying a transaction. You must now query the block and search for your tx hash in the results. Generally speaking this makes the block query return oversized payloads as now every query for a block returns the fees paid for every action on it. Fundamentally this a TX result not a block result.

If we wanted a block result it should be the total fees paid over the whole block.

("actionName", fee.action_name.to_string()).index(),
("asset", fee.asset.to_string()).index(),
("feeAmount", fee.amount.to_string()).index(),
("sourceActionIndex", fee.source_action_index.to_string()).index(),
Copy link
Member

Choose a reason for hiding this comment

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

I actually think we should change this name to "positionInTransaction". I was part of the original review and had to do a double take what sourceActionIndex means.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Followup issue here: #1735

@ethanoroshiba ethanoroshiba added this pull request to the merge queue Oct 24, 2024
Merged via the queue into main with commit 1df9031 Oct 24, 2024
46 checks passed
@ethanoroshiba ethanoroshiba deleted the eoroshiba/move_fee_event_creation branch October 24, 2024 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sequencer pertaining to the astria-sequencer crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants