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: randomize key order for testnet stx faucet transactions #2120

Merged
merged 6 commits into from
Oct 15, 2024

Conversation

rafaelcr
Copy link
Collaborator

This PR makes a few fixes to the testnet STX faucet:

  • Instead of forming an array of TestnetNetworks with the STACKS_FAUCET_NODE_HOST and STACKS_FAUCET_NODE_PORT values from .env plus the standard testnet network, these ENV vars are now treated only as override values. This fixes an issue where both pairs of values essentially pointed to the same network nodes causing faucet transactions to be duplicated in certain scenarios.
  • Instead of always attempting to send faucet STX from the first key, keys are now selected in random order. If a key fails from nonce issues, other keys will be tried until we run out of keys. This spreads out the load and reduces the probability of failed transactions.
  • Nonce values are now taken from the API nonce estimator, which includes transactions currently in the mempool. This reduces the possibility of nonce conflicts.
  • Transaction fees are now estimated by stacks.js, with a fallback to a default fee of 200 ustx.

Copy link

codecov bot commented Oct 14, 2024

Codecov Report

Attention: Patch coverage is 61.90476% with 24 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/api/routes/faucets.ts 60.00% 24 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Member

@zone117x zone117x 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

github-actions bot commented Oct 15, 2024

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

if (fee) options.fee = fee;

// Detect possible custom network chain ID
network.chainId = await fetchNetworkChainID(network);
Copy link
Member

Choose a reason for hiding this comment

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

@zone117x Just curious, why not use the STACKS_CHAIN_ID env var here?

Copy link
Member

Choose a reason for hiding this comment

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

It could, but there are ways to deploy the API without setting that env var (SKIP_STACKS_CHAIN_ID_CHECK=bool was added a while back). I don't really have a strong opinion on what to use here.

@rafaelcr rafaelcr merged commit f7265f9 into beta Oct 15, 2024
27 checks passed
@rafaelcr rafaelcr deleted the fix/faucet-keys branch October 15, 2024 14:32
blockstack-devops pushed a commit that referenced this pull request Oct 15, 2024
## [8.1.0-beta.3](v8.1.0-beta.2...v8.1.0-beta.3) (2024-10-15)

### Bug Fixes

* randomize key order for testnet stx faucet transactions ([#2120](#2120)) ([f7265f9](f7265f9))
* update mempool garbage collection logic for 3.0 ([#2117](#2117)) ([8b10b69](8b10b69))
@blockstack-devops
Copy link

🎉 This PR is included in version 8.1.0-beta.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

blockstack-devops pushed a commit that referenced this pull request Oct 16, 2024
## [8.1.0](v8.0.4...v8.1.0) (2024-10-16)

### Features

* add block etag ([#2103](#2103)) ([66e6800](66e6800))
* add cache handler for principal activity including mempool transactions ([#2100](#2100)) ([2370c21](2370c21))
* add principal cache etag to account endpoints ([#2097](#2097)) ([28e9864](28e9864))
* return estimated balance in account balance endpoints ([#2104](#2104)) ([e217cea](e217cea))

### Bug Fixes

* add declaration copy step in build ([#2110](#2110)) ([2b6aa6a](2b6aa6a))
* prune and restore mempool transactions with equal nonces for the same sender ([#2091](#2091)) ([1ce75de](1ce75de))
* randomize key order for testnet stx faucet transactions ([#2120](#2120)) ([f7265f9](f7265f9))
* update mempool garbage collection logic for 3.0 ([#2117](#2117)) ([8b10b69](8b10b69))
* use total_count CTE and return it with the parsed results ([#2073](#2073)) ([bb30911](bb30911))
@blockstack-devops
Copy link

🎉 This PR is included in version 8.1.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
None yet
Development

Successfully merging this pull request may close these issues.

4 participants