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

Use staleness for pricing #87

Merged
merged 2 commits into from
Nov 14, 2023
Merged

Use staleness for pricing #87

merged 2 commits into from
Nov 14, 2023

Conversation

ali-bahjati
Copy link
Collaborator

@ali-bahjati ali-bahjati commented Nov 13, 2023

This PR adds dynamic (exponential) pricing based on staleness of the feeds that the publishers publish. This feature, combined with the recent fees for the price updates causes the spike on fee to last some time before going away.

The second commit contains a little refactoring to fix warnings. Please review commit-by-commit.

// Get the estimated compute unit price and wrap it so it stays below the maximum total
// compute unit fee. We additionally divide such price by 2 to make sure a spike
// doesn't get propagated forever.
let estimated_price = (estimated_recent_price >> 1).min(maximum_unit_price);
Copy link

Choose a reason for hiding this comment

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

hardcore division 😎

Copy link
Contributor

@jayantk jayantk left a comment

Choose a reason for hiding this comment

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

LGTM. left a couple comments but feel free to address in a separate PR


// Use exponentially higher price if this publisher hasn't published in a while for the accounts
// in this batch. This will use the maximum total compute unit fee if the publisher
// hasn't updated for >= MAXIMUM_SLOT_GAP_FOR_DYNAMIC_COMPUTE_UNIT_PRICE slots.
Copy link
Contributor

Choose a reason for hiding this comment

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

this is pretty much guaranteed to use the maximum price when the market opens each day right?

I think that behavior is fine -- I think the max price isn't so high that we can't afford 1 of these transactions per day per price feed or whatever -- though probably worth a comment justifying it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah it was a certain challenge. I think we should see how it will work with the other dynamic mechanism (which is decaying) and make sure it won't get very expensive.

@@ -88,6 +87,7 @@ const UPDATE_PRICE_NO_FAIL_ON_ERROR: i32 = 13;
// measure while using dynamic compute price to prevent the exporter from paying too much for a
// single transaction
const MAXIMUM_TOTAL_COMPUTE_UNIT_FEE_MICRO_LAMPORTS: u64 = 1_000_000_000_000;
const MAXIMUM_SLOT_GAP_FOR_DYNAMIC_COMPUTE_UNIT_PRICE: u64 = 25;
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest putting both of these consts into the config. these are the kind of thing that we'll probably want to tune easily in an emergency.

This commit adds dynamic (exponential) pricing based on staleness
of the feeds that the publishers publish.

This feature, combined with the recent fees for the price updates
causes the spike on fee to last some time before going away.
@ali-bahjati ali-bahjati force-pushed the use-staleness-for-pricing branch from d2a9808 to ff26d55 Compare November 14, 2023 14:43
@ali-bahjati ali-bahjati merged commit 87b0445 into main Nov 14, 2023
2 checks passed
@ali-bahjati ali-bahjati deleted the use-staleness-for-pricing branch November 14, 2023 14:43
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.

4 participants