Skip to content

Conversation

@zone117x
Copy link
Contributor

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 }
]

@github-actions
Copy link

github-actions bot commented Nov 19, 2024

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

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

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

🎉 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