-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: accurate gas calculation for Amplifier API reporting #18
base: main
Are you sure you want to change the base?
Conversation
@@ -81,24 +83,41 @@ pub async fn fetch_logs( | |||
) | |||
.await?; | |||
|
|||
// parse the provided accounts | |||
let message = transaction_with_meta.transaction.decode().unwrap().message; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get rid of unwrap
2f3861b
to
c8edf3e
Compare
2511cd4
to
452159f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It overall looks good to me 👍 but take my review with pinct of salt, as i am not fullly familiar with the code yet. I would just fix the CI and get rid of the unwraps (as you already noted).
Maybe in a future we could save some lines of code by improving local test helpers. Not on this PR though, as i think we are still discovering the patterns.
Just sharing one random though that came to my mind was if adding a positive margin to the gas sum (I saw it in other projects) would be needed here ? But probably that's not our job here, as this is only part of the calculation (The Solana side). Such a margin should be added by the last aggregation layer if that's the case.
@@ -693,15 +683,497 @@ mod tests { | |||
} | |||
|
|||
#[test_log::test(tokio::test)] | |||
async fn event_forwrding_only_gas_event() { | |||
async fn event_forwrding_message_approved() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async fn event_forwrding_message_approved() { | |
async fn event_forwarding_message_approved() { |
036b7a8
to
cf1c030
Compare
cf1c030
to
9aeeed6
Compare
Closes #15
Computes the total gas cost (in lamports) for a given Solana transaction, factoring in:
Direct transaction cost.
Additional costs from multi-step gateway instructions (e.g., verification sessions, message payload uploads).
added unittests to ensure that we parse & compute gas for message approval and message execution
Implemented a function that will scrape the Solana RPCs to build an accurate model of how much was paid in fees for every action