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

feat: option to modify estimated fees in /v2/fees/transaction proxy #2172

Merged
merged 3 commits into from
Nov 19, 2024

Conversation

zone117x
Copy link
Member

Adds a hook to the /v2/fees/transaction endpoint in the RPC proxy.

Configure using the env var STACKS_CORE_FEE_ESTIMATION_MODIFIER. The fee estimations returned by the stacks-node will be multiplied by this value.

For example with STACKS_CORE_FEE_ESTIMATION_MODIFIER=0.5, if the response from stacks-core is:

estimations: [
  { fee: 400 },
  { fee: 800 },
  { fee: 1000 }
]

Then the modified response will be:

estimations: [
  { fee: 200 },
  { fee: 400 },
  { fee: 500 }
]

Copy link

github-actions bot commented Nov 19, 2024

Vercel deployment URL: https://stacks-blockchain-8aav9b1mt-hirosystems.vercel.app 🚀

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

// https://github.com/stacks-network/stacks-core/blob/20d5137438c7d169ea97dd2b6a4d51b8374a4751/stackslib/src/chainstate/stacks/db/blocks.rs#L338
const MINIMUM_TX_FEE_RATE_PER_BYTE = 1;

function getFeeEstimationModifier(): number | null {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we do this in a lazy way? e.g. parse once and keep it cached in a global var

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me see if I can do that in a way that still lets the test configure it..

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Comment on lines 156 to 158
// Use the `node:http` agent for requests https://github.com/fastify/fastify-reply-from?tab=readme-ov-file#globalagent
globalAgent: true,
http: {},
Copy link
Member Author

Choose a reason for hiding this comment

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

Fastify defaults to using Fetch/undici which isn't supported by the nock testing lib used to mock network responses. These settings cause it to use the node:http global agent. From what I understand, it's a bit slower but probably fine.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice looks like that works 6ab509e

Copy link
Collaborator

@rafaelcr rafaelcr left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@obycode obycode left a comment

Choose a reason for hiding this comment

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

LGTM!

@zone117x zone117x merged commit 9b7e97d into beta Nov 19, 2024
27 checks passed
@zone117x zone117x deleted the feat/fee-estimate-middleware branch November 19, 2024 17:46
blockstack-devops pushed a commit that referenced this pull request Nov 19, 2024
## [8.3.0-beta.1](v8.2.2...v8.3.0-beta.1) (2024-11-19)

### Features

* option to modify estimated fees in /v2/fees/transaction proxy ([#2172](#2172)) ([9b7e97d](9b7e97d))
@blockstack-devops
Copy link

🎉 This PR is included in version 8.3.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

blockstack-devops pushed a commit that referenced this pull request Dec 10, 2024
## [8.3.0](v8.2.3...v8.3.0) (2024-12-10)

### Features

* option to modify estimated fees in /v2/fees/transaction proxy ([#2172](#2172)) ([9b7e97d](9b7e97d))

### Bug Fixes

* socket-io reconnection bug ([#2174](#2174)) ([b99c672](b99c672))
@blockstack-devops
Copy link

🎉 This PR is included in version 8.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants